Compare commits
706 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 | |||
| a2af7fd407 | |||
| 34e0b4a71e | |||
| 8fb4b73f55 | |||
| 684806305e | |||
| b653107b96 | |||
| 41c548bb23 | |||
| a8380712bb | |||
| 419aed3539 | |||
| 3e0b5f78a2 | |||
| 37817a0cd8 |
@@ -0,0 +1,211 @@
|
||||
<?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 collation conversion tool.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2012 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This function is designed for MySQL databases only!');
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'collation'=>false, 'available'=>false),
|
||||
array('h'=>'help', 'l'=>'list', 'a'=>'available'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"MySQL collation conversions script.
|
||||
|
||||
It is strongly recommended to stop the web server before the conversion.
|
||||
This script may be executed before the main upgrade - 1.9.x data for example.
|
||||
|
||||
Options:
|
||||
--collation=COLLATION Convert MySQL tables to different collation
|
||||
-l, --list Show table and column information
|
||||
-a, --available Show list of available collations
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/mysql_collation.php --collation=utf8_general_ci
|
||||
";
|
||||
|
||||
if (!empty($options['collation'])) {
|
||||
$collations = mysql_get_collations();
|
||||
$collation = clean_param($options['collation'], PARAM_ALPHANUMEXT);
|
||||
$collation = strtolower($collation);
|
||||
if (!isset($collations[$collation])) {
|
||||
cli_error("Error: collation '$collation' is not available on this server!");
|
||||
}
|
||||
|
||||
echo "Converting tables and columns to '$collation' for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$converted = 0;
|
||||
$skipped = 0;
|
||||
$errors = 0;
|
||||
foreach ($rs as $table) {
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
if ($table->collation === $collation) {
|
||||
echo "NO CHANGE\n";
|
||||
$skipped++;
|
||||
|
||||
} else {
|
||||
$DB->change_database_structure("ALTER TABLE $table->name DEFAULT COLLATE = $collation");
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
}
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $table->name WHERE collation IS NOT NULL";
|
||||
$rs2 = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs2 as $column) {
|
||||
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
|
||||
echo ' '.str_pad($column->field, 36). " - ";
|
||||
if ($column->collation === $collation) {
|
||||
echo "NO CHANGE\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($column->type === 'tinytext' or $column->type === 'mediumtext' or $column->type === 'text' or $column->type === 'longtext') {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||
// primary, unique and inc are not supported for texts
|
||||
$sql = "ALTER TABLE $table->name MODIFY COLUMN $column->field $column->type COLLATE $collation $notnull $default";
|
||||
$DB->change_database_structure($sql);
|
||||
|
||||
} else if (strpos($column->type, 'varchar') === 0) {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = !is_null($column->default) ? "DEFAULT '$column->default'" : '';
|
||||
// primary, unique and inc are not supported for texts
|
||||
$sql = "ALTER TABLE $table->name MODIFY COLUMN $column->field $column->type COLLATE $collation $notnull $default";
|
||||
$DB->change_database_structure($sql);
|
||||
} else {
|
||||
echo "ERROR (unknown column type: $column->type)\n";
|
||||
$error++;
|
||||
continue;
|
||||
}
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
}
|
||||
$rs2->close();
|
||||
}
|
||||
$rs->close();
|
||||
echo "Converted: $converted, skipped: $skipped, errors: $errors\n";
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
echo "List of tables for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$counts = array();
|
||||
foreach ($rs as $table) {
|
||||
if (isset($counts[$table->collation])) {
|
||||
$counts[$table->collation]++;
|
||||
} else {
|
||||
$counts[$table->collation] = 1;
|
||||
}
|
||||
echo str_pad($table->name, 40);
|
||||
echo $table->collation. "\n";
|
||||
$collations = mysql_get_column_collations($table->name);
|
||||
foreach ($collations as $columname=>$collation) {
|
||||
if (isset($counts[$collation])) {
|
||||
$counts[$collation]++;
|
||||
} else {
|
||||
$counts[$collation] = 1;
|
||||
}
|
||||
echo ' ';
|
||||
echo str_pad($columname, 36);
|
||||
echo $collation. "\n";
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo "\n";
|
||||
echo "Table collations summary for $CFG->wwwroot:\n";
|
||||
foreach ($counts as $collation => $count) {
|
||||
echo "$collation: $count\n";
|
||||
}
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['available'])) {
|
||||
echo "List of available MySQL collations for $CFG->wwwroot:\n";
|
||||
$collations = mysql_get_collations();
|
||||
foreach ($collations as $collation) {
|
||||
echo " $collation\n";
|
||||
}
|
||||
die;
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========== Some functions ==============
|
||||
|
||||
function mysql_get_collations() {
|
||||
global $DB;
|
||||
|
||||
$collations = array();
|
||||
$sql = "SHOW COLLATION WHERE Collation LIKE 'utf8\_%' AND Charset = 'utf8'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $collation) {
|
||||
$collations[$collation->collation] = $collation->collation;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
$collation = $DB->get_dbcollation();
|
||||
if (isset($collations[$collation])) {
|
||||
$collations[$collation] .= ' (default)';
|
||||
}
|
||||
|
||||
return $collations;
|
||||
}
|
||||
|
||||
function mysql_get_column_collations($tablename) {
|
||||
global $DB;
|
||||
|
||||
$collations = array();
|
||||
$sql = "SELECT column_name, collation_name
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_schema = DATABASE() AND table_name = ? AND collation_name IS NOT NULL";
|
||||
$rs = $DB->get_recordset_sql($sql, array($tablename));
|
||||
foreach($rs as $record) {
|
||||
$collations[$record->column_name] = $record->collation_name;
|
||||
}
|
||||
$rs->close();
|
||||
return $collations;
|
||||
}
|
||||
+117
-1
@@ -659,5 +659,121 @@
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.4" 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.2" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK 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_CHECK 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="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK 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>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
@@ -242,6 +242,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
|
||||
|
||||
// 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
|
||||
@@ -263,6 +264,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
|
||||
|
||||
// Apply to strings.
|
||||
$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 = $filterinfo->active == TEXTFILTER_DISABLED;
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
|
||||
@@ -203,17 +203,18 @@ echo get_string('username') . ":\n";
|
||||
if (!empty($formerror['username'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo '<input type="text" name="username" size="20" maxlength="100" />';
|
||||
echo html_writer::label(get_string('username'), 'menuusername', false, array('class' => 'accesshide'));
|
||||
echo '<input id="menuusername" type="text" name="username" size="20" maxlength="100" />';
|
||||
|
||||
// choose a remote host
|
||||
echo " " . get_string('remotehost', 'mnet') . ":\n";
|
||||
echo " " . html_writer::label(get_string('remotehost', 'mnet'), 'menumnet_host_id') . ":\n";
|
||||
if (!empty($formerror['mnet_host_id'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo html_writer::select($mnethosts, 'mnet_host_id');
|
||||
|
||||
// choose an access level
|
||||
echo " " . get_string('accesslevel', 'mnet') . ":\n";
|
||||
echo " " . html_writer::label(get_string('accesslevel', 'mnet'), 'menuaccessctrl') . ":\n";
|
||||
if (!empty($formerror['accessctrl'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/mnet/lib.php');
|
||||
require_once($CFG->dirroot.'/admin/mnet/peer_forms.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/mnet/peer_forms.php');
|
||||
|
||||
require_login();
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$currentaction = 'hide';
|
||||
}
|
||||
$select = new single_select(portfolio_action_url($pluginid, 'pf'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . $pluginid);
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
$table->data[] = array($pluginname, $OUTPUT->render($select), $settings);
|
||||
}
|
||||
if (!in_array($plugin, $usedplugins)) {
|
||||
@@ -218,6 +219,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$insaneplugins[] = $p;
|
||||
} else {
|
||||
$select = new single_select(portfolio_action_url($p, 'pf'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . $p);
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
$table->data[] = array(portfolio_static_function($p, 'get_name'), $OUTPUT->render($select), '');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading(get_string('upgradestalefiles', 'admin'));
|
||||
$output .= $this->box_start('generalbox', 'notice');
|
||||
$output .= get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading'));
|
||||
$output .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN);
|
||||
$output .= html_writer::empty_tag('br');
|
||||
$output .= html_writer::tag('div', $this->single_button($this->page->url, get_string('reload'), 'get'), array('class' => 'buttons'));
|
||||
$output .= $this->box_end();
|
||||
|
||||
@@ -352,7 +352,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
|
||||
$select = new single_select(repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));
|
||||
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
// Display up/down link
|
||||
$updown = '';
|
||||
$spacer = $OUTPUT->spacer(array('height'=>15, 'width'=>15)); // should be done with CSS instead
|
||||
@@ -389,6 +389,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
// 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'));
|
||||
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '');
|
||||
}
|
||||
}
|
||||
|
||||
+30
-5
@@ -104,20 +104,45 @@ switch ($context->contextlevel) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the list of the reported-on user's role assignments - must be after
|
||||
// the page setup code above, or the language might be wrong.
|
||||
$reportuser = $userselector->get_selected_user();
|
||||
if (!is_null($reportuser)) {
|
||||
$roleassignments = get_user_roles_with_special($context, $reportuser->id);
|
||||
$rolenames = role_get_names($context);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
// These are needed early because of tabs.php
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
$overridableroles = get_overridable_roles($context, ROLENAME_BOTH);
|
||||
|
||||
// Print heading.
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
// If a user has been chosen, show all the permissions for this user.
|
||||
$reportuser = $userselector->get_selected_user();
|
||||
if (!is_null($reportuser)) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo $OUTPUT->heading(get_string('permissionsforuser', 'role', fullname($reportuser)), 3);
|
||||
|
||||
if (!empty($roleassignments)) {
|
||||
echo $OUTPUT->heading(get_string('rolesforuser', 'role', fullname($reportuser)), 3);
|
||||
echo html_writer::start_tag('ul');
|
||||
|
||||
$systemcontext = context_system::instance();
|
||||
foreach ($roleassignments as $ra) {
|
||||
$racontext = context::instance_by_id($ra->contextid);
|
||||
$link = html_writer::link($racontext->get_url(), $racontext->get_context_name());
|
||||
|
||||
$rolename = $rolenames[$ra->roleid]->localname;
|
||||
if (has_capability('moodle/role:manage', $systemcontext)) {
|
||||
$rolename = html_writer::link(new moodle_url('/admin/roles/define.php',
|
||||
array('action' => 'view', 'roleid' => $ra->roleid)), $rolename);
|
||||
}
|
||||
|
||||
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', 'role', fullname($reportuser)), 3);
|
||||
$table = new check_capability_table($context, $reportuser, $contextname);
|
||||
$table->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
+4
-6
@@ -1042,12 +1042,10 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
|
||||
$countfields = 'SELECT COUNT(u.id)';
|
||||
|
||||
$sql = " FROM {user} u
|
||||
WHERE u.id IN ($enrolsql) $wherecondition
|
||||
AND u.id NOT IN (
|
||||
SELECT r.userid
|
||||
FROM {role_assignments} r
|
||||
WHERE r.contextid = :contextid
|
||||
AND r.roleid = :roleid)";
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.roleid = :roleid AND ra.contextid = :contextid)
|
||||
WHERE u.id IN ($enrolsql)
|
||||
$wherecondition
|
||||
AND ra.id IS NULL";
|
||||
$order = ' ORDER BY lastname ASC, firstname ASC';
|
||||
|
||||
$params['contextid'] = $this->context->id;
|
||||
|
||||
@@ -166,7 +166,8 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
|
||||
$context = context::instance_by_id($contextid);
|
||||
|
||||
// Print the context name.
|
||||
echo $OUTPUT->heading($context->get_context_name(), 4, 'contextname');
|
||||
echo $OUTPUT->heading(html_writer::link($context->get_url(), $context->get_context_name()),
|
||||
4, 'contextname');
|
||||
|
||||
// If there are any role assignments here, print them.
|
||||
foreach ($contexts[$contextid]->roleassignments as $ra) {
|
||||
@@ -189,7 +190,7 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->fullname = $fullname;
|
||||
$a->contextlevel = get_contextlevel_name($context->contextlevel);
|
||||
$a->contextlevel = $context->get_level_name();
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
$strgoto = get_string('gotoassignsystemroles', 'role');
|
||||
$strcheck = get_string('checksystempermissionsfor', 'role', $a);
|
||||
|
||||
@@ -185,6 +185,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$setting = new admin_setting_configcheckbox('cachejs', new lang_string('cachejs', 'admin'), new lang_string('cachejs_help', 'admin'), 1);
|
||||
$setting->set_updatedcallback('js_reset_all_caches');
|
||||
$temp->add($setting);
|
||||
$temp->add(new admin_setting_configcheckbox('modchooserdefault', new lang_string('modchooserdefault', 'admin'), new lang_string('configmodchooserdefault', 'admin'), 1));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// link to tag management interface
|
||||
|
||||
@@ -47,6 +47,11 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'), new lang_string('courselegacyfiles_help'), key($choices), $choices));
|
||||
}
|
||||
|
||||
$choices = array();
|
||||
$choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
|
||||
$choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
|
||||
|
||||
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
|
||||
$choices = array();
|
||||
$choices[NOGROUPS] = new lang_string('groupsnone', 'group');
|
||||
|
||||
@@ -77,7 +77,7 @@ if (!during_initial_install()) { //do not use during installation
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagebackup', new lang_string('frontpagebackup', 'admin'), $CFG->wwwroot.'/backup/backup.php?id='.SITEID, 'moodle/backup:backupcourse', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', new lang_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/files/index.php?id='.SITEID.'&wdir=/backupdata', 'moodle/restore:restorecourse', false, $frontpagecontext));
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', new lang_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/backup/restorefile.php?contextid='.$frontpagecontext->id, 'moodle/restore:restorecourse', false, $frontpagecontext));
|
||||
|
||||
$questioncapabilities = array(
|
||||
'moodle/question:add',
|
||||
|
||||
@@ -14,7 +14,8 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$temp->add(new admin_setting_heading('iplookup', new lang_string('iplookup', 'admin'), new lang_string('iplookupinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configfile('geoipfile', new lang_string('geoipfile', 'admin'), new lang_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
|
||||
$temp->add(new admin_setting_configtext('googlemapkey', new lang_string('googlemapkey', 'admin'), new lang_string('configgooglemapkey', 'admin', $CFG->wwwroot), ''));
|
||||
$temp->add(new admin_setting_configtext('googlemapkey', new lang_string('googlemapkey', 'admin'), new lang_string('configgooglemapkey', 'admin', $CFG->wwwroot), '', PARAM_RAW, 60));
|
||||
$temp->add(new admin_setting_configtext('googlemapkey3', new lang_string('googlemapkey3', 'admin'), new lang_string('googlemapkey3_help', 'admin'), '', PARAM_RAW, 60));
|
||||
|
||||
$temp->add(new admin_setting_configtext('allcountrycodes', new lang_string('allcountrycodes', 'admin'), new lang_string('configallcountrycodes', 'admin'), '', '/^(?:\w+(?:,\w+)*)?$/'));
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ if (isset($CFG->mnet_dispatcher_mode) and $CFG->mnet_dispatcher_mode !== 'off')
|
||||
new admin_externalpage(
|
||||
'mnetpeer' . $host->id,
|
||||
$host->name,
|
||||
$CFG->wwwroot . '/admin/mnet/peers.php?step=update&hostid=' . $host->id,
|
||||
$CFG->wwwroot . '/'.$CFG->admin.'/mnet/peers.php?step=update&hostid=' . $host->id,
|
||||
'moodle/site:config'
|
||||
)
|
||||
);
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@
|
||||
$timezones = get_list_of_timezones();
|
||||
|
||||
echo '<center><form action="timezone.php" method="post">';
|
||||
echo "$strusers ($strall): ";
|
||||
echo html_writer::label($strusers . ' (' . $strall . '): ', 'menuzone');
|
||||
echo html_writer::select($timezones, "zone", $current, array('99'=>get_string("serverlocaltime")));
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
|
||||
echo '<input type="submit" value="'.s($strsavechanges).'" />';
|
||||
|
||||
@@ -26,9 +26,9 @@ define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/upgradableassignmentstable.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentstable.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
|
||||
|
||||
require_sesskey();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade');
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/upgradableassignmentstable.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/paginationform.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentstable.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/paginationform.php');
|
||||
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('listnotupgraded'));
|
||||
|
||||
@@ -42,8 +42,8 @@ M.tool_assignmentupgrade = {
|
||||
}
|
||||
});
|
||||
|
||||
var batchform = Y.one('.tool_assignmentupgrade_batchform form');
|
||||
batchform.on('submit', function(e) {
|
||||
var upgradeselectedbutton = Y.one('#id_upgradeselected');
|
||||
upgradeselectedbutton.on('click', function(e) {
|
||||
checkboxes = Y.all('td.c0 input');
|
||||
var selectedassignments = [];
|
||||
checkboxes.each(function(node) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
require_sesskey();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
require_sesskey();
|
||||
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
<?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 migrates data from current database to another
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - su to apache account or sudo before execution
|
||||
* - already broken DB scheme or invalid data
|
||||
*
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2012 Petr Skoda {@link 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');
|
||||
require_once(__DIR__.'/../locallib.php');
|
||||
|
||||
$help =
|
||||
"Database migration script.
|
||||
|
||||
It is strongly recommended to turn off the web server
|
||||
or enable CLI maintenance mode before starting the migration.
|
||||
|
||||
Options:
|
||||
--dbtype=TYPE Database type.
|
||||
--dblibrary=TYPE Database library. Defaults to 'native'.
|
||||
--dbhost=HOST Database host.
|
||||
--dbname=NAME Database name.
|
||||
--dbuser=USERNAME Database user.
|
||||
--dbpass=PASSWORD Database password.
|
||||
--dbport=NUMBER Database port.
|
||||
--prefix=STRING Table prefix for above database tables.
|
||||
--dbsocket=PATH Use database sockets. Available for some databases only.
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/dbtransfer/cli/migrate.php
|
||||
";
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'dbtype' => null,
|
||||
'dblibrary' => 'native',
|
||||
'dbhost' => null,
|
||||
'dbname' => null,
|
||||
'dbuser' => null,
|
||||
'dbpass' => null,
|
||||
'dbport' => null,
|
||||
'prefix' => null,
|
||||
'dbsocket' => null,
|
||||
'maintenance' => null,
|
||||
'list' => false,
|
||||
'help' => false,
|
||||
),
|
||||
array(
|
||||
'm' => 'maintenance',
|
||||
'l' => 'list',
|
||||
'h' => 'help',
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
cli_error(get_string('missingconfigversion', 'debug'));
|
||||
}
|
||||
|
||||
echo "\n".get_string('cliheading', 'tool_dbtransfer')."\n\n";
|
||||
|
||||
$drivers = tool_dbtransfer_get_drivers();
|
||||
|
||||
if (!isset($options['dbtype'])) {
|
||||
$choose = array();
|
||||
foreach ($drivers as $driver => $name) {
|
||||
list($dbtype, $dblibrary) = explode('/', $driver);
|
||||
$choose[$dbtype] = $dbtype;
|
||||
}
|
||||
$optionsstr = implode(', ', $choose);
|
||||
cli_heading(get_string('databasetypehead', 'install')." ($optionsstr)");
|
||||
$options['dbtype'] = cli_input(get_string('clitypevalue', 'admin'), '', $choose, true);
|
||||
}
|
||||
|
||||
$choose = array();
|
||||
foreach ($drivers as $driver => $name) {
|
||||
list($dbtype, $dblibrary) = explode('/', $driver);
|
||||
if ($dbtype === $options['dbtype']) {
|
||||
$choose[$dblibrary] = $dblibrary;
|
||||
}
|
||||
}
|
||||
if (!isset($options['dblibrary']) or !isset($choose[$options['dblibrary']])) {
|
||||
$optionsstr = implode(', ', $choose);
|
||||
cli_heading('Database library'." ($optionsstr)"); // Note: no need to localise unless we add real PDO drivers.
|
||||
$options['dblibrary'] = cli_input(get_string('clitypevalue', 'admin'), '', $choose, true);
|
||||
}
|
||||
|
||||
if (!isset($options['dbhost'])) {
|
||||
cli_heading(get_string('databasehost', 'install'));
|
||||
$options['dbhost'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
|
||||
if (!isset($options['dbname'])) {
|
||||
cli_heading(get_string('databasename', 'install'));
|
||||
$options['dbname'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
|
||||
if (!isset($options['dbuser'])) {
|
||||
cli_heading(get_string('databaseuser', 'install'));
|
||||
$options['dbuser'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
|
||||
if (!isset($options['dbpass'])) {
|
||||
cli_heading(get_string('databasepass', 'install'));
|
||||
$options['dbpass'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
|
||||
if (!isset($options['prefix'])) {
|
||||
cli_heading(get_string('dbprefix', 'install'));
|
||||
$options['prefix'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
|
||||
if (!isset($options['dbport'])) {
|
||||
cli_heading(get_string('dbport', 'install'));
|
||||
$options['dbport'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
|
||||
if ($CFG->ostype !== 'WINDOWS') {
|
||||
if (!isset($options['dbsocket'])) {
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$options['dbsocket'] = cli_input(get_string('clitypevalue', 'admin'));
|
||||
}
|
||||
}
|
||||
|
||||
$a = (object)array('dbtypefrom' => $CFG->dbtype, 'dbtype' => $options['dbtype'],
|
||||
'dbname' => $options['dbname'], 'dbhost' => $options['dbhost']);
|
||||
cli_heading(get_string('transferringdbto', 'tool_dbtransfer', $a));
|
||||
|
||||
// Try target DB connection.
|
||||
$problem = '';
|
||||
|
||||
$targetdb = moodle_database::get_driver_instance($options['dbtype'], $options['dblibrary']);
|
||||
$dboptions = array();
|
||||
if ($options['dbport']) {
|
||||
$dboptions['dbport'] = $options['dbport'];
|
||||
}
|
||||
if ($options['dbsocket']) {
|
||||
$dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
try {
|
||||
$targetdb->connect($options['dbhost'], $options['dbuser'], $options['dbpass'], $options['dbname'],
|
||||
$options['prefix'], $dboptions);
|
||||
if ($targetdb->get_tables()) {
|
||||
$problem .= get_string('targetdatabasenotempty', 'tool_dbtransfer');
|
||||
}
|
||||
} catch (moodle_exception $e) {
|
||||
$problem .= $e->debuginfo."\n\n";
|
||||
$problem .= get_string('notargetconectexception', 'tool_dbtransfer');
|
||||
}
|
||||
|
||||
if ($problem !== '') {
|
||||
echo $problem."\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$feedback = new text_progress_trace();
|
||||
tool_dbtransfer_transfer_database($DB, $targetdb, $feedback);
|
||||
$feedback->finished();
|
||||
|
||||
cli_heading(get_string('success'));
|
||||
exit(0);
|
||||
@@ -17,19 +17,28 @@
|
||||
/**
|
||||
* Transfer form
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2008 Petr Skoda
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 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';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
|
||||
/**
|
||||
* Definition of db export settings form.
|
||||
*
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class database_export_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
/**
|
||||
* Define the export form.
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbexport', 'tool_dbtransfer'));
|
||||
|
||||
@@ -17,55 +17,84 @@
|
||||
/**
|
||||
* Transfer form
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2008 Petr Skoda
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 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';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
require_once(__DIR__.'/locallib.php');
|
||||
|
||||
|
||||
/**
|
||||
* Definition of db transfer settings form.
|
||||
*
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class database_transfer_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
/**
|
||||
* Define transfer form.
|
||||
*/
|
||||
protected function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbtransfer', 'tool_dbtransfer'));
|
||||
$mform->addElement('header', 'database', get_string('targetdatabase', 'tool_dbtransfer'));
|
||||
|
||||
$supported = array (
|
||||
'mysqli/native',
|
||||
'pgsql/native',
|
||||
'mssql/native',
|
||||
'oci/native',
|
||||
'sqlsrv/native',
|
||||
);
|
||||
$drivers = array();
|
||||
foreach($supported as $driver) {
|
||||
list($dbtype, $dblibrary) = explode('/', $driver);
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary);
|
||||
if ($targetdb->driver_installed() !== true) {
|
||||
continue;
|
||||
}
|
||||
$drivers[$driver] = $driver;
|
||||
}
|
||||
$drivers = tool_dbtransfer_get_drivers();
|
||||
$drivers = array_reverse($drivers, true);
|
||||
$drivers[''] = get_string('choosedots');
|
||||
$drivers = array_reverse($drivers, true);
|
||||
|
||||
$mform->addElement('select', 'driver', get_string('dbtype', 'install'), $drivers);
|
||||
$mform->addElement('text', 'dbhost', get_string('dbhost', 'install'));
|
||||
$mform->addElement('text', 'dbname', get_string('database', 'install'));
|
||||
$mform->addElement('text', 'dbuser', get_string('user'));
|
||||
$mform->addElement('text', 'dbpass', get_string('password'));
|
||||
$mform->addElement('text', 'dbhost', get_string('databasehost', 'install'));
|
||||
$mform->addElement('text', 'dbname', get_string('databasename', 'install'));
|
||||
$mform->addElement('text', 'dbuser', get_string('databaseuser', 'install'));
|
||||
$mform->addElement('passwordunmask', 'dbpass', get_string('databasepass', 'install'));
|
||||
$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
|
||||
$mform->addElement('text', 'dbport', get_string('dbport', 'install'));
|
||||
$mform->addElement('text', 'dbsocket', get_string('databasesocket', 'install'));
|
||||
if ($CFG->ostype !== 'WINDOWS') {
|
||||
$mform->addElement('text', 'dbsocket', get_string('databasesocket', 'install'));
|
||||
} else {
|
||||
$mform->addElement('hidden', 'dbsocket');
|
||||
}
|
||||
|
||||
$mform->addRule('driver', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbhost', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbname', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbuser', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbpass', get_string('required'), 'required', null);
|
||||
$mform->addRule('prefix', get_string('required'), 'required', null);
|
||||
if (!isset($drivers['mysqli/native'])) {
|
||||
$mform->addRule('prefix', get_string('required'), 'required', null);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'database', get_string('options', 'tool_dbtransfer'));
|
||||
|
||||
$mform->addElement('advcheckbox', 'enablemaintenance', get_string('enablemaintenance', 'tool_dbtransfer'));
|
||||
$mform->addHelpButton('enablemaintenance', 'enablemaintenance', 'tool_dbtransfer');
|
||||
|
||||
$this->add_action_buttons(false, get_string('transferdata', 'tool_dbtransfer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate prefix is present for non-mysql drivers.
|
||||
* @param array $data
|
||||
* @param array $files
|
||||
* @return array
|
||||
*/
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
if ($data['driver'] !== 'mysqli/native') {
|
||||
// This is a bloody hack, let's pretend we do not need to look at db family...
|
||||
if ($data['prefix'] === '') {
|
||||
$errors['prefix'] = get_string('required');
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
/**
|
||||
* Export
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2008 Petr Skoda
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -32,15 +31,15 @@ require_once('database_export_form.php');
|
||||
require_login();
|
||||
admin_externalpage_setup('tooldbexport');
|
||||
|
||||
//create form
|
||||
// Create form.
|
||||
$form = new database_export_form();
|
||||
|
||||
if ($data = $form->get_data()) {
|
||||
dbtransfer_export_xml_database($data->description, $DB);
|
||||
tool_dbtransfer_export_xml_database($data->description, $DB);
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
// TODO: add some more info here
|
||||
// TODO: add some more info here.
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
/**
|
||||
* Transfer tool
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2008 Petr Skoda
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -32,8 +31,9 @@ require_once('database_transfer_form.php');
|
||||
require_login();
|
||||
admin_externalpage_setup('tooldbtransfer');
|
||||
|
||||
// Create the form
|
||||
// Create the form.
|
||||
$form = new database_transfer_form();
|
||||
$problem = '';
|
||||
|
||||
// If we have valid input.
|
||||
if ($data = $form->get_data()) {
|
||||
@@ -47,33 +47,63 @@ if ($data = $form->get_data()) {
|
||||
if ($data->dbsocket) {
|
||||
$dboptions['dbsocket'] = $data->dbsocket;
|
||||
}
|
||||
if (!$targetdb->connect($data->dbhost, $data->dbuser, $data->dbpass, $data->dbname, $data->prefix, $dboptions)) {
|
||||
throw new dbtransfer_exception('notargetconectexception', null, "$CFG->wwwroot/$CFG->admin/tool/dbtransfer/");
|
||||
}
|
||||
if ($targetdb->get_tables()) {
|
||||
throw new dbtransfer_exception('targetdatabasenotempty', null, "$CFG->wwwroot/$CFG->admin/tool/dbtransfer/");
|
||||
try {
|
||||
$targetdb->connect($data->dbhost, $data->dbuser, $data->dbpass, $data->dbname, $data->prefix, $dboptions);
|
||||
if ($targetdb->get_tables()) {
|
||||
$problem .= get_string('targetdatabasenotempty', 'tool_dbtransfer');
|
||||
}
|
||||
} catch (moodle_exception $e) {
|
||||
$problem .= get_string('notargetconectexception', 'tool_dbtransfer').'<br />'.$e->debuginfo;
|
||||
}
|
||||
|
||||
// Start output.
|
||||
echo $OUTPUT->header();
|
||||
$data->dbtype = $dbtype;
|
||||
echo $OUTPUT->heading(get_string('transferringdbto', 'tool_dbtransfer', $data));
|
||||
if ($problem === '') {
|
||||
// Scroll down to the bottom when finished.
|
||||
$PAGE->requires->js_init_code("window.scrollTo(0, 5000000);");
|
||||
|
||||
// Do the transfer.
|
||||
$feedback = new html_list_progress_trace();
|
||||
dbtransfer_transfer_database($DB, $targetdb, $feedback);
|
||||
$feedback->finished();
|
||||
// Enable CLI maintenance mode if requested.
|
||||
if ($data->enablemaintenance) {
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
tool_dbtransfer_create_maintenance_file();
|
||||
}
|
||||
|
||||
// Finish up.
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
// Start output.
|
||||
echo $OUTPUT->header();
|
||||
$data->dbtype = $dbtype;
|
||||
$data->dbtypefrom = $CFG->dbtype;
|
||||
echo $OUTPUT->heading(get_string('transferringdbto', 'tool_dbtransfer', $data));
|
||||
|
||||
// Do the transfer.
|
||||
$CFG->tool_dbransfer_migration_running = true;
|
||||
try {
|
||||
$feedback = new html_list_progress_trace();
|
||||
tool_dbtransfer_transfer_database($DB, $targetdb, $feedback);
|
||||
$feedback->finished();
|
||||
} catch (Exception $e) {
|
||||
if ($data->enablemaintenance) {
|
||||
tool_dbtransfer_maintenance_callback();
|
||||
}
|
||||
unset($CFG->tool_dbransfer_migration_running);
|
||||
throw $e;
|
||||
}
|
||||
unset($CFG->tool_dbransfer_migration_running);
|
||||
|
||||
// Finish up.
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise display the settings form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('transferdbtoserver', 'tool_dbtransfer'));
|
||||
echo '<p>', get_string('transferdbintro', 'tool_dbtransfer'), "</p>\n\n";
|
||||
|
||||
$info = format_text(get_string('transferdbintro', 'tool_dbtransfer'), FORMAT_MARKDOWN);
|
||||
echo $OUTPUT->box($info);
|
||||
|
||||
$form->display();
|
||||
if ($problem !== '') {
|
||||
echo $OUTPUT->box($problem, 'generalbox error');
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -15,21 +15,29 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'tool_generator', language 'en', branch 'MOODLE_22_STABLE'
|
||||
* Strings for component 'tool_generator', language 'en'.
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['dbexport'] = 'Database transfer';
|
||||
$string['dbtransfer'] = 'Database export';
|
||||
$string['clidriverlist'] = 'Available database drivers for migration';
|
||||
$string['cliheading'] = 'Database migration - make sure nobody is accessing the server during migration!';
|
||||
$string['climigrationnotice'] = 'Database migration in progress, please wait until the migration completes and server administrator updates configuration and deletes the $CFG->dataroot/climaintenance.html file.';
|
||||
$string['convertinglogdisplay'] = 'Converting log display actions';
|
||||
$string['dbexport'] = 'Database export';
|
||||
$string['dbtransfer'] = 'Database migration';
|
||||
$string['enablemaintenance'] = 'Enable maintenance mode';
|
||||
$string['enablemaintenance_help'] = 'This option enables maintanance mode during and after the database migration, it prevents access of all users until the migration is completed. Please note that administrator has to manually delete $CFG->dataroot/climaintenance.html file after updating config.php settings to resume normal operation.';
|
||||
$string['exportdata'] = 'Export data';
|
||||
$string['notargetconectexception'] = 'Can not connect target database, sorry.';
|
||||
$string['options'] = 'Options';
|
||||
$string['pluginname'] = 'Database transfer';
|
||||
$string['targetdatabase'] = 'Target database';
|
||||
$string['targetdatabasenotempty'] = 'Target database must not contain any tables with given prefix!';
|
||||
$string['transferdata'] = 'Transfer data';
|
||||
$string['transferdbintro'] = 'This script will transfer the entire contents of this database to another database server.';
|
||||
$string['transferdbintro'] = 'This script will transfer the entire contents of this database to another database server. It is often used for migration of data to different database type.';
|
||||
$string['transferdbtoserver'] = 'Transfer this Moodle database to another server';
|
||||
$string['transferringdbto'] = 'Transferring this database to {$a->dbtype} database {$a->dbname} on {$a->dbhost}';
|
||||
$string['transferringdbto'] = 'Transferring this {$a->dbtypefrom} database to {$a->dbtype} database "{$a->dbname}" on "{$a->dbhost}"';
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
/**
|
||||
* Export db content to file.
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org}
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -44,11 +43,16 @@ TODO:
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/dtllib.php');
|
||||
|
||||
|
||||
function dbtransfer_export_xml_database($description, $mdb) {
|
||||
/**
|
||||
* Initiate database export.
|
||||
* @param string $description
|
||||
* @param moodle_database $mdb
|
||||
* @return does not return, calls die()
|
||||
*/
|
||||
function tool_dbtransfer_export_xml_database($description, $mdb) {
|
||||
@set_time_limit(0);
|
||||
|
||||
session_get_instance()->write_close(); // release session
|
||||
session_get_instance()->write_close(); // Release session.
|
||||
|
||||
header('Content-Type: application/xhtml+xml; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename=database.xml');
|
||||
@@ -61,16 +65,145 @@ function dbtransfer_export_xml_database($description, $mdb) {
|
||||
$var = new file_xml_database_exporter('php://output', $mdb);
|
||||
$var->export_database($description);
|
||||
|
||||
// no more output
|
||||
// No more output.
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
function dbtransfer_transfer_database($sourcedb, $targetdb, $feedback = null) {
|
||||
/**
|
||||
* Initiate database transfer.
|
||||
* @param moodle_database $sourcedb
|
||||
* @param moodle_database $targetdb
|
||||
* @param progress_trace $feedback
|
||||
* @return void
|
||||
*/
|
||||
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null) {
|
||||
@set_time_limit(0);
|
||||
|
||||
session_get_instance()->write_close(); // release session
|
||||
session_get_instance()->write_close(); // Release session.
|
||||
|
||||
$var = new database_mover($sourcedb, $targetdb, true, $feedback);
|
||||
$var->export_database(null);
|
||||
|
||||
tool_dbtransfer_rebuild_target_log_actions($targetdb, $feedback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Very hacky function for rebuilding of log actions in target database.
|
||||
* @param moodle_database $target
|
||||
* @param progress_trace $feedback
|
||||
* @return void
|
||||
* @throws Exception on conversion error
|
||||
*/
|
||||
function tool_dbtransfer_rebuild_target_log_actions(moodle_database $target, progress_trace $feedback = null) {
|
||||
global $DB, $CFG;
|
||||
require_once("$CFG->libdir/upgradelib.php");
|
||||
|
||||
$feedback->output(get_string('convertinglogdisplay', 'tool_dbtransfer'));
|
||||
|
||||
$olddb = $DB;
|
||||
$DB = $target;
|
||||
try {
|
||||
$DB->delete_records('log_display', array('component'=>'moodle'));
|
||||
log_update_descriptions('moodle');
|
||||
$plugintypes = get_plugin_types();
|
||||
foreach ($plugintypes as $type => $location) {
|
||||
$plugs = get_plugin_list($type);
|
||||
foreach ($plugs as $plug => $fullplug) {
|
||||
$component = $type.'_'.$plug;
|
||||
$DB->delete_records('log_display', array('component'=>$component));
|
||||
log_update_descriptions($component);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$DB = $olddb;
|
||||
throw $e;
|
||||
}
|
||||
$DB = $olddb;
|
||||
$feedback->output(get_string('done', 'core_dbtransfer', null), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of fully working database drivers present in system.
|
||||
* @return array
|
||||
*/
|
||||
function tool_dbtransfer_get_drivers() {
|
||||
global $CFG;
|
||||
|
||||
$files = new RegexIterator(new DirectoryIterator("$CFG->libdir/dml"), '|^.*_moodle_database\.php$|');
|
||||
$drivers = array();
|
||||
|
||||
foreach ($files as $file) {
|
||||
$matches = null;
|
||||
preg_match('|^([a-z0-9]+)_([a-z]+)_moodle_database\.php$|', $file->getFilename(), $matches);
|
||||
if (!$matches) {
|
||||
continue;
|
||||
}
|
||||
$dbtype = $matches[1];
|
||||
$dblibrary = $matches[2];
|
||||
|
||||
if ($dbtype === 'sqlite3') {
|
||||
// Blacklist unfinished drivers.
|
||||
continue;
|
||||
}
|
||||
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary, false);
|
||||
if ($targetdb->driver_installed() !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$driver = $dbtype.'/'.$dblibrary;
|
||||
|
||||
$drivers[$driver] = $targetdb->get_name();
|
||||
};
|
||||
|
||||
return $drivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CLI maintenance file to prevent all access.
|
||||
*/
|
||||
function tool_dbtransfer_create_maintenance_file() {
|
||||
global $CFG;
|
||||
|
||||
register_shutdown_function('tool_dbtransfer_maintenance_callback');
|
||||
|
||||
$options = new stdClass();
|
||||
$options->trusted = false;
|
||||
$options->noclean = false;
|
||||
$options->smiley = false;
|
||||
$options->filter = false;
|
||||
$options->para = true;
|
||||
$options->newlines = false;
|
||||
|
||||
$message = format_text(get_string('climigrationnotice', 'tool_dbtransfer'), FORMAT_MARKDOWN, $options);
|
||||
$message = bootstrap_renderer::early_error_content($message, '', '', array());
|
||||
$html = <<<OET
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<header><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><header/>
|
||||
<body>$message</body>
|
||||
</html>
|
||||
OET;
|
||||
|
||||
file_put_contents("$CFG->dataroot/climaintenance.html", $html);
|
||||
@chmod("$CFG->dataroot/climaintenance.html", $CFG->filepermissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback is responsible for unsetting maintenance mode
|
||||
* if the migration is interrupted.
|
||||
*/
|
||||
function tool_dbtransfer_maintenance_callback() {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->tool_dbransfer_migration_running)) {
|
||||
// Migration was finished properly - keep the maintenance file in place.
|
||||
return;
|
||||
}
|
||||
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// Failed migration, revert to normal site operation.
|
||||
unlink("$CFG->dataroot/climaintenance.html");
|
||||
error_log('tool_dbtransfer: Interrupted database migration detected, switching off CLI maintenance mode.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,19 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Link to InnoDB conversion tool
|
||||
* Add hidden links db transfer tool
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org}
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($hassiteconfig) {
|
||||
// DB transfer related pages
|
||||
$ADMIN->add('experimental', new admin_externalpage('tooldbtransfer', get_string('dbtransfer', 'tool_dbtransfer'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/index.php', 'moodle/site:config', true));
|
||||
$ADMIN->add('experimental', new admin_externalpage('tooldbexport', get_string('dbexport', 'tool_dbtransfer'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/dbexport.php', 'moodle/site:config', true));
|
||||
}
|
||||
$ADMIN->add('experimental', new admin_externalpage('tooldbtransfer', get_string('dbtransfer', 'tool_dbtransfer'),
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/index.php', 'moodle/site:config', false));
|
||||
// DB export/import is not ready yet - keep it hidden for now.
|
||||
$ADMIN->add('experimental', new admin_externalpage('tooldbexport', get_string('dbexport', 'tool_dbtransfer'),
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/dbexport.php', 'moodle/site:config', true));
|
||||
}
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
/**
|
||||
* Version details.
|
||||
*
|
||||
* @package tool
|
||||
* @subpackage dbtransfer
|
||||
* @copyright 2008 Petr Skoda
|
||||
* @package tool_dbtransfer
|
||||
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2012061700; // Requires this Moodle version
|
||||
$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->version = 2012062200; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2012061700; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
@@ -287,7 +287,7 @@ $url = new moodle_url('/admin/tool/langimport/index.php', array('mode' => DELETI
|
||||
echo html_writer::start_tag('td', array('valign' => 'top'));
|
||||
echo html_writer::start_tag('form', array('id' => 'uninstallform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::label(get_string('installedlangs', 'tool_langimport'), 'uninstalllang');
|
||||
echo html_writer::label(get_string('installedlangs', 'tool_langimport'), 'menuuninstalllang');
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::select($installedlangs, 'uninstalllang', '', false, array('size' => 15));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
@@ -315,7 +315,7 @@ if (!empty($options)) {
|
||||
$url = new moodle_url('/admin/tool/langimport/index.php', array('mode' => INSTALLATION_OF_SELECTED_LANG));
|
||||
echo html_writer::start_tag('form', array('id' => 'installform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::label(get_string('availablelangs','install'), 'pack');
|
||||
echo html_writer::label(get_string('availablelangs','install'), 'menupack');
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::select($options, 'pack[]', '', false, array('size' => 15, 'multiple' => 'multiple'));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
|
||||
@@ -123,7 +123,7 @@ Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$/usr/bin/php lib/phpunit/tool.php --install
|
||||
\$ php ".phpunit_bootstrap_cli_argument_path('/admin/tool/phpunit/cli/util.php')." --install
|
||||
";
|
||||
echo $help;
|
||||
exit(0);
|
||||
@@ -150,7 +150,7 @@ if ($diag) {
|
||||
} else if ($drop) {
|
||||
// make sure tests do not run in parallel
|
||||
phpunit_util::acquire_test_lock();
|
||||
phpunit_util::drop_site();
|
||||
phpunit_util::drop_site(true);
|
||||
// note: we must stop here because $CFG is messed up and we can not reinstall, sorry
|
||||
exit(0);
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ if (isset($script)) {
|
||||
|
||||
// The flexitable that will root listings
|
||||
$table = new xhprof_table_sql('profiling-list-table');
|
||||
$baseurl = $CFG->wwwroot . '/admin/tool/profiling/index.php';
|
||||
$baseurl = $CFG->wwwroot . '/'.$CFG->admin.'/tool/profiling/index.php';
|
||||
|
||||
// Check if we are listing all or some URL ones
|
||||
$sqlconditions = '';
|
||||
|
||||
@@ -38,25 +38,29 @@ $sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
###################################################################
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading('Search and replace text throughout the whole database');
|
||||
echo $OUTPUT->heading(get_string('pageheader', 'tool_replace'));
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql' and $DB->get_dbfamily() !== 'postgres') {
|
||||
//TODO: add $DB->text_replace() to DML drivers
|
||||
echo $OUTPUT->notification('Sorry, this feature is implemented only for MySQL and PostgreSQL databases.');
|
||||
echo $OUTPUT->notification(get_string('notimplemented', 'tool_replace'));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
if (!data_submitted() or !$search or !$replace or !confirm_sesskey() or !$sure) { /// Print a form
|
||||
echo $OUTPUT->notification('This script is not supported, always make complete backup before proceeding!<br />This operation can not be reverted!');
|
||||
echo $OUTPUT->notification(get_string('notsupported', 'tool_replace'));
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="index.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<div><label for="search">Search whole database for: </label><input id="search" type="text" name="search" size="40" /> (usually previous server URL)</div>';
|
||||
echo '<div><label for="replace">Replace with this string: </label><input type="text" id="replace" name="replace" size="40" /> (usually new server URL)</div>';
|
||||
echo '<div><label for="sure">I understand the risks of this operation: </label><input type="checkbox" id="sure" name="sure" value="1" /></div>';
|
||||
echo '<div><label for="search">'.get_string('searchwholedb', 'tool_replace').
|
||||
' </label><input id="search" type="text" name="search" size="40" /> ('.
|
||||
get_string('searchwholedbhelp', 'tool_replace').')</div>';
|
||||
echo '<div><label for="replace">'.get_string('replacewith', 'tool_replace').
|
||||
' </label><input type="text" id="replace" name="replace" size="40" /> ('.
|
||||
get_string('replacewithhelp', 'tool_replace').')</div>';
|
||||
echo '<div><label for="sure">'.get_string('disclaimer', 'tool_replace').' </label><input type="checkbox" id="sure" name="sure" value="1" /></div>';
|
||||
echo '<div class="buttons"><input type="submit" class="singlebutton" value="Yes, do it now" /></div>';
|
||||
echo '</div></form>';
|
||||
echo '</div>';
|
||||
@@ -70,9 +74,9 @@ db_replace($search, $replace);
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
echo $OUTPUT->notification(get_string('notifyrebuilding', 'tool_replace'), 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
echo $OUTPUT->notification(get_string('notifyfinished', 'tool_replace'), 'notifysuccess');
|
||||
|
||||
echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
|
||||
|
||||
|
||||
@@ -23,4 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['disclaimer'] = 'I understand the risks of this operation:';
|
||||
$string['pageheader'] = 'Search and replace text throughout the whole database';
|
||||
$string['notifyfinished'] = '...finished';
|
||||
$string['notifyrebuilding'] = 'Rebuilding course cache...';
|
||||
$string['notimplemented'] = 'Sorry, this feature is implemented only for MySQL and PostgreSQL databases.';
|
||||
$string['notsupported'] ='This script is not supported, always make complete backup before proceeding!<br />This operation can not be reverted!';
|
||||
$string['pluginname'] = 'DB search and replace';
|
||||
$string['replacewith'] = 'Replace with this string:';
|
||||
$string['replacewithhelp'] = 'usually new server URL';
|
||||
$string['searchwholedb'] = 'Search whole database for:';
|
||||
$string['searchwholedbhelp'] = 'usually previous server URL';
|
||||
@@ -96,6 +96,7 @@ echo $OUTPUT->box_start(); // The forms section at the top
|
||||
|
||||
<form method="post" action="index.php">
|
||||
<div>
|
||||
<label class="accesshide" for="keyword_el"><?php print_string('spamkeyword', 'tool_spamcleaner') ?></label>
|
||||
<input type="text" name="keyword" id="keyword_el" value="<?php p($keyword) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
|
||||
<input type="submit" value="<?php echo get_string('spamsearch', 'tool_spamcleaner')?>" />
|
||||
|
||||
@@ -38,6 +38,7 @@ $string['spamfromcomments'] = 'From comments:';
|
||||
$string['spamfrommessages'] = 'From messages:';
|
||||
$string['spamfromforumpost'] = 'From forum post:';
|
||||
$string['spaminvalidresult'] = 'Unknown but invalid result';
|
||||
$string['spamkeyword'] = 'Keyword';
|
||||
$string['spamoperation'] = 'Operation';
|
||||
$string['spamresult'] = 'Results of searching user profiles containing:';
|
||||
$string['spamsearch'] = 'Search for these keywords';
|
||||
|
||||
@@ -857,6 +857,8 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
if ($duration > 0) { // sanity check
|
||||
$timeend = $today + $duration;
|
||||
}
|
||||
} else if ($manualcache[$courseid]->enrolperiod > 0) {
|
||||
$timeend = $today + $manualcache[$courseid]->enrolperiod;
|
||||
}
|
||||
|
||||
$manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend);
|
||||
|
||||
@@ -113,7 +113,7 @@ class new_table_from_mysql extends XMLDBAction {
|
||||
$o.= ' <input type="hidden" name ="postaction" value="edit_table" />';
|
||||
$o.= ' <input type="hidden" name ="sesskey" value="' . sesskey() . '" />';
|
||||
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
|
||||
$o.= ' <tr><td><label for="table" accesskey="t">' . $this->str['createtable'] .' </label>' . html_writer::select($selecttables, 'table') . '<label for="after" accesskey="a">' . $this->str['aftertable'] . ' </label>' .html_writer::select($aftertables, 'after') . '</td></tr>';
|
||||
$o.= ' <tr><td><label for="menutable" accesskey="t">' . $this->str['createtable'] .' </label>' . html_writer::select($selecttables, 'table') . '<label for="menuafter" accesskey="a">' . $this->str['aftertable'] . ' </label>' .html_writer::select($aftertables, 'after') . '</td></tr>';
|
||||
$o.= ' <tr><td colspan="2" align="center"><input type="submit" value="' .$this->str['create'] . '" /></td></tr>';
|
||||
$o.= ' <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>';
|
||||
$o.= ' </table>';
|
||||
|
||||
@@ -114,7 +114,7 @@ class view_structure_php extends XMLDBAction {
|
||||
$o.= ' <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />';
|
||||
$o.= ' <input type="hidden" name ="action" value="view_structure_php" />';
|
||||
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
|
||||
$o.= ' <tr><td><label for="action" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="table" accesskey="t">' . $this->str['selecttable'] . ' </label>' .html_writer::select($poptables, 'table', $tableparam, false) . '</td></tr>';
|
||||
$o.= ' <tr><td><label for="menucommand" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="menutable" accesskey="t">' . $this->str['selecttable'] . ' </label>' .html_writer::select($poptables, 'table', $tableparam, false) . '</td></tr>';
|
||||
$o.= ' <tr><td colspan="2" align="center"><input type="submit" value="' .$this->str['view'] . '" /></td></tr>';
|
||||
$o.= ' </table>';
|
||||
$o.= '</div></form>';
|
||||
|
||||
@@ -163,7 +163,7 @@ class view_table_php extends XMLDBAction {
|
||||
$o.= ' <input type="hidden" name ="table" value="' . s($tableparam) . '" />';
|
||||
$o.= ' <input type="hidden" name ="action" value="view_table_php" />';
|
||||
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
|
||||
$o.= ' <tr><td><label for="action" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="fieldkeyindex" accesskey="f">' . $this->str['selectfieldkeyindex'] . ' </label>' .html_writer::select($popfields, 'fieldkeyindex', $origfieldkeyindexparam, false) . '</td></tr>';
|
||||
$o.= ' <tr><td><label for="menucommand" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="menufieldkeyindex" accesskey="f">' . $this->str['selectfieldkeyindex'] . ' </label>' .html_writer::select($popfields, 'fieldkeyindex', $origfieldkeyindexparam, false) . '</td></tr>';
|
||||
$o.= ' <tr><td colspan="2" align="center"><input type="submit" value="' .$this->str['view'] . '" /></td></tr>';
|
||||
$o.= ' </table>';
|
||||
$o.= '</div></form>';
|
||||
|
||||
+14
-14
@@ -94,9 +94,9 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_cas_hostname_key', 'auth_cas') ?>:</td>
|
||||
<td align="right"><label for="hostname"><?php print_string('auth_cas_hostname_key', 'auth_cas') ?>: </label></td>
|
||||
<td>
|
||||
<input name="hostname" type="text" size="30" value="<?php echo $config->hostname ?>" />
|
||||
<input name="hostname" id="hostname" type="text" size="30" value="<?php echo $config->hostname ?>" />
|
||||
<?php if (isset($err['hostname'])) { echo $OUTPUT->error_text($err['hostname']); } ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -105,10 +105,10 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">
|
||||
<?php print_string('auth_cas_baseuri_key', 'auth_cas') ?>:
|
||||
<label for="baseuri"><?php print_string('auth_cas_baseuri_key', 'auth_cas') ?>: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="baseuri" type="text" size="30" value="<?php echo $config->baseuri ?>" />
|
||||
<input name="baseuri" id="baseuri" type="text" size="30" value="<?php echo $config->baseuri ?>" />
|
||||
<?php if (isset($err['baseuri'])) { echo $OUTPUT->error_text($err['baseuri']); } ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -117,10 +117,10 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">
|
||||
<?php print_string('auth_cas_port_key', 'auth_cas') ?>:
|
||||
<label for="port"><?php print_string('auth_cas_port_key', 'auth_cas') ?>: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="port" type="text" size="30" value="<?php echo $config->port ?>" />
|
||||
<input name="port" id="port" type="text" size="30" value="<?php echo $config->port ?>" />
|
||||
<?php if (isset($err['port'])) { echo $OUTPUT->error_text($err['port']); } ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -129,7 +129,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">
|
||||
<?php print_string('auth_cas_casversion', 'auth_cas') ?>:
|
||||
<?php echo html_writer::label(get_string('auth_cas_casversion', 'auth_cas'), 'menucasversion'); ?>:
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
@@ -145,7 +145,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_cas_language_key', 'auth_cas') ?>:</td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_cas_language_key', 'auth_cas'), 'menulanguage'); ?>:</td>
|
||||
<td>
|
||||
<?php echo html_writer::select($CASLANGUAGES, 'language', $config->language, false); ?>
|
||||
</td>
|
||||
@@ -155,7 +155,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">
|
||||
<?php print_string('auth_cas_proxycas_key', 'auth_cas') ?>:
|
||||
<?php echo html_writer::label(get_string('auth_cas_proxycas_key', 'auth_cas'), 'menuproxycas'); ?>:
|
||||
</td>
|
||||
<td>
|
||||
<?php echo html_writer::select($yesno, 'proxycas', $config->proxycas, false); ?>
|
||||
@@ -165,7 +165,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_cas_logoutcas_key', 'auth_cas') ?>:</td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_cas_logoutcas_key', 'auth_cas'), 'menulogoutcas'); ?>:</td>
|
||||
<td>
|
||||
<?php echo html_writer::select($yesno, 'logoutcas', $config->logoutcas, false); ?>
|
||||
</td>
|
||||
@@ -174,7 +174,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_cas_multiauth_key', 'auth_cas') ?>:</td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_cas_multiauth_key', 'auth_cas'), 'menumultiauth'); ?>:</td>
|
||||
<td>
|
||||
<?php echo html_writer::select($yesno, 'multiauth', $config->multiauth, false); ?>
|
||||
</td>
|
||||
@@ -183,7 +183,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_cas_certificate_check_key', 'auth_cas') ?>:</td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_cas_certificate_check_key', 'auth_cas'), 'menucertificate_check'); ?>:</td>
|
||||
<td>
|
||||
<?php echo html_writer::select($yesno, 'certificate_check', $config->certificate_check, false); ?>
|
||||
</td>
|
||||
@@ -192,7 +192,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_cas_certificate_path_key', 'auth_cas') ?>:</td>
|
||||
<td align="right"><label for="certificate_path"><?php print_string('auth_cas_certificate_path_key', 'auth_cas') ?>: </label></td>
|
||||
<td>
|
||||
<input name="certificate_path" id="certificate_path" type="text" size="30" value="<?php echo $config->certificate_path ?>" />
|
||||
<?php if (isset($err['certificate_path'])) echo $OUTPUT->error_text($err['certificate_path']); ?>
|
||||
@@ -219,7 +219,7 @@ $yesno = array( get_string('no'), get_string('yes') );
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="menuversion"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label></td>
|
||||
<td align="right"><label for="menuldap_version"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$versions = array();
|
||||
|
||||
+3
-1
@@ -132,7 +132,9 @@ class auth_plugin_email extends auth_plugin_base {
|
||||
|
||||
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
|
||||
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
|
||||
$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
|
||||
if ($user->firstaccess == 0) {
|
||||
$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
|
||||
}
|
||||
return AUTH_CONFIRM_OK;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['auth_emaildescription'] = 'Email confirmation is the default authentication method. When the user signs up, choosing their own new username and password, a confirmation email is sent to the user\'s email address. This email contains a secure link to a page where the user can confirm their account. Future logins just check the username and password against the stored values in the Moodle database.';
|
||||
$string['auth_emaildescription'] = '<p>Email-based self-registration enables a user to create their own account via a \'Create new account\' button on the login page. The user then receives an email containing a secure link to a page where they can confirm their account. Future logins just check the username and password against the stored values in the Moodle database.</p><p>Note: In addition to enabling the plugin, email-based self-registration must also be selected from the self registration drop-down menu on the \'Manage authentication\' page.</p>';
|
||||
$string['auth_emailnoemail'] = 'Tried to send you an email but failed!';
|
||||
$string['auth_emailrecaptcha'] = 'Adds a visual/audio confirmation form element to the signup page for email self-registering users. This protects your site against spammers and contributes to a worthwhile cause. See http://www.google.com/recaptcha/learnmore for more details. <br /><em>PHP cURL extension is required.</em>';
|
||||
$string['auth_emailrecaptcha_key'] = 'Enable reCAPTCHA element';
|
||||
|
||||
+12
-12
@@ -27,9 +27,9 @@
|
||||
<table cellspacing="0" cellpadding="5" border="0">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_fchost_key", "auth_fc") ?>:</td>
|
||||
<td align="right"><label for="host"><?php print_string("auth_fchost_key", "auth_fc") ?>:</label></td>
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host?>" />
|
||||
<input name="host" id="host" type="text" size="30" value="<?php echo $config->host?>" />
|
||||
<?php if (isset($err["host"])) echo $OUTPUT->error_text($err["host"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -38,9 +38,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_fcfppport_key", "auth_fc") ?>:</td>
|
||||
<td align="right"><label for="fppport"><?php print_string("auth_fcfppport_key", "auth_fc") ?>: </label></td>
|
||||
<td>
|
||||
<input name="fppport" type="text" size="30" value="<?php echo $config->fppport?>" />
|
||||
<input name="fppport" id="fppport" type="text" size="30" value="<?php echo $config->fppport?>" />
|
||||
<?php if (isset($err["fppport"])) echo $OUTPUT->error_text($err["host"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -49,9 +49,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_fcuserid_key", "auth_fc") ?>:</td>
|
||||
<td align="right"><label for="userid"><?php print_string("auth_fcuserid_key", "auth_fc") ?>:</label></td>
|
||||
<td>
|
||||
<input name="userid" type="text" size="30" maxlength="15" value="<?php echo $config->userid?>" />
|
||||
<input name="userid" id="userid" type="text" size="30" maxlength="15" value="<?php echo $config->userid?>" />
|
||||
<?php if (isset($err["userid"])) echo $OUTPUT->error_text($err["userid"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -59,9 +59,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_fcpasswd_key", "auth_fc") ?>:</td>
|
||||
<td align="right"><label for="passwd"><?php print_string("auth_fcpasswd_key", "auth_fc") ?>:</label></td>
|
||||
<td>
|
||||
<input name="passwd" type="password" size="30" maxlength="12" value="<?php echo $config->passwd?>" />
|
||||
<input name="passwd" id="passwd" type="password" size="30" maxlength="12" value="<?php echo $config->passwd?>" />
|
||||
<?php if (isset($err["passwd"])) echo $OUTPUT->error_text($err["passwd"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -70,9 +70,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_fccreators_key", "auth_fc") ?>:</td>
|
||||
<td align="right"><label for="creators"><?php print_string("auth_fccreators_key", "auth_fc") ?>: </label></td>
|
||||
<td>
|
||||
<input name="creators" type="text" size="30" value="<?php echo $config->creators?>" />
|
||||
<input name="creators" id="creators" type="text" size="30" value="<?php echo $config->creators?>" />
|
||||
<?php if (isset($err["creators"])) echo $OUTPUT->error_text($err["creators"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -81,9 +81,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_fcchangepasswordurl', 'auth_fc') ?>: </td>
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_fcchangepasswordurl', 'auth_fc') ?>: </label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
|
||||
@@ -18,9 +18,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
<table cellspacing="0" cellpadding="5" border="0">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_imaphost_key', 'auth_imap') ?>: </td>
|
||||
<td align="right"><label for="host"><?php print_string('auth_imaphost_key', 'auth_imap') ?>: </label></td>
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['host'])) {
|
||||
@@ -40,7 +40,7 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_imaptype_key', 'auth_imap') ?>: </td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_imaptype_key', 'auth_imap'), 'menutype'); ?>: </td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
@@ -56,9 +56,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_imapport_key', 'auth_imap') ?>: </td>
|
||||
<td align="right"><label for="port"><?php print_string('auth_imapport_key', 'auth_imap') ?>: </label></td>
|
||||
<td>
|
||||
<input name="port" type="text" size="6" value="<?php echo $config->port ?>" />
|
||||
<input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['port'])) {
|
||||
@@ -71,9 +71,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_imapchangepasswordurl_key', 'auth_imap') ?>: </td>
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_imapchangepasswordurl_key', 'auth_imap') ?>: </label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
|
||||
+3
-1
@@ -546,7 +546,9 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
return AUTH_CONFIRM_FAIL;
|
||||
}
|
||||
$DB->set_field('user', 'confirmed', 1, array('id'=>$user->id));
|
||||
$DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
|
||||
if ($user->firstaccess == 0) {
|
||||
$DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
|
||||
}
|
||||
return AUTH_CONFIRM_OK;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -118,7 +118,7 @@ $yesno = array(get_string('no'), get_string('yes'));
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">
|
||||
<label for="menuversion"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label>
|
||||
<label for="menuldap_version"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
@@ -170,7 +170,9 @@ class auth_plugin_manual extends auth_plugin_base {
|
||||
return AUTH_CONFIRM_ALREADY;
|
||||
} else {
|
||||
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
|
||||
$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
|
||||
if ($user->firstaccess == 0) {
|
||||
$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
|
||||
}
|
||||
return AUTH_CONFIRM_OK;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -22,9 +22,9 @@ if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict'
|
||||
<table cellspacing="0" cellpadding="5">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('rpc_negotiation_timeout', 'auth_mnet'); ?>: </td>
|
||||
<td align="right"><label for="rpc_negotiation_timeout"><?php print_string('rpc_negotiation_timeout', 'auth_mnet'); ?>: </label></td>
|
||||
<td>
|
||||
<input name="rpc_negotiation_timeout" type="text" size="5" value="<?php echo $config->rpc_negotiation_timeout ?>" />
|
||||
<input name="rpc_negotiation_timeout" id="rpc_negotiation_timeout" type="text" size="5" value="<?php echo $config->rpc_negotiation_timeout ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['rpc_negotiation_timeout'])) {
|
||||
@@ -45,7 +45,7 @@ if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict'
|
||||
<?php /*
|
||||
See MDL-21327 for why this is commented out
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auto_add_remote_users', 'auth_mnet'); ?>: </td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auto_add_remote_users', 'auth_mnet'), 'menuauto_add_remote_users'); ?>: </td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
<table cellspacing="0" cellpadding="5" border="0">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_nntphost_key', 'auth_nntp') ?>: </td>
|
||||
<td align="right"><label for="host"><?php print_string('auth_nntphost_key', 'auth_nntp') ?>: </label></td>
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["host"])) {
|
||||
@@ -37,9 +37,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_nntpport_key', 'auth_nntp') ?>: </td>
|
||||
<td align="right"><label for="port"><?php print_string('auth_nntpport_key', 'auth_nntp') ?>: </label></td>
|
||||
<td>
|
||||
<input name="port" type="text" size="6" value="<?php echo $config->port ?>" />
|
||||
<input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["port"])) {
|
||||
@@ -52,9 +52,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_nntpchangepasswordurl_key', 'auth_nntp') ?>: </td>
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_nntpchangepasswordurl_key', 'auth_nntp') ?>: </label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
|
||||
@@ -21,9 +21,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
<table cellspacing="0" cellpadding="5" border="0">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_pop3host_key', 'auth_pop3') ?>: </td>
|
||||
<td align="right"><label for="host"><?php print_string('auth_pop3host_key', 'auth_pop3') ?>: </label></td>
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['host'])) {
|
||||
@@ -43,7 +43,7 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_pop3type_key', 'auth_pop3') ?>: </td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_pop3type_key', 'auth_pop3'), 'menutype'); ?>: </td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
@@ -59,9 +59,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_pop3port_key', 'auth_pop3') ?>: </td>
|
||||
<td align="right"><label for="port"><?php print_string('auth_pop3port_key', 'auth_pop3') ?>: </label></td>
|
||||
<td>
|
||||
<input name="port" type="text" size="6" value="<?php echo $config->port ?>" />
|
||||
<input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['port'])) {
|
||||
@@ -74,9 +74,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_pop3mailbox_key', 'auth_pop3') ?>: </td>
|
||||
<td align="right"><label for="mailbox"><?php print_string('auth_pop3mailbox_key', 'auth_pop3') ?>: </label></td>
|
||||
<td>
|
||||
<input name="mailbox" type="text" size="6" value="<?php echo $config->mailbox ?>" />
|
||||
<input name="mailbox" id="mailbox" type="text" size="6" value="<?php echo $config->mailbox ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['mailbox'])) {
|
||||
@@ -89,9 +89,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_pop3changepasswordurl_key', 'auth_pop3') ?>: </td>
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_pop3changepasswordurl_key', 'auth_pop3') ?>: </label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
|
||||
@@ -30,9 +30,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
<table cellspacing="0" cellpadding="5" border="0">
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_radiushost_key', 'auth_radius') ?>: </td>
|
||||
<td align="right"><label for="host"><?php print_string('auth_radiushost_key', 'auth_radius') ?>: </label></td>
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['host'])) {
|
||||
@@ -45,9 +45,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_radiusnasport_key', 'auth_radius') ?>: </td>
|
||||
<td align="right"><label for="nasport"><?php print_string('auth_radiusnasport_key', 'auth_radius') ?>: </label></td>
|
||||
<td>
|
||||
<input name="nasport" type="text" size="6" value="<?php echo $config->nasport ?>" />
|
||||
<input name="nasport" id="nasport" type="text" size="6" value="<?php echo $config->nasport ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['nasport'])) {
|
||||
@@ -60,7 +60,7 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top" >
|
||||
<td align="right"><?php print_string('auth_radiustype_key', 'auth_radius') ?>: </td>
|
||||
<td align="right"><?php echo html_writer::label(get_string('auth_radiustype_key', 'auth_radius'), 'menuradiustype'); ?>: </td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
@@ -82,9 +82,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
|
||||
|
||||
<tr valign="top" >
|
||||
<td align="right"><?php print_string('auth_radiussecret_key', 'auth_radius') ?>: </td>
|
||||
<td align="right"><label for="secret"><?php print_string('auth_radiussecret_key', 'auth_radius') ?>: </label></td>
|
||||
<td>
|
||||
<input name="secret" type="text" size="6" value="<?php echo $config->secret ?>" />
|
||||
<input name="secret" id="secret" type="text" size="6" value="<?php echo $config->secret ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['secret'])) {
|
||||
@@ -97,9 +97,9 @@ if (!isset($config->changepasswordurl)) {
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_radiuschangepasswordurl_key', 'auth_radius') ?>: </td>
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_radiuschangepasswordurl_key', 'auth_radius') ?>: </label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
|
||||
+12
-12
@@ -20,17 +20,17 @@
|
||||
<table cellspacing="0" cellpadding="5" border="0">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("username") ?>:</td>
|
||||
<td align="right"><label for="user_attribute"><?php print_string("username") ?>: </label></td>
|
||||
<td>
|
||||
<input name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute ?>" />
|
||||
<input id="user_attribute" name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute ?>" />
|
||||
</td>
|
||||
<td><?php print_string("auth_shib_username_description", "auth_shibboleth") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_convert_data", "auth_shibboleth") ?>:</td>
|
||||
<td align="right"><label for="convert_data"><?php print_string("auth_shib_convert_data", "auth_shibboleth") ?>: </label></td>
|
||||
<td>
|
||||
<input name="convert_data" type="text" size="30" value="<?php echo $config->convert_data?>" />
|
||||
<input name="convert_data" id="convert_data" type="text" size="30" value="<?php echo $config->convert_data?>" />
|
||||
<?php
|
||||
|
||||
if ($config->convert_data and $config->convert_data != '' and !is_readable($config->convert_data)) {
|
||||
@@ -82,9 +82,9 @@ urn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_logout_url", "auth_shibboleth") ?>:</td>
|
||||
<td align="right"><label for="logout_handler"><?php print_string("auth_shib_logout_url", "auth_shibboleth") ?>: </label></td>
|
||||
<td>
|
||||
<input name="logout_handler" type="text" size="30" value="<?php
|
||||
<input name="logout_handler" id="logout_handler" type="text" size="30" value="<?php
|
||||
if ( isset($config->logout_handler) and !empty($config->logout_handler)){
|
||||
echo $config->logout_handler;
|
||||
}
|
||||
@@ -94,9 +94,9 @@ urn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_logout_return_url", "auth_shibboleth") ?>:</td>
|
||||
<td align="right"><label for="logout_return_url"><?php print_string("auth_shib_logout_return_url", "auth_shibboleth") ?>: </label></td>
|
||||
<td>
|
||||
<input name="logout_return_url" type="text" size="30" value="<?php
|
||||
<input name="logout_return_url" id="logout_return_url" type="text" size="30" value="<?php
|
||||
if ( isset($config->logout_return_url) and !empty($config->logout_return_url)){
|
||||
echo $config->logout_return_url;
|
||||
}
|
||||
@@ -106,9 +106,9 @@ urn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_auth_method", "auth_shibboleth") ?>:</td>
|
||||
<td align="right"><label for="login_name"><?php print_string("auth_shib_auth_method", "auth_shibboleth") ?>: </label></td>
|
||||
<td>
|
||||
<input name="login_name" type="text" size="30" value="<?php
|
||||
<input name="login_name" id="login_name" type="text" size="30" value="<?php
|
||||
if ( isset($config->login_name) and !empty($config->login_name)){
|
||||
echo htmlentities($config->login_name);
|
||||
} else {
|
||||
@@ -120,9 +120,9 @@ urn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_shib_changepasswordurl', 'auth_shibboleth') ?>: </td>
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_shib_changepasswordurl', 'auth_shibboleth') ?>: </label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
|
||||
@@ -29,9 +29,9 @@ if ($show_instructions) {
|
||||
|
||||
?>
|
||||
<div class="guestsub">
|
||||
<p><?php print_string("auth_shibboleth_select_organization", "auth_shibboleth"); ?></p>
|
||||
<p><label for="idp"><?php print_string("auth_shibboleth_select_organization", "auth_shibboleth"); ?></label></p>
|
||||
<form action="login.php" method="post" id="guestlogin">
|
||||
<select name="idp">
|
||||
<select id="idp" name="idp">
|
||||
<option value="-" ><?php print_string("auth_shibboleth_select_member", "auth_shibboleth"); ?></option>
|
||||
<?php
|
||||
print_idp_list();
|
||||
|
||||
@@ -63,6 +63,7 @@ $PAGE->https_required();
|
||||
$loginsite = get_string("loginsite");
|
||||
|
||||
$PAGE->set_url('/auth/shibboleth/login.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->navbar->add($loginsite);
|
||||
$PAGE->set_title("$site->fullname: $loginsite");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
|
||||
@@ -96,14 +96,19 @@ class file_nested_element extends backup_nested_element {
|
||||
if (is_null($this->backupid)) {
|
||||
$this->backupid = $processor->get_var(backup::VAR_BACKUPID);
|
||||
}
|
||||
parent::process($processor);
|
||||
return parent::process($processor);
|
||||
}
|
||||
|
||||
public function fill_values($values) {
|
||||
// Fill values
|
||||
parent::fill_values($values);
|
||||
// Do our own tasks (copy file from moodle to backup)
|
||||
backup_file_manager::copy_file_moodle2backup($this->backupid, $values);
|
||||
try {
|
||||
backup_file_manager::copy_file_moodle2backup($this->backupid, $values);
|
||||
} catch (file_exception $e) {
|
||||
$this->add_result(array('missing_files_in_pool' => true));
|
||||
$this->add_log('missing file in pool: ' . $e->debuginfo, backup::LOG_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -293,30 +293,46 @@ abstract class restore_activity_task extends restore_task {
|
||||
// Define activity_userinfo. Dependent of:
|
||||
// - users root setting
|
||||
// - section_userinfo setting (if exists)
|
||||
// - activity_included setting
|
||||
// - activity_included setting.
|
||||
$settingname = $settingprefix . 'userinfo';
|
||||
$selectvalues = array(0=>get_string('no')); // Safer options
|
||||
$defaultvalue = false; // Safer default
|
||||
$defaultvalue = false;
|
||||
if (isset($this->info->settings[$settingname]) && $this->info->settings[$settingname]) { // Only enabled when available
|
||||
$selectvalues = array(1=>get_string('yes'), 0=>get_string('no'));
|
||||
$defaultvalue = true;
|
||||
}
|
||||
|
||||
$activity_userinfo = new restore_activity_userinfo_setting($settingname, base_setting::IS_BOOLEAN, $defaultvalue);
|
||||
$activity_userinfo->set_ui(new backup_setting_ui_select($activity_userinfo, get_string('includeuserinfo','backup'), $selectvalues));
|
||||
if (!$defaultvalue) {
|
||||
// This is a bit hacky, but if there is no user data to restore, then
|
||||
// we replace the standard check-box with a select menu with the
|
||||
// single choice 'No', and the select menu is clever enough that if
|
||||
// there is only one choice, it just displays a static string.
|
||||
//
|
||||
// It would probably be better design to have a special UI class
|
||||
// setting_ui_checkbox_or_no, rather than this hack, but I am not
|
||||
// going to do that today.
|
||||
$activity_userinfo->set_ui(new backup_setting_ui_select($activity_userinfo, '-',
|
||||
array(0 => get_string('no'))));
|
||||
} else {
|
||||
$activity_userinfo->get_ui()->set_label('-');
|
||||
}
|
||||
|
||||
$this->add_setting($activity_userinfo);
|
||||
|
||||
// Look for "users" root setting
|
||||
$users = $this->plan->get_setting('users');
|
||||
$users->add_dependency($activity_userinfo);
|
||||
|
||||
// Look for "section_userinfo" section setting (if exists)
|
||||
$settingname = 'section_' . $this->info->sectionid . '_userinfo';
|
||||
if ($this->plan->setting_exists($settingname)) {
|
||||
$section_userinfo = $this->plan->get_setting($settingname);
|
||||
$section_userinfo->add_dependency($activity_userinfo);
|
||||
}
|
||||
// Look for "activity_included" setting
|
||||
|
||||
// Look for "activity_included" setting.
|
||||
$activity_included->add_dependency($activity_userinfo);
|
||||
|
||||
// End of common activity settings, let's add the particular ones
|
||||
// End of common activity settings, let's add the particular ones.
|
||||
$this->define_my_settings();
|
||||
}
|
||||
|
||||
|
||||
@@ -169,21 +169,36 @@ class restore_section_task extends restore_task {
|
||||
|
||||
// Define section_userinfo. Dependent of:
|
||||
// - users root setting
|
||||
// - section_included setting
|
||||
// - section_included setting.
|
||||
$settingname = $settingprefix . 'userinfo';
|
||||
$selectvalues = array(0=>get_string('no')); // Safer options
|
||||
$defaultvalue = false; // Safer default
|
||||
$defaultvalue = false;
|
||||
if (isset($this->info->settings[$settingname]) && $this->info->settings[$settingname]) { // Only enabled when available
|
||||
$selectvalues = array(1=>get_string('yes'), 0=>get_string('no'));
|
||||
$defaultvalue = true;
|
||||
}
|
||||
|
||||
$section_userinfo = new restore_section_userinfo_setting($settingname, base_setting::IS_BOOLEAN, $defaultvalue);
|
||||
$section_userinfo->set_ui(new backup_setting_ui_select($section_userinfo, get_string('includeuserinfo','backup'), $selectvalues));
|
||||
if (!$defaultvalue) {
|
||||
// This is a bit hacky, but if there is no user data to restore, then
|
||||
// we replace the standard check-box with a select menu with the
|
||||
// single choice 'No', and the select menu is clever enough that if
|
||||
// there is only one choice, it just displays a static string.
|
||||
//
|
||||
// It would probably be better design to have a special UI class
|
||||
// setting_ui_checkbox_or_no, rather than this hack, but I am not
|
||||
// going to do that today.
|
||||
$section_userinfo->set_ui(new backup_setting_ui_select($section_userinfo, get_string('includeuserinfo','backup'),
|
||||
array(0 => get_string('no'))));
|
||||
} else {
|
||||
$section_userinfo->get_ui()->set_label(get_string('includeuserinfo','backup'));
|
||||
}
|
||||
|
||||
$this->add_setting($section_userinfo);
|
||||
// Look for "users" root setting
|
||||
|
||||
// Look for "users" root setting.
|
||||
$users = $this->plan->get_setting('users');
|
||||
$users->add_dependency($section_userinfo);
|
||||
// Look for "section_included" section setting
|
||||
|
||||
// Look for "section_included" section setting.
|
||||
$section_included->add_dependency($section_userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,14 @@ class restore_gradebook_structure_step extends restore_structure_step {
|
||||
|
||||
$data->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
|
||||
|
||||
$newitemid = $DB->insert_record('grade_letters', $data);
|
||||
$gradeletter = (array)$data;
|
||||
unset($gradeletter['id']);
|
||||
if (!$DB->record_exists('grade_letters', $gradeletter)) {
|
||||
$newitemid = $DB->insert_record('grade_letters', $data);
|
||||
} else {
|
||||
$newitemid = $data->id;
|
||||
}
|
||||
|
||||
$this->set_mapping('grade_letter', $oldid, $newitemid);
|
||||
}
|
||||
protected function process_grade_setting($data) {
|
||||
@@ -1737,6 +1744,23 @@ class restore_calendarevents_structure_step extends restore_structure_step {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Handle events with empty eventtype //MDL-32827
|
||||
if(empty($data->eventtype)) {
|
||||
if ($data->courseid == $SITE->id) { // Site event
|
||||
$data->eventtype = "site";
|
||||
} else if ($data->courseid != 0 && $data->groupid == 0 && ($data->modulename == 'assignment' || $data->modulename == 'assign')) {
|
||||
// Course assingment event
|
||||
$data->eventtype = "due";
|
||||
} else if ($data->courseid != 0 && $data->groupid == 0) { // Course event
|
||||
$data->eventtype = "course";
|
||||
} else if ($data->groupid) { // Group event
|
||||
$data->eventtype = "group";
|
||||
} else if ($data->userid) { // User event
|
||||
$data->eventtype = "user";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'name' => $data->name,
|
||||
@@ -2384,17 +2408,21 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
|
||||
/**
|
||||
* process activity grade_letters. Note that, while these are possible,
|
||||
* because grade_letters are contextid based, in proctice, only course
|
||||
* because grade_letters are contextid based, in practice, only course
|
||||
* context letters can be defined. So we keep here this method knowing
|
||||
* it won't be executed ever. gradebook restore will restore course letters.
|
||||
*/
|
||||
protected function process_grade_letter($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
$data['contextid'] = $this->task->get_contextid();
|
||||
$gradeletter = (object)$data;
|
||||
|
||||
$data->contextid = $this->task->get_contextid();
|
||||
$newitemid = $DB->insert_record('grade_letters', $data);
|
||||
// Check if it exists before adding it
|
||||
unset($data['id']);
|
||||
if (!$DB->record_exists('grade_letters', $data)) {
|
||||
$newitemid = $DB->insert_record('grade_letters', $gradeletter);
|
||||
}
|
||||
// no need to save any grade_letter mapping
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
This files describes API changes in /backup/*,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 2.4 ===
|
||||
|
||||
* Since 2.3.1+ the backup file name schema has changed. The ID of the course will always be part of
|
||||
the filename regardless of the setting 'backup_shortname'. See MDL-33812.
|
||||
|
||||
=== 2.3 ===
|
||||
|
||||
* Since 2.3.1+ the backup file name schema has changed. The ID of the course will always be part of
|
||||
the filename regardless of the setting 'backup_shortname'. See MDL-33812.
|
||||
|
||||
=== 2.2 ===
|
||||
|
||||
* Since 2.2.4+ the backup file name schema has changed. The ID of the course will always be part of
|
||||
the filename regardless of the setting 'backup_shortname'. See MDL-33812.
|
||||
@@ -112,7 +112,7 @@ abstract class backup_plan_dbops extends backup_dbops {
|
||||
|
||||
// Get all sections belonging to requested course
|
||||
$sectionsarr = array();
|
||||
$sections = $DB->get_records('course_sections', array('course' => $courseid));
|
||||
$sections = $DB->get_records('course_sections', array('course' => $courseid), 'section');
|
||||
foreach ($sections as $section) {
|
||||
$sectionsarr[] = $section->id;
|
||||
}
|
||||
@@ -197,19 +197,19 @@ abstract class backup_plan_dbops extends backup_dbops {
|
||||
* @param int $courseid/$sectionid/$cmid
|
||||
* @param bool $users Should be true is users were included in the backup
|
||||
* @param bool $anonymised Should be true is user information was anonymized.
|
||||
* @param bool $useidasname true to use id, false to use strings (default)
|
||||
* @param bool $useidonly only use the ID in the file name
|
||||
* @return string The filename to use
|
||||
*/
|
||||
public static function get_default_backup_filename($format, $type, $id, $users, $anonymised, $useidasname = false) {
|
||||
public static function get_default_backup_filename($format, $type, $id, $users, $anonymised, $useidonly = false) {
|
||||
global $DB;
|
||||
|
||||
// Calculate backup word
|
||||
$backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename')));
|
||||
$backupword = trim(clean_filename($backupword), '_');
|
||||
|
||||
// Not $useidonly, lets fetch the name
|
||||
$shortname = '';
|
||||
// Not $useidasname, lets calculate it, else $id will be used
|
||||
if (!$useidasname) {
|
||||
if (!$useidonly) {
|
||||
// Calculate proper name element (based on type)
|
||||
switch ($type) {
|
||||
case backup::TYPE_1COURSE:
|
||||
@@ -231,7 +231,11 @@ abstract class backup_plan_dbops extends backup_dbops {
|
||||
$shortname = textlib::strtolower(trim(clean_filename($shortname), '_'));
|
||||
}
|
||||
|
||||
$name = empty($shortname) ? $id : $shortname;
|
||||
// The name will always contain the ID, but we append the course short name if requested.
|
||||
$name = $id;
|
||||
if (!$useidonly && $shortname != '') {
|
||||
$name .= '-' . $shortname;
|
||||
}
|
||||
|
||||
// Calculate date
|
||||
$backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig'));
|
||||
|
||||
@@ -819,10 +819,13 @@ abstract class restore_dbops {
|
||||
* @param int|null $olditemid
|
||||
* @param int|null $forcenewcontextid explicit value for the new contextid (skip mapping)
|
||||
* @param bool $skipparentitemidctxmatch
|
||||
* @return array of result object
|
||||
*/
|
||||
public static function send_files_to_pool($basepath, $restoreid, $component, $filearea, $oldcontextid, $dfltuserid, $itemname = null, $olditemid = null, $forcenewcontextid = null, $skipparentitemidctxmatch = false) {
|
||||
global $DB;
|
||||
|
||||
$results = array();
|
||||
|
||||
if ($forcenewcontextid) {
|
||||
// Some components can have "forced" new contexts (example: questions can end belonging to non-standard context mappings,
|
||||
// with questions originally at system/coursecat context in source being restored to course context in target). So we need
|
||||
@@ -902,8 +905,14 @@ abstract class restore_dbops {
|
||||
// this is a regular file, it must be present in the backup pool
|
||||
$backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash);
|
||||
|
||||
// The file is not found in the backup.
|
||||
if (!file_exists($backuppath)) {
|
||||
throw new restore_dbops_exception('file_not_found_in_pool', $file);
|
||||
$result = new stdClass();
|
||||
$result->code = 'file_missing_in_backup';
|
||||
$result->message = sprintf('missing file %s%s in backup', $file->filepath, $file->filename);
|
||||
$result->level = backup::LOG_WARNING;
|
||||
$results[] = $result;
|
||||
continue;
|
||||
}
|
||||
|
||||
// create the file in the filepool if it does not exist yet
|
||||
@@ -960,6 +969,7 @@ abstract class restore_dbops {
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,8 @@ abstract class backup_cron_automated_helper {
|
||||
const BACKUP_STATUS_UNFINISHED = 2;
|
||||
/** Course automated backup was skipped */
|
||||
const BACKUP_STATUS_SKIPPED = 3;
|
||||
/** Course automated backup had warnings */
|
||||
const BACKUP_STATUS_WARNING = 4;
|
||||
|
||||
/** Run if required by the schedule set in config. Default. **/
|
||||
const RUN_ON_SCHEDULE = 0;
|
||||
@@ -110,7 +112,7 @@ abstract class backup_cron_automated_helper {
|
||||
$nextstarttime = backup_cron_automated_helper::calculate_next_automated_backup($admin->timezone, $now);
|
||||
$showtime = "undefined";
|
||||
if ($nextstarttime > 0) {
|
||||
$showtime = userdate($nextstarttime,"",$admin->timezone);
|
||||
$showtime = date('r', $nextstarttime);
|
||||
}
|
||||
|
||||
$rs = $DB->get_recordset('course');
|
||||
@@ -124,7 +126,14 @@ abstract class backup_cron_automated_helper {
|
||||
}
|
||||
|
||||
// Skip courses that do not yet need backup
|
||||
$skipped = !(($backupcourse->nextstarttime >= 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY);
|
||||
$skipped = !(($backupcourse->nextstarttime > 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY);
|
||||
if ($skipped && $backupcourse->nextstarttime != $nextstarttime) {
|
||||
$backupcourse->nextstarttime = $nextstarttime;
|
||||
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_SKIPPED;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Backup of \'' . $course->fullname . '\' is scheduled on ' . $showtime);
|
||||
}
|
||||
|
||||
// Skip backup of unavailable courses that have remained unmodified in a month
|
||||
if (!$skipped && empty($course->visible) && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + settings were unmodified last month
|
||||
//Check log if there were any modifications to the course content
|
||||
@@ -132,16 +141,17 @@ abstract class backup_cron_automated_helper {
|
||||
$params = array('courseid' => $course->id, 'time' => $now-31*24*60*60, 'action' => '%view%');
|
||||
$logexists = $DB->record_exists_select('log', $sqlwhere, $params);
|
||||
if (!$logexists) {
|
||||
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_SKIPPED;
|
||||
$backupcourse->laststatus = self::BACKUP_STATUS_SKIPPED;
|
||||
$backupcourse->nextstarttime = $nextstarttime;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Skipping unchanged course '.$course->fullname);
|
||||
$skipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Now we backup every non-skipped course
|
||||
if (!$skipped) {
|
||||
mtrace('Backing up '.$course->fullname, '...');
|
||||
mtrace('Backing up '.$course->fullname.'...');
|
||||
|
||||
//We have to send a email because we have included at least one backup
|
||||
$emailpending = true;
|
||||
@@ -152,7 +162,7 @@ abstract class backup_cron_automated_helper {
|
||||
$starttime = time();
|
||||
|
||||
$backupcourse->laststarttime = time();
|
||||
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED;
|
||||
$backupcourse->laststatus = self::BACKUP_STATUS_UNFINISHED;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
|
||||
$backupcourse->laststatus = backup_cron_automated_helper::launch_automated_backup($course, $backupcourse->laststarttime, $admin->id);
|
||||
@@ -161,7 +171,7 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
|
||||
if ($backupcourse->laststatus) {
|
||||
if ($backupcourse->laststatus === self::BACKUP_STATUS_OK) {
|
||||
// Clean up any excess course backups now that we have
|
||||
// taken a successful backup.
|
||||
$removedcount = backup_cron_automated_helper::remove_excess_backups($course);
|
||||
@@ -180,17 +190,18 @@ abstract class backup_cron_automated_helper {
|
||||
$message = "";
|
||||
|
||||
$count = backup_cron_automated_helper::get_backup_status_array();
|
||||
$haserrors = ($count[backup_cron_automated_helper::BACKUP_STATUS_ERROR] != 0 || $count[backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED] != 0);
|
||||
$haserrors = ($count[self::BACKUP_STATUS_ERROR] != 0 || $count[self::BACKUP_STATUS_UNFINISHED] != 0);
|
||||
|
||||
//Build the message text
|
||||
//Summary
|
||||
$message .= get_string('summary')."\n";
|
||||
$message .= "==================================================\n";
|
||||
$message .= " ".get_string('courses').": ".array_sum($count)."\n";
|
||||
$message .= " ".get_string('ok').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_OK]."\n";
|
||||
$message .= " ".get_string('skipped').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_SKIPPED]."\n";
|
||||
$message .= " ".get_string('error').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_ERROR]."\n";
|
||||
$message .= " ".get_string('unfinished').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED]."\n\n";
|
||||
$message .= " ".get_string('ok').": ".$count[self::BACKUP_STATUS_OK]."\n";
|
||||
$message .= " ".get_string('skipped').": ".$count[self::BACKUP_STATUS_SKIPPED]."\n";
|
||||
$message .= " ".get_string('error').": ".$count[self::BACKUP_STATUS_ERROR]."\n";
|
||||
$message .= " ".get_string('unfinished').": ".$count[self::BACKUP_STATUS_UNFINISHED]."\n";
|
||||
$message .= " ".get_string('warning').": ".$count[self::BACKUP_STATUS_WARNING]."\n\n";
|
||||
|
||||
//Reference
|
||||
if ($haserrors) {
|
||||
@@ -253,9 +264,10 @@ abstract class backup_cron_automated_helper {
|
||||
self::BACKUP_STATUS_OK => 0,
|
||||
self::BACKUP_STATUS_UNFINISHED => 0,
|
||||
self::BACKUP_STATUS_SKIPPED => 0,
|
||||
self::BACKUP_STATUS_WARNING => 0
|
||||
);
|
||||
|
||||
$statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');
|
||||
$statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');
|
||||
|
||||
foreach ($statuses as $status) {
|
||||
if (empty($status->statuscount)) {
|
||||
@@ -270,36 +282,47 @@ abstract class backup_cron_automated_helper {
|
||||
/**
|
||||
* Works out the next time the automated backup should be run.
|
||||
*
|
||||
* @param mixed $timezone
|
||||
* @param int $now
|
||||
* @return int
|
||||
* @param mixed $timezone user timezone
|
||||
* @param int $now timestamp, should not be in the past, most likely time()
|
||||
* @return int timestamp of the next execution at server time
|
||||
*/
|
||||
public static function calculate_next_automated_backup($timezone, $now) {
|
||||
|
||||
$result = -1;
|
||||
$result = 0;
|
||||
$config = get_config('backup');
|
||||
$midnight = usergetmidnight($now, $timezone);
|
||||
$autohour = $config->backup_auto_hour;
|
||||
$automin = $config->backup_auto_minute;
|
||||
|
||||
// Gets the user time relatively to the server time.
|
||||
$date = usergetdate($now, $timezone);
|
||||
$usertime = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'], $date['year']);
|
||||
$diff = $now - $usertime;
|
||||
|
||||
//Get number of days (from today) to execute backups
|
||||
$automateddays = substr($config->backup_auto_weekdays,$date['wday']) . $config->backup_auto_weekdays;
|
||||
$daysfromtoday = strpos($automateddays, "1");
|
||||
if (empty($daysfromtoday)) {
|
||||
$daysfromtoday = 1;
|
||||
// Get number of days (from user's today) to execute backups.
|
||||
$automateddays = substr($config->backup_auto_weekdays, $date['wday']) . $config->backup_auto_weekdays;
|
||||
$daysfromnow = strpos($automateddays, "1");
|
||||
|
||||
// Error, there are no days to schedule the backup for.
|
||||
if ($daysfromnow === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//If some day has been found
|
||||
if ($daysfromtoday !== false) {
|
||||
//Calculate distance
|
||||
$dist = ($daysfromtoday * 86400) + //Days distance
|
||||
($config->backup_auto_hour * 3600) + //Hours distance
|
||||
($config->backup_auto_minute * 60); //Minutes distance
|
||||
$result = $midnight + $dist;
|
||||
// Checks if the date would happen in the future (of the user).
|
||||
$userresult = mktime($autohour, $automin, 0, $date['mon'], $date['mday'] + $daysfromnow, $date['year']);
|
||||
if ($userresult <= $usertime) {
|
||||
// If not, we skip the first scheduled day, that should fix it.
|
||||
$daysfromnow = strpos($automateddays, "1", 1);
|
||||
$userresult = mktime($autohour, $automin, 0, $date['mon'], $date['mday'] + $daysfromnow, $date['year']);
|
||||
}
|
||||
|
||||
//If that time is past, call the function recursively to obtain the next valid day
|
||||
if ($result > 0 && $result < time()) {
|
||||
$result = self::calculate_next_automated_backup($timezone, $result);
|
||||
// Now we generate the time relative to the server.
|
||||
$result = $userresult + $diff;
|
||||
|
||||
// If that time is past, call the function recursively to obtain the next valid day.
|
||||
if ($result <= $now) {
|
||||
// Checking time() in here works, but makes PHPUnit Tests extremely hard to predict.
|
||||
// $now should never be earlier than time() anyway...
|
||||
$result = self::calculate_next_automated_backup($timezone, $now + DAYSECS);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -315,7 +338,7 @@ abstract class backup_cron_automated_helper {
|
||||
*/
|
||||
public static function launch_automated_backup($course, $starttime, $userid) {
|
||||
|
||||
$outcome = true;
|
||||
$outcome = self::BACKUP_STATUS_OK;
|
||||
$config = get_config('backup');
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_AUTOMATED, $userid);
|
||||
|
||||
@@ -350,6 +373,7 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$bc->execute_plan();
|
||||
$results = $bc->get_results();
|
||||
$outcome = self::outcome_from_results($results);
|
||||
$file = $results['backup_destination']; // may be empty if file already moved to target location
|
||||
$dir = $config->backup_auto_destination;
|
||||
$storage = (int)$config->backup_auto_storage;
|
||||
@@ -358,8 +382,10 @@ abstract class backup_cron_automated_helper {
|
||||
}
|
||||
if ($file && !empty($dir) && $storage !== 0) {
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, !$config->backup_shortname);
|
||||
$outcome = $file->copy_content_to($dir.'/'.$filename);
|
||||
if ($outcome && $storage === 1) {
|
||||
if (!$file->copy_content_to($dir.'/'.$filename)) {
|
||||
$outcome = self::BACKUP_STATUS_ERROR;
|
||||
}
|
||||
if ($outcome != self::BACKUP_STATUS_ERROR && $storage === 1) {
|
||||
$file->delete();
|
||||
}
|
||||
}
|
||||
@@ -368,7 +394,7 @@ abstract class backup_cron_automated_helper {
|
||||
$bc->log('backup_auto_failed_on_course', backup::LOG_ERROR, $course->shortname); // Log error header.
|
||||
$bc->log('Exception: ' . $e->errorcode, backup::LOG_ERROR, $e->a, 1); // Log original exception problem.
|
||||
$bc->log('Debug: ' . $e->debuginfo, backup::LOG_DEBUG, null, 1); // Log original debug information.
|
||||
$outcome = false;
|
||||
$outcome = self::BACKUP_STATUS_ERROR;
|
||||
}
|
||||
|
||||
$bc->destroy();
|
||||
@@ -377,6 +403,30 @@ abstract class backup_cron_automated_helper {
|
||||
return $outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the backup outcome by analysing its results.
|
||||
*
|
||||
* @param array $results returned by a backup
|
||||
* @return int {@link self::BACKUP_STATUS_OK} and other constants
|
||||
*/
|
||||
public static function outcome_from_results($results) {
|
||||
$outcome = self::BACKUP_STATUS_OK;
|
||||
foreach ($results as $code => $value) {
|
||||
// Each possible error and warning code has to be specified in this switch
|
||||
// which basically analyses the results to return the correct backup status.
|
||||
switch ($code) {
|
||||
case 'missing_files_in_pool':
|
||||
$outcome = self::BACKUP_STATUS_WARNING;
|
||||
break;
|
||||
}
|
||||
// If we found the highest error level, we exit the loop.
|
||||
if ($outcome == self::BACKUP_STATUS_ERROR) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes deleted courses fromn the backup_courses table so that we don't
|
||||
* waste time backing them up.
|
||||
@@ -409,7 +459,12 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$config = get_config('backup');
|
||||
$active = (int)$config->backup_auto_active;
|
||||
if ($active === self::AUTO_BACKUP_DISABLED || ($rundirective == self::RUN_ON_SCHEDULE && $active === self::AUTO_BACKUP_MANUAL)) {
|
||||
$weekdays = (string)$config->backup_auto_weekdays;
|
||||
|
||||
// In case of automated backup also check that it is scheduled for at least one weekday.
|
||||
if ($active === self::AUTO_BACKUP_DISABLED ||
|
||||
($rundirective == self::RUN_ON_SCHEDULE && $active === self::AUTO_BACKUP_MANUAL) ||
|
||||
($rundirective == self::RUN_ON_SCHEDULE && strpos($weekdays, '1') === false)) {
|
||||
return self::STATE_DISABLED;
|
||||
} else if (!empty($config->backup_auto_running)) {
|
||||
// Detect if the backup_auto_running semaphore is a valid one
|
||||
|
||||
@@ -0,0 +1,442 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Unit tests for backups cron helper.
|
||||
*
|
||||
* @package core_backup
|
||||
* @category phpunit
|
||||
* @copyright 2012 Frédéric Massart <fred@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/backup/util/helper/backup_cron_helper.class.php');
|
||||
|
||||
/**
|
||||
* Unit tests for backup cron helper
|
||||
*/
|
||||
class backup_cron_helper_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test {@link backup_cron_automated_helper::calculate_next_automated_backup}.
|
||||
*/
|
||||
public function test_next_automated_backup() {
|
||||
$this->resetAfterTest();
|
||||
set_config('backup_auto_active', '1', 'backup');
|
||||
|
||||
// Notes
|
||||
// - backup_auto_weekdays starts on Sunday
|
||||
// - Tests cannot be done in the past
|
||||
// - Only the DST on the server side is handled.
|
||||
|
||||
// Every Tue and Fri at 11pm.
|
||||
set_config('backup_auto_weekdays', '0010010', 'backup');
|
||||
set_config('backup_auto_hour', '23', 'backup');
|
||||
set_config('backup_auto_minute', '0', 'backup');
|
||||
$timezone = 99;
|
||||
|
||||
$now = strtotime('next Monday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-23:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Tuesday 18:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-23:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Wednesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('5-23:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Thursday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('5-23:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Friday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('5-23:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Saturday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-23:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Sunday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-23:00', date('w-H:i', $next));
|
||||
|
||||
// Every Sun and Sat at 12pm.
|
||||
set_config('backup_auto_weekdays', '1000001', 'backup');
|
||||
set_config('backup_auto_hour', '0', 'backup');
|
||||
set_config('backup_auto_minute', '0', 'backup');
|
||||
$timezone = 99;
|
||||
|
||||
$now = strtotime('next Monday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Tuesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Wednesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Thursday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Friday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Saturday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Sunday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
// Every Sun at 4am.
|
||||
set_config('backup_auto_weekdays', '1000000', 'backup');
|
||||
set_config('backup_auto_hour', '4', 'backup');
|
||||
set_config('backup_auto_minute', '0', 'backup');
|
||||
$timezone = 99;
|
||||
|
||||
$now = strtotime('next Monday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Tuesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Wednesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Thursday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Friday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Saturday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Sunday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-04:00', date('w-H:i', $next));
|
||||
|
||||
// Every day but Wed at 8:30pm.
|
||||
set_config('backup_auto_weekdays', '1110111', 'backup');
|
||||
set_config('backup_auto_hour', '20', 'backup');
|
||||
set_config('backup_auto_minute', '30', 'backup');
|
||||
$timezone = 99;
|
||||
|
||||
$now = strtotime('next Monday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('1-20:30', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Tuesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-20:30', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Wednesday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('4-20:30', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Thursday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('4-20:30', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Friday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('5-20:30', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Saturday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-20:30', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Sunday 17:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-20:30', date('w-H:i', $next));
|
||||
|
||||
// Sun, Tue, Thu, Sat at 12pm.
|
||||
set_config('backup_auto_weekdays', '1010101', 'backup');
|
||||
set_config('backup_auto_hour', '0', 'backup');
|
||||
set_config('backup_auto_minute', '0', 'backup');
|
||||
$timezone = 99;
|
||||
|
||||
$now = strtotime('next Monday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Tuesday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('4-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Wednesday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('4-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Thursday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Friday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('6-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Saturday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0-00:00', date('w-H:i', $next));
|
||||
|
||||
$now = strtotime('next Sunday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('2-00:00', date('w-H:i', $next));
|
||||
|
||||
// None.
|
||||
set_config('backup_auto_weekdays', '0000000', 'backup');
|
||||
set_config('backup_auto_hour', '15', 'backup');
|
||||
set_config('backup_auto_minute', '30', 'backup');
|
||||
$timezone = 99;
|
||||
|
||||
$now = strtotime('next Sunday 13:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals('0', $next);
|
||||
|
||||
// Playing with timezones.
|
||||
set_config('backup_auto_weekdays', '1111111', 'backup');
|
||||
set_config('backup_auto_hour', '20', 'backup');
|
||||
set_config('backup_auto_minute', '00', 'backup');
|
||||
|
||||
$timezone = 99;
|
||||
date_default_timezone_set('Australia/Perth');
|
||||
$now = strtotime('18:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-20:00'), date('w-H:i', $next));
|
||||
|
||||
$timezone = 99;
|
||||
date_default_timezone_set('Europe/Brussels');
|
||||
$now = strtotime('18:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-20:00'), date('w-H:i', $next));
|
||||
|
||||
$timezone = 99;
|
||||
date_default_timezone_set('America/New_York');
|
||||
$now = strtotime('18:00:00');
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-20:00'), date('w-H:i', $next));
|
||||
|
||||
// Viva Australia! (UTC+8).
|
||||
date_default_timezone_set('Australia/Perth');
|
||||
$now = strtotime('18:00:00');
|
||||
|
||||
$timezone = -10.0; // 12am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-14:00', strtotime('tomorrow')), date('w-H:i', $next));
|
||||
|
||||
$timezone = -5.0; // 5am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-09:00', strtotime('tomorrow')), date('w-H:i', $next));
|
||||
|
||||
$timezone = 0.0; // 10am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-04:00', strtotime('tomorrow')), date('w-H:i', $next));
|
||||
|
||||
$timezone = 3.0; // 1pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-01:00', strtotime('tomorrow')), date('w-H:i', $next));
|
||||
|
||||
$timezone = 8.0; // 6pm for the user (same than the server).
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-20:00'), date('w-H:i', $next));
|
||||
|
||||
$timezone = 9.0; // 7pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-19:00'), date('w-H:i', $next));
|
||||
|
||||
$timezone = 13.0; // 12am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$this->assertEquals(date('w-15:00', strtotime('tomorrow')), date('w-H:i', $next));
|
||||
|
||||
// Let's have a Belgian beer! (UTC+1 / UTC+2 DST).
|
||||
date_default_timezone_set('Europe/Brussels');
|
||||
$now = strtotime('18:00:00');
|
||||
$dst = date('I');
|
||||
|
||||
$timezone = -10.0; // 7am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-07:00', strtotime('tomorrow')) : date('w-08:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = -5.0; // 12pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-02:00', strtotime('tomorrow')) : date('w-03:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 0.0; // 5pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-21:00') : date('w-22:00');
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 3.0; // 8pm for the user (note the expected time is today while in DST).
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-18:00', strtotime('tomorrow')) : date('w-19:00');
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 8.0; // 1am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-13:00', strtotime('tomorrow')) : date('w-14:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 9.0; // 2am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-12:00', strtotime('tomorrow')) : date('w-13:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 13.0; // 6am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-08:00', strtotime('tomorrow')) : date('w-09:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
// The big apple! (UTC-5 / UTC-4 DST).
|
||||
date_default_timezone_set('America/New_York');
|
||||
$now = strtotime('18:00:00');
|
||||
$dst = date('I');
|
||||
|
||||
$timezone = -10.0; // 1pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-01:00', strtotime('tomorrow')) : date('w-02:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = -5.0; // 6pm for the user (server time).
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-20:00') : date('w-21:00');
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 0.0; // 11pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-15:00', strtotime('tomorrow')) : date('w-16:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 3.0; // 2am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-12:00', strtotime('tomorrow')) : date('w-13:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 8.0; // 7am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-07:00', strtotime('tomorrow')) : date('w-08:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 9.0; // 8am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-06:00', strtotime('tomorrow')) : date('w-07:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 13.0; // 6am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? date('w-02:00', strtotime('tomorrow')) : date('w-03:00', strtotime('tomorrow'));
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
// Some more timezone tests
|
||||
set_config('backup_auto_weekdays', '0100001', 'backup');
|
||||
set_config('backup_auto_hour', '20', 'backup');
|
||||
set_config('backup_auto_minute', '00', 'backup');
|
||||
|
||||
date_default_timezone_set('Europe/Brussels');
|
||||
$now = strtotime('next Monday 18:00:00');
|
||||
$dst = date('I');
|
||||
|
||||
$timezone = -12.0; // 1pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '2-09:00' : '2-10:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = -4.0; // 1pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '2-01:00' : '2-02:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 0.0; // 5pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '1-21:00' : '1-22:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 2.0; // 7pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '1-19:00' : '1-20:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 4.0; // 9pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '6-17:00' : '6-18:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 12.0; // 6am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '6-09:00' : '6-10:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
// Some more timezone tests
|
||||
set_config('backup_auto_weekdays', '0100001', 'backup');
|
||||
set_config('backup_auto_hour', '02', 'backup');
|
||||
set_config('backup_auto_minute', '00', 'backup');
|
||||
|
||||
date_default_timezone_set('America/New_York');
|
||||
$now = strtotime('next Monday 04:00:00');
|
||||
$dst = date('I');
|
||||
|
||||
$timezone = -12.0; // 8pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '1-09:00' : '1-10:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = -4.0; // 4am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '6-01:00' : '6-02:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 0.0; // 8am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '5-21:00' : '5-22:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 2.0; // 10am for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '5-19:00' : '5-20:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 4.0; // 12pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '5-17:00' : '5-18:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
$timezone = 12.0; // 8pm for the user.
|
||||
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
|
||||
$expected = !$dst ? '5-09:00' : '5-10:00';
|
||||
$this->assertEquals($expected, date('w-H:i', $next));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -94,11 +94,22 @@ abstract class backup_structure_step extends backup_step {
|
||||
// Process structure definition
|
||||
$structure->process($pr);
|
||||
|
||||
// Get the results from the nested elements
|
||||
$results = $structure->get_results();
|
||||
|
||||
// Get the log messages to append to the log
|
||||
$logs = $structure->get_logs();
|
||||
foreach ($logs as $log) {
|
||||
$this->log($log->message, $log->level, $log->a, $log->depth, $log->display);
|
||||
}
|
||||
|
||||
// Close everything
|
||||
$xw->stop();
|
||||
|
||||
// Destroy the structure. It helps PHP 5.2 memory a lot!
|
||||
$structure->destroy();
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -218,8 +218,14 @@ abstract class restore_structure_step extends restore_step {
|
||||
*/
|
||||
public function add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null) {
|
||||
$filesctxid = is_null($filesctxid) ? $this->task->get_old_contextid() : $filesctxid;
|
||||
restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component,
|
||||
$filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid);
|
||||
$results = restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component,
|
||||
$filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid);
|
||||
$resultstoadd = array();
|
||||
foreach ($results as $result) {
|
||||
$this->log($result->message, $result->level);
|
||||
$resultstoadd[$result->code] = true;
|
||||
}
|
||||
$this->task->add_result($resultstoadd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,8 @@ class backup_nested_element extends base_nested_element implements processable {
|
||||
protected $aliases; // Define DB->final element aliases
|
||||
protected $fileannotations; // array of file areas to be searched by file annotations
|
||||
protected $counter; // Number of instances of this element that have been processed
|
||||
protected $results; // Logs the results we encounter during the process.
|
||||
protected $logs; // Some log messages that could be retrieved later.
|
||||
|
||||
/**
|
||||
* Constructor - instantiates one backup_nested_element, specifying its basic info.
|
||||
@@ -55,8 +57,16 @@ class backup_nested_element extends base_nested_element implements processable {
|
||||
$this->aliases = array();
|
||||
$this->fileannotations = array();
|
||||
$this->counter = 0;
|
||||
$this->results = array();
|
||||
$this->logs = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the nested element
|
||||
*
|
||||
* @param object $processor the processor
|
||||
* @return void
|
||||
*/
|
||||
public function process($processor) {
|
||||
if (!$processor instanceof base_processor) { // No correct processor, throw exception
|
||||
throw new base_element_struct_exception('incorrect_processor');
|
||||
@@ -113,6 +123,69 @@ class backup_nested_element extends base_nested_element implements processable {
|
||||
$iterator->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a log message to an array
|
||||
*
|
||||
* @see backup_helper::log()
|
||||
* @param string $message to add to the logs
|
||||
* @param int $level level of importance {@link backup::LOG_DEBUG} and other constants
|
||||
* @param mixed $a to be included in $message
|
||||
* @param int $depth of the message
|
||||
* @param display $bool supporting translation via get_string() if true
|
||||
* @return void
|
||||
*/
|
||||
protected function add_log($message, $level, $a = null, $depth = null, $display = false) {
|
||||
// Adding the result to the oldest parent.
|
||||
if ($this->get_parent()) {
|
||||
$parent = $this->get_grandparent();
|
||||
$parent->add_log($message, $level, $a, $depth, $display);
|
||||
} else {
|
||||
$log = new stdClass();
|
||||
$log->message = $message;
|
||||
$log->level = $level;
|
||||
$log->a = $a;
|
||||
$log->depth = $depth;
|
||||
$log->display = $display;
|
||||
$this->logs[] = $log;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the results to an array
|
||||
*
|
||||
* @param array $result associative array
|
||||
* @return void
|
||||
*/
|
||||
protected function add_result($result) {
|
||||
if (is_array($result)) {
|
||||
// Adding the result to the oldest parent.
|
||||
if ($this->get_parent()) {
|
||||
$parent = $this->get_grandparent();
|
||||
$parent->add_result($result);
|
||||
} else {
|
||||
$this->results = array_merge($this->results, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the logs
|
||||
*
|
||||
* @return array of log objects
|
||||
*/
|
||||
public function get_logs() {
|
||||
return $this->logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the results
|
||||
*
|
||||
* @return associative array of results
|
||||
*/
|
||||
public function get_results() {
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
public function set_source_array($arr) {
|
||||
// TODO: Only elements having final elements can set source
|
||||
$this->var_array = $arr;
|
||||
|
||||
@@ -487,6 +487,9 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
|
||||
if (!empty($this->results['include_file_references_to_external_content'])) {
|
||||
$output .= $renderer->notification(get_string('filereferencesincluded', 'backup'), 'notifyproblem');
|
||||
}
|
||||
if (!empty($this->results['missing_files_in_pool'])) {
|
||||
$output .= $renderer->notification(get_string('missingfilesinpool', 'backup'), 'notifyproblem');
|
||||
}
|
||||
$output .= $renderer->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
|
||||
$output .= $renderer->continue_button($restorerul);
|
||||
$output .= $renderer->box_end();
|
||||
|
||||
@@ -96,7 +96,6 @@ abstract class base_moodleform extends moodleform {
|
||||
* @global moodle_page $PAGE
|
||||
*/
|
||||
function definition_after_data() {
|
||||
global $PAGE;
|
||||
$buttonarray=array();
|
||||
$buttonarray[] = $this->_form->createElement('submit', 'submitbutton', get_string($this->uistage->get_ui()->get_name().'stage'.$this->uistage->get_stage().'action', 'backup'), array('class'=>'proceedbutton'));
|
||||
if (!$this->uistage->is_first_stage()) {
|
||||
@@ -106,13 +105,9 @@ abstract class base_moodleform extends moodleform {
|
||||
$this->_form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
|
||||
$this->_form->closeHeaderBefore('buttonar');
|
||||
|
||||
$config = new stdClass;
|
||||
$config->title = get_string('confirmcancel', 'backup');
|
||||
$config->question = get_string('confirmcancelquestion', 'backup');
|
||||
$config->yesLabel = get_string('confirmcancelyes', 'backup');
|
||||
$config->noLabel = get_string('confirmcancelno', 'backup');
|
||||
$PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
|
||||
$this->_definition_finalized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes any open divs
|
||||
*/
|
||||
@@ -318,7 +313,20 @@ abstract class base_moodleform extends moodleform {
|
||||
* Displays the form
|
||||
*/
|
||||
public function display() {
|
||||
global $PAGE;
|
||||
|
||||
$this->require_definition_after_data();
|
||||
|
||||
$config = new stdClass;
|
||||
$config->title = get_string('confirmcancel', 'backup');
|
||||
$config->question = get_string('confirmcancelquestion', 'backup');
|
||||
$config->yesLabel = get_string('confirmcancelyes', 'backup');
|
||||
$config->noLabel = get_string('confirmcancelno', 'backup');
|
||||
$PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
|
||||
|
||||
$PAGE->requires->yui_module('moodle-backup-backupselectall', 'M.core_backup.select_all_init',
|
||||
array(array('select' => get_string('select'), 'all' => get_string('all'), 'none' => get_string('none'))));
|
||||
|
||||
parent::display();
|
||||
}
|
||||
|
||||
@@ -327,7 +335,6 @@ abstract class base_moodleform extends moodleform {
|
||||
*/
|
||||
public function require_definition_after_data() {
|
||||
if (!$this->_definition_finalized) {
|
||||
$this->_definition_finalized = true;
|
||||
$this->definition_after_data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,6 +772,9 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
|
||||
$html .= $renderer->box_end();
|
||||
}
|
||||
$html .= $renderer->box_start();
|
||||
if (array_key_exists('file_missing_in_backup', $this->results)) {
|
||||
$html .= $renderer->notification(get_string('restorefileweremissing', 'backup'), 'notifyproblem');
|
||||
}
|
||||
$html .= $renderer->notification(get_string('restoreexecutionsuccess', 'backup'), 'notifysuccess');
|
||||
$html .= $renderer->continue_button(new moodle_url('/course/view.php', array(
|
||||
'id' => $this->get_ui()->get_controller()->get_courseid())), 'get');
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
YUI.add('moodle-backup-backupselectall', function(Y) {
|
||||
|
||||
// Namespace for the backup
|
||||
M.core_backup = M.core_backup || {};
|
||||
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*/
|
||||
M.core_backup.select_all_init = function(str) {
|
||||
var formid = null;
|
||||
|
||||
var helper = function(e, check, type) {
|
||||
e.preventDefault();
|
||||
|
||||
var len = type.length;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
if (name.substring(name.length - len) == type) {
|
||||
checkbox.set('checked', check);
|
||||
}
|
||||
});
|
||||
|
||||
// At this point, we really need to persuade the form we are part of to
|
||||
// update all of its disabledIf rules. However, as far as I can see,
|
||||
// given the way that lib/form/form.js is written, that is impossible.
|
||||
if (formid && M.form) {
|
||||
M.form.updateFormState(formid);
|
||||
}
|
||||
};
|
||||
|
||||
var html_generator = function(classname, idtype) {
|
||||
return '<div class="' + classname + '">' +
|
||||
'<div class="fitem fitem_fcheckbox">' +
|
||||
'<div class="fitemtitle">' + str.select + '</div>' +
|
||||
'<div class="felement">' +
|
||||
'<a id="backup-all-' + idtype + '" href="#">' + str.all + '</a> / ' +
|
||||
'<a id="backup-none-' + idtype + '" href="#">' + str.none + '</a>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
};
|
||||
|
||||
var firstsection = Y.one('fieldset#coursesettings .fcontainer.clearfix .grouped_settings.section_level');
|
||||
if (!firstsection) {
|
||||
// This is not a relevant page.
|
||||
return;
|
||||
}
|
||||
if (!firstsection.one('.felement.fcheckbox')) {
|
||||
// No checkboxes.
|
||||
return;
|
||||
}
|
||||
|
||||
formid = firstsection.ancestor('form').getAttribute('id');
|
||||
|
||||
var withuserdata = false;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
if (name.substring(name.length - 9) == '_userdata') {
|
||||
withuserdata = '_userdata';
|
||||
} else if (name.substring(name.length - 9) == '_userinfo') {
|
||||
withuserdata = '_userinfo';
|
||||
}
|
||||
});
|
||||
|
||||
var html = html_generator('include_setting section_level', 'included');
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata');
|
||||
}
|
||||
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
|
||||
firstsection.insert(links, 'before');
|
||||
|
||||
Y.one('#backup-all-included').on('click', function(e) { helper(e, true, '_included'); });
|
||||
Y.one('#backup-none-included').on('click', function(e) { helper(e, false, '_included'); });
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata').on('click', function(e) { helper(e, true, withuserdata); });
|
||||
Y.one('#backup-none-userdata').on('click', function(e) { helper(e, false, withuserdata); });
|
||||
}
|
||||
}
|
||||
|
||||
}, '@VERSION@', {'requires':['base','node','event', 'node-event-simulate']});
|
||||
@@ -86,17 +86,20 @@ class block_blog_recent extends block_base {
|
||||
|
||||
$context = $this->page->context;
|
||||
|
||||
$url = new moodle_url('/blog/index.php');
|
||||
$filter = array();
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
$filter['module'] = $context->instanceid;
|
||||
$a = new stdClass;
|
||||
$a->type = get_string('modulename', $this->page->cm->modname);
|
||||
$strview = get_string('viewallmodentries', 'blog', $a);
|
||||
$url->param('modid', $context->instanceid);
|
||||
} else if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$filter['course'] = $context->instanceid;
|
||||
$a = new stdClass;
|
||||
$a->type = get_string('course');
|
||||
$strview = get_string('viewblogentries', 'blog', $a);
|
||||
$url->param('courseid', $context->instanceid);
|
||||
} else {
|
||||
$strview = get_string('viewsiteentries', 'blog');
|
||||
}
|
||||
@@ -104,7 +107,6 @@ class block_blog_recent extends block_base {
|
||||
|
||||
$bloglisting = new blog_listing($filter);
|
||||
$entries = $bloglisting->get_entries(0, $this->config->numberofrecentblogentries, 4);
|
||||
$url = new moodle_url('/blog/index.php', $filter);
|
||||
|
||||
if (!empty($entries)) {
|
||||
$entrieslist = array();
|
||||
|
||||
@@ -71,7 +71,7 @@ class block_community extends block_list {
|
||||
$icon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/group'),
|
||||
'class' => 'icon', 'alt' => get_string('addcourse', 'block_community')));
|
||||
$addcourseurl = new moodle_url('/blocks/community/communitycourse.php',
|
||||
array('add' => true, 'courseid' => $coursecontext->instanceid));
|
||||
array('add' => true, 'courseid' => $this->page->course->id));
|
||||
$searchlink = html_writer::tag('a', $icon . ' ' . get_string('addcourse', 'block_community'),
|
||||
array('href' => $addcourseurl->out(false)));
|
||||
$this->content->items[] = $searchlink;
|
||||
@@ -91,7 +91,7 @@ class block_community extends block_list {
|
||||
'alt' => get_string('removecommunitycourse', 'block_community')));
|
||||
$deleteurl = new moodle_url('/blocks/community/communitycourse.php',
|
||||
array('remove' => true,
|
||||
'courseid' => $coursecontext->instanceid,
|
||||
'courseid' => $this->page->course->id,
|
||||
'communityid' => $course->id, 'sesskey' => sesskey()));
|
||||
$deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl));
|
||||
|
||||
|
||||
@@ -19,15 +19,14 @@
|
||||
*
|
||||
* @package block
|
||||
* @subpackage completion
|
||||
* @copyright 2009 Catalyst IT Ltd
|
||||
* @copyright 2009-2012 Catalyst IT Ltd
|
||||
* @author Aaron Barnes <aaronb@catalyst.net.nz>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
require_once($CFG->libdir.'/completionlib.php');
|
||||
require_once("{$CFG->libdir}/completionlib.php");
|
||||
|
||||
/**
|
||||
* Course completion status
|
||||
@@ -36,25 +35,27 @@ require_once($CFG->libdir.'/completionlib.php');
|
||||
class block_completionstatus extends block_base {
|
||||
|
||||
public function init() {
|
||||
$this->title = get_string('pluginname', 'block_completionstatus');
|
||||
$this->title = get_string('pluginname', 'block_completionstatus');
|
||||
}
|
||||
|
||||
public function get_content() {
|
||||
global $USER, $CFG, $DB, $COURSE;
|
||||
global $USER;
|
||||
|
||||
// If content is cached
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$course = $this->page->course;
|
||||
|
||||
// Create empty content
|
||||
$this->content = new stdClass;
|
||||
$this->content = new stdClass();
|
||||
|
||||
// Can edit settings?
|
||||
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
|
||||
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
|
||||
// Get course completion data
|
||||
$info = new completion_info($this->page->course);
|
||||
$info = new completion_info($course);
|
||||
|
||||
// Don't display if completion isn't enabled!
|
||||
if (!completion_info::is_enabled_for_site()) {
|
||||
@@ -84,9 +85,9 @@ class block_completionstatus extends block_base {
|
||||
// Check this user is enroled
|
||||
if (!$info->is_tracked_user($USER->id)) {
|
||||
// If not enrolled, but are can view the report:
|
||||
if (has_capability('report/completion:view', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
|
||||
$this->content->text = '<a href="'.$CFG->wwwroot.'/report/completion/index.php?course='.$COURSE->id.
|
||||
'">'.get_string('viewcoursereport', 'completion').'</a>';
|
||||
if (has_capability('report/completion:view', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$report = new moodle_url('/report/completion/index.php', array('course' => $course->id));
|
||||
$this->content->text = '<a href="'.$report->out().'">'.get_string('viewcoursereport', 'completion').'</a>';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ class block_completionstatus extends block_base {
|
||||
// Load course completion
|
||||
$params = array(
|
||||
'userid' => $USER->id,
|
||||
'course' => $COURSE->id
|
||||
'course' => $course->id
|
||||
);
|
||||
$ccompletion = new completion_completion($params);
|
||||
|
||||
@@ -221,7 +222,8 @@ class block_completionstatus extends block_base {
|
||||
$this->content->text .= $shtml.'</tbody></table>';
|
||||
|
||||
// Display link to detailed view
|
||||
$this->content->footer = '<br><a href="'.$CFG->wwwroot.'/blocks/completionstatus/details.php?course='.$COURSE->id.'">'.get_string('moredetails', 'completion').'</a>';
|
||||
$details = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id));
|
||||
$this->content->footer = '<br><a href="'.$details->out().'">'.get_string('moredetails', 'completion').'</a>';
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
+130
-115
@@ -19,27 +19,23 @@
|
||||
*
|
||||
* @package block
|
||||
* @subpackage completion
|
||||
* @copyright 2009 Catalyst IT Ltd
|
||||
* @copyright 2009-2012 Catalyst IT Ltd
|
||||
* @author Aaron Barnes <aaronb@catalyst.net.nz>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/completionlib.php');
|
||||
|
||||
|
||||
// TODO: Make this page Moodle 2.0 compliant
|
||||
require_once(dirname(__FILE__).'/../../config.php');
|
||||
require_once("{$CFG->libdir}/completionlib.php");
|
||||
|
||||
|
||||
///
|
||||
/// Load data
|
||||
///
|
||||
$id = required_param('course', PARAM_INT);
|
||||
// User id
|
||||
$userid = optional_param('user', 0, PARAM_INT);
|
||||
|
||||
// Load course
|
||||
$course = $DB->get_record('course', array('id' => $id));
|
||||
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
|
||||
|
||||
// Load user
|
||||
if ($userid) {
|
||||
@@ -76,21 +72,13 @@ if (!$can_view) {
|
||||
// Load completion data
|
||||
$info = new completion_info($course);
|
||||
|
||||
$returnurl = "{$CFG->wwwroot}/course/view.php?id={$id}";
|
||||
$returnurl = new moodle_url('/course/view.php', array('id' => $id));
|
||||
|
||||
// Don't display if completion isn't enabled!
|
||||
if (!$info->is_enabled()) {
|
||||
print_error('completionnotenabled', 'completion', $returnurl);
|
||||
}
|
||||
|
||||
// Load criteria to display
|
||||
$completions = $info->get_completions($user->id);
|
||||
|
||||
// Check if this course has any criteria
|
||||
if (empty($completions)) {
|
||||
print_error('nocriteriaset', 'completion', $returnurl);
|
||||
}
|
||||
|
||||
// Check this user is enroled
|
||||
if (!$info->is_tracked_user($user->id)) {
|
||||
if ($USER->id == $user->id) {
|
||||
@@ -104,6 +92,7 @@ if (!$info->is_tracked_user($user->id)) {
|
||||
///
|
||||
/// Display page
|
||||
///
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
|
||||
// Print header
|
||||
$page = get_string('completionprogressdetails', 'block_completionstatus');
|
||||
@@ -111,7 +100,7 @@ $title = format_string($course->fullname) . ': ' . $page;
|
||||
|
||||
$PAGE->navbar->add($page);
|
||||
$PAGE->set_pagelayout('standard');
|
||||
$PAGE->set_url('/blocks/completionstatus/details.php', array('course' => $course->id));
|
||||
$PAGE->set_url('/blocks/completionstatus/details.php', array('course' => $course->id, 'user' => $user->id));
|
||||
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
|
||||
$PAGE->set_heading($title);
|
||||
echo $OUTPUT->header();
|
||||
@@ -135,122 +124,148 @@ $coursecomplete = $info->is_course_complete($user->id);
|
||||
// Has this user completed any criteria?
|
||||
$criteriacomplete = $info->count_course_user_data($user->id);
|
||||
|
||||
// Load course completion
|
||||
$params = array(
|
||||
'userid' => $user->id,
|
||||
'course' => $course->id,
|
||||
);
|
||||
$ccompletion = new completion_completion($params);
|
||||
|
||||
if ($coursecomplete) {
|
||||
echo get_string('complete');
|
||||
} else if (!$criteriacomplete) {
|
||||
} else if (!$criteriacomplete && !$ccompletion->timestarted) {
|
||||
echo '<i>'.get_string('notyetstarted', 'completion').'</i>';
|
||||
} else {
|
||||
echo '<i>'.get_string('inprogress','completion').'</i>';
|
||||
}
|
||||
|
||||
echo '</td></tr>';
|
||||
echo '<tr><td colspan="2"><b>'.get_string('required').':</b> ';
|
||||
|
||||
// Get overall aggregation method
|
||||
$overall = $info->get_aggregation_method();
|
||||
// Load criteria to display
|
||||
$completions = $info->get_completions($user->id);
|
||||
|
||||
if ($overall == COMPLETION_AGGREGATION_ALL) {
|
||||
echo get_string('criteriarequiredall', 'completion');
|
||||
// Check if this course has any criteria
|
||||
if (empty($completions)) {
|
||||
echo '<tr><td colspan="2"><br />';
|
||||
echo $OUTPUT->box(get_string('err_nocriteria', 'completion'), 'noticebox');
|
||||
echo '</td></tr></tbody></table>';
|
||||
} else {
|
||||
echo get_string('criteriarequiredany', 'completion');
|
||||
}
|
||||
echo '<tr><td colspan="2"><b>'.get_string('required').':</b> ';
|
||||
|
||||
echo '</td></tr></tbody></table>';
|
||||
// Get overall aggregation method
|
||||
$overall = $info->get_aggregation_method();
|
||||
|
||||
// Generate markup for criteria statuses
|
||||
echo '<table class="generalbox boxaligncenter" cellpadding="3"><tbody>';
|
||||
echo '<tr class="ccheader">';
|
||||
echo '<th class="c0 header" scope="col">'.get_string('criteriagroup', 'block_completionstatus').'</th>';
|
||||
echo '<th class="c1 header" scope="col">'.get_string('criteria', 'completion').'</th>';
|
||||
echo '<th class="c2 header" scope="col">'.get_string('requirement', 'block_completionstatus').'</th>';
|
||||
echo '<th class="c3 header" scope="col">'.get_string('status').'</th>';
|
||||
echo '<th class="c4 header" scope="col">'.get_string('complete').'</th>';
|
||||
echo '<th class="c5 header" scope="col">'.get_string('completiondate', 'report_completion').'</th>';
|
||||
echo '</tr>';
|
||||
|
||||
// Save row data
|
||||
$rows = array();
|
||||
|
||||
global $COMPLETION_CRITERIA_TYPES;
|
||||
|
||||
// Loop through course criteria
|
||||
foreach ($completions as $completion) {
|
||||
$criteria = $completion->get_criteria();
|
||||
$complete = $completion->is_complete();
|
||||
|
||||
$row = array();
|
||||
$row['type'] = $criteria->criteriatype;
|
||||
$row['title'] = $criteria->get_title();
|
||||
$row['status'] = $completion->get_status();
|
||||
$row['timecompleted'] = $completion->timecompleted;
|
||||
$row['details'] = $criteria->get_details($completion);
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
// Print table
|
||||
$last_type = '';
|
||||
$agg_type = false;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
||||
// Criteria group
|
||||
echo '<td class="c0">';
|
||||
if ($last_type !== $row['details']['type']) {
|
||||
$last_type = $row['details']['type'];
|
||||
echo $last_type;
|
||||
|
||||
// Reset agg type
|
||||
$agg_type = true;
|
||||
if ($overall == COMPLETION_AGGREGATION_ALL) {
|
||||
echo get_string('criteriarequiredall', 'completion');
|
||||
} else {
|
||||
// Display aggregation type
|
||||
if ($agg_type) {
|
||||
$agg = $info->get_aggregation_method($row['type']);
|
||||
|
||||
echo '(<i>';
|
||||
|
||||
if ($agg == COMPLETION_AGGREGATION_ALL) {
|
||||
echo strtolower(get_string('all', 'completion'));
|
||||
} else {
|
||||
echo strtolower(get_string('any', 'completion'));
|
||||
}
|
||||
|
||||
echo '</i> '.strtolower(get_string('required')).')';
|
||||
$agg_type = false;
|
||||
}
|
||||
echo get_string('criteriarequiredany', 'completion');
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
// Criteria title
|
||||
echo '<td class="c1">';
|
||||
echo $row['details']['criteria'];
|
||||
echo '</td>';
|
||||
echo '</td></tr></tbody></table>';
|
||||
|
||||
// Requirement
|
||||
echo '<td class="c2">';
|
||||
echo $row['details']['requirement'];
|
||||
echo '</td>';
|
||||
|
||||
// Status
|
||||
echo '<td class="c3">';
|
||||
echo $row['details']['status'];
|
||||
echo '</td>';
|
||||
|
||||
// Is complete
|
||||
echo '<td class="c4">';
|
||||
echo ($row['status'] === get_string('yes')) ? get_string('yes') : get_string('no');
|
||||
echo '</td>';
|
||||
|
||||
// Completion data
|
||||
echo '<td class="c5">';
|
||||
if ($row['timecompleted']) {
|
||||
echo userdate($row['timecompleted'], '%e %B %G');
|
||||
} else {
|
||||
echo '-';
|
||||
}
|
||||
echo '</td>';
|
||||
// Generate markup for criteria statuses
|
||||
echo '<table class="generalbox logtable boxaligncenter" id="criteriastatus" width="100%"><tbody>';
|
||||
echo '<tr class="ccheader">';
|
||||
echo '<th class="c0 header" scope="col">'.get_string('criteriagroup', 'block_completionstatus').'</th>';
|
||||
echo '<th class="c1 header" scope="col">'.get_string('criteria', 'completion').'</th>';
|
||||
echo '<th class="c2 header" scope="col">'.get_string('requirement', 'block_completionstatus').'</th>';
|
||||
echo '<th class="c3 header" scope="col">'.get_string('status').'</th>';
|
||||
echo '<th class="c4 header" scope="col">'.get_string('complete').'</th>';
|
||||
echo '<th class="c5 header" scope="col">'.get_string('completiondate', 'report_completion').'</th>';
|
||||
echo '</tr>';
|
||||
|
||||
// Save row data
|
||||
$rows = array();
|
||||
|
||||
// Loop through course criteria
|
||||
foreach ($completions as $completion) {
|
||||
$criteria = $completion->get_criteria();
|
||||
|
||||
$row = array();
|
||||
$row['type'] = $criteria->criteriatype;
|
||||
$row['title'] = $criteria->get_title();
|
||||
$row['status'] = $completion->get_status();
|
||||
$row['complete'] = $completion->is_complete();
|
||||
$row['timecompleted'] = $completion->timecompleted;
|
||||
$row['details'] = $criteria->get_details($completion);
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
// Print table
|
||||
$last_type = '';
|
||||
$agg_type = false;
|
||||
$oddeven = 0;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
||||
echo '<tr class="r' . $oddeven . '">';
|
||||
|
||||
// Criteria group
|
||||
echo '<td class="cell c0">';
|
||||
if ($last_type !== $row['details']['type']) {
|
||||
$last_type = $row['details']['type'];
|
||||
echo $last_type;
|
||||
|
||||
// Reset agg type
|
||||
$agg_type = true;
|
||||
} else {
|
||||
// Display aggregation type
|
||||
if ($agg_type) {
|
||||
$agg = $info->get_aggregation_method($row['type']);
|
||||
|
||||
echo '(<i>';
|
||||
|
||||
if ($agg == COMPLETION_AGGREGATION_ALL) {
|
||||
echo strtolower(get_string('aggregateall', 'completion'));
|
||||
} else {
|
||||
echo strtolower(get_string('aggregateany', 'completion'));
|
||||
}
|
||||
|
||||
echo '</i> '.strtolower(get_string('required')).')';
|
||||
$agg_type = false;
|
||||
}
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
// Criteria title
|
||||
echo '<td class="cell c1">';
|
||||
echo $row['details']['criteria'];
|
||||
echo '</td>';
|
||||
|
||||
// Requirement
|
||||
echo '<td class="cell c2">';
|
||||
echo $row['details']['requirement'];
|
||||
echo '</td>';
|
||||
|
||||
// Status
|
||||
echo '<td class="cell c3">';
|
||||
echo $row['details']['status'];
|
||||
echo '</td>';
|
||||
|
||||
// Is complete
|
||||
echo '<td class="cell c4">';
|
||||
echo $row['complete'] ? get_string('yes') : get_string('no');
|
||||
echo '</td>';
|
||||
|
||||
// Completion data
|
||||
echo '<td class="cell c5">';
|
||||
if ($row['timecompleted']) {
|
||||
echo userdate($row['timecompleted'], get_string('strftimedate', 'langconfig'));
|
||||
} else {
|
||||
echo '-';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
// for row striping
|
||||
$oddeven = $oddeven ? 0 : 1;
|
||||
}
|
||||
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
|
||||
echo '</tbody></table>';
|
||||
echo '<div class="buttons">';
|
||||
$courseurl = new moodle_url("/course/view.php", array('id' => $course->id));
|
||||
echo $OUTPUT->single_button($courseurl, get_string('returntocourse', 'block_completionstatus'), 'get');
|
||||
echo '</div>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -5,3 +5,4 @@ $string['criteriagroup'] = 'Criteria group';
|
||||
$string['firstofsecond'] = '{$a->first} of {$a->second}';
|
||||
$string['pluginname'] = 'Course completion status';
|
||||
$string['requirement'] = 'Requirement';
|
||||
$string['returntocourse'] = 'Return to course';
|
||||
|
||||
@@ -64,7 +64,7 @@ class block_course_overview extends block_base {
|
||||
$courses_limit = $courses_limit + 1;
|
||||
}
|
||||
|
||||
$courses = enrol_get_my_courses('id, shortname, modinfo', 'visible DESC,sortorder ASC', $courses_limit);
|
||||
$courses = enrol_get_my_courses('id, shortname, modinfo, sectioncache', 'visible DESC,sortorder ASC', $courses_limit);
|
||||
$site = get_site();
|
||||
$course = $site; //just in case we need the old global $course hack
|
||||
|
||||
|
||||
@@ -77,6 +77,11 @@ class block_navigation_renderer extends plugin_renderer_base {
|
||||
$isexpandable = (empty($expansionlimit) || ($item->type > navigation_node::TYPE_ACTIVITY || $item->type < $expansionlimit) || ($item->contains_active_node() && $item->children->count() > 0));
|
||||
$isbranch = $isexpandable && ($item->children->count() > 0 || ($item->has_children() && (isloggedin() || $item->type <= navigation_node::TYPE_CATEGORY)));
|
||||
|
||||
// Skip elements which have no content and no action - no point in showing them
|
||||
if (!$isexpandable && empty($item->action)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hasicon = ((!$isbranch || $item->type == navigation_node::TYPE_ACTIVITY || $item->type == navigation_node::TYPE_RESOURCE) && $item->icon instanceof renderable);
|
||||
|
||||
if ($hasicon) {
|
||||
|
||||
@@ -106,7 +106,7 @@ class block_news_items extends block_base {
|
||||
$tooltiptext = get_string('rsssubscriberssposts','forum');
|
||||
}
|
||||
if (!isloggedin()) {
|
||||
$userid = 0;
|
||||
$userid = $CFG->siteguest;
|
||||
} else {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ for($i = 1; $i < 3; $i++){
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<?php print_string('numsections'.$i, 'block_section_links'); ?>:
|
||||
<label for="menunumsections<?php echo $i; ?>"><?php print_string('numsections'.$i, 'block_section_links'); ?>:</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php choose_from_menu($numberofsections, 'numsections'.$i, $selected[$i][0]); ?>
|
||||
@@ -77,7 +77,7 @@ for($i = 1; $i < 3; $i++){
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<?php print_string('incby'.$i, 'block_section_links'); ?>:
|
||||
<label for="menuincby<?php echo $i;?>"><?php print_string('incby'.$i, 'block_section_links'); ?>:</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php choose_from_menu($increments, 'incby'.$i, $selected[$i][1]); ?>
|
||||
|
||||
@@ -40,6 +40,7 @@ class block_tags extends block_base {
|
||||
global $CFG, $COURSE, $SITE, $USER, $SCRIPT, $OUTPUT;
|
||||
|
||||
if (empty($CFG->usetags)) {
|
||||
$this->content = new stdClass();
|
||||
$this->content->text = '';
|
||||
if ($this->page->user_is_editing()) {
|
||||
$this->content->text = get_string('disabledtags', 'block_tags');
|
||||
@@ -225,7 +226,6 @@ class block_tags extends block_base {
|
||||
if ($officialtags) { $this->content->text .= $officialtagscontent; }
|
||||
if ($coursetags) { $this->content->text .= $coursetagscontent; }
|
||||
if ($commtags) { $this->content->text .= $commtagscontent; }
|
||||
|
||||
// add the input form section (allowing a user to tag the current course) and navigation, or loggin message
|
||||
if ($loggedin) {
|
||||
// only show the input form on course pages for those allowed (or not barred)
|
||||
@@ -250,7 +250,8 @@ class block_tags extends block_base {
|
||||
<div class="coursetag_form_wrapper">
|
||||
<div class="coursetag_form_positioner">
|
||||
<div class="coursetag_form_input1">
|
||||
<input type="text" name="coursetag_sug_keyword" class="coursetag_form_input1a" disabled="disabled" />
|
||||
<label class="accesshide" for="coursetag_sug_keyword">$tagthisunit</label>
|
||||
<input type="text" name="coursetag_sug_keyword" id="coursetag_sug_keyword" class="coursetag_form_input1a" disabled="disabled" />
|
||||
</div>
|
||||
<div class="coursetag_form_input2">
|
||||
<input type="text" name="coursetag_new_tag" id="coursetag_new_tag" class="coursetag_form_input2a"
|
||||
|
||||
+23
-14
@@ -38,11 +38,12 @@ class blog_edit_form extends moodleform {
|
||||
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
|
||||
$mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), 'size="60"');
|
||||
$mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), array('size' => 60, 'maxlength' => 128));
|
||||
$mform->addElement('editor', 'summary_editor', get_string('entrybody', 'blog'), null, $summaryoptions);
|
||||
|
||||
$mform->setType('subject', PARAM_TEXT);
|
||||
$mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client');
|
||||
$mform->addRule('subject', get_string('maximumchars', '', 128), 'maxlength', 128, 'client');
|
||||
|
||||
$mform->setType('summary_editor', PARAM_RAW);
|
||||
$mform->addRule('summary_editor', get_string('emptybody', 'blog'), 'required', null, 'client');
|
||||
@@ -70,24 +71,28 @@ class blog_edit_form extends moodleform {
|
||||
$allmodnames = array();
|
||||
|
||||
if (!empty($CFG->useblogassociations)) {
|
||||
if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid))) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
|
||||
if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid)))) {
|
||||
if (!empty($courseid)) {
|
||||
$course = $DB->get_record('course', array('id' => $courseid));
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$a = new stdClass();
|
||||
$a->coursename = format_string($course->fullname, true, array('context' => $context));
|
||||
$contextid = $context->id;
|
||||
} else {
|
||||
$context = context::instance_by_id($entry->courseassoc);
|
||||
$sql = 'SELECT fullname FROM {course} cr LEFT JOIN {context} ct ON ct.instanceid = cr.id WHERE ct.id = ?';
|
||||
$a = new stdClass();
|
||||
$a->coursename = $DB->get_field_sql($sql, array($entry->courseassoc));
|
||||
$contextid = $entry->courseassoc;
|
||||
}
|
||||
|
||||
$mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
|
||||
$mform->setDefault('courseassoc', $contextid);
|
||||
} else if ((!empty($entry->modassoc) || !empty($modid)) && has_capability('moodle/blog:associatemodule', $sitecontext)) {
|
||||
if (has_capability('moodle/blog:associatecourse', $context)) {
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
|
||||
$mform->setDefault('courseassoc', $contextid);
|
||||
}
|
||||
|
||||
} else if ((!empty($entry->modassoc) || !empty($modid))) {
|
||||
if (!empty($modid)) {
|
||||
$mod = get_coursemodule_from_id(false, $modid);
|
||||
$a = new stdClass();
|
||||
@@ -100,11 +105,14 @@ class blog_edit_form extends moodleform {
|
||||
$a = new stdClass();
|
||||
$a->modtype = $DB->get_field('modules', 'name', array('id' => $cm->module));
|
||||
$a->modname = $DB->get_field($a->modtype, 'name', array('id' => $cm->instance));
|
||||
$modid = $context->instanceid;
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
|
||||
$mform->setDefault('modassoc', $context->id);
|
||||
if (has_capability('moodle/blog:associatemodule', $context)) {
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
|
||||
$mform->setDefault('modassoc', $context->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,13 +138,13 @@ class blog_edit_form extends moodleform {
|
||||
global $CFG, $DB, $USER;
|
||||
|
||||
$errors = array();
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
// validate course association
|
||||
if (!empty($data['courseassoc']) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
|
||||
if (!empty($data['courseassoc'])) {
|
||||
$coursecontext = context::instance_by_id($data['courseassoc'], IGNORE_MISSING);
|
||||
|
||||
if ($coursecontext and $coursecontext->contextlevel == CONTEXT_COURSE) {
|
||||
$canassociatecourse = has_capability('moodle/blog:associatecourse', $coursecontext);
|
||||
if ($coursecontext->contextlevel == CONTEXT_COURSE && $canassociatecourse) {
|
||||
if (!is_enrolled($coursecontext) and !is_viewing($coursecontext)) {
|
||||
$errors['courseassoc'] = get_string('studentnotallowed', '', fullname($USER, true));
|
||||
}
|
||||
@@ -150,7 +158,8 @@ class blog_edit_form extends moodleform {
|
||||
$modcontextid = $data['modassoc'];
|
||||
$modcontext = context::instance_by_id($modcontextid, IGNORE_MISSING);
|
||||
|
||||
if ($modcontext and $modcontext->contextlevel == CONTEXT_MODULE) {
|
||||
$canassociatemodule = has_capability('moodle/blog:associatecourse', $modcontext);
|
||||
if ($modcontext->contextlevel == CONTEXT_MODULE && $canassociatemodule) {
|
||||
// get context of the mod's course
|
||||
$coursecontext = $modcontext->get_course_context(true);
|
||||
|
||||
|
||||
@@ -44,7 +44,16 @@ $message = null;
|
||||
if ($delete && confirm_sesskey()) {
|
||||
$externalbloguserid = $DB->get_field('blog_external', 'userid', array('id' => $delete));
|
||||
if ($externalbloguserid == $USER->id) {
|
||||
// Delete the external blog
|
||||
$DB->delete_records('blog_external', array('id' => $delete));
|
||||
|
||||
// Delete the external blog's posts
|
||||
$deletewhere = 'module = :module
|
||||
AND userid = :userid
|
||||
AND ' . $DB->sql_isnotempty('post', 'uniquehash', false, false) . '
|
||||
AND ' . $DB->sql_compare_text('content') . ' = ' . $DB->sql_compare_text(':delete');
|
||||
$DB->delete_records_select('post', $deletewhere, array('module' => 'blog_external', 'userid' => $USER->id, 'delete' => $delete));
|
||||
|
||||
$message = get_string('externalblogdeleted', 'blog');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ if (!empty($groupid)) {
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$group->courseid))) {
|
||||
print_error(get_string('invalidcourseid', 'blog'));
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
+16
-11
@@ -510,8 +510,9 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
|
||||
}
|
||||
|
||||
// Check that the user can associate with the course
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
if (!has_capability('moodle/blog:associatecourse', $sitecontext)) {
|
||||
$sitecontext = context_system::instance();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
if (!has_capability('moodle/blog:associatecourse', $coursecontext)) {
|
||||
return $options;
|
||||
}
|
||||
// Generate the cache key
|
||||
@@ -526,7 +527,6 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
|
||||
return $courseoptions[$key];
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$canparticipate = (is_enrolled($coursecontext) or is_viewing($coursecontext));
|
||||
|
||||
if (has_capability('moodle/blog:view', $coursecontext)) {
|
||||
@@ -587,8 +587,9 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
}
|
||||
|
||||
// Check the user can associate with the module
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
if (!has_capability('moodle/blog:associatemodule', $sitecontext)) {
|
||||
$modcontext = context_module::instance($module->id);
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:associatemodule', $modcontext)) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
@@ -604,15 +605,17 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
return $moduleoptions[$module->id];
|
||||
}
|
||||
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $module->id);
|
||||
$canparticipate = (is_enrolled($modcontext) or is_viewing($modcontext));
|
||||
|
||||
if (has_capability('moodle/blog:view', $modcontext)) {
|
||||
// Save correct module name for later usage.
|
||||
$modulename = get_string('modulename', $module->modname);
|
||||
|
||||
// We can view!
|
||||
if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
|
||||
// View all entries about this module
|
||||
$a = new stdClass;
|
||||
$a->type = $module->modname;
|
||||
$a->type = $modulename;
|
||||
$options['moduleview'] = array(
|
||||
'string' => get_string('viewallmodentries', 'blog', $a),
|
||||
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id))
|
||||
@@ -620,13 +623,13 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
}
|
||||
// View MY entries about this module
|
||||
$options['moduleviewmine'] = array(
|
||||
'string' => get_string('viewmyentriesaboutmodule', 'blog', $module->modname),
|
||||
'string' => get_string('viewmyentriesaboutmodule', 'blog', $modulename),
|
||||
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id, 'userid'=>$USER->id))
|
||||
);
|
||||
if (!empty($user) && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
|
||||
// View the given users entries about this module
|
||||
$a = new stdClass;
|
||||
$a->mod = $module->modname;
|
||||
$a->mod = $modulename;
|
||||
$a->user = fullname($user);
|
||||
$options['moduleviewuser'] = array(
|
||||
'string' => get_string('blogentriesbyuseraboutmodule', 'blog', $a),
|
||||
@@ -638,7 +641,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
if (has_capability('moodle/blog:create', $sitecontext) and $canparticipate) {
|
||||
// The user can blog about this module
|
||||
$options['moduleadd'] = array(
|
||||
'string' => get_string('blogaboutthismodule', 'blog', $module->modname),
|
||||
'string' => get_string('blogaboutthismodule', 'blog', $modulename),
|
||||
'link' => new moodle_url('/blog/edit.php', array('action'=>'add', 'modid'=>$module->id))
|
||||
);
|
||||
}
|
||||
@@ -740,7 +743,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
if (!empty($modid) && $CFG->useblogassociations && has_capability('moodle/blog:associatemodule', $sitecontext)) { // modid always overrides courseid, so the $course object may be reset here
|
||||
// modid always overrides courseid, so the $course object may be reset here
|
||||
if (!empty($modid) && $CFG->useblogassociations) {
|
||||
|
||||
$headers['filters']['module'] = $modid;
|
||||
// A groupid param may conflict with this coursemod's courseid. Ignore groupid in that case
|
||||
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$modid));
|
||||
|
||||
+2
-3
@@ -405,11 +405,10 @@ class blog_entry {
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
global $DB, $USER;
|
||||
|
||||
$returnurl = '';
|
||||
global $DB;
|
||||
|
||||
$this->delete_attachments();
|
||||
$this->remove_associations();
|
||||
|
||||
$DB->delete_records('post', array('id' => $this->id));
|
||||
tag_set('post', $this->id, array());
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ echo $OUTPUT->box_end();
|
||||
$event->time = calendar_format_event_time($event, time(), null, false);
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
echo $renderer->start_layout();
|
||||
echo $renderer->event($event);
|
||||
echo $renderer->event($event, false);
|
||||
echo $renderer->complete_layout();
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
+1
-1
@@ -123,10 +123,10 @@ if ($eventid !== 0) {
|
||||
$event = new stdClass();
|
||||
$event->action = $action;
|
||||
$event->course = $courseid;
|
||||
$event->courseid = $courseid;
|
||||
$event->timeduration = 0;
|
||||
if ($formoptions->eventtypes->courses) {
|
||||
if (!$issite) {
|
||||
$event->courseid = $courseid;
|
||||
$event->eventtype = 'course';
|
||||
} else {
|
||||
unset($formoptions->eventtypes->courses);
|
||||
|
||||
@@ -1627,6 +1627,7 @@ function calendar_print_month_selector($name, $selected) {
|
||||
for ($i=1; $i<=12; $i++) {
|
||||
$months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), '%B');
|
||||
}
|
||||
echo html_writer::label(get_string('months'), 'menu'. $name, false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($months, $name, $selected, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -710,7 +710,9 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
$select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => base64_encode($returnurl->out(false)), 'var' => 'setcourse', 'sesskey'=>sesskey())), 'id', $courseoptions, $selected, null);
|
||||
$select->class = 'cal_courses_flt';
|
||||
if ($label !== null) {
|
||||
$select->label = $label;
|
||||
$select->set_label($label);
|
||||
} else {
|
||||
$select->set_label(get_string('listofcourses'), array('class' => 'accesshide'));
|
||||
}
|
||||
return $this->output->render($select);
|
||||
}
|
||||
|
||||
@@ -422,6 +422,7 @@ if (!$courses) {
|
||||
make_categories_list($movetocategories, $notused, 'moodle/category:manage');
|
||||
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
|
||||
echo '<tr><td colspan="3" align="right">';
|
||||
echo html_writer::label(get_string('moveselectedcoursesto'), 'movetoid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($movetocategories, 'moveto', $category->id, null, array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@
|
||||
$strcategories = get_string("categories");
|
||||
|
||||
if (! $course = $DB->get_record("course", array("id"=>$id))) {
|
||||
print_error("invalidcourseid", 'error', '', $id);
|
||||
print_error("invalidcourseid");
|
||||
}
|
||||
if ($site->id == $course->id) {
|
||||
// can not delete frontpage!
|
||||
print_error("invalidcourseid", 'error', '', $id);
|
||||
print_error("invalidcourseid");
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
+1
-1
@@ -514,7 +514,7 @@ M.course_dndupload = {
|
||||
namespan: document.createElement('span')
|
||||
};
|
||||
|
||||
preview.li.className = 'dndupload-preview activity resource modtype_resource dndupload-hidden';
|
||||
preview.li.className = 'dndupload-preview dndupload-hidden';
|
||||
|
||||
preview.div.className = 'mod-indent';
|
||||
preview.li.appendChild(preview.div);
|
||||
|
||||
@@ -124,7 +124,7 @@ class course_edit_form extends moodleform {
|
||||
array(COURSE_DISPLAY_SINGLEPAGE => get_string('coursedisplay_single'),
|
||||
COURSE_DISPLAY_MULTIPAGE => get_string('coursedisplay_multi')));
|
||||
$mform->addHelpButton('coursedisplay', 'coursedisplay');
|
||||
$mform->setDefault('coursedisplay', COURSE_DISPLAY_SINGLEPAGE);
|
||||
$mform->setDefault('coursedisplay', $courseconfig->coursedisplay);
|
||||
|
||||
for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
|
||||
$sectionmenu[$i] = "$i";
|
||||
@@ -229,7 +229,7 @@ class course_edit_form extends moodleform {
|
||||
if (!empty($course->id)) {
|
||||
$mform->setConstant('visible', $course->visible);
|
||||
} else {
|
||||
$mform->setConstant('visible', $category->visible);
|
||||
$mform->setConstant('visible', $courseconfig->visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ require_once($CFG->libdir . '/conditionlib.php');
|
||||
require_once('editsection_form.php');
|
||||
|
||||
$id = required_param('id',PARAM_INT); // Week/topic ID
|
||||
$sectionreturn = optional_param('sectionreturn', 0, PARAM_BOOL);
|
||||
$sectionreturn = optional_param('sr', 0, PARAM_INT);
|
||||
|
||||
$PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sectionreturn'=> $sectionreturn));
|
||||
$PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sr'=> $sectionreturn));
|
||||
|
||||
$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
|
||||
@@ -60,11 +60,7 @@ $mform = new editsection_form($PAGE->url, array('course' => $course, 'editoropti
|
||||
'cs' => $section, 'showavailability' => $section->showavailability));
|
||||
$mform->set_data($section); // set current value
|
||||
|
||||
if ($sectionreturn) {
|
||||
$returnurl = course_get_url($course, $section->section);
|
||||
} else {
|
||||
$returnurl = course_get_url($course);
|
||||
}
|
||||
$returnurl = course_get_url($course, $sectionreturn);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
if ($mform->is_cancelled()){
|
||||
|
||||
@@ -38,6 +38,7 @@ class editsection_form extends moodleform {
|
||||
$course = $this->_customdata['course'];
|
||||
|
||||
if (!empty($CFG->enableavailability)) {
|
||||
$mform->addElement('header', '', get_string('availabilityconditions', 'condition'));
|
||||
// Grouping conditions - only if grouping is enabled at site level
|
||||
if (!empty($CFG->enablegroupmembersonly)) {
|
||||
$options = array();
|
||||
@@ -49,7 +50,6 @@ class editsection_form extends moodleform {
|
||||
$grouping->name, true, array('context' => $context));
|
||||
}
|
||||
}
|
||||
$mform->addElement('header', '', get_string('availabilityconditions', 'condition'));
|
||||
$mform->addElement('select', 'groupingid', get_string('groupingsection', 'group'), $options);
|
||||
$mform->addHelpButton('groupingid', 'groupingsection', 'group');
|
||||
}
|
||||
|
||||
@@ -668,13 +668,12 @@ class core_course_external extends external_api {
|
||||
'options' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'name' => new external_value(PARAM_ALPHA, 'The backup option name:
|
||||
'name' => new external_value(PARAM_ALPHAEXT, 'The backup option name:
|
||||
"activities" (int) Include course activites (default to 1 that is equal to yes),
|
||||
"blocks" (int) Include course blocks (default to 1 that is equal to yes),
|
||||
"filters" (int) Include course filters (default to 1 that is equal to yes),
|
||||
"users" (int) Include users (default to 0 that is equal to no),
|
||||
"role_assignments" (int) Include role assignments (default to 0 that is equal to no),
|
||||
"user_files" (int) Include user files (default to 0 that is equal to no),
|
||||
"comments" (int) Include user comments (default to 0 that is equal to no),
|
||||
"completion_information" (int) Include user course completion information (default to 0 that is equal to no),
|
||||
"logs" (int) Include course logs (default to 0 that is equal to no),
|
||||
@@ -722,7 +721,7 @@ class core_course_external extends external_api {
|
||||
// Context validation.
|
||||
|
||||
if (! ($course = $DB->get_record('course', array('id'=>$params['courseid'])))) {
|
||||
throw new moodle_exception('invalidcourseid', 'error', '', $params['courseid']);
|
||||
throw new moodle_exception('invalidcourseid', 'error');
|
||||
}
|
||||
|
||||
// Category where duplicated course is going to be created.
|
||||
@@ -739,7 +738,6 @@ class core_course_external extends external_api {
|
||||
'filters' => 1,
|
||||
'users' => 0,
|
||||
'role_assignments' => 0,
|
||||
'user_files' => 0,
|
||||
'comments' => 0,
|
||||
'completion_information' => 0,
|
||||
'logs' => 0,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user