Compare commits
667 Commits
main
...
v3.10.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
| 46f6bae002 | |||
| 8aacc3fa2b | |||
| 0715960dd8 | |||
| 65084e7371 | |||
| da4b94e012 | |||
| e243810142 | |||
| f018e92334 | |||
| 46e3cfa354 | |||
| 25cf4fa5ca | |||
| 0fb7847e09 | |||
| b63f17b5f1 | |||
| 52305c9a2e | |||
| 6b3d163a56 | |||
| efc576fc5c | |||
| 90fbc58de6 | |||
| 087845bb30 | |||
| 7d10f35278 | |||
| 9476b48942 | |||
| 7e11261633 | |||
| 15a4e4c87c | |||
| 895f38cc76 | |||
| acd1c82403 | |||
| c9271eba7c | |||
| 0cf4bb2afc | |||
| 58a89a46e4 | |||
| 1882bb4792 | |||
| bb7d679395 | |||
| 048a652106 | |||
| 23e24a504e | |||
| 761898c876 | |||
| dc976fba1e | |||
| e2faf67247 | |||
| b97899634c | |||
| 2427b92114 | |||
| 34770016ee | |||
| d00c00dd4f | |||
| ed1cc02522 | |||
| e1151bf6f5 | |||
| bbb887f6ae | |||
| 4403b8f60d | |||
| 3c3b43a58c | |||
| 04e2dc7c3b | |||
| 05574af1a6 | |||
| 5337ca485c | |||
| 3b0034cc91 | |||
| ab6ca27571 | |||
| 149e530cc1 | |||
| 9a7aed4a25 | |||
| ed04c3824c | |||
| 97e8cb0de4 | |||
| a435c63e16 | |||
| c2321a263b | |||
| f3d7526419 | |||
| d3432a883c | |||
| e1cab8e18e | |||
| bc28c05995 | |||
| 4865d2a0ae | |||
| 8317134779 | |||
| fbac2e9296 | |||
| 599eed0f95 | |||
| 7d52d5def6 | |||
| 0459910b53 | |||
| 0dd7bb8374 | |||
| bcba1347f8 | |||
| b0e1edd427 | |||
| b0007a154c | |||
| 8c9d3695e3 | |||
| 184944ce6a | |||
| ad9f9e54a3 | |||
| 943b261760 | |||
| 8dbc7c6532 | |||
| 6f7fe5df9c | |||
| 11b6df58db | |||
| 36beec930e | |||
| 750fe24949 | |||
| cc718b59d0 | |||
| 4dcc2d37c6 | |||
| d358b91e2b | |||
| c053b93f0c | |||
| cdf91cc236 | |||
| fab34222ca | |||
| a9f5f8094c | |||
| 10e16c69c8 | |||
| 6594c54b2e | |||
| 6dc336a5d4 | |||
| 39128991d7 | |||
| e1990f2f33 | |||
| 1ce223c7e1 | |||
| 6694715840 | |||
| 0a43a459ba | |||
| 7e0bcbfb19 | |||
| eaf89f7754 | |||
| 5bbfcc25c0 | |||
| 4a495d66b8 | |||
| b13ec3c353 | |||
| 5903054142 | |||
| 2dd9b53fd6 | |||
| 7f20e2071c | |||
| 0ab106f41c | |||
| 9f82c9aece | |||
| 1f13dff1a7 | |||
| be396eddf0 | |||
| 4af4d709a4 | |||
| 46606b3ddd | |||
| 35bc26b516 | |||
| 106c64ac24 | |||
| ddf72dd60d | |||
| 0ae27225f5 | |||
| a6674bf8a4 | |||
| dc87fd4b3f | |||
| d81a94807b | |||
| c611109ed7 | |||
| 74ef7dc5b1 | |||
| 8996ed98c7 | |||
| 3fcba4be5e | |||
| 55d463b9f2 | |||
| bbb58b10ad | |||
| f266c852c3 | |||
| b14daeaa9a | |||
| 8e083da3d5 | |||
| 8312eeacb0 | |||
| 0ce40927cf | |||
| 0cdfaccd4e | |||
| d386d21360 | |||
| 5429ece3f8 | |||
| 32f99bc4d1 | |||
| df0df3110d | |||
| 2ced8c6674 | |||
| 17056bf206 | |||
| 27b09acf75 | |||
| d159c32b84 | |||
| 221f0e16d0 | |||
| 55189def65 | |||
| 086a2adc35 | |||
| 3c315a874a | |||
| b4a8a99898 | |||
| 08e8205d6f | |||
| 0a54a501eb | |||
| 213ea00afe | |||
| 9428e33d55 | |||
| 31a98b3fb2 | |||
| ae6da7d6a0 | |||
| 4d5bc273ce | |||
| 33c7881448 | |||
| b7146b655a | |||
| 178d5a0e23 | |||
| f576390bd2 | |||
| 7ed7afad98 | |||
| a7e12a77b1 | |||
| 09e02634d4 | |||
| be019636d1 | |||
| 7789be4030 | |||
| 91c9ca0f49 | |||
| 7c0923a3e4 | |||
| 83cba7b9b0 | |||
| cb4418bc5b | |||
| 4db3403481 | |||
| 9296086653 | |||
| 38d4a1b75f | |||
| 1b4ef7cd88 | |||
| 3576eb4835 | |||
| 39eb58c754 | |||
| c6731f8045 | |||
| 252f95e1b7 | |||
| c24c9e174b | |||
| 199333208d | |||
| 91557080d7 | |||
| 3370b20e3c | |||
| 2c98bfc4f4 | |||
| 36f0c3d531 | |||
| 1ebbd18b82 | |||
| 04a02b5bd9 | |||
| 506df9bdbd | |||
| 873b4847f5 | |||
| a2aa548af7 | |||
| d0c89df9ee | |||
| 30eccfabaa | |||
| 63e2c543ae | |||
| a69b38d604 | |||
| 0ea391d1eb | |||
| 17d4bc49f6 | |||
| 57a13a5971 | |||
| 12fce2a4bd | |||
| b68dd3a121 | |||
| eb4c7963c0 | |||
| dde0818f6c | |||
| ad28920d0b | |||
| a5cde22a26 | |||
| 44719d2ad9 | |||
| 784c09c834 | |||
| 004be78003 | |||
| 7fae5f61ef | |||
| d7cadcc244 | |||
| 2cb45addb1 | |||
| 5ea92799c4 | |||
| 55c9482171 | |||
| 1a7928173b | |||
| c3299761f7 | |||
| 9aeb59af73 | |||
| 3759daa952 | |||
| 15044cea7f | |||
| 1170a8b694 | |||
| 69959c371f | |||
| ec46b18e13 | |||
| f1acce7bef | |||
| 1c6e578db4 | |||
| a7ea95030c | |||
| 3f04dbee09 | |||
| 6a91117d4a | |||
| cfe9f53e91 | |||
| decd480c42 | |||
| d947f53d4c | |||
| 00877bf283 | |||
| 6f86e933ed | |||
| 6d7b36da59 | |||
| 7924191691 | |||
| 0628d11380 | |||
| 151a63b4cc | |||
| 4ebfbfe88c | |||
| 93a60507fc | |||
| 0a8371c690 | |||
| 604f19afd6 | |||
| bda1473afa | |||
| d70cfda576 | |||
| 3dc820a057 | |||
| 4b64516b0e | |||
| e8496407e9 | |||
| 0ab3fd7958 | |||
| d103bdba3d | |||
| cf1d32e9c5 | |||
| b5fe033b18 | |||
| 05a3e35677 | |||
| 03058394f2 | |||
| 1a80427018 | |||
| a2b727d7bc | |||
| b2a382016f | |||
| 31efbf2e0e | |||
| 3540343ceb | |||
| 78076a621f | |||
| ca80e9a68d | |||
| 9b9b38f44e | |||
| 8e5b007c3e | |||
| d487ee2240 | |||
| 300e4aef4c | |||
| eefa5c928f | |||
| 407dcd4922 | |||
| 8d9a36fb8a | |||
| b2d43a7db1 | |||
| 876a5c143b | |||
| c562848596 | |||
| 74efdb135d | |||
| 46d1546c6e | |||
| c2ba78902c | |||
| 12fb5964f2 | |||
| 52a84caaaa | |||
| 524f6a656b | |||
| 86e69ea7b2 | |||
| 12820e3a56 | |||
| 36905f42b8 | |||
| fd532533dd | |||
| d6806beb3e | |||
| 9ab387d707 | |||
| 2a4d1c64bf | |||
| a0999ab66f | |||
| 7e3f7e3d7c | |||
| 823bc36276 | |||
| 1f3aacf8fc | |||
| 38bcf316ee | |||
| f993881244 | |||
| 3277fc9db6 | |||
| ef3720efbd | |||
| 41bc6b9400 | |||
| b9f8e3e114 | |||
| 355d07e0b4 | |||
| 5af206ad2a | |||
| 5ec265b48d | |||
| 35b29ce7d9 | |||
| bec49592ce | |||
| 57bb99edd4 | |||
| eb6b828b81 | |||
| 8b09853319 | |||
| fe1031244b | |||
| 03de8ed6d9 | |||
| 6fae5e65e9 | |||
| d7157063c3 | |||
| 477fb6c9d6 | |||
| c50b024463 | |||
| fadd2915eb | |||
| c71355941b | |||
| 18871c74e2 | |||
| 5cffc7f78b | |||
| 946159a554 | |||
| 8d371859dc | |||
| aad6afe979 | |||
| d12c1406df | |||
| 5130127a3e | |||
| 651dbb729c | |||
| 2c8db06e7a | |||
| e98d18241f | |||
| 3e460f45ac | |||
| d5e30e0108 | |||
| 7db1a61a72 | |||
| d335530a28 | |||
| 6fe5bb1b96 | |||
| e2a73965ca | |||
| ccd0b96591 | |||
| 851f0d3354 | |||
| 5576a97713 | |||
| b235c3a5a7 | |||
| c00b8b7cab | |||
| b19f178e0d | |||
| 56b28e8e0b | |||
| 6658d9fba1 | |||
| 09dabe003a | |||
| 85f136094b | |||
| 1c55d84794 | |||
| 3ac504fd3d | |||
| 1f25df48b1 | |||
| 64ba1753a8 | |||
| 0e8d14f4e9 | |||
| 9c28e07d31 | |||
| 4ea44f96e5 | |||
| c5c1b8b121 | |||
| 3490f29ad9 | |||
| 3b03a3da47 | |||
| a6aefe15f0 | |||
| b294665c21 | |||
| 2b50abffa2 | |||
| acb848cdce | |||
| 7cd362b873 | |||
| cc16de4ccc | |||
| c0af823086 | |||
| 8b026809c5 | |||
| 2dbc9a5005 | |||
| d224506353 | |||
| 0d1187b052 | |||
| a2e3aa6806 | |||
| adac2a9e55 | |||
| 2fca843e49 | |||
| 157a497a3e | |||
| 4f0fc4f45b | |||
| 27b1425eb2 | |||
| 40e41c1997 | |||
| 89ce0b387e | |||
| 9b64c178dd | |||
| 69cc1d1dd5 | |||
| 39c8e99e67 | |||
| 833ab0ea9f | |||
| 2b87250347 | |||
| 95d1f1f18d | |||
| d23f05828f | |||
| 972340b678 | |||
| 3971892bd3 | |||
| b18b714165 | |||
| 781545d34d | |||
| 19fe7f27a8 | |||
| bd686af064 | |||
| fd18dc14ff | |||
| e840b14f4c | |||
| 730aa1dcb0 | |||
| 9ef6492e5d | |||
| 41ad54e182 | |||
| 2a1fb5b5e7 | |||
| 56adf1f3d8 | |||
| a36870c175 | |||
| a0f377cf2b | |||
| 7905d70497 | |||
| d0a55062f9 | |||
| 7f177d440c | |||
| 8730ffcbe1 | |||
| 486aa319c2 | |||
| 6fa8e1c86f | |||
| dcfb713ca6 | |||
| 9d82cdb62e | |||
| a88f50d1b2 | |||
| 94adb3429b | |||
| bd516bf05c | |||
| 02829c03c1 | |||
| e9435e8f6d | |||
| 6a750d283d | |||
| b5e39191fc | |||
| 42c1cf3b03 | |||
| a5cd815635 | |||
| 1fdb4fda4a | |||
| 61772eb89b | |||
| e49ccc92c4 | |||
| f9f289f69d | |||
| e16b858ff9 | |||
| f4bdb898c7 | |||
| 2d502fd749 | |||
| b552d604ff | |||
| 6d73afb2bf | |||
| 0ad2d843d7 | |||
| 82a1e8fae7 | |||
| a2c1a20055 | |||
| 76c3dc5f6b | |||
| 62ea8b1cae | |||
| c36d5093e3 | |||
| fae57261e7 | |||
| 11a49b08e7 | |||
| a730c334c7 | |||
| fb5e3957be | |||
| 54524f1ff0 | |||
| bbfbe8e260 | |||
| cfe02e4d3e | |||
| 611399214b | |||
| 321de29e93 | |||
| f200ba55f8 | |||
| 8d791e12ba | |||
| 8923308d47 | |||
| 0e97e40e5a | |||
| 7254648363 | |||
| c3176af430 | |||
| cb82c4d901 | |||
| bf127517b3 | |||
| 29e56fef72 | |||
| b249ab9df4 | |||
| 7805d0bb44 | |||
| 6fcc509ed1 | |||
| ebd136ca12 | |||
| c96a155937 | |||
| fdb7f85140 | |||
| fbae45d7c9 | |||
| a398a60092 | |||
| de0e594a10 | |||
| 93097192e6 | |||
| 1427573cde | |||
| 28790a42ad | |||
| e5f0085cdb | |||
| 682593054d | |||
| 8fba6189fe | |||
| 31188e93d6 | |||
| 9bc368f71c | |||
| 1aa7c68c6f | |||
| 23efc7337a | |||
| cf4b6c8c94 | |||
| abb2037b0f | |||
| c94b6b2ab7 | |||
| ab5d361c80 | |||
| 334333b6c7 | |||
| 3d08cd2272 | |||
| 83a5ed90ce | |||
| d945333b47 | |||
| da84b731c7 | |||
| 36f3b1e418 | |||
| a3cc6898e9 | |||
| fcbca18c7b | |||
| c0280f4405 | |||
| c83543095a | |||
| 13e34fb428 | |||
| c705434a62 | |||
| cfe1a9a8d8 | |||
| 94d05a5bfb | |||
| 2562b9f3a3 | |||
| e8b05c6cb4 | |||
| 8f0297915c | |||
| b25763e875 | |||
| 84bcfbb0d5 | |||
| e419e7acba | |||
| 309aad5a82 | |||
| 8452418666 | |||
| 5ba67416e6 | |||
| bd0de2d965 | |||
| db54910ce2 | |||
| 9d356676c3 | |||
| a9d3f4b96c | |||
| ca6cf0bd21 | |||
| 7d990ee185 | |||
| e2a11dc2aa | |||
| a2a6303397 | |||
| 6c4cdd6d96 | |||
| 4bb41b4e5a | |||
| a937d4d807 | |||
| 2301f9bfaa | |||
| 0e9c755896 | |||
| 3452156e6e | |||
| 6ef1780225 | |||
| a8c60a4c31 | |||
| b2995f7a29 | |||
| 51201bc672 | |||
| aa13890df0 | |||
| 644b80410d | |||
| b36a28b37a | |||
| 386223bd86 | |||
| 95359bf9e7 | |||
| 1bc2a3b345 | |||
| 709b46dbfd | |||
| 94c19e0fea | |||
| 4a60349a8a | |||
| 2189db9c86 | |||
| f54cb0c257 | |||
| 95e0ff974c | |||
| db361e09e7 | |||
| f2b1242364 | |||
| d0fd7bc58c | |||
| 916809d995 | |||
| e22ac10067 | |||
| f558127d0e | |||
| fc1d22ea70 | |||
| 5d1979c911 | |||
| fe346f0afb | |||
| 8d5470145d | |||
| 61d32ad081 | |||
| 558ef4f778 | |||
| c8221dedcd | |||
| 5265491a8f | |||
| b96e85feac | |||
| 817d6dcdbb | |||
| de1a942280 | |||
| 3e1c856bd9 | |||
| cce23499e6 | |||
| 74160de2cb | |||
| 4ca7232b1f | |||
| ded581156a | |||
| 4cfc74d176 | |||
| 893cf77d33 | |||
| e66f450c8f | |||
| f9f41f5061 | |||
| 76e2d15794 | |||
| 31d3fd27fc | |||
| 2874c6d5a1 | |||
| d8892dcca3 | |||
| 85a1c2c99e | |||
| 58bf730494 | |||
| d179137f1b | |||
| 8eafd115cc | |||
| 3b111cf8a0 | |||
| a244344e2e | |||
| 23fed91412 | |||
| dee4097c9d | |||
| 7665c701fd | |||
| 3827cbe523 | |||
| f6a2d57b3e | |||
| 35a5c1adda | |||
| e4d86a6ec4 | |||
| 8d2229db48 | |||
| 4d6b3406c5 | |||
| 11a58dd4b0 | |||
| 0713666486 | |||
| 260e9753d4 | |||
| e83fad7382 | |||
| c7e5431086 | |||
| 10ba6d0aa1 | |||
| a4f4cbf095 | |||
| 66c757f689 | |||
| 2f7236aa3c | |||
| a704b87f8b | |||
| 59f48908aa | |||
| e6f0b5a3a3 | |||
| 7a85cc6d2e | |||
| 3d08c7d396 | |||
| f809bca508 | |||
| fbcc91236e | |||
| 2dab18e681 | |||
| 3565a77362 | |||
| cbecc140f7 | |||
| c3a4859c7d | |||
| 330ba8cb10 | |||
| 4e32add0ac | |||
| e48fecc679 | |||
| d7113bee4e | |||
| 61ce84f178 | |||
| e3bfcb1cde | |||
| 4a6a2636a0 | |||
| 09646d7b53 | |||
| 9211552660 | |||
| f51678c56a | |||
| fa3b387185 | |||
| dddff390da | |||
| 6bcc070827 | |||
| e1e362b7ff | |||
| ae12edc741 | |||
| 5934444b27 | |||
| c187594e5b | |||
| f9f0f1cc26 | |||
| f0b7948c96 | |||
| 3114d04721 | |||
| e78b9f9574 | |||
| b0d96c297b | |||
| 54d32ce4a9 | |||
| 71f44b0611 | |||
| b8a0258357 | |||
| db8fea04f5 | |||
| 227281d355 | |||
| fb6460ca98 | |||
| 424c5df1eb | |||
| 64c4074699 | |||
| b4ab127434 | |||
| 4d03cc37b2 | |||
| 195e7c9cf1 | |||
| 1ffb6b09ee | |||
| 06411e3689 | |||
| e419e18f0d | |||
| 3263daba84 | |||
| 59a5923924 | |||
| f2602288eb | |||
| 4413ca209f | |||
| 427f046cff | |||
| e29edbe89e | |||
| e9df0c43bc | |||
| d71659dd6d | |||
| fb6c682850 | |||
| 356a8ee948 | |||
| fe9ecef92b | |||
| 9c1f7874d8 | |||
| 96fac6d9ce | |||
| 4b327e1109 | |||
| f649cd722f | |||
| 03e84b68a1 | |||
| 51dc7d230f | |||
| 1044e94507 | |||
| c4303bba51 | |||
| 9d32114bf6 | |||
| 8ddb17b641 | |||
| 30990ac512 | |||
| 0c6f661def | |||
| 24d0335a0a | |||
| 52836faa5b | |||
| 64f64e44d8 | |||
| a133b89976 | |||
| 93fec2c58c | |||
| 3db6d44feb | |||
| 83aa08c7e1 | |||
| 79082f8b6b | |||
| 544c7d68b6 | |||
| 699a82df1a | |||
| d369c098be | |||
| 191448afc5 | |||
| 606fbca6b4 | |||
| 050eb97c33 | |||
| f6f824597a | |||
| f2b4fba61e | |||
| 3a394dd671 | |||
| 98480b3932 | |||
| e010b2e75c | |||
| aa3a9c7895 | |||
| f075ec01ca | |||
| c4c770f48c | |||
| 24ce9b8a10 | |||
| adebc5f811 | |||
| afc19a201c | |||
| aa7707cd52 | |||
| 676c840c5c | |||
| 1222c2125e | |||
| 776b4a85d1 | |||
| 29fe254b17 | |||
| bf84a08900 | |||
| 97043c76b7 | |||
| c1813ed818 | |||
| 49f1803c9d | |||
| 157f8a87b4 | |||
| c66bf80bd8 | |||
| ad25efc776 | |||
| 1019a2b5ba | |||
| 7404858689 | |||
| 7b313f407a | |||
| 931fc89e13 | |||
| fbbfe9aa00 | |||
| b81952a23d | |||
| 12ffcc5097 | |||
| bd1eaea02b | |||
| 99a8358b85 | |||
| 0a352c4790 | |||
| 67dfb55d49 | |||
| 12bd4bc5ad | |||
| 22ec6995ea | |||
| ae3af1d860 |
@@ -67,6 +67,9 @@ lib/babel-polyfill/
|
||||
lib/polyfills/
|
||||
lib/emoji-data/
|
||||
lib/plist/
|
||||
lib/zipstream/
|
||||
lib/php-enum/
|
||||
lib/http-message/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
|
||||
@@ -33,6 +33,7 @@ CVS
|
||||
/.project
|
||||
/.buildpath
|
||||
/.cache
|
||||
.phpunit.result.cache
|
||||
phpunit.xml
|
||||
# Composer support. Do not ignore composer.json, or composer.lock. These should be shipped by us.
|
||||
composer.phar
|
||||
|
||||
@@ -68,6 +68,9 @@ lib/babel-polyfill/
|
||||
lib/polyfills/
|
||||
lib/emoji-data/
|
||||
lib/plist/
|
||||
lib/zipstream/
|
||||
lib/php-enum/
|
||||
lib/http-message/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
|
||||
+13
-6
@@ -2,10 +2,9 @@
|
||||
# process (which uses our internal CI system) this file is here for the benefit
|
||||
# of community developers git clones - see MDL-51458.
|
||||
|
||||
# We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976
|
||||
# is fixed.
|
||||
notifications:
|
||||
email: false
|
||||
email:
|
||||
if: env(MOODLE_EMAIL) != no
|
||||
|
||||
language: php
|
||||
|
||||
@@ -174,7 +173,9 @@ before_script:
|
||||
# Enable test external resources
|
||||
sed -i \
|
||||
-e "/require_once/i \\define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://127.0.0.1:8080');" \
|
||||
-e "/require_once/i \\define('TEST_EXTERNAL_FILES_HTTPS_URL', 'http://127.0.0.1:8080');" \
|
||||
config.php ;
|
||||
|
||||
# Redis cache store tests
|
||||
sed -i \
|
||||
-e "/require_once/i \\define('TEST_CACHESTORE_REDIS_TESTSERVERS', '127.0.0.1');" \
|
||||
@@ -212,7 +213,7 @@ before_script:
|
||||
# We need the official upstream for comparison
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
git fetch upstream master;
|
||||
git fetch upstream MOODLE_310_STABLE;
|
||||
export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
|
||||
export GIT_COMMIT="$TRAVIS_COMMIT";
|
||||
export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
|
||||
@@ -254,8 +255,6 @@ script:
|
||||
if [ "$TASK" = 'PHPUNIT' ];
|
||||
then
|
||||
vendor/bin/phpunit --fail-on-risky --disallow-test-output --verbose;
|
||||
EXTTESTS_HITS=$(docker logs exttests 2>&1 | grep -Fv -e 'AH00558' -e '[pid 1]' | wc -l)
|
||||
echo -e "\nTest local resources number of hits: ${EXTTESTS_HITS}.\n"
|
||||
fi
|
||||
|
||||
- >
|
||||
@@ -292,3 +291,11 @@ script:
|
||||
exit 1 ;
|
||||
fi
|
||||
fi
|
||||
|
||||
after_script:
|
||||
- >
|
||||
if [ "$TASK" = 'PHPUNIT' ];
|
||||
then
|
||||
EXTTESTS_HITS=$(docker logs exttests 2>&1 | grep -Fv -e 'AH00558' -e '[pid 1]' | wc -l)
|
||||
echo -e "\nTest local resources number of hits: ${EXTTESTS_HITS}.\n"
|
||||
fi
|
||||
|
||||
@@ -43,7 +43,7 @@ class testoutgoingmailconf_form extends \moodleform {
|
||||
$mform = $this->_form;
|
||||
|
||||
// Recipient.
|
||||
$options = ['maxlength' => '100', 'size' => '25'];
|
||||
$options = ['maxlength' => '100', 'size' => '25', 'autocomplete' => 'email'];
|
||||
$mform->addElement('text', 'recipient', get_string('testoutgoingmailconf_toemail', 'admin'), $options);
|
||||
$mform->setType('recipient', PARAM_EMAIL);
|
||||
$mform->addRule('recipient', get_string('required'), 'required');
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* External admin page class that allows a callback to be provided to determine whether page can be accessed
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2019 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core_admin\local\externalpage;
|
||||
|
||||
use admin_externalpage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("{$CFG->libdir}/adminlib.php");
|
||||
|
||||
/**
|
||||
* Admin externalpage class
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2019 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class accesscallback extends admin_externalpage {
|
||||
|
||||
/** @var callable $accesscheckcallback */
|
||||
protected $accesscheckcallback;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $visiblename
|
||||
* @param string $url
|
||||
* @param callable $accesscheckcallback The callback method that will be executed to check whether user has access to
|
||||
* this page. The setting instance ($this) is passed as an argument to the callback. Should return boolean value
|
||||
* @param bool $hidden
|
||||
*/
|
||||
public function __construct(string $name, string $visiblename, string $url, callable $accesscheckcallback,
|
||||
bool $hidden = false) {
|
||||
|
||||
$this->accesscheckcallback = $accesscheckcallback;
|
||||
|
||||
parent::__construct($name, $visiblename, $url, [], $hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the current user has access to this external page based on access callback
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check_access() {
|
||||
return ($this->accesscheckcallback)($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Auto complete admin setting.
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2020 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core_admin\local\settings;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
/**
|
||||
* Auto complete setting class.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @copyright 2020 The Open University
|
||||
*/
|
||||
class autocomplete extends \admin_setting_configmultiselect {
|
||||
/** @var boolean Should we allow typing new entries to the field? */
|
||||
protected $tags = false;
|
||||
/** @var string Name of an AMD module to send/process ajax requests. */
|
||||
protected $ajax = '';
|
||||
/** @var string Placeholder text for an empty list. */
|
||||
protected $placeholder = '';
|
||||
/** @var bool Whether the search has to be case-sensitive. */
|
||||
protected $casesensitive = false;
|
||||
/** @var bool Show suggestions by default - but this can be turned off. */
|
||||
protected $showsuggestions = true;
|
||||
/** @var string String that is shown when there are no selections. */
|
||||
protected $noselectionstring = '';
|
||||
/** @var string Delimiter to store values in database. */
|
||||
protected $delimiter = ',';
|
||||
/** @var string Should be multiple choices? */
|
||||
protected $multiple = true;
|
||||
/** @var string The link to manage choices. */
|
||||
protected $manageurl = true;
|
||||
/** @var string The text to display in manage link. */
|
||||
protected $managetext = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting'
|
||||
* for ones in config_plugins.
|
||||
* @param string $visiblename localised
|
||||
* @param string $description long localised info
|
||||
* @param array $defaultsetting array of selected items
|
||||
* @param array $choices options for autocomplete field
|
||||
* @param array $attributes settings for autocomplete field
|
||||
*/
|
||||
public function __construct($name, $visiblename, $description, $defaultsetting, $choices, $attributes = null) {
|
||||
|
||||
if ($attributes === null) {
|
||||
$attributes = [];
|
||||
}
|
||||
|
||||
$this->placeholder = get_string('search');
|
||||
$this->noselectionstring = get_string('noselection', 'form');
|
||||
$defaultattributes = [
|
||||
'tags',
|
||||
'showsuggestions',
|
||||
'placeholder',
|
||||
'noselectionstring',
|
||||
'ajax',
|
||||
'casesensitive',
|
||||
'delimiter',
|
||||
'multiple',
|
||||
'manageurl',
|
||||
'managetext'
|
||||
];
|
||||
|
||||
foreach ($defaultattributes as $attributename) {
|
||||
if (isset($attributes[$attributename])) {
|
||||
$this->$attributename = $attributes[$attributename];
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($name, $visiblename, $description, $defaultsetting, $choices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the select setting(s)
|
||||
*
|
||||
* @return mixed null or array. Null if no settings else array of setting(s)
|
||||
*/
|
||||
public function get_setting() {
|
||||
$result = $this->config_read($this->name);
|
||||
if (is_null($result)) {
|
||||
return null;
|
||||
}
|
||||
if ($result === '') {
|
||||
return [];
|
||||
}
|
||||
return explode($this->delimiter, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves setting(s) provided through $data
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function write_setting($data) {
|
||||
if (!is_array($data)) {
|
||||
return ''; // Ignore it.
|
||||
}
|
||||
if (!$this->load_choices() || empty($this->choices)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
unset($data['xxxxx']);
|
||||
|
||||
$save = [];
|
||||
foreach ($data as $value) {
|
||||
if (!array_key_exists($value, $this->choices)) {
|
||||
continue; // Ignore it.
|
||||
}
|
||||
$save[] = $value;
|
||||
}
|
||||
|
||||
return ($this->config_write($this->name, implode($this->delimiter, $save)) ? '' : get_string('errorsetting', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns XHTML autocomplete field
|
||||
*
|
||||
* @param array $data Array of values to select by default
|
||||
* @param string $query
|
||||
* @return string XHTML autocomplete field
|
||||
*/
|
||||
public function output_html($data, $query = '') {
|
||||
global $OUTPUT;
|
||||
|
||||
if (!$this->load_choices() or empty($this->choices)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$default = $this->get_defaultsetting();
|
||||
if (empty($default)) {
|
||||
$default = [];
|
||||
}
|
||||
|
||||
if (is_null($data)) {
|
||||
$data = [];
|
||||
}
|
||||
|
||||
$context = [
|
||||
'id' => $this->get_id(),
|
||||
'name' => $this->get_full_name()
|
||||
];
|
||||
|
||||
$defaults = [];
|
||||
$options = [];
|
||||
$template = 'core_admin/local/settings/autocomplete';
|
||||
|
||||
foreach ($this->choices as $value => $name) {
|
||||
if (in_array($value, $default)) {
|
||||
$defaults[] = $name;
|
||||
}
|
||||
$options[] = [
|
||||
'value' => $value,
|
||||
'text' => $name,
|
||||
'selected' => in_array($value, $data),
|
||||
'disabled' => false
|
||||
];
|
||||
}
|
||||
|
||||
$context['options'] = $options;
|
||||
$context['tags'] = $this->tags;
|
||||
$context['placeholder'] = $this->placeholder;
|
||||
$context['casesensitive'] = $this->casesensitive;
|
||||
$context['multiple'] = $this->multiple;
|
||||
$context['showsuggestions'] = $this->showsuggestions;
|
||||
$context['manageurl'] = $this->manageurl;
|
||||
$context['managetext'] = $this->managetext;
|
||||
|
||||
if (is_null($default)) {
|
||||
$defaultinfo = null;
|
||||
} if (!empty($defaults)) {
|
||||
$defaultinfo = implode(', ', $defaults);
|
||||
} else {
|
||||
$defaultinfo = get_string('none');
|
||||
}
|
||||
|
||||
$element = $OUTPUT->render_from_template($template, $context);
|
||||
|
||||
return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $defaultinfo, $query);
|
||||
}
|
||||
}
|
||||
@@ -178,6 +178,7 @@ class filesize extends \admin_setting {
|
||||
'id' => $this->get_id(),
|
||||
'name' => $this->get_full_name(),
|
||||
'value' => $data['v'],
|
||||
'readonly' => $this->is_readonly(),
|
||||
'options' => array_map(function($unit, $title) use ($data, $defaultunit) {
|
||||
return [
|
||||
'value' => $unit,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Payment gateway admin setting.
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core_admin\local\settings;
|
||||
|
||||
/**
|
||||
* Generic class for managing plugins in a table that allows re-ordering and enable/disable of each plugin.
|
||||
*/
|
||||
class manage_payment_gateway_plugins extends \admin_setting_manage_plugins {
|
||||
/**
|
||||
* Get the admin settings section title (use get_string).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_section_title() {
|
||||
return get_string('type_paygw_plural', 'plugin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of plugin to manage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_plugin_type() {
|
||||
return 'paygw';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the second column.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_info_column_name() {
|
||||
return get_string('supportedcurrencies', 'core_payment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of plugin to manage.
|
||||
*
|
||||
* @param plugininfo The plugin info class.
|
||||
* @return string
|
||||
*/
|
||||
public function get_info_column($plugininfo) {
|
||||
$codes = $plugininfo->get_supported_currencies();
|
||||
|
||||
$currencies = [];
|
||||
foreach ($codes as $c) {
|
||||
$currencies[$c] = new \lang_string($c, 'core_currencies');
|
||||
}
|
||||
|
||||
return implode(get_string('listsep', 'langconfig') . ' ', $currencies);
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,8 @@ class task_log_table extends \table_sql {
|
||||
'userid' => get_string('user', 'admin'),
|
||||
'timestart' => get_string('task_starttime', 'admin'),
|
||||
'duration' => get_string('task_duration', 'admin'),
|
||||
'hostname' => get_string('hostname', 'tool_task'),
|
||||
'pid' => get_string('pid', 'tool_task'),
|
||||
'db' => get_string('task_dbstats', 'admin'),
|
||||
'result' => get_string('task_result', 'admin'),
|
||||
'actions' => '',
|
||||
@@ -132,6 +134,7 @@ class task_log_table extends \table_sql {
|
||||
|
||||
$sql = "SELECT
|
||||
tl.id, tl.type, tl.component, tl.classname, tl.userid, tl.timestart, tl.timeend,
|
||||
tl.hostname, tl.pid,
|
||||
tl.dbreads, tl.dbwrites, tl.result,
|
||||
tl.dbreads + tl.dbwrites AS db,
|
||||
tl.timeend - tl.timestart AS duration,
|
||||
|
||||
@@ -37,11 +37,13 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'showsql' => false,
|
||||
'showdebugging' => false,
|
||||
'ignorelimits' => false,
|
||||
'force' => false,
|
||||
], [
|
||||
'h' => 'help',
|
||||
'e' => 'execute',
|
||||
'k' => 'keep-alive',
|
||||
'i' => 'ignorelimits',
|
||||
'f' => 'force',
|
||||
]
|
||||
);
|
||||
|
||||
@@ -61,6 +63,7 @@ Options:
|
||||
-e, --execute Run all queued adhoc tasks
|
||||
-k, --keep-alive=N Keep this script alive for N seconds and poll for new adhoc tasks
|
||||
-i --ignorelimits Ignore task_adhoc_concurrency_limit and task_adhoc_max_runtime limits
|
||||
-f, --force Run even if cron is disabled
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/adhoc_task.php --execute
|
||||
@@ -92,6 +95,12 @@ if (moodle_needs_upgrading()) {
|
||||
if (empty($options['execute'])) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!get_config('core', 'cron_enabled') && !$options['force']) {
|
||||
mtrace('Cron is disabled. Use --force to override.');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (empty($options['keep-alive'])) {
|
||||
$options['keep-alive'] = 0;
|
||||
}
|
||||
|
||||
+105
-6
@@ -36,14 +36,23 @@ require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
[
|
||||
'help' => false,
|
||||
'stop' => false,
|
||||
),
|
||||
array(
|
||||
'list' => false,
|
||||
'force' => false,
|
||||
'enable' => false,
|
||||
'disable' => false,
|
||||
'disable-wait' => false,
|
||||
], [
|
||||
'h' => 'help',
|
||||
's' => 'stop',
|
||||
)
|
||||
'l' => 'list',
|
||||
'f' => 'force',
|
||||
'e' => 'enable',
|
||||
'd' => 'disable',
|
||||
'w' => 'disable-wait',
|
||||
]
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
@@ -56,8 +65,13 @@ if ($options['help']) {
|
||||
"Execute periodic cron actions.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-s, --stop Notify all other running cron processes to stop after the current task
|
||||
-h, --help Print out this help
|
||||
-s, --stop Notify all other running cron processes to stop after the current task
|
||||
-l, --list Show the list of currently running tasks and how long they have been running
|
||||
-f, --force Execute task even if cron is disabled
|
||||
-e, --enable Enable cron
|
||||
-d, --disable Disable cron
|
||||
-w, --disable-wait=600 Disable cron and wait until all tasks finished or fail after N seconds (optional param)
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/cron.php
|
||||
@@ -74,6 +88,91 @@ if ($options['stop']) {
|
||||
die;
|
||||
}
|
||||
|
||||
if ($options['enable']) {
|
||||
set_config('cron_enabled', 1);
|
||||
mtrace('Cron has been enabled for the site.');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['disable']) {
|
||||
set_config('cron_enabled', 0);
|
||||
\core\task\manager::clear_static_caches();
|
||||
mtrace('Cron has been disabled for the site.');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['list']) {
|
||||
$tasks = \core\task\manager::get_running_tasks();
|
||||
mtrace('The list of currently running tasks:');
|
||||
$format = "%7s %-12s %-9s %-20s %-52s\n";
|
||||
printf ($format,
|
||||
'PID',
|
||||
'HOST',
|
||||
'TYPE',
|
||||
'TIME',
|
||||
'CLASSNAME'
|
||||
);
|
||||
foreach ($tasks as $task) {
|
||||
printf ($format,
|
||||
$task->pid,
|
||||
substr($task->hostname, 0, 12),
|
||||
$task->type,
|
||||
format_time(time() - $task->timestarted),
|
||||
substr($task->classname, 0, 52)
|
||||
);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($wait = $options['disable-wait']) {
|
||||
$started = time();
|
||||
if (true === $wait) {
|
||||
// Default waiting time.
|
||||
$waitsec = 600;
|
||||
} else {
|
||||
$waitsec = $wait;
|
||||
$wait = true;
|
||||
}
|
||||
|
||||
set_config('cron_enabled', 0);
|
||||
\core\task\manager::clear_static_caches();
|
||||
mtrace('Cron has been disabled for the site.');
|
||||
mtrace('Allocating '. format_time($waitsec) . ' for the tasks to finish.');
|
||||
|
||||
$lastcount = 0;
|
||||
while ($wait) {
|
||||
$tasks = \core\task\manager::get_running_tasks();
|
||||
|
||||
if (count($tasks) == 0) {
|
||||
mtrace('');
|
||||
mtrace('All scheduled and adhoc tasks finished.');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (time() - $started >= $waitsec) {
|
||||
mtrace('');
|
||||
mtrace('Wait time ('. format_time($waitsec) . ') elapsed, but ' . count($tasks) . ' task(s) still running.');
|
||||
mtrace('Exiting with code 1.');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (count($tasks) !== $lastcount) {
|
||||
mtrace('');
|
||||
mtrace(count($tasks) . " tasks currently running.", '');
|
||||
$lastcount = count($tasks);
|
||||
} else {
|
||||
mtrace('.', '');
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!get_config('core', 'cron_enabled') && !$options['force']) {
|
||||
mtrace('Cron is disabled. Use --force to override.');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
\core\local\cli\shutdown::script_supports_graceful_exit();
|
||||
|
||||
cron_run();
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script allows to restore a course from CLI.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', 1);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
require_once($CFG->dirroot . "/backup/util/includes/restore_includes.php");
|
||||
|
||||
list($options, $unrecognized) = cli_get_params([
|
||||
'file' => '',
|
||||
'categoryid' => '',
|
||||
'showdebugging' => false,
|
||||
'help' => false,
|
||||
], [
|
||||
'f' => 'file',
|
||||
'c' => 'categoryid',
|
||||
's' => 'showdebugging',
|
||||
'h' => 'help',
|
||||
]);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help'] || !($options['file']) || !($options['categoryid'])) {
|
||||
$help = <<<EOL
|
||||
Restore backup into provided category.
|
||||
|
||||
Options:
|
||||
-f, --file=STRING Path to the backup file.
|
||||
-c, --categoryid=INT ID of the category to restore too.
|
||||
-s, --showdebugging Show developer level debugging information
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/restore_backup.php --file=/path/to/backup/file.mbz --categoryid=1\n
|
||||
EOL;
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['showdebugging']) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
print_error('noadmins');
|
||||
}
|
||||
|
||||
if (!file_exists($options['file'])) {
|
||||
print_error('filenotfound');
|
||||
}
|
||||
|
||||
if (!$category = $DB->get_record('course_categories', ['id' => $options['categoryid']], 'id')) {
|
||||
print_error('invalidcategoryid');
|
||||
}
|
||||
|
||||
$backupdir = "restore_" . uniqid();
|
||||
$path = $CFG->tempdir . DIRECTORY_SEPARATOR . "backup" . DIRECTORY_SEPARATOR . $backupdir;
|
||||
|
||||
cli_heading(get_string('extractingbackupfileto', 'backup', $path));
|
||||
$fp = get_file_packer('application/vnd.moodle.backup');
|
||||
$fp->extract_to_pathname($options['file'], $path);
|
||||
|
||||
cli_heading(get_string('preprocessingbackupfile'));
|
||||
try {
|
||||
list($fullname, $shortname) = restore_dbops::calculate_course_names(0, get_string('restoringcourse', 'backup'),
|
||||
get_string('restoringcourseshortname', 'backup'));
|
||||
|
||||
$courseid = restore_dbops::create_new_course($fullname, $shortname, $category->id);
|
||||
|
||||
$rc = new restore_controller($backupdir, $courseid, backup::INTERACTIVE_NO,
|
||||
backup::MODE_GENERAL, $admin->id, backup::TARGET_NEW_COURSE);
|
||||
$rc->execute_precheck();
|
||||
$rc->execute_plan();
|
||||
$rc->destroy();
|
||||
} catch (Exception $e) {
|
||||
cli_heading(get_string('cleaningtempdata'));
|
||||
fulldelete($path);
|
||||
print_error('generalexceptionmessage', 'error', '', $e->getMessage());
|
||||
}
|
||||
|
||||
cli_heading(get_string('restoredcourseid', 'backup', $courseid));
|
||||
exit(0);
|
||||
@@ -30,8 +30,17 @@ require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/cronlib.php");
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array('help' => false, 'list' => false, 'execute' => false, 'showsql' => false, 'showdebugging' => false),
|
||||
array('h' => 'help')
|
||||
[
|
||||
'help' => false,
|
||||
'list' => false,
|
||||
'execute' => false,
|
||||
'showsql' => false,
|
||||
'showdebugging' => false,
|
||||
'force' => false,
|
||||
], [
|
||||
'h' => 'help',
|
||||
'f' => 'force',
|
||||
]
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
@@ -49,6 +58,7 @@ if ($options['help'] or (!$options['list'] and !$options['execute'])) {
|
||||
--showsql Show sql queries before they are executed
|
||||
--showdebugging Show developer level debugging information
|
||||
-h, --help Print out this help
|
||||
-f, --force Execute task even if cron is disabled
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/scheduled_task.php --execute=\\core\\task\\session_cleanup_task
|
||||
@@ -121,6 +131,13 @@ if ($execute = $options['execute']) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!get_config('core', 'cron_enabled') && !$options['force']) {
|
||||
mtrace('Cron is disabled. Use --force to override.');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
\core\task\manager::scheduled_task_starting($task);
|
||||
|
||||
// Increase memory limit.
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
|
||||
@@ -38,17 +38,17 @@ if ($unrecognized) {
|
||||
}
|
||||
|
||||
// If necessary add files that should be ignored - such as in 3rd party plugins.
|
||||
$blacklist = array();
|
||||
$ignorelist = array();
|
||||
$path = $options['path'];
|
||||
if (!file_exists($path)) {
|
||||
cli_error("Invalid path $path");
|
||||
}
|
||||
|
||||
if ($options['ie9fix']) {
|
||||
core_admin_recurse_svgs($path, '', 'core_admin_svgtool_ie9fix', $blacklist);
|
||||
core_admin_recurse_svgs($path, '', 'core_admin_svgtool_ie9fix', $ignorelist);
|
||||
|
||||
} else if ($options['noaspectratio']) {
|
||||
core_admin_recurse_svgs($path, '', 'core_admin_svgtool_noaspectratio', $blacklist);
|
||||
core_admin_recurse_svgs($path, '', 'core_admin_svgtool_noaspectratio', $ignorelist);
|
||||
|
||||
} else {
|
||||
$help =
|
||||
@@ -153,9 +153,9 @@ function core_admin_svgtool_noaspectratio($file) {
|
||||
* @param string $base
|
||||
* @param string $sub
|
||||
* @param string $filecallback
|
||||
* @param array $blacklist
|
||||
* @param array $ignorelist List of files to be ignored and skipped.
|
||||
*/
|
||||
function core_admin_recurse_svgs($base, $sub, $filecallback, $blacklist) {
|
||||
function core_admin_recurse_svgs($base, $sub, $filecallback, $ignorelist) {
|
||||
if (is_dir("$base/$sub")) {
|
||||
$items = new DirectoryIterator("$base/$sub");
|
||||
foreach ($items as $item) {
|
||||
@@ -163,7 +163,7 @@ function core_admin_recurse_svgs($base, $sub, $filecallback, $blacklist) {
|
||||
continue;
|
||||
}
|
||||
$file = $item->getFilename();
|
||||
core_admin_recurse_svgs("$base/$sub", $file, $filecallback, $blacklist);
|
||||
core_admin_recurse_svgs("$base/$sub", $file, $filecallback, $ignorelist);
|
||||
}
|
||||
unset($item);
|
||||
unset($items);
|
||||
@@ -174,7 +174,7 @@ function core_admin_recurse_svgs($base, $sub, $filecallback, $blacklist) {
|
||||
return;
|
||||
}
|
||||
$file = realpath("$base/$sub");
|
||||
if (in_array($file, $blacklist)) {
|
||||
if (in_array($file, $ignorelist)) {
|
||||
return;
|
||||
}
|
||||
$filecallback($file);
|
||||
|
||||
@@ -3163,4 +3163,185 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.10" requires="3.5">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="10.2.29" />
|
||||
<VENDOR name="mysql" version="5.7" />
|
||||
<VENDOR name="postgres" version="9.6" />
|
||||
<VENDOR name="mssql" version="11.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.2.0" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mbstringrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+4
-2
@@ -49,6 +49,7 @@
|
||||
array($module->id));
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
redirect(new moodle_url('/admin/modules.php'));
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
@@ -66,6 +67,7 @@
|
||||
array($module->id));
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
redirect(new moodle_url('/admin/modules.php'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
@@ -121,8 +123,8 @@
|
||||
$count = -1;
|
||||
}
|
||||
if ($count>0) {
|
||||
$countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
|
||||
"&sesskey=".sesskey()."\" title=\"$strshowmodulecourse\">$count</a>";
|
||||
$countlink = $OUTPUT->action_link(new moodle_url('/course/search.php', ['modulelist' => $module->name]),
|
||||
$count, null, ['title' => $strshowmodulecourse]);
|
||||
} else if ($count < 0) {
|
||||
$countlink = get_string('error');
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -53,7 +53,6 @@ $pageurl = new moodle_url('/admin/plugins.php', $pageparams);
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
|
||||
if ($uninstall) {
|
||||
require_sesskey();
|
||||
|
||||
if (!$confirmed) {
|
||||
admin_externalpage_setup('pluginsoverview', '', $pageparams);
|
||||
@@ -92,6 +91,7 @@ if ($uninstall) {
|
||||
exit();
|
||||
|
||||
} else {
|
||||
require_sesskey();
|
||||
$SESSION->pluginuninstallreturn = $pluginfo->get_return_url_after_uninstall($return);
|
||||
$progress = new progress_trace_buffer(new text_progress_trace(), false);
|
||||
$pluginman->uninstall_plugin($pluginfo->component, $progress);
|
||||
|
||||
@@ -536,7 +536,7 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
$user1->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist2->get_userids(), '', 0.0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $userlist2->get_userids());
|
||||
|
||||
// The user list for coursecontext1 should user1, user2 and admin (role creator).
|
||||
$userlist3 = new \core_privacy\local\request\userlist($coursecontext1, $component);
|
||||
@@ -547,7 +547,7 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
$user2->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist3->get_userids(), '', 0.0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $userlist3->get_userids());
|
||||
|
||||
// The user list for coursecatcontext should user2 and admin (role creator).
|
||||
$userlist4 = new \core_privacy\local\request\userlist($coursecatcontext, $component);
|
||||
@@ -557,7 +557,7 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
$user2->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist4->get_userids(), '', 0.0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $userlist4->get_userids());
|
||||
|
||||
// The user list for systemcontext should user1 and admin (role creator).
|
||||
$userlist6 = new \core_privacy\local\request\userlist($systemcontext, $component);
|
||||
@@ -567,7 +567,7 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
$user1->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist6->get_userids(), '', 0.0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $userlist6->get_userids());
|
||||
|
||||
// The user list for cmcontext should user1, user2 and admin (role creator).
|
||||
$userlist7 = new \core_privacy\local\request\userlist($cmcontext, $component);
|
||||
@@ -578,7 +578,7 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
$user2->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist7->get_userids(), '', 0.0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $userlist7->get_userids());
|
||||
|
||||
// The user list for blockcontext should user1 and admin (role creator).
|
||||
$userlist8 = new \core_privacy\local\request\userlist($blockcontext, $component);
|
||||
@@ -588,7 +588,7 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
$user1->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist8->get_userids(), '', 0.0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $userlist8->get_userids());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -744,4 +744,4 @@ class core_role_privacy_testcase extends provider_testcase {
|
||||
}
|
||||
return $rolesnames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-3
@@ -68,9 +68,16 @@ if ($errormsg !== '') {
|
||||
$showsettingslinks = true;
|
||||
|
||||
if ($hassiteconfig) {
|
||||
require_once("admin_settings_search_form.php");
|
||||
$form = new admin_settings_search_form();
|
||||
$form->display();
|
||||
$data = [
|
||||
'action' => new moodle_url('/admin/search.php'),
|
||||
'btnclass' => 'btn-primary',
|
||||
'inputname' => 'query',
|
||||
'searchstring' => get_string('search'),
|
||||
'query' => $query,
|
||||
'extraclasses' => 'd-flex justify-content-center'
|
||||
];
|
||||
echo $OUTPUT->render_from_template('core/search_input', $data);
|
||||
|
||||
echo '<hr>';
|
||||
if ($query) {
|
||||
echo admin_search_settings_html($query);
|
||||
|
||||
@@ -131,15 +131,10 @@ if ($hassiteconfig && \core_analytics\manager::is_analytics_enabled()) {
|
||||
$timesplittingdefaults, $timesplittingoptions)
|
||||
);
|
||||
|
||||
// Predictions processor output dir.
|
||||
$defaultmodeloutputdir = rtrim($CFG->dataroot, '/') . DIRECTORY_SEPARATOR . 'models';
|
||||
if (empty(get_config('analytics', 'modeloutputdir')) && !file_exists($defaultmodeloutputdir) &&
|
||||
is_writable($defaultmodeloutputdir)) {
|
||||
// Automatically create the dir for them so users don't see the invalid value red cross.
|
||||
mkdir($defaultmodeloutputdir, $CFG->directorypermissions, true);
|
||||
}
|
||||
// Predictions processor output dir - specify default in setting description (used if left blank).
|
||||
$defaultmodeloutputdir = \core_analytics\model::default_output_dir();
|
||||
$settings->add(new admin_setting_configdirectory('analytics/modeloutputdir', new lang_string('modeloutputdir', 'analytics'),
|
||||
new lang_string('modeloutputdirinfo', 'analytics'), $defaultmodeloutputdir));
|
||||
new lang_string('modeloutputdirwithdefaultinfo', 'analytics', $defaultmodeloutputdir), ''));
|
||||
|
||||
// Disable web interface evaluation and get predictions.
|
||||
$settings->add(new admin_setting_configcheckbox('analytics/onlycli', new lang_string('onlycli', 'analytics'),
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use core_admin\local\settings\filesize;
|
||||
|
||||
$capabilities = array(
|
||||
'moodle/backup:backupcourse',
|
||||
'moodle/category:manage',
|
||||
@@ -75,6 +77,17 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
|
||||
1, $choices));
|
||||
|
||||
// Enable/disable download course content.
|
||||
$choices = [
|
||||
DOWNLOAD_COURSE_CONTENT_DISABLED => new lang_string('no'),
|
||||
DOWNLOAD_COURSE_CONTENT_ENABLED => new lang_string('yes'),
|
||||
];
|
||||
$downloadcontentsitedefault = new admin_setting_configselect('moodlecourse/downloadcontentsitedefault',
|
||||
new lang_string('enabledownloadcoursecontent', 'course'),
|
||||
new lang_string('downloadcoursecontent_help', 'course'), 0, $choices);
|
||||
$downloadcontentsitedefault->add_dependent_on('downloadcoursecontentallowed');
|
||||
$temp->add($downloadcontentsitedefault);
|
||||
|
||||
// Course format.
|
||||
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
|
||||
|
||||
@@ -161,6 +174,21 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
|
||||
$ADMIN->add('courses', $temp);
|
||||
|
||||
// Download course content.
|
||||
$downloadcoursedefaulturl = new moodle_url('/admin/settings.php', ['section' => 'coursesettings']);
|
||||
$temp = new admin_settingpage('downloadcoursecontent', new lang_string('downloadcoursecontent', 'course'));
|
||||
$temp->add(new admin_setting_configcheckbox('downloadcoursecontentallowed',
|
||||
new lang_string('downloadcoursecontentallowed', 'admin'),
|
||||
new lang_string('downloadcoursecontentallowed_desc', 'admin', $downloadcoursedefaulturl->out()), 0));
|
||||
|
||||
// 50MB default maximum size per file when downloading course content.
|
||||
$defaultmaxdownloadsize = 50 * filesize::UNIT_MB;
|
||||
$temp->add(new filesize('maxsizeperdownloadcoursefile', new lang_string('maxsizeperdownloadcoursefile', 'admin'),
|
||||
new lang_string('maxsizeperdownloadcoursefile_desc', 'admin'), $defaultmaxdownloadsize, filesize::UNIT_MB));
|
||||
$temp->hide_if('maxsizeperdownloadcoursefile', 'downloadcoursecontentallowed');
|
||||
|
||||
$ADMIN->add('courses', $temp);
|
||||
|
||||
// "courserequests" settingpage.
|
||||
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecourserequests',
|
||||
@@ -184,6 +212,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
// Add a category for the Activity Chooser.
|
||||
$ADMIN->add('courses', new admin_category('activitychooser', new lang_string('activitychoosercategory', 'course')));
|
||||
$temp = new admin_settingpage('activitychoosersettings', new lang_string('activitychoosersettings', 'course'));
|
||||
// Tab mode for the activity chooser.
|
||||
$temp->add(
|
||||
new admin_setting_configselect(
|
||||
'activitychoosertabmode',
|
||||
@@ -197,6 +226,31 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// Build a list of plugins that use the footer callback.
|
||||
$pluginswithfunction = get_plugins_with_function('custom_chooser_footer', 'lib.php');
|
||||
$pluginsoptions = [];
|
||||
$pluginsoptions[COURSE_CHOOSER_FOOTER_NONE] = get_string('activitychooserhidefooter', 'course');
|
||||
if ($pluginswithfunction) {
|
||||
foreach ($pluginswithfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginname => $pluginfunction) {
|
||||
$plugin = $plugintype.'_'.$pluginname;
|
||||
$pluginsoptions[$plugin] = get_string('pluginname', $plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Select what plugin to show in the footer.
|
||||
$temp->add(
|
||||
new admin_setting_configselect(
|
||||
'activitychooseractivefooter',
|
||||
new lang_string('activitychooseractivefooter', 'course'),
|
||||
new lang_string('activitychooseractivefooter_desc', 'course'),
|
||||
COURSE_CHOOSER_FOOTER_NONE,
|
||||
$pluginsoptions
|
||||
)
|
||||
);
|
||||
|
||||
$ADMIN->add('activitychooser', $temp);
|
||||
$ADMIN->add('activitychooser',
|
||||
new admin_externalpage('activitychooserrecommended', new lang_string('activitychooserrecommendations', 'course'),
|
||||
@@ -259,6 +313,9 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
['value' => 1, 'locked' => 0])
|
||||
);
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_legacyfiles',
|
||||
new lang_string('generallegacyfiles', 'backup'),
|
||||
new lang_string('configlegacyfiles', 'backup'), array('value' => 1, 'locked' => 0)));
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for general import configuration and defaults.
|
||||
@@ -285,6 +342,9 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
new lang_string('configgeneralcontentbankcontent', 'backup'),
|
||||
['value' => 1, 'locked' => 0])
|
||||
);
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_legacyfiles',
|
||||
new lang_string('generallegacyfiles', 'backup'),
|
||||
new lang_string('configlegacyfiles', 'backup'), array('value' => 1, 'locked' => 0)));
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
@@ -411,6 +471,10 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
1)
|
||||
);
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_legacyfiles',
|
||||
new lang_string('generallegacyfiles', 'backup'),
|
||||
new lang_string('configlegacyfiles', 'backup'), 1));
|
||||
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
|
||||
|
||||
@@ -473,6 +537,9 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_contentbankcontent',
|
||||
new lang_string('generalcontentbankcontent', 'backup'),
|
||||
new lang_string('configrestorecontentbankcontent', 'backup'), array('value' => 1, 'locked' => 0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_legacyfiles',
|
||||
new lang_string('generallegacyfiles', 'backup'),
|
||||
new lang_string('configlegacyfiles', 'backup'), array('value' => 1, 'locked' => 0)));
|
||||
|
||||
// Restore defaults when merging into another course.
|
||||
$temp->add(new admin_setting_heading('mergerestoredefaults', new lang_string('mergerestoredefaults', 'backup'), ''));
|
||||
|
||||
@@ -8,6 +8,8 @@ if ($hassiteconfig) {
|
||||
$temp = new admin_settingpage('langsettings', new lang_string('languagesettings', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('autolang', new lang_string('autolang', 'admin'), new lang_string('configautolang', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('lang', new lang_string('lang', 'admin'), new lang_string('configlang', 'admin'), current_language(), get_string_manager()->get_list_of_translations())); // $CFG->lang might be set in installer already, default en is in setup.php
|
||||
$temp->add(new admin_setting_configcheckbox('autolangusercreation', new lang_string('autolangusercreation', 'admin'),
|
||||
new lang_string('configautolangusercreation', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('langmenu', new lang_string('langmenu', 'admin'), new lang_string('configlangmenu', 'admin'), 1));
|
||||
$temp->add(new admin_setting_langlist());
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', new lang_string('langcache', 'admin'), new lang_string('langcache_desc', 'admin'), 1));
|
||||
|
||||
+50
-14
@@ -1,21 +1,57 @@
|
||||
<?php
|
||||
// This file is part of Moodle - https://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/>.
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
/**
|
||||
* Define administration settings on the Location settings page.
|
||||
*
|
||||
* @package core
|
||||
* @category admin
|
||||
* @copyright 2006 Martin Dougiamas <martin@moodle.com>
|
||||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// "locations" settingpage
|
||||
$temp = new admin_settingpage('locationsettings', new lang_string('locationsettings', 'admin'));
|
||||
$temp->add(new admin_setting_servertimezone());
|
||||
$temp->add(new admin_setting_forcetimezone());
|
||||
$temp->add(new admin_settings_country_select('country', new lang_string('country', 'admin'), new lang_string('configcountry', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('defaultcity', new lang_string('defaultcity', 'admin'), new lang_string('defaultcity_help', 'admin'), ''));
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$temp->add(new admin_setting_heading('iplookup', new lang_string('iplookup', 'admin'), new lang_string('iplookupinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configfile('geoip2file', new lang_string('geoipfile', 'admin'),
|
||||
new lang_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLite2-City.mmdb'));
|
||||
$temp->add(new admin_setting_configtext('googlemapkey3', new lang_string('googlemapkey3', 'admin'), new lang_string('googlemapkey3_help', 'admin'), '', PARAM_RAW, 60));
|
||||
if ($hassiteconfig) {
|
||||
$temp = new admin_settingpage('locationsettings', new lang_string('locationsettings', 'core_admin'));
|
||||
|
||||
$temp->add(new admin_setting_configtext('allcountrycodes', new lang_string('allcountrycodes', 'admin'), new lang_string('configallcountrycodes', 'admin'), '', '/^(?:\w+(?:,\w+)*)?$/'));
|
||||
if ($ADMIN->fulltree) {
|
||||
$temp->add(new admin_setting_servertimezone());
|
||||
|
||||
$temp->add(new admin_setting_forcetimezone());
|
||||
|
||||
$temp->add(new admin_settings_country_select('country', new lang_string('country', 'core_admin'),
|
||||
new lang_string('configcountry', 'core_admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configtext('defaultcity', new lang_string('defaultcity', 'core_admin'),
|
||||
new lang_string('defaultcity_help', 'core_admin'), ''));
|
||||
|
||||
$temp->add(new admin_setting_heading('iplookup', new lang_string('iplookup', 'core_admin'),
|
||||
new lang_string('iplookupinfo', 'core_admin')));
|
||||
|
||||
$temp->add(new admin_setting_configfile('geoip2file', new lang_string('geoipfile', 'core_admin'),
|
||||
new lang_string('configgeoipfile', 'core_admin', $CFG->dataroot . '/geoip/'),
|
||||
$CFG->dataroot . '/geoip/GeoLite2-City.mmdb'));
|
||||
|
||||
$temp->add(new admin_setting_configtext('googlemapkey3', new lang_string('googlemapkey3', 'core_admin'),
|
||||
new lang_string('googlemapkey3_help', 'core_admin'), '', PARAM_RAW, 60));
|
||||
|
||||
$temp->add(new admin_setting_countrycodes('allcountrycodes', new lang_string('allcountrycodes', 'core_admin'),
|
||||
new lang_string('configallcountrycodes', 'core_admin')));
|
||||
}
|
||||
|
||||
$ADMIN->add('location', $temp);
|
||||
|
||||
} // end of speedup
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Adds payments links to the admin tree
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2020 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$ADMIN->add('payment', new admin_externalpage(
|
||||
'paymentaccounts',
|
||||
new lang_string('paymentaccounts', 'payment'),
|
||||
new moodle_url("/payment/accounts.php"),
|
||||
['moodle/payment:manageaccounts', 'moodle/payment:viewpayments']));
|
||||
@@ -280,6 +280,25 @@ if ($hassiteconfig) {
|
||||
$plugin->load_settings($ADMIN, 'mediaplayers', $hassiteconfig);
|
||||
}
|
||||
|
||||
// Payment gateway plugins.
|
||||
$ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_paygw_plural', 'plugin')));
|
||||
$temp = new admin_settingpage('managepaymentgateways', new lang_string('type_paygwmanage', 'plugin'));
|
||||
$temp->add(new \core_admin\local\settings\manage_payment_gateway_plugins());
|
||||
$temp->add(new admin_setting_description(
|
||||
'managepaymentgatewayspostfix',
|
||||
'',
|
||||
new lang_string('gotopaymentaccounts', 'payment',
|
||||
html_writer::link(new moodle_url('/payment/accounts.php'), get_string('paymentaccounts', 'payment')))
|
||||
));
|
||||
$ADMIN->add('paymentgateways', $temp);
|
||||
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('paygw');
|
||||
core_collator::asort_objects_by_property($plugins, 'displayname');
|
||||
foreach ($plugins as $plugin) {
|
||||
/** @var \core\plugininfo\paygw $plugin */
|
||||
$plugin->load_settings($ADMIN, 'paymentgateways', $hassiteconfig);
|
||||
}
|
||||
|
||||
// Data format settings.
|
||||
$ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
|
||||
$temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
|
||||
@@ -591,7 +610,7 @@ if ($hassiteconfig) {
|
||||
global $CFG;
|
||||
|
||||
// Check nobody's setting the indexing and query-only server to the same one.
|
||||
if ($CFG->searchenginequeryonly === $value) {
|
||||
if (isset($CFG->searchenginequeryonly) && $CFG->searchenginequeryonly === $value) {
|
||||
return get_string('searchenginequeryonlysame', 'admin');
|
||||
} else {
|
||||
return '';
|
||||
@@ -661,7 +680,7 @@ if ($hassiteconfig) {
|
||||
global $CFG;
|
||||
|
||||
// Check nobody's setting the indexing and query-only server to the same one.
|
||||
if ($CFG->searchengine === $value) {
|
||||
if (isset($CFG->searchengine) && $CFG->searchengine === $value) {
|
||||
return get_string('searchenginequeryonlysame', 'admin');
|
||||
} else {
|
||||
return '';
|
||||
|
||||
+457
-318
@@ -1,162 +1,225 @@
|
||||
<?php
|
||||
// This file is part of Moodle - https://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 file defines settingpages and externalpages under the "server" category
|
||||
/**
|
||||
* Defines settingpages and externalpages under the "server" category.
|
||||
*
|
||||
* @package core
|
||||
* @category admin
|
||||
* @copyright 2006 Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
// "systempaths" settingpage
|
||||
$temp = new admin_settingpage('systempaths', new lang_string('systempaths','admin'));
|
||||
$temp->add(new admin_setting_configexecutable('pathtophp', new lang_string('pathtophp', 'admin'),
|
||||
new lang_string('configpathtophp', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'), new lang_string('configpathtodu', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtogs', new lang_string('pathtogs', 'admin'), new lang_string('pathtogs_help', 'admin'), '/usr/bin/gs'));
|
||||
$temp->add(new admin_setting_configexecutable('pathtopython', new lang_string('pathtopython', 'admin'),
|
||||
new lang_string('pathtopythondesc', 'admin'), ''));
|
||||
$ADMIN->add('server', $temp);
|
||||
if ($hassiteconfig) {
|
||||
// System paths.
|
||||
$temp = new admin_settingpage('systempaths', new lang_string('systempaths', 'admin'));
|
||||
$temp->add(new admin_setting_configexecutable('pathtophp', new lang_string('pathtophp', 'admin'),
|
||||
new lang_string('configpathtophp', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'),
|
||||
new lang_string('configpathtodu', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'),
|
||||
new lang_string('edhelpaspellpath'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'),
|
||||
new lang_string('pathtodot_help', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtogs', new lang_string('pathtogs', 'admin'),
|
||||
new lang_string('pathtogs_help', 'admin'), '/usr/bin/gs'));
|
||||
$temp->add(new admin_setting_configexecutable('pathtopython', new lang_string('pathtopython', 'admin'),
|
||||
new lang_string('pathtopythondesc', 'admin'), ''));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
// Support contact.
|
||||
$temp = new admin_settingpage('supportcontact', new lang_string('supportcontact', 'admin'));
|
||||
$primaryadmin = get_admin();
|
||||
if ($primaryadmin) {
|
||||
$primaryadminemail = $primaryadmin->email;
|
||||
$primaryadminname = fullname($primaryadmin, true);
|
||||
} else {
|
||||
// No defaults during installation - admin user must be created first.
|
||||
$primaryadminemail = null;
|
||||
$primaryadminname = null;
|
||||
}
|
||||
$temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'),
|
||||
new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
|
||||
$setting = new admin_setting_configtext('supportemail', new lang_string('supportemail', 'admin'),
|
||||
new lang_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_EMAIL);
|
||||
$setting->set_force_ltr(true);
|
||||
$temp->add($setting);
|
||||
$temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'),
|
||||
new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
// Session handling.
|
||||
$temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
|
||||
if (empty($CFG->session_handler_class) and $DB->session_lock_supported()) {
|
||||
$temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'),
|
||||
new lang_string('configdbsessions', 'admin'), 0));
|
||||
}
|
||||
|
||||
// "supportcontact" settingpage
|
||||
$temp = new admin_settingpage('supportcontact', new lang_string('supportcontact','admin'));
|
||||
$primaryadmin = get_admin();
|
||||
if ($primaryadmin) {
|
||||
$primaryadminemail = $primaryadmin->email;
|
||||
$primaryadminname = fullname($primaryadmin, true);
|
||||
} else {
|
||||
// no defaults during installation - admin user must be created first
|
||||
$primaryadminemail = NULL;
|
||||
$primaryadminname = NULL;
|
||||
}
|
||||
$temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'),
|
||||
new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
|
||||
$setting = new admin_setting_configtext('supportemail', new lang_string('supportemail', 'admin'),
|
||||
new lang_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_EMAIL);
|
||||
$setting->set_force_ltr(true);
|
||||
$temp->add($setting);
|
||||
$temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'), new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
|
||||
$ADMIN->add('server', $temp);
|
||||
$temp->add(new admin_setting_configduration('sessiontimeout', new lang_string('sessiontimeout', 'admin'),
|
||||
new lang_string('configsessiontimeout', 'admin'), 8 * 60 * 60));
|
||||
|
||||
$temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'),
|
||||
new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'),
|
||||
new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'),
|
||||
new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
// "sessionhandling" settingpage
|
||||
$temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
|
||||
if (empty($CFG->session_handler_class) and $DB->session_lock_supported()) {
|
||||
$temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'), new lang_string('configdbsessions', 'admin'), 0));
|
||||
}
|
||||
// Statistics.
|
||||
$temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
|
||||
$temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'),
|
||||
new lang_string('configstatsfirstrun', 'admin'), 'none',
|
||||
[
|
||||
'none' => new lang_string('none'),
|
||||
60 * 60 * 24 * 7 => new lang_string('numweeks', 'moodle', 1),
|
||||
60 * 60 * 24 * 14 => new lang_string('numweeks', 'moodle', 2),
|
||||
60 * 60 * 24 * 21 => new lang_string('numweeks', 'moodle', 3),
|
||||
60 * 60 * 24 * 28 => new lang_string('nummonths', 'moodle', 1),
|
||||
60 * 60 * 24 * 56 => new lang_string('nummonths', 'moodle', 2),
|
||||
60 * 60 * 24 * 84 => new lang_string('nummonths', 'moodle', 3),
|
||||
60 * 60 * 24 * 112 => new lang_string('nummonths', 'moodle', 4),
|
||||
60 * 60 * 24 * 140 => new lang_string('nummonths', 'moodle', 5),
|
||||
60 * 60 * 24 * 168 => new lang_string('nummonths', 'moodle', 6),
|
||||
'all' => new lang_string('all')
|
||||
]
|
||||
));
|
||||
$temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'),
|
||||
new lang_string('configstatsmaxruntime3', 'admin'), 0,
|
||||
[
|
||||
0 => new lang_string('untilcomplete'),
|
||||
60 * 30 => '10 ' . new lang_string('minutes'),
|
||||
60 * 30 => '30 ' . new lang_string('minutes'),
|
||||
60 * 60 => '1 ' . new lang_string('hour'),
|
||||
60 * 60 * 2 => '2 ' . new lang_string('hours'),
|
||||
60 * 60 * 3 => '3 ' . new lang_string('hours'),
|
||||
60 * 60 * 4 => '4 ' . new lang_string('hours'),
|
||||
60 * 60 * 5 => '5 ' . new lang_string('hours'),
|
||||
60 * 60 * 6 => '6 ' . new lang_string('hours'),
|
||||
60 * 60 * 7 => '7 ' . new lang_string('hours'),
|
||||
60 * 60 * 8 => '8 ' . new lang_string('hours'),
|
||||
]
|
||||
));
|
||||
$temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'),
|
||||
new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('statsuserthreshold', new lang_string('statsuserthreshold', 'admin'),
|
||||
new lang_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
$temp->add(new admin_setting_configduration('sessiontimeout', new lang_string('sessiontimeout', 'admin'),
|
||||
new lang_string('configsessiontimeout', 'admin'), 8 * 60 * 60));
|
||||
// HTTP.
|
||||
$temp = new admin_settingpage('http', new lang_string('http', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('slasharguments', new lang_string('slasharguments', 'admin'),
|
||||
new lang_string('configslasharguments', 'admin'), 1));
|
||||
$temp->add(new admin_setting_heading('reverseproxy', new lang_string('reverseproxy', 'admin'), '', ''));
|
||||
$options = [
|
||||
0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR'
|
||||
];
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'),
|
||||
new lang_string('configgetremoteaddrconf', 'admin'),
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP, $options));
|
||||
$temp->add(new admin_setting_configtext('reverseproxyignore', new lang_string('reverseproxyignore', 'admin'),
|
||||
new lang_string('configreverseproxyignore', 'admin'), ''));
|
||||
|
||||
$temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'), new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'), new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'), new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
|
||||
$ADMIN->add('server', $temp);
|
||||
$temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'),
|
||||
new lang_string('webproxyinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'),
|
||||
new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
|
||||
$temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'),
|
||||
new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
|
||||
$options = ['HTTP' => 'HTTP'];
|
||||
if (defined('CURLPROXY_SOCKS5')) {
|
||||
$options['SOCKS5'] = 'SOCKS5';
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'),
|
||||
new lang_string('configproxytype', 'admin'), 'HTTP', $options));
|
||||
$temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'),
|
||||
new lang_string('configproxyuser', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'),
|
||||
new lang_string('configproxypassword', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'),
|
||||
new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
$temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
|
||||
$options = [0 => new lang_string('disable'), 1 => new lang_string('enable')];
|
||||
$temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
|
||||
new lang_string('helpsitemaintenance', 'admin'), 0, $options));
|
||||
$temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
|
||||
'', ''));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
// "stats" settingpage
|
||||
$temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
|
||||
$temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'), new lang_string('configstatsfirstrun', 'admin'), 'none', array('none' => new lang_string('none'),
|
||||
60*60*24*7 => new lang_string('numweeks','moodle',1),
|
||||
60*60*24*14 => new lang_string('numweeks','moodle',2),
|
||||
60*60*24*21 => new lang_string('numweeks','moodle',3),
|
||||
60*60*24*28 => new lang_string('nummonths','moodle',1),
|
||||
60*60*24*56 => new lang_string('nummonths','moodle',2),
|
||||
60*60*24*84 => new lang_string('nummonths','moodle',3),
|
||||
60*60*24*112 => new lang_string('nummonths','moodle',4),
|
||||
60*60*24*140 => new lang_string('nummonths','moodle',5),
|
||||
60*60*24*168 => new lang_string('nummonths','moodle',6),
|
||||
'all' => new lang_string('all') )));
|
||||
$temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'), new lang_string('configstatsmaxruntime3', 'admin'), 0, array(0 => new lang_string('untilcomplete'),
|
||||
60*30 => '10 '.new lang_string('minutes'),
|
||||
60*30 => '30 '.new lang_string('minutes'),
|
||||
60*60 => '1 '.new lang_string('hour'),
|
||||
60*60*2 => '2 '.new lang_string('hours'),
|
||||
60*60*3 => '3 '.new lang_string('hours'),
|
||||
60*60*4 => '4 '.new lang_string('hours'),
|
||||
60*60*5 => '5 '.new lang_string('hours'),
|
||||
60*60*6 => '6 '.new lang_string('hours'),
|
||||
60*60*7 => '7 '.new lang_string('hours'),
|
||||
60*60*8 => '8 '.new lang_string('hours') )));
|
||||
$temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'), new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('statsuserthreshold', new lang_string('statsuserthreshold', 'admin'), new lang_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
|
||||
$ADMIN->add('server', $temp);
|
||||
// Cleanup.
|
||||
$temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'),
|
||||
new lang_string('configdeleteunconfirmed', 'admin'), 168,
|
||||
[
|
||||
0 => new lang_string('never'),
|
||||
168 => new lang_string('numdays', '', 7),
|
||||
144 => new lang_string('numdays', '', 6),
|
||||
120 => new lang_string('numdays', '', 5),
|
||||
96 => new lang_string('numdays', '', 4),
|
||||
72 => new lang_string('numdays', '', 3),
|
||||
48 => new lang_string('numdays', '', 2),
|
||||
24 => new lang_string('numdays', '', 1),
|
||||
12 => new lang_string('numhours', '', 12),
|
||||
6 => new lang_string('numhours', '', 6),
|
||||
1 => new lang_string('numhours', '', 1),
|
||||
]
|
||||
));
|
||||
|
||||
$temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'),
|
||||
new lang_string('configdeleteincompleteusers', 'admin'), 0,
|
||||
[
|
||||
0 => new lang_string('never'),
|
||||
168 => new lang_string('numdays', '', 7),
|
||||
144 => new lang_string('numdays', '', 6),
|
||||
120 => new lang_string('numdays', '', 5),
|
||||
96 => new lang_string('numdays', '', 4),
|
||||
72 => new lang_string('numdays', '', 3),
|
||||
48 => new lang_string('numdays', '', 2),
|
||||
24 => new lang_string('numdays', '', 1),
|
||||
]
|
||||
));
|
||||
|
||||
// "http" settingpage
|
||||
$temp = new admin_settingpage('http', new lang_string('http', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('slasharguments', new lang_string('slasharguments', 'admin'), new lang_string('configslasharguments', 'admin'), 1));
|
||||
$temp->add(new admin_setting_heading('reverseproxy', new lang_string('reverseproxy', 'admin'), '', ''));
|
||||
$options = array(
|
||||
0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'),
|
||||
new lang_string('configgetremoteaddrconf', 'admin'),
|
||||
GETREMOTEADDR_SKIP_DEFAULT, $options));
|
||||
$temp->add(new admin_setting_configtext('reverseproxyignore', new lang_string('reverseproxyignore', 'admin'), new lang_string('configreverseproxyignore', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
|
||||
new lang_string('disablegradehistory_help', 'grades'), 0));
|
||||
|
||||
$temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
|
||||
$temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'), new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
|
||||
$options = array('HTTP'=>'HTTP');
|
||||
if (defined('CURLPROXY_SOCKS5')) {
|
||||
$options['SOCKS5'] = 'SOCKS5';
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'), new lang_string('configproxytype','admin'), 'HTTP', $options));
|
||||
$temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'), new lang_string('configproxyuser', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'), new lang_string('configproxypassword', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'), new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
|
||||
$ADMIN->add('server', $temp);
|
||||
$temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
|
||||
new lang_string('gradehistorylifetime_help', 'grades'), 0,
|
||||
[
|
||||
0 => new lang_string('neverdeletehistory', 'grades'),
|
||||
1000 => new lang_string('numdays', '', 1000),
|
||||
365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
150 => new lang_string('numdays', '', 150),
|
||||
120 => new lang_string('numdays', '', 120),
|
||||
90 => new lang_string('numdays', '', 90),
|
||||
60 => new lang_string('numdays', '', 60),
|
||||
30 => new lang_string('numdays', '', 30),
|
||||
]
|
||||
));
|
||||
|
||||
$temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
|
||||
$options = array(0=>new lang_string('disable'), 1=>new lang_string('enable'));
|
||||
$temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
|
||||
new lang_string('helpsitemaintenance', 'admin'), 0, $options));
|
||||
$temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
|
||||
'', ''));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
$temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'), new lang_string('configdeleteunconfirmed', 'admin'), 168, array(0 => new lang_string('never'),
|
||||
168 => new lang_string('numdays', '', 7),
|
||||
144 => new lang_string('numdays', '', 6),
|
||||
120 => new lang_string('numdays', '', 5),
|
||||
96 => new lang_string('numdays', '', 4),
|
||||
72 => new lang_string('numdays', '', 3),
|
||||
48 => new lang_string('numdays', '', 2),
|
||||
24 => new lang_string('numdays', '', 1),
|
||||
12 => new lang_string('numhours', '', 12),
|
||||
6 => new lang_string('numhours', '', 6),
|
||||
1 => new lang_string('numhours', '', 1))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'), new lang_string('configdeleteincompleteusers', 'admin'), 0, array(0 => new lang_string('never'),
|
||||
168 => new lang_string('numdays', '', 7),
|
||||
144 => new lang_string('numdays', '', 6),
|
||||
120 => new lang_string('numdays', '', 5),
|
||||
96 => new lang_string('numdays', '', 4),
|
||||
72 => new lang_string('numdays', '', 3),
|
||||
48 => new lang_string('numdays', '', 2),
|
||||
24 => new lang_string('numdays', '', 1))));
|
||||
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
|
||||
new lang_string('disablegradehistory_help', 'grades'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
|
||||
new lang_string('gradehistorylifetime_help', 'grades'), 0, array(0 => new lang_string('neverdeletehistory', 'grades'),
|
||||
1000 => new lang_string('numdays', '', 1000),
|
||||
365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
150 => new lang_string('numdays', '', 150),
|
||||
120 => new lang_string('numdays', '', 120),
|
||||
90 => new lang_string('numdays', '', 90),
|
||||
60 => new lang_string('numdays', '', 60),
|
||||
30 => new lang_string('numdays', '', 30))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('tempdatafoldercleanup', new lang_string('tempdatafoldercleanup', 'admin'),
|
||||
new lang_string('configtempdatafoldercleanup', 'admin'), 168, array(
|
||||
$temp->add(new admin_setting_configselect('tempdatafoldercleanup', new lang_string('tempdatafoldercleanup', 'admin'),
|
||||
new lang_string('configtempdatafoldercleanup', 'admin'), 168,
|
||||
[
|
||||
1 => new lang_string('numhours', '', 1),
|
||||
3 => new lang_string('numhours', '', 3),
|
||||
6 => new lang_string('numhours', '', 6),
|
||||
@@ -166,227 +229,303 @@ $temp->add(new admin_setting_configselect('tempdatafoldercleanup', new lang_stri
|
||||
24 => new lang_string('numhours', '', 24),
|
||||
48 => new lang_string('numdays', '', 2),
|
||||
168 => new lang_string('numdays', '', 7),
|
||||
)));
|
||||
]
|
||||
));
|
||||
|
||||
$ADMIN->add('server', $temp);
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
$temp->add(new admin_setting_configduration('filescleanupperiod',
|
||||
new lang_string('filescleanupperiod', 'admin'),
|
||||
new lang_string('filescleanupperiod_help', 'admin'),
|
||||
86400));
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
|
||||
$ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
|
||||
$ADMIN->add('server', new admin_externalpage('testoutgoingmailconf', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
new moodle_url("$CFG->wwwroot/$CFG->admin/testoutgoingmailconf.php"), 'moodle/site:config', true));
|
||||
// Environment.
|
||||
$ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment', 'admin'),
|
||||
"{$CFG->wwwroot}/{$CFG->admin}/environment.php"));
|
||||
|
||||
// PHP info.
|
||||
$ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'),
|
||||
"{$CFG->wwwroot}/{$CFG->admin}/phpinfo.php"));
|
||||
|
||||
// "performance" settingpage
|
||||
$temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
|
||||
// Test outgoing mail configuration (hidden, accessed via direct link from the settings page).
|
||||
$ADMIN->add('server', new admin_externalpage('testoutgoingmailconf', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
new moodle_url('/admin/testoutgoingmailconf.php'), 'moodle/site:config', true));
|
||||
|
||||
// Memory limit options for large administration tasks.
|
||||
$memoryoptions = array(
|
||||
'64M' => '64M',
|
||||
'128M' => '128M',
|
||||
'256M' => '256M',
|
||||
'512M' => '512M',
|
||||
'1024M' => '1024M',
|
||||
'2048M' => '2048M');
|
||||
// Performance.
|
||||
$temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
|
||||
|
||||
// Allow larger memory usage for 64-bit sites only.
|
||||
if (PHP_INT_SIZE === 8) {
|
||||
$memoryoptions['3072M'] = '3072M';
|
||||
$memoryoptions['4096M'] = '4096M';
|
||||
}
|
||||
// Memory limit options for large administration tasks.
|
||||
$memoryoptions = [
|
||||
'64M' => '64M',
|
||||
'128M' => '128M',
|
||||
'256M' => '256M',
|
||||
'512M' => '512M',
|
||||
'1024M' => '1024M',
|
||||
'2048M' => '2048M',
|
||||
];
|
||||
|
||||
$temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
|
||||
new lang_string('configextramemorylimit', 'admin'), '512M',
|
||||
$memoryoptions));
|
||||
$temp->add(new admin_setting_configtext('maxtimelimit', new lang_string('maxtimelimit', 'admin'),
|
||||
// Allow larger memory usage for 64-bit sites only.
|
||||
if (PHP_INT_SIZE === 8) {
|
||||
$memoryoptions['3072M'] = '3072M';
|
||||
$memoryoptions['4096M'] = '4096M';
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
|
||||
new lang_string('configextramemorylimit', 'admin'), '512M', $memoryoptions));
|
||||
|
||||
$temp->add(new admin_setting_configtext('maxtimelimit', new lang_string('maxtimelimit', 'admin'),
|
||||
new lang_string('maxtimelimit_desc', 'admin'), 0, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
|
||||
new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
|
||||
new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
|
||||
new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
|
||||
new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
|
||||
|
||||
$ADMIN->add('server', $temp);
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
// Tasks.
|
||||
$ADMIN->add('server', new admin_category('taskconfig', new lang_string('taskadmintitle', 'admin')));
|
||||
|
||||
$ADMIN->add('server', new admin_category('taskconfig', new lang_string('taskadmintitle', 'admin')));
|
||||
$temp = new admin_settingpage('taskprocessing', new lang_string('taskprocessing','admin'));
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_scheduled_concurrency_limit',
|
||||
new lang_string('task_scheduled_concurrency_limit', 'admin'),
|
||||
new lang_string('task_scheduled_concurrency_limit_desc', 'admin'),
|
||||
3,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
// Task processing.
|
||||
$temp = new admin_settingpage('taskprocessing', new lang_string('taskprocessing', 'admin'));
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_scheduled_max_runtime',
|
||||
new lang_string('task_scheduled_max_runtime', 'admin'),
|
||||
new lang_string('task_scheduled_max_runtime_desc', 'admin'),
|
||||
30 * MINSECS
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_adhoc_concurrency_limit',
|
||||
new lang_string('task_adhoc_concurrency_limit', 'admin'),
|
||||
new lang_string('task_adhoc_concurrency_limit_desc', 'admin'),
|
||||
3,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_adhoc_max_runtime',
|
||||
new lang_string('task_adhoc_max_runtime', 'admin'),
|
||||
new lang_string('task_adhoc_max_runtime_desc', 'admin'),
|
||||
30 * MINSECS
|
||||
)
|
||||
);
|
||||
$ADMIN->add('taskconfig', $temp);
|
||||
|
||||
$temp = new admin_settingpage('tasklogging', new lang_string('tasklogging','admin'));
|
||||
$temp->add(
|
||||
new admin_setting_configselect(
|
||||
'task_logmode',
|
||||
new lang_string('task_logmode', 'admin'),
|
||||
new lang_string('task_logmode_desc', 'admin'),
|
||||
\core\task\logmanager::MODE_ALL,
|
||||
[
|
||||
\core\task\logmanager::MODE_ALL => new lang_string('task_logmode_all', 'admin'),
|
||||
\core\task\logmanager::MODE_FAILONLY => new lang_string('task_logmode_failonly', 'admin'),
|
||||
\core\task\logmanager::MODE_NONE => new lang_string('task_logmode_none', 'admin'),
|
||||
]
|
||||
)
|
||||
);
|
||||
$temp->add(
|
||||
new admin_setting_configcheckbox(
|
||||
'task_logtostdout',
|
||||
new lang_string('task_logtostdout', 'admin'),
|
||||
new lang_string('task_logtostdout_desc', 'admin'),
|
||||
$setting = new admin_setting_configcheckbox(
|
||||
'cron_enabled',
|
||||
new lang_string('cron_enabled', 'admin'),
|
||||
new lang_string('cron_enabled_desc', 'admin'),
|
||||
1
|
||||
)
|
||||
);
|
||||
);
|
||||
$setting->set_updatedcallback('theme_reset_static_caches');
|
||||
$temp->add($setting);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_scheduled_concurrency_limit',
|
||||
new lang_string('task_scheduled_concurrency_limit', 'admin'),
|
||||
new lang_string('task_scheduled_concurrency_limit_desc', 'admin'),
|
||||
3,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
|
||||
if (\core\task\logmanager::uses_standard_settings()) {
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_logretention',
|
||||
new \lang_string('task_logretention', 'admin'),
|
||||
new \lang_string('task_logretention_desc', 'admin'),
|
||||
28 * DAYSECS
|
||||
'task_scheduled_max_runtime',
|
||||
new lang_string('task_scheduled_max_runtime', 'admin'),
|
||||
new lang_string('task_scheduled_max_runtime_desc', 'admin'),
|
||||
30 * MINSECS
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_logretainruns',
|
||||
new \lang_string('task_logretainruns', 'admin'),
|
||||
new \lang_string('task_logretainruns_desc', 'admin'),
|
||||
20,
|
||||
'task_adhoc_concurrency_limit',
|
||||
new lang_string('task_adhoc_concurrency_limit', 'admin'),
|
||||
new lang_string('task_adhoc_concurrency_limit_desc', 'admin'),
|
||||
3,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
}
|
||||
$ADMIN->add('taskconfig', $temp);
|
||||
|
||||
if (\core\task\logmanager::uses_standard_settings()) {
|
||||
$ADMIN->add('taskconfig', new admin_externalpage(
|
||||
'tasklogs',
|
||||
new lang_string('tasklogs','admin'),
|
||||
"{$CFG->wwwroot}/{$CFG->admin}/tasklogs.php"
|
||||
));
|
||||
}
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_adhoc_max_runtime',
|
||||
new lang_string('task_adhoc_max_runtime', 'admin'),
|
||||
new lang_string('task_adhoc_max_runtime_desc', 'admin'),
|
||||
30 * MINSECS
|
||||
)
|
||||
);
|
||||
$ADMIN->add('taskconfig', $temp);
|
||||
|
||||
// E-mail settings.
|
||||
$ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin')));
|
||||
// Task log configuration.
|
||||
$temp = new admin_settingpage('tasklogging', new lang_string('tasklogging', 'admin'));
|
||||
$temp->add(
|
||||
new admin_setting_configselect(
|
||||
'task_logmode',
|
||||
new lang_string('task_logmode', 'admin'),
|
||||
new lang_string('task_logmode_desc', 'admin'),
|
||||
\core\task\logmanager::MODE_ALL,
|
||||
[
|
||||
\core\task\logmanager::MODE_ALL => new lang_string('task_logmode_all', 'admin'),
|
||||
\core\task\logmanager::MODE_FAILONLY => new lang_string('task_logmode_failonly', 'admin'),
|
||||
\core\task\logmanager::MODE_NONE => new lang_string('task_logmode_none', 'admin'),
|
||||
]
|
||||
)
|
||||
);
|
||||
$temp->add(
|
||||
new admin_setting_configcheckbox(
|
||||
'task_logtostdout',
|
||||
new lang_string('task_logtostdout', 'admin'),
|
||||
new lang_string('task_logtostdout_desc', 'admin'),
|
||||
1
|
||||
)
|
||||
);
|
||||
|
||||
$temp = new admin_settingpage('outgoingmailconfig', new lang_string('outgoingmailconfig', 'admin'));
|
||||
if (\core\task\logmanager::uses_standard_settings()) {
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_logretention',
|
||||
new \lang_string('task_logretention', 'admin'),
|
||||
new \lang_string('task_logretention_desc', 'admin'),
|
||||
28 * DAYSECS
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(new admin_setting_heading('smtpheading', new lang_string('smtp', 'admin'),
|
||||
new lang_string('smtpdetail', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('smtphosts', new lang_string('smtphosts', 'admin'),
|
||||
new lang_string('configsmtphosts', 'admin'), '', PARAM_RAW));
|
||||
$options = array('' => new lang_string('none', 'admin'), 'ssl' => 'SSL', 'tls' => 'TLS');
|
||||
$temp->add(new admin_setting_configselect('smtpsecure', new lang_string('smtpsecure', 'admin'),
|
||||
new lang_string('configsmtpsecure', 'admin'), '', $options));
|
||||
$authtypeoptions = array('LOGIN' => 'LOGIN', 'PLAIN' => 'PLAIN', 'NTLM' => 'NTLM', 'CRAM-MD5' => 'CRAM-MD5');
|
||||
$temp->add(new admin_setting_configselect('smtpauthtype', new lang_string('smtpauthtype', 'admin'),
|
||||
new lang_string('configsmtpauthtype', 'admin'), 'LOGIN', $authtypeoptions));
|
||||
$temp->add(new admin_setting_configtext('smtpuser', new lang_string('smtpuser', 'admin'),
|
||||
new lang_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configpasswordunmask('smtppass', new lang_string('smtppass', 'admin'),
|
||||
new lang_string('configsmtpuser', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configtext('smtpmaxbulk', new lang_string('smtpmaxbulk', 'admin'),
|
||||
new lang_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_heading('noreplydomainheading', new lang_string('noreplydomain', 'admin'),
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_logretainruns',
|
||||
new \lang_string('task_logretainruns', 'admin'),
|
||||
new \lang_string('task_logretainruns_desc', 'admin'),
|
||||
20,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
}
|
||||
$ADMIN->add('taskconfig', $temp);
|
||||
|
||||
// Task logs.
|
||||
if (\core\task\logmanager::uses_standard_settings()) {
|
||||
$ADMIN->add('taskconfig', new admin_externalpage(
|
||||
'tasklogs',
|
||||
new lang_string('tasklogs', 'admin'),
|
||||
"{$CFG->wwwroot}/{$CFG->admin}/tasklogs.php"
|
||||
));
|
||||
}
|
||||
|
||||
// Email.
|
||||
$ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin')));
|
||||
|
||||
// Outgoing mail configuration.
|
||||
$temp = new admin_settingpage('outgoingmailconfig', new lang_string('outgoingmailconfig', 'admin'));
|
||||
|
||||
$temp->add(new admin_setting_heading('smtpheading', new lang_string('smtp', 'admin'),
|
||||
new lang_string('smtpdetail', 'admin')));
|
||||
|
||||
$temp->add(new admin_setting_configtext('smtphosts', new lang_string('smtphosts', 'admin'),
|
||||
new lang_string('configsmtphosts', 'admin'), '', PARAM_RAW));
|
||||
|
||||
$options = [
|
||||
'' => new lang_string('none', 'admin'),
|
||||
'ssl' => 'SSL',
|
||||
'tls' => 'TLS',
|
||||
];
|
||||
|
||||
$temp->add(new admin_setting_configselect('smtpsecure', new lang_string('smtpsecure', 'admin'),
|
||||
new lang_string('configsmtpsecure', 'admin'), '', $options));
|
||||
|
||||
$authtypeoptions = [
|
||||
'LOGIN' => 'LOGIN',
|
||||
'PLAIN' => 'PLAIN',
|
||||
'NTLM' => 'NTLM',
|
||||
'CRAM-MD5' => 'CRAM-MD5',
|
||||
];
|
||||
|
||||
$temp->add(new admin_setting_configselect('smtpauthtype', new lang_string('smtpauthtype', 'admin'),
|
||||
new lang_string('configsmtpauthtype', 'admin'), 'LOGIN', $authtypeoptions));
|
||||
|
||||
$temp->add(new admin_setting_configtext('smtpuser', new lang_string('smtpuser', 'admin'),
|
||||
new lang_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
|
||||
|
||||
$temp->add(new admin_setting_configpasswordunmask('smtppass', new lang_string('smtppass', 'admin'),
|
||||
new lang_string('configsmtpuser', 'admin'), ''));
|
||||
|
||||
$temp->add(new admin_setting_configtext('smtpmaxbulk', new lang_string('smtpmaxbulk', 'admin'),
|
||||
new lang_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_heading('noreplydomainheading', new lang_string('noreplydomain', 'admin'),
|
||||
new lang_string('noreplydomaindetail', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('noreplyaddress', new lang_string('noreplyaddress', 'admin'),
|
||||
new lang_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_EMAIL));
|
||||
$temp->add(new admin_setting_configtextarea('allowedemaildomains',
|
||||
|
||||
$temp->add(new admin_setting_configtext('noreplyaddress', new lang_string('noreplyaddress', 'admin'),
|
||||
new lang_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_EMAIL));
|
||||
|
||||
$temp->add(new admin_setting_configtextarea('allowedemaildomains',
|
||||
new lang_string('allowedemaildomains', 'admin'),
|
||||
new lang_string('configallowedemaildomains', 'admin'),
|
||||
''));
|
||||
$url = new moodle_url('/admin/testoutgoingmailconf.php');
|
||||
$link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
|
||||
$temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
|
||||
$temp->add(new admin_setting_heading('divertallemailsheading', new lang_string('divertallemails', 'admin'),
|
||||
new lang_string('divertallemailsdetail', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('divertallemailsto',
|
||||
new lang_string('divertallemailsto', 'admin'),
|
||||
new lang_string('divertallemailsto_desc', 'admin'),
|
||||
''));
|
||||
$temp->add(new admin_setting_configtextarea('divertallemailsexcept',
|
||||
new lang_string('divertallemailsexcept', 'admin'),
|
||||
new lang_string('divertallemailsexcept_desc', 'admin'),
|
||||
'', PARAM_RAW, '50', '4'));
|
||||
|
||||
$noreplyaddress = isset($CFG->noreplyaddress) ? $CFG->noreplyaddress : 'noreply@example.com';
|
||||
$dkimdomain = substr(strrchr($noreplyaddress, "@"), 1);
|
||||
$dkimselector = empty($CFG->emaildkimselector) ? '[selector]' : $CFG->emaildkimselector;
|
||||
$pempath = "\$CFG->dataroot/dkim/{$dkimdomain}/{$dkimselector}.private";
|
||||
$temp->add(new admin_setting_heading('emaildkim', new lang_string('emaildkim', 'admin'),
|
||||
new lang_string('emaildkiminfo', 'admin', ['path' => $pempath, 'docs' => \get_docs_url('Mail_configuration#DKIM')])));
|
||||
$temp->add(new admin_setting_configtext('emaildkimselector', new lang_string('emaildkimselector', 'admin'),
|
||||
new lang_string('configemaildkimselector', 'admin'), '', PARAM_FILE));
|
||||
|
||||
$url = new moodle_url('/admin/testoutgoingmailconf.php');
|
||||
$link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
|
||||
$temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
new lang_string('testoutgoingmaildetail', 'admin', $link)));
|
||||
$temp->add(new admin_setting_heading('emaildoesnotfit', new lang_string('doesnotfit', 'admin'),
|
||||
|
||||
$temp->add(new admin_setting_heading('emaildoesnotfit', new lang_string('doesnotfit', 'admin'),
|
||||
new lang_string('doesnotfitdetail', 'admin')));
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']); // Not needed here.
|
||||
$options = array();
|
||||
$options['0'] = 'UTF-8';
|
||||
$options = array_merge($options, $charsets);
|
||||
$temp->add(new admin_setting_configselect('sitemailcharset', new lang_string('sitemailcharset', 'admin'),
|
||||
new lang_string('configsitemailcharset','admin'), '0', $options));
|
||||
$temp->add(new admin_setting_configcheckbox('allowusermailcharset', new lang_string('allowusermailcharset', 'admin'),
|
||||
new lang_string('configallowusermailcharset', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowattachments', new lang_string('allowattachments', 'admin'),
|
||||
new lang_string('configallowattachments', 'admin'), 1));
|
||||
$options = array('LF' => 'LF', 'CRLF' => 'CRLF');
|
||||
$temp->add(new admin_setting_configselect('mailnewline', new lang_string('mailnewline', 'admin'),
|
||||
new lang_string('configmailnewline', 'admin'), 'LF', $options));
|
||||
|
||||
$choices = array(new lang_string('never', 'admin'),
|
||||
new lang_string('always', 'admin'),
|
||||
new lang_string('onlynoreply', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'),
|
||||
new lang_string('configemailfromvia', 'admin'), 1, $choices));
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']);
|
||||
$options = [
|
||||
'0' => 'UTF-8',
|
||||
];
|
||||
$options = array_merge($options, $charsets);
|
||||
$temp->add(new admin_setting_configselect('sitemailcharset', new lang_string('sitemailcharset', 'admin'),
|
||||
new lang_string('configsitemailcharset', 'admin'), '0', $options));
|
||||
|
||||
$temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'),
|
||||
$temp->add(new admin_setting_configcheckbox('allowusermailcharset', new lang_string('allowusermailcharset', 'admin'),
|
||||
new lang_string('configallowusermailcharset', 'admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('allowattachments', new lang_string('allowattachments', 'admin'),
|
||||
new lang_string('configallowattachments', 'admin'), 1));
|
||||
|
||||
$options = [
|
||||
'LF' => 'LF',
|
||||
'CRLF' => 'CRLF',
|
||||
];
|
||||
$temp->add(new admin_setting_configselect('mailnewline', new lang_string('mailnewline', 'admin'),
|
||||
new lang_string('configmailnewline', 'admin'), 'LF', $options));
|
||||
|
||||
$choices = [
|
||||
new lang_string('never', 'admin'),
|
||||
new lang_string('always', 'admin'),
|
||||
new lang_string('onlynoreply', 'admin'),
|
||||
];
|
||||
$temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'),
|
||||
new lang_string('configemailfromvia', 'admin'), 1, $choices));
|
||||
|
||||
$temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'),
|
||||
new lang_string('configemailsubjectprefix', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtextarea('emailheaders', new lang_string('emailheaders', 'admin'),
|
||||
|
||||
$temp->add(new admin_setting_configtextarea('emailheaders', new lang_string('emailheaders', 'admin'),
|
||||
new lang_string('configemailheaders', 'admin'), '', PARAM_RAW, '50', '3'));
|
||||
|
||||
$ADMIN->add('email', $temp);
|
||||
$ADMIN->add('email', $temp);
|
||||
|
||||
// "update notifications" settingpage
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
$temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
|
||||
new lang_string('updateautocheck_desc', 'core_admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
|
||||
new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
|
||||
array(
|
||||
MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
|
||||
MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
|
||||
MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
|
||||
MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
|
||||
)));
|
||||
$temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
|
||||
new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
|
||||
$ADMIN->add('server', $temp);
|
||||
// Update notifications.
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
$temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
|
||||
new lang_string('updateautocheck_desc', 'core_admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
|
||||
new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
|
||||
[
|
||||
MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
|
||||
MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
|
||||
MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
|
||||
MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
|
||||
]
|
||||
));
|
||||
$temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
|
||||
new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
|
||||
$ADMIN->add('server', $temp);
|
||||
}
|
||||
}
|
||||
|
||||
} // end of speedup
|
||||
|
||||
@@ -39,6 +39,7 @@ $ADMIN->add('root', new admin_category('license', new lang_string('license')));
|
||||
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
|
||||
$ADMIN->add('root', new admin_category('language', new lang_string('language')));
|
||||
$ADMIN->add('root', new admin_category('messaging', new lang_string('messagingcategory', 'admin')));
|
||||
$ADMIN->add('root', new admin_category('payment', new lang_string('payments', 'payment')));
|
||||
$ADMIN->add('root', new admin_category('modules', new lang_string('plugins', 'admin')));
|
||||
$ADMIN->add('root', new admin_category('security', new lang_string('security','admin')));
|
||||
$ADMIN->add('root', new admin_category('appearance', new lang_string('appearance','admin')));
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_admin\local\settings\autocomplete
|
||||
|
||||
Admin setting auto complete.
|
||||
|
||||
Context variables required for this template:
|
||||
* name - element name
|
||||
* id - element id
|
||||
* options - choices
|
||||
* multiple - is multiple choices?
|
||||
* manageurl - url to manage choices
|
||||
* managetext - string to display manage url
|
||||
* tags - Should we allow typing new entries to the field?
|
||||
* ajax - Name of an AMD module to send/process ajax requests
|
||||
* placeholder - Placeholder text for an empty list
|
||||
* casesensitive - Whether the search has to be case-sensitive
|
||||
* showsuggestions - Show suggestions by default - but this can be turned off
|
||||
* noselectionstring - String that is shown when there are no selections
|
||||
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "name0",
|
||||
"id": "id0",
|
||||
"options": [{
|
||||
"value": "1",
|
||||
"text": "option 1",
|
||||
"selected": true,
|
||||
"disabled": false
|
||||
}],
|
||||
"multiple": true,
|
||||
"manageurl": "",
|
||||
"managetext": "",
|
||||
"tags": false,
|
||||
"ajax": "",
|
||||
"placeholder": "",
|
||||
"casesensitive": false,
|
||||
"showsuggestions": true,
|
||||
"noselectionstring": ""
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting autocomplete.
|
||||
}}
|
||||
|
||||
<div class="form-select defaultsnext">
|
||||
<input type="hidden" name="{{name}}[xxxxx]" value="_qf__force_multiselect_submission">
|
||||
<select class="custom-select" name="{{name}}[]"
|
||||
id="{{id}}"
|
||||
{{#multiple}}multiple{{/multiple}}>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
|
||||
{{/options}}
|
||||
</select>
|
||||
{{#manageurl}}
|
||||
<a href="{{manageurl}}">{{managetext}}</a>
|
||||
{{/manageurl}}
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
{{#js}}
|
||||
require(['core/form-autocomplete'], function(module) {
|
||||
module.enhance({{#quote}}#{{id}}{{/quote}},
|
||||
{{tags}},
|
||||
{{#quote}}{{ajax}}{{/quote}},
|
||||
{{#quote}}{{placeholder}}{{/quote}},
|
||||
{{casesensitive}},
|
||||
{{showsuggestions}},
|
||||
{{#quote}}{{noselectionstring}}{{/quote}});
|
||||
});
|
||||
{{/js}}
|
||||
@@ -25,6 +25,7 @@
|
||||
* value - yes value
|
||||
* id - element id
|
||||
* checked - boole
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
@@ -32,10 +33,11 @@
|
||||
"no": "False",
|
||||
"value": "True",
|
||||
"id": "test0",
|
||||
"checked": "checked"
|
||||
"checked": "checked",
|
||||
"readonly": false
|
||||
}
|
||||
}}
|
||||
<div class="form-checkbox defaultsnext">
|
||||
<input type="hidden" name="{{name}}" value="{{no}}">
|
||||
<input type="checkbox" name="{{name}}" value="{{value}}" id="{{id}}" {{#checked}}checked{{/checked}}>
|
||||
<input {{#readonly}}disabled{{/readonly}} type="checkbox" name="{{name}}" value="{{value}}" id="{{id}}" {{#checked}}checked{{/checked}}>
|
||||
</div>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
* id - element id
|
||||
* value - element value
|
||||
* haspreviewconfig - show preview of selected color
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
@@ -32,6 +33,7 @@
|
||||
"name": "name0",
|
||||
"id": "id0",
|
||||
"value": "#555655",
|
||||
"readonly": false,
|
||||
"haspreviewconfig": false
|
||||
}
|
||||
}}
|
||||
@@ -44,7 +46,7 @@
|
||||
{{>core/pix_icon}}
|
||||
{{/icon}}
|
||||
</div>
|
||||
<input type="text" name="{{name}}" id="{{id}}" value="{{value}}" size="12" class="form-control text-ltr">
|
||||
<input type="text" name="{{name}}" id="{{id}}" value="{{value}}" size="12" class="form-control text-ltr" {{#readonly}}disabled{{/readonly}}>
|
||||
{{#haspreviewconfig}}
|
||||
<input type="button" id="{{id}}_preview" value={{#quote}}{{#str}}preview{{/str}}{{/quote}} class="admin_colourpicker_preview">
|
||||
{{/haspreviewconfig}}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"name": "test",
|
||||
"value": "/my-super-secret-path/",
|
||||
"id": "test0",
|
||||
"readonly": true,
|
||||
"readonly": false,
|
||||
"showvalidity": true,
|
||||
"valid": false
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* name - form element name
|
||||
* options - list of options for units containing name, value, selected
|
||||
* value - yes
|
||||
* readonly - bool
|
||||
* id - element id
|
||||
|
||||
Example context (json):
|
||||
@@ -30,6 +31,7 @@
|
||||
"name": "test",
|
||||
"value": "5",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"options": [ { "name": "Minutes", "value": "mins", "selected": true } ]
|
||||
}
|
||||
}}
|
||||
@@ -38,9 +40,9 @@
|
||||
}}
|
||||
<div class="form-duration defaultsnext">
|
||||
<div class="form-inline">
|
||||
<input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr">
|
||||
<input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr" {{#readonly}}disabled{{/readonly}}>
|
||||
<label class="sr-only" for="{{id}}u">{{#str}}durationunits, admin{{/str}}</label>
|
||||
<select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select">
|
||||
<select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select" {{#readonly}}disabled{{/readonly}}>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"name": "test",
|
||||
"value": "/usr/bin/cowsay",
|
||||
"id": "test0",
|
||||
"readonly": true,
|
||||
"readonly": false,
|
||||
"showvalidity": true,
|
||||
"valid": false
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
* readonly - Make the field readonly
|
||||
* value - value
|
||||
* showvalidity - Show a green check if the path is readable
|
||||
* readonly - bool
|
||||
* valid - True if the path is readable
|
||||
|
||||
Example context (json):
|
||||
@@ -33,8 +34,9 @@
|
||||
"name": "test",
|
||||
"value": "/my-super-secret-path/file",
|
||||
"id": "test0",
|
||||
"readonly": true,
|
||||
"readonly": false,
|
||||
"showvalidity": true,
|
||||
"readonly": false,
|
||||
"valid": false
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -24,12 +24,14 @@
|
||||
* options - list of options for units containing name, value, selected
|
||||
* value - yes
|
||||
* id - element id
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "test",
|
||||
"value": "5",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"options": [ { "name": "KB", "value": "1024", "selected": true } ]
|
||||
}
|
||||
}}
|
||||
@@ -38,9 +40,9 @@
|
||||
}}
|
||||
<div class="form-filesize defaultsnext">
|
||||
<div class="form-inline">
|
||||
<input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr">
|
||||
<input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr" {{#readonly}}disabled{{/readonly}}>
|
||||
<label class="sr-only" for="{{id}}u">{{#str}}filesizeunits, admin{{/str}}</label>
|
||||
<select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select">
|
||||
<select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select" {{#readonly}}disabled{{/readonly}}>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -24,11 +24,13 @@
|
||||
* id - element id
|
||||
* size - element size
|
||||
* options - list of options containing name, value, selected
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "test",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"size": "3",
|
||||
"options": [ { "name": "Option 1", "value": "V", "selected": true },
|
||||
{ "name": "Option 2", "value": "V", "selected": true } ]
|
||||
@@ -39,7 +41,7 @@
|
||||
}}
|
||||
<div class="form-select">
|
||||
<input type="hidden" name="{{name}}[xxxxx]" value="1">
|
||||
<select id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
|
||||
<select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
* size - element size
|
||||
* options - list of options not grouped
|
||||
* optgroups - list of options grouped containing the group label and for each option: name, value, selected
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "test",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"size": "3",
|
||||
"options": [
|
||||
{ "name": "Option 1", "value": "V", "selected": false },
|
||||
@@ -58,7 +60,7 @@
|
||||
}}
|
||||
<div class="form-select">
|
||||
<input type="hidden" name="{{name}}[xxxxx]" value="1">
|
||||
<select id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
|
||||
<select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* size - form element size
|
||||
* value - form element value
|
||||
* id - element id
|
||||
* forced - has value been defined in config.php
|
||||
* readonly - has value been defined in config.php
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
@@ -32,10 +32,10 @@
|
||||
"id": "test0",
|
||||
"size": "8",
|
||||
"value": "secret",
|
||||
"forced": false
|
||||
"readonly": false
|
||||
}
|
||||
}}
|
||||
{{#forced}}
|
||||
{{#readonly}}
|
||||
<div class="form-password">
|
||||
<input type="text"
|
||||
name = "{{ name }}"
|
||||
@@ -46,8 +46,8 @@
|
||||
disabled
|
||||
>
|
||||
</div>
|
||||
{{/forced}}
|
||||
{{^forced}}
|
||||
{{/readonly}}
|
||||
{{^readonly}}
|
||||
<div class="form-password">
|
||||
<span data-passwordunmask="wrapper" data-passwordunmaskid="{{ id }}">
|
||||
<span data-passwordunmask="editor">
|
||||
@@ -76,4 +76,4 @@ require(['core_form/passwordunmask'], function(PasswordUnmask) {
|
||||
new PasswordUnmask("{{ id }}");
|
||||
});
|
||||
{{/js}}
|
||||
{{/forced}}
|
||||
{{/readonly}}
|
||||
|
||||
@@ -23,11 +23,13 @@
|
||||
* name - form element name
|
||||
* id - element id
|
||||
* options - list of options containing name, value, selected
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "test",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"options": [
|
||||
{ "name": "Option 1", "value": "V", "selected": true },
|
||||
{ "name": "Option 2", "value": "V", "selected": true }
|
||||
@@ -38,7 +40,7 @@
|
||||
Setting configselect.
|
||||
}}
|
||||
<div class="form-select defaultsnext">
|
||||
<select id="{{id}}" name="{{name}}" class="custom-select">
|
||||
<select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}" class="custom-select">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
Context variables required for this template:
|
||||
* name - form element name
|
||||
* id - element id
|
||||
* readonly - bool
|
||||
* options - list of options (not grouped)
|
||||
* optgroups - list of options grouped containing the group label and for each option: name, value, selected
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
{
|
||||
"name": "test",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"options": [
|
||||
{ "name": "Option 1", "value": "V", "selected": false },
|
||||
{ "name": "Option 2", "value": "V", "selected": false }
|
||||
@@ -55,7 +57,7 @@
|
||||
Setting configselect with optgroup support.
|
||||
}}
|
||||
<div class="form-select defaultsnext">
|
||||
<select id="{{id}}" name="{{name}}" class="custom-select">
|
||||
<select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}" class="custom-select">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
* size - element size
|
||||
* forceltr - always display as ltr
|
||||
* attributes - list of additional attributes containing name, value
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
@@ -34,6 +35,7 @@
|
||||
"value": "A tall, dark stranger will have more fun than you.",
|
||||
"size": "21",
|
||||
"forceltr": false,
|
||||
"readonly": false,
|
||||
"attributes": [ { "name": "readonly", "value": "readonly" } ]
|
||||
}
|
||||
}}
|
||||
@@ -41,5 +43,5 @@
|
||||
Setting configtext.
|
||||
}}
|
||||
<div class="form-text defaultsnext">
|
||||
<input type="text" name="{{name}}" value="{{value}}" size="{{size}}" id="{{id}}" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">
|
||||
<input type="text" name="{{name}}" value="{{value}}" size="{{size}}" id="{{id}}" class="form-control {{#forceltr}}text-ltr{{/forceltr}}" {{#readonly}}disabled{{/readonly}}>
|
||||
</div>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"cols": "30",
|
||||
"rows": "3",
|
||||
"value": "Excellent day for putting Slinkies on an escalator.",
|
||||
"readonly": false,
|
||||
"id": "test0"
|
||||
}
|
||||
}}
|
||||
@@ -40,5 +41,5 @@
|
||||
Setting configtextarea.
|
||||
}}
|
||||
<div class="form-textarea">
|
||||
<textarea rows="{{rows}}" cols="{{cols}}" id="{{id}}" name="{{name}}" spellcheck="true" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">{{value}}</textarea>
|
||||
<textarea {{#readonly}}disabled{{/readonly}} rows="{{rows}}" cols="{{cols}}" id="{{id}}" name="{{name}}" spellcheck="true" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">{{value}}</textarea>
|
||||
</div>
|
||||
|
||||
@@ -24,11 +24,13 @@
|
||||
* id - element id
|
||||
* hours - list of valid hour options containing name, value, selected
|
||||
* minutes - list of valid minute options containing name, value, selected
|
||||
* readonly - bool
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "test",
|
||||
"id": "test0",
|
||||
"readonly": false,
|
||||
"minutes": [
|
||||
{ "name": "00", "value": "0", "selected": true },
|
||||
{ "name": "01", "value": "1", "selected": false }
|
||||
@@ -45,13 +47,13 @@
|
||||
<div class="form-time defaultsnext">
|
||||
<div class="form-inline text-ltr">
|
||||
<label class="sr-only" for="{{id}}h">{{#str}}hours{{/str}}</label>
|
||||
<select id="{{id}}h" name="{{name}}[h]" class="custom-select">
|
||||
<select id="{{id}}h" name="{{name}}[h]" class="custom-select" {{#readonly}}disabled{{/readonly}}>
|
||||
{{#hours}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/hours}}
|
||||
</select>:
|
||||
<label class="sr-only" for="{{id}}m">{{#str}}minutes{{/str}}</label>
|
||||
<select id="{{id}}m" name="{{name}}[m]" class="custom-select">
|
||||
<select id="{{id}}m" name="{{name}}[m]" class="custom-select" {{#readonly}}disabled{{/readonly}}>
|
||||
{{#minutes}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/minutes}}
|
||||
|
||||
@@ -56,7 +56,7 @@ class behat_admin extends behat_base {
|
||||
$this->execute('behat_navigation::i_select_from_flat_navigation_drawer', [get_string('administrationsite')]);
|
||||
|
||||
// Search by label.
|
||||
$this->execute('behat_forms::i_set_the_field_to', [get_string('query', 'admin'), $label]);
|
||||
$this->execute('behat_forms::i_set_the_field_to', [get_string('search'), $label]);
|
||||
$this->execute("behat_forms::press_button", get_string('search', 'admin'));
|
||||
|
||||
// Admin settings does not use the same DOM structure than other moodle forms
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
@core @core_admin
|
||||
Feature: Administrator is warned and when trying to set invalid allcountrycodes value.
|
||||
In order to avoid misconfiguration of the country selector fields
|
||||
As an admin
|
||||
I want to be warned when I try to set an invalid country code in the allcountrycodes field
|
||||
|
||||
Scenario: Attempting to set allcountrycodes field with valid country codes
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Location > Location settings" in site administration
|
||||
When I set the following administration settings values:
|
||||
| All country codes | CZ,BE,GB,ES |
|
||||
Then I should not see "Invalid country code"
|
||||
|
||||
Scenario: Attempting to set allcountrycodes field with invalid country code
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Location > Location settings" in site administration
|
||||
When I set the following administration settings values:
|
||||
| All country codes | CZ,BE,FOOBAR,GB,ES |
|
||||
Then I should see "Invalid country code: FOOBAR"
|
||||
|
||||
Scenario: Attempting to unset allcountrycodes field
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Location > Location settings" in site administration
|
||||
And I set the following administration settings values:
|
||||
| All country codes | CZ,BE,GB,ES |
|
||||
And I navigate to "Location > Location settings" in site administration
|
||||
When I set the following administration settings values:
|
||||
| All country codes | |
|
||||
Then I should not see "Invalid country code"
|
||||
@@ -0,0 +1,34 @@
|
||||
@core @core_admin
|
||||
Feature: Configure language settings for the site
|
||||
In order to configure language settings for the site
|
||||
As an admin
|
||||
I want to set language settings relevant to my site users
|
||||
|
||||
Scenario: Set languages on language menu
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language settings" in site administration
|
||||
When I set the field "Languages on language menu" to "en"
|
||||
And I press "Save changes"
|
||||
Then I should not see "Invalid language code"
|
||||
|
||||
Scenario: Reset languages on language menu
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language settings" in site administration
|
||||
When I set the field "Languages on language menu" to ""
|
||||
And I press "Save changes"
|
||||
Then I should not see "Invalid language code"
|
||||
|
||||
Scenario Outline: Set languages on language menu with invalid language
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language settings" in site administration
|
||||
When I set the field "Languages on language menu" to "<fieldvalue>"
|
||||
And I press "Save changes"
|
||||
Then I should see "Invalid language code: <invalidlang>"
|
||||
Examples:
|
||||
| fieldvalue | invalidlang |
|
||||
| xx | xx |
|
||||
| xx\|Bad | xx |
|
||||
| en,qq | qq |
|
||||
| en,qq\|Bad | qq |
|
||||
| en$$ | en$$ |
|
||||
| en$$\|Bad | en$$ |
|
||||
@@ -64,7 +64,7 @@ class models_list implements \renderable, \templatable {
|
||||
$data = new \stdClass();
|
||||
|
||||
$newmodelmenu = new \action_menu();
|
||||
$newmodelmenu->set_menu_trigger(get_string('newmodel', 'tool_analytics'), 'btn btn-default');
|
||||
$newmodelmenu->set_menu_trigger(get_string('newmodel', 'tool_analytics'), 'btn btn-secondary');
|
||||
$newmodelmenu->set_alignment(\action_menu::TL, \action_menu::BL);
|
||||
|
||||
$newmodelmenu->add(new \action_menu_link(
|
||||
|
||||
@@ -57,10 +57,10 @@
|
||||
{{/trainedexternally}}
|
||||
|
||||
{{! Hidden by default if #trainedexternally as the default option is trainedmodel in this case.}}
|
||||
<div id="id-evaluation-timesplitting-container" class="m-t-1 {{#trainedexternally}}hidden{{/trainedexternally}}">
|
||||
<div id="id-evaluation-timesplitting-container" class="mt-3 {{#trainedexternally}}hidden{{/trainedexternally}}">
|
||||
{{#str}} selecttimesplittingforevaluation, tool_analytics {{/str}}
|
||||
<div>
|
||||
<select id="id-evaluation-timesplitting" name="timesplitting" class="custom-select m-t-1">
|
||||
<select id="id-evaluation-timesplitting" name="timesplitting" class="custom-select mt-3">
|
||||
{{#timesplittingmethods}}
|
||||
<option value="{{id}}">{{text}}</option>
|
||||
{{/timesplittingmethods}}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<input class="custom-control-input" type="radio" name="exportoption" id="id-mode-exportmodel" value="exportmodel" checked>
|
||||
<label class="custom-control-label" for="id-mode-exportmodel">{{#str}} exportmodel, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox m-l-2" id="id-includeweights-container">
|
||||
<div class="custom-control custom-checkbox ml-5" id="id-includeweights-container">
|
||||
<input class="custom-control-input" type="checkbox" id="id-includeweights" value="1" checked>
|
||||
<label class="custom-control-label" for="id-includeweights">{{#str}} exportincludeweights, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
|
||||
@@ -66,8 +66,6 @@ class tool_analytics_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* test_potential_contexts description
|
||||
*
|
||||
* @expectedException required_capability_exception
|
||||
*/
|
||||
public function test_potential_contexts_no_manager() {
|
||||
$this->resetAfterTest();
|
||||
@@ -75,6 +73,7 @@ class tool_analytics_external_testcase extends externallib_advanced_testcase {
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
|
||||
$this->expectException(required_capability_exception::class);
|
||||
$this->assertCount(2, \tool_analytics\external::potential_contexts());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => false,
|
||||
'disable-composer' => false,
|
||||
'composer-upgrade' => true,
|
||||
'composer-self-update' => true,
|
||||
),
|
||||
array(
|
||||
'j' => 'parallel',
|
||||
@@ -65,19 +68,36 @@ $help = "
|
||||
Behat utilities to initialise behat tests
|
||||
|
||||
Usage:
|
||||
php init.php [--parallel=value [--maxruns=value] [--fromrun=value --torun=value]] [--help]
|
||||
php init.php [--parallel=value [--maxruns=value] [--fromrun=value --torun=value]]
|
||||
[--axe] [-o | --optimize-runs] [-a | --add-core-features-to-theme]
|
||||
[--no-composer-self-update] [--no-composer-upgrade]
|
||||
[--disable-composer]
|
||||
[--help]
|
||||
|
||||
Options:
|
||||
-j, --parallel Number of parallel behat run to initialise
|
||||
-m, --maxruns Max parallel processes to be executed at one time.
|
||||
--fromrun Execute run starting from (Used for parallel runs on different vms)
|
||||
--torun Execute run till (Used for parallel runs on different vms)
|
||||
--axe Include axe accessibility tests
|
||||
-j, --parallel Number of parallel behat run to initialise
|
||||
-m, --maxruns Max parallel processes to be executed at one time
|
||||
--fromrun Execute run starting from (Used for parallel runs on different vms)
|
||||
--torun Execute run till (Used for parallel runs on different vms)
|
||||
--axe Include axe accessibility tests
|
||||
|
||||
-o, --optimize-runs Split features with specified tags in all parallel runs.
|
||||
-a, --add-core-features-to-theme Add all core features to specified theme's
|
||||
-o, --optimize-runs
|
||||
Split features with specified tags in all parallel runs.
|
||||
|
||||
-h, --help Print out this help
|
||||
-a, --add-core-features-to-theme
|
||||
Add all core features to specified theme's
|
||||
|
||||
--no-composer-self-update
|
||||
Prevent upgrade of the composer utility using its self-update command
|
||||
|
||||
--no-composer-upgrade
|
||||
Prevent update development dependencies using composer
|
||||
|
||||
--disable-composer
|
||||
A shortcut to disable composer self-update and dependency update
|
||||
Note: Installation of composer and/or dependencies will still happen as required
|
||||
|
||||
-h, --help Print out this help
|
||||
|
||||
Example from Moodle root directory:
|
||||
\$ php admin/tool/behat/cli/init.php --parallel=2
|
||||
@@ -120,8 +140,15 @@ if ($options['parallel'] && $options['parallel'] > 1) {
|
||||
$cwd = getcwd();
|
||||
$output = null;
|
||||
|
||||
// If behat dependencies not downloaded then do it first, else symfony/process can't be used.
|
||||
testing_update_composer_dependencies();
|
||||
if ($options['disable-composer']) {
|
||||
// Disable self-update and upgrade easily.
|
||||
// Note: Installation will still occur regardless of this setting.
|
||||
$options['composer-self-update'] = false;
|
||||
$options['composer-upgrade'] = false;
|
||||
}
|
||||
|
||||
// Install and update composer and dependencies as required.
|
||||
testing_update_composer_dependencies($options['composer-self-update'], $options['composer-upgrade']);
|
||||
|
||||
// Check whether the behat test environment needs to be updated.
|
||||
chdir(__DIR__);
|
||||
|
||||
@@ -187,10 +187,13 @@ if ($options['install']) {
|
||||
behat_config_manager::set_behat_run_config_value('axe', $options['axe']);
|
||||
|
||||
// Enable test mode.
|
||||
$timestart = microtime(true);
|
||||
mtrace('Creating Behat configuration ...', '');
|
||||
behat_util::start_test_mode($options['add-core-features-to-theme'], $options['optimize-runs'], $parallel, $run);
|
||||
mtrace(' done in ' . round(microtime(true) - $timestart, 2) . ' seconds.');
|
||||
|
||||
// Themes are only built in the 'enable' command.
|
||||
behat_util::build_themes();
|
||||
behat_util::build_themes(true);
|
||||
mtrace("Testing environment themes built");
|
||||
|
||||
// This is only displayed once for parallel install.
|
||||
|
||||
@@ -87,7 +87,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
/**
|
||||
* Setup test.
|
||||
*/
|
||||
public function setup() {
|
||||
public function setUp(): void {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
@@ -165,7 +165,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -324,7 +324,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -368,7 +368,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -399,7 +399,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -428,7 +428,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -532,7 +532,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -611,7 +611,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
// Check contexts.
|
||||
@@ -646,7 +646,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,7 +662,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,7 +693,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||
|
||||
foreach ($paths as $key => $feature) {
|
||||
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class tool_capability_events_testcase extends advanced_testcase {
|
||||
/**
|
||||
* Setup testcase.
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
$this->setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
}
|
||||
|
||||
admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js
Vendored
+27
-4
@@ -53,6 +53,13 @@ SEARCH.prototype = {
|
||||
* @protected
|
||||
*/
|
||||
button: null,
|
||||
/**
|
||||
* The cancel button for the form.
|
||||
* @property button
|
||||
* @type Node
|
||||
* @protected
|
||||
*/
|
||||
cancel: null,
|
||||
/**
|
||||
* The last search node if there is one.
|
||||
* If there is a last search node then the last search term will be persisted between requests.
|
||||
@@ -76,17 +83,28 @@ SEARCH.prototype = {
|
||||
this.button = this.form.all('input[type=submit]');
|
||||
this.lastsearch = this.form.one('input[name=search]');
|
||||
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
|
||||
this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" class="input-group simplesearchform mb-2"' +
|
||||
'data-fieldtype="text"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch"><span class="sr-only"' +
|
||||
this.get('strsearch') + '</span></label>');
|
||||
this.cancel = Y.Node.create('<a class="btn btn-clear d-none icon-no-margin">' +
|
||||
'<i class="icon fa fa-times fa-fw " aria-hidden="true"></i>' +
|
||||
'</a>');
|
||||
this.input = Y.Node.create('<input type="text" class="form-control withclear" placeholder="' +
|
||||
this.get('strsearch') + '"id="capabilitysearch" />');
|
||||
|
||||
div.append(label).append(this.input);
|
||||
div.append(label).append(this.input).append(this.cancel);
|
||||
|
||||
this.select.insert(div, 'before');
|
||||
|
||||
this.input.on('keyup', this.typed, this);
|
||||
this.select.on('change', this.validate, this);
|
||||
|
||||
this.cancel.on('click', function() {
|
||||
this.input.set('value', '');
|
||||
this.typed();
|
||||
}, this);
|
||||
|
||||
if (this.lastsearch) {
|
||||
this.input.set('value', this.lastsearch.get('value'));
|
||||
this.typed();
|
||||
@@ -133,6 +151,11 @@ SEARCH.prototype = {
|
||||
last.set('selected', true);
|
||||
}
|
||||
}
|
||||
if (search !== '') {
|
||||
this.cancel.removeClass("d-none");
|
||||
} else {
|
||||
this.cancel.addClass("d-none");
|
||||
}
|
||||
this.validate();
|
||||
}
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
YUI.add("moodle-tool_capability-search",function(i,t){var e=function(){e.superclass.constructor.apply(this,arguments)};e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,lastsearch:null,initializer:function(){this.form=i.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=i.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),e=i.Node.create('<label for="capabilitysearch">'+this.get("strsearch")+"</label>");this.input=i.Node.create('<input type="text" id="capabilitysearch" />'),t.append(e).append(this.input),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),i=0,s=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(i++,s=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===i?this.input.addClass("error"):(this.input.removeClass("error"),1===i&&s.set("selected",!0)),this.validate()}},i.extend(e,i.Base,e.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]});
|
||||
YUI.add("moodle-tool_capability-search",function(s,t){var e=function(){e.superclass.constructor.apply(this,arguments)};e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,cancel:null,lastsearch:null,initializer:function(){this.form=s.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=s.Node.create('<div id="capabilitysearchui" class="input-group simplesearchform mb-2"data-fieldtype="text"></div>'),e=s.Node.create('<label for="capabilitysearch"><span class="sr-only"'+this.get("strsearch")+"</span></label>");this.cancel=s.Node.create('<a class="btn btn-clear d-none icon-no-margin"><i class="icon fa fa-times fa-fw " aria-hidden="true"></i></a>'),this.input=s.Node.create('<input type="text" class="form-control withclear" placeholder="'+this.get("strsearch")+'"id="capabilitysearch" />'),t.append(e).append(this.input).append(this.cancel),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.cancel.on("click",function(){this.input.set("value",""),this.typed()},this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),s=0,i=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(s++,i=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===s?this.input.addClass("error"):(this.input.removeClass("error"),1===s&&i.set("selected",!0)),""!==e?this.cancel.removeClass("d-none"):this.cancel.addClass("d-none"),this.validate()}},s.extend(e,s.Base,e.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]});
|
||||
Vendored
+27
-4
@@ -53,6 +53,13 @@ SEARCH.prototype = {
|
||||
* @protected
|
||||
*/
|
||||
button: null,
|
||||
/**
|
||||
* The cancel button for the form.
|
||||
* @property button
|
||||
* @type Node
|
||||
* @protected
|
||||
*/
|
||||
cancel: null,
|
||||
/**
|
||||
* The last search node if there is one.
|
||||
* If there is a last search node then the last search term will be persisted between requests.
|
||||
@@ -76,17 +83,28 @@ SEARCH.prototype = {
|
||||
this.button = this.form.all('input[type=submit]');
|
||||
this.lastsearch = this.form.one('input[name=search]');
|
||||
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
|
||||
this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" class="input-group simplesearchform mb-2"' +
|
||||
'data-fieldtype="text"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch"><span class="sr-only"' +
|
||||
this.get('strsearch') + '</span></label>');
|
||||
this.cancel = Y.Node.create('<a class="btn btn-clear d-none icon-no-margin">' +
|
||||
'<i class="icon fa fa-times fa-fw " aria-hidden="true"></i>' +
|
||||
'</a>');
|
||||
this.input = Y.Node.create('<input type="text" class="form-control withclear" placeholder="' +
|
||||
this.get('strsearch') + '"id="capabilitysearch" />');
|
||||
|
||||
div.append(label).append(this.input);
|
||||
div.append(label).append(this.input).append(this.cancel);
|
||||
|
||||
this.select.insert(div, 'before');
|
||||
|
||||
this.input.on('keyup', this.typed, this);
|
||||
this.select.on('change', this.validate, this);
|
||||
|
||||
this.cancel.on('click', function() {
|
||||
this.input.set('value', '');
|
||||
this.typed();
|
||||
}, this);
|
||||
|
||||
if (this.lastsearch) {
|
||||
this.input.set('value', this.lastsearch.get('value'));
|
||||
this.typed();
|
||||
@@ -133,6 +151,11 @@ SEARCH.prototype = {
|
||||
last.set('selected', true);
|
||||
}
|
||||
}
|
||||
if (search !== '') {
|
||||
this.cancel.removeClass("d-none");
|
||||
} else {
|
||||
this.cancel.addClass("d-none");
|
||||
}
|
||||
this.validate();
|
||||
}
|
||||
};
|
||||
|
||||
+27
-4
@@ -51,6 +51,13 @@ SEARCH.prototype = {
|
||||
* @protected
|
||||
*/
|
||||
button: null,
|
||||
/**
|
||||
* The cancel button for the form.
|
||||
* @property button
|
||||
* @type Node
|
||||
* @protected
|
||||
*/
|
||||
cancel: null,
|
||||
/**
|
||||
* The last search node if there is one.
|
||||
* If there is a last search node then the last search term will be persisted between requests.
|
||||
@@ -74,17 +81,28 @@ SEARCH.prototype = {
|
||||
this.button = this.form.all('input[type=submit]');
|
||||
this.lastsearch = this.form.one('input[name=search]');
|
||||
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
|
||||
this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" class="input-group simplesearchform mb-2"' +
|
||||
'data-fieldtype="text"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch"><span class="sr-only"' +
|
||||
this.get('strsearch') + '</span></label>');
|
||||
this.cancel = Y.Node.create('<a class="btn btn-clear d-none icon-no-margin">' +
|
||||
'<i class="icon fa fa-times fa-fw " aria-hidden="true"></i>' +
|
||||
'</a>');
|
||||
this.input = Y.Node.create('<input type="text" class="form-control withclear" placeholder="' +
|
||||
this.get('strsearch') + '"id="capabilitysearch" />');
|
||||
|
||||
div.append(label).append(this.input);
|
||||
div.append(label).append(this.input).append(this.cancel);
|
||||
|
||||
this.select.insert(div, 'before');
|
||||
|
||||
this.input.on('keyup', this.typed, this);
|
||||
this.select.on('change', this.validate, this);
|
||||
|
||||
this.cancel.on('click', function() {
|
||||
this.input.set('value', '');
|
||||
this.typed();
|
||||
}, this);
|
||||
|
||||
if (this.lastsearch) {
|
||||
this.input.set('value', this.lastsearch.get('value'));
|
||||
this.typed();
|
||||
@@ -131,6 +149,11 @@ SEARCH.prototype = {
|
||||
last.set('selected', true);
|
||||
}
|
||||
}
|
||||
if (search !== '') {
|
||||
this.cancel.removeClass("d-none");
|
||||
} else {
|
||||
this.cancel.addClass("d-none");
|
||||
}
|
||||
this.validate();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
/**
|
||||
* Setup function- we will create a course and add an assign instance to it.
|
||||
*/
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Create some users.
|
||||
@@ -60,9 +60,6 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
cohort_add_member($this->cohort->id, $this->userassignover->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException required_capability_exception
|
||||
*/
|
||||
public function test_create_cohort_role_assignment_without_permission() {
|
||||
$this->setUser($this->userassignto);
|
||||
$params = (object) array(
|
||||
@@ -70,12 +67,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
'roleid' => $this->roleid,
|
||||
'cohortid' => $this->cohort->id
|
||||
);
|
||||
$this->expectException(required_capability_exception::class);
|
||||
api::create_cohort_role_assignment($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException core_competency\invalid_persistent_exception
|
||||
*/
|
||||
public function test_create_cohort_role_assignment_with_invalid_data() {
|
||||
$this->setAdminUser();
|
||||
$params = (object) array(
|
||||
@@ -83,6 +78,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
'roleid' => -8,
|
||||
'cohortid' => $this->cohort->id
|
||||
);
|
||||
$this->expectException(\core_competency\invalid_persistent_exception::class);
|
||||
api::create_cohort_role_assignment($params);
|
||||
}
|
||||
|
||||
@@ -100,9 +96,6 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
$this->assertEquals($result->get('cohortid'), $this->cohort->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException required_capability_exception
|
||||
*/
|
||||
public function test_delete_cohort_role_assignment_without_permission() {
|
||||
$this->setAdminUser();
|
||||
$params = (object) array(
|
||||
@@ -112,12 +105,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
);
|
||||
$result = api::create_cohort_role_assignment($params);
|
||||
$this->setUser($this->userassignto);
|
||||
$this->expectException(required_capability_exception::class);
|
||||
api::delete_cohort_role_assignment($result->get('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException dml_missing_record_exception
|
||||
*/
|
||||
public function test_delete_cohort_role_assignment_with_invalid_data() {
|
||||
$this->setAdminUser();
|
||||
$params = (object) array(
|
||||
@@ -126,6 +117,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
|
||||
'cohortid' => $this->cohort->id
|
||||
);
|
||||
$result = api::create_cohort_role_assignment($params);
|
||||
$this->expectException(dml_missing_record_exception::class);
|
||||
api::delete_cohort_role_assignment($result->get('id') + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
|
||||
/**
|
||||
* Overriding setUp() function to always reset after tests.
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest(true);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
|
||||
CONTEXT_COURSECAT
|
||||
];
|
||||
// Test the User's contexts equal the system and course category context.
|
||||
$this->assertEquals($expected, $contextlevels, '', 0, 10, true);
|
||||
$this->assertEqualsCanonicalizing($expected, $contextlevels);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Creates Formular for customlang file export
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Thomas Wedekind <Thomas.Wedekind@univie.ac.at>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_customlang\form;
|
||||
|
||||
use tool_customlang_utils;
|
||||
|
||||
/**
|
||||
* Formular for customlang file export
|
||||
*
|
||||
* @copyright 2020 Thomas Wedekind <Thomas.Wedekind@univie.ac.at>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class export extends \moodleform {
|
||||
|
||||
/**
|
||||
* Add elements to form
|
||||
*/
|
||||
public function definition() {
|
||||
$lng = $this->_customdata['lng'];
|
||||
$mform = $this->_form;
|
||||
|
||||
$langdir = tool_customlang_utils::get_localpack_location($lng);
|
||||
|
||||
// The export button only appears if a local lang is present.
|
||||
if (!check_dir_exists($langdir) || !count(glob("$langdir/*"))) {
|
||||
print_error('nolocallang', 'tool_customlang');
|
||||
}
|
||||
|
||||
$langfiles = scandir($langdir);
|
||||
$fileoptions = [];
|
||||
foreach ($langfiles as $file) {
|
||||
if (substr($file, 0, 1) != '.') {
|
||||
$fileoptions[$file] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'lng', $lng);
|
||||
$mform->setType('lng', PARAM_LANG);
|
||||
|
||||
$select = $mform->addElement('select', 'files', get_string('exportfilter', 'tool_customlang'), $fileoptions);
|
||||
$select->setMultiple(true);
|
||||
$mform->addRule('files', get_string('required'), 'required', null, 'client');
|
||||
$mform->setDefault('files', $fileoptions);
|
||||
|
||||
$this->add_action_buttons(true, get_string('export', 'tool_customlang'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Upload a zip of custom lang php files.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_customlang\form;
|
||||
|
||||
use tool_customlang\local\importer;
|
||||
|
||||
/**
|
||||
* Upload a zip/php of custom lang php files.
|
||||
*
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class import extends \moodleform {
|
||||
|
||||
/**
|
||||
* Form definition.
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
$mform->addElement('header', 'settingsheader', get_string('import', 'tool_customlang'));
|
||||
|
||||
$mform->addElement('hidden', 'lng');
|
||||
$mform->setType('lng', PARAM_LANG);
|
||||
$mform->setDefault('lng', $this->_customdata['lng']);
|
||||
|
||||
$filemanageroptions = array(
|
||||
'accepted_types' => array('.php', '.zip'),
|
||||
'maxbytes' => 0,
|
||||
'maxfiles' => 1,
|
||||
'subdirs' => 0
|
||||
);
|
||||
|
||||
$mform->addElement('filepicker', 'pack', get_string('langpack', 'tool_customlang'),
|
||||
null, $filemanageroptions);
|
||||
$mform->addRule('pack', null, 'required');
|
||||
|
||||
$modes = [
|
||||
importer::IMPORTALL => get_string('import_all', 'tool_customlang'),
|
||||
importer::IMPORTUPDATE => get_string('import_update', 'tool_customlang'),
|
||||
importer::IMPORTNEW => get_string('import_new', 'tool_customlang'),
|
||||
];
|
||||
$mform->addElement('select', 'importmode', get_string('import_mode', 'tool_customlang'), $modes);
|
||||
|
||||
$mform->addElement('submit', 'importcustomstrings', get_string('importfile', 'tool_customlang'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Custom lang importer.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_customlang\local;
|
||||
|
||||
use tool_customlang\local\mlang\phpparser;
|
||||
use tool_customlang\local\mlang\logstatus;
|
||||
use tool_customlang\local\mlang\langstring;
|
||||
use core\output\notification;
|
||||
use stored_file;
|
||||
use coding_exception;
|
||||
use moodle_exception;
|
||||
use core_component;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class containing tha custom lang importer
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class importer {
|
||||
|
||||
/** @var int imports will only create new customizations */
|
||||
public const IMPORTNEW = 1;
|
||||
/** @var int imports will only update the current customizations */
|
||||
public const IMPORTUPDATE = 2;
|
||||
/** @var int imports all strings */
|
||||
public const IMPORTALL = 3;
|
||||
|
||||
/**
|
||||
* @var string the language name
|
||||
*/
|
||||
protected $lng;
|
||||
|
||||
/**
|
||||
* @var int the importation mode (new, update, all)
|
||||
*/
|
||||
protected $importmode;
|
||||
|
||||
/**
|
||||
* @var string request folder path
|
||||
*/
|
||||
private $folder;
|
||||
|
||||
/**
|
||||
* @var array import log messages
|
||||
*/
|
||||
private $log;
|
||||
|
||||
/**
|
||||
* Constructor for the importer class.
|
||||
*
|
||||
* @param string $lng the current language to import.
|
||||
* @param int $importmode the import method (IMPORTALL, IMPORTNEW, IMPORTUPDATE).
|
||||
*/
|
||||
public function __construct(string $lng, int $importmode = self::IMPORTALL) {
|
||||
$this->lng = $lng;
|
||||
$this->importmode = $importmode;
|
||||
$this->log = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last parse log.
|
||||
*
|
||||
* @return logstatus[] mlang logstatus with the messages
|
||||
*/
|
||||
public function get_log(): array {
|
||||
return $this->log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import customlang files.
|
||||
*
|
||||
* @param stored_file[] $files array of files to import
|
||||
*/
|
||||
public function import(array $files): void {
|
||||
// Create a temporal folder to store the files.
|
||||
$this->folder = make_request_directory(false);
|
||||
|
||||
$langfiles = $this->deploy_files($files);
|
||||
|
||||
$this->process_files($langfiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy all files into a request folder.
|
||||
*
|
||||
* @param stored_file[] $files array of files to deploy
|
||||
* @return string[] of file paths
|
||||
*/
|
||||
private function deploy_files(array $files): array {
|
||||
$result = [];
|
||||
// Desploy all files.
|
||||
foreach ($files as $file) {
|
||||
if ($file->get_mimetype() == 'application/zip') {
|
||||
$result = array_merge($result, $this->unzip_file($file));
|
||||
} else {
|
||||
$path = $this->folder.'/'.$file->get_filename();
|
||||
$file->copy_content_to($path);
|
||||
$result = array_merge($result, [$path]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unzip a file into the request folder.
|
||||
*
|
||||
* @param stored_file $file the zip file to unzip
|
||||
* @return string[] of zip content paths
|
||||
*/
|
||||
private function unzip_file(stored_file $file): array {
|
||||
$fp = get_file_packer('application/zip');
|
||||
$zipcontents = $fp->extract_to_pathname($file, $this->folder);
|
||||
if (!$zipcontents) {
|
||||
throw new moodle_exception("Error Unzipping file", 1);
|
||||
}
|
||||
$result = [];
|
||||
foreach ($zipcontents as $contentname => $success) {
|
||||
if ($success) {
|
||||
$result[] = $this->folder.'/'.$contentname;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import strings from a list of langfiles.
|
||||
*
|
||||
* @param string[] $langfiles an array with file paths
|
||||
*/
|
||||
private function process_files(array $langfiles): void {
|
||||
$parser = phpparser::get_instance();
|
||||
foreach ($langfiles as $filepath) {
|
||||
$component = $this->component_from_filepath($filepath);
|
||||
if ($component) {
|
||||
$strings = $parser->parse(file_get_contents($filepath));
|
||||
$this->import_strings($strings, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to get the component from a filepath.
|
||||
*
|
||||
* @param string $filepath the filepath
|
||||
* @return stdCalss|null the DB record of that component
|
||||
*/
|
||||
private function component_from_filepath(string $filepath) {
|
||||
global $DB;
|
||||
|
||||
// Get component from filename.
|
||||
$pathparts = pathinfo($filepath);
|
||||
if (empty($pathparts['filename'])) {
|
||||
throw new coding_exception("Cannot get filename from $filepath", 1);
|
||||
}
|
||||
$filename = $pathparts['filename'];
|
||||
|
||||
$normalized = core_component::normalize_component($filename);
|
||||
if (count($normalized) == 1 || empty($normalized[1])) {
|
||||
$componentname = $normalized[0];
|
||||
} else {
|
||||
$componentname = implode('_', $normalized);
|
||||
}
|
||||
|
||||
$result = $DB->get_record('tool_customlang_components', ['name' => $componentname]);
|
||||
|
||||
if (!$result) {
|
||||
$this->log[] = new logstatus('notice_missingcomponent', notification::NOTIFY_ERROR, null, $componentname);
|
||||
return null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import an array of strings into the customlang tables.
|
||||
*
|
||||
* @param langstring[] $strings the langstring to set
|
||||
* @param stdClass $component the target component
|
||||
*/
|
||||
private function import_strings(array $strings, stdClass $component): void {
|
||||
global $DB;
|
||||
|
||||
foreach ($strings as $newstring) {
|
||||
// Check current DB entry.
|
||||
$customlang = $DB->get_record('tool_customlang', [
|
||||
'componentid' => $component->id,
|
||||
'stringid' => $newstring->id,
|
||||
'lang' => $this->lng,
|
||||
]);
|
||||
if (!$customlang) {
|
||||
$customlang = null;
|
||||
}
|
||||
|
||||
if ($this->can_save_string($customlang, $newstring, $component)) {
|
||||
$customlang->local = $newstring->text;
|
||||
$customlang->timecustomized = $newstring->timemodified;
|
||||
$customlang->outdated = 0;
|
||||
$customlang->modified = 1;
|
||||
$DB->update_record('tool_customlang', $customlang);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a specific string can be saved based on the current importmode.
|
||||
*
|
||||
* @param stdClass $customlang customlang original record
|
||||
* @param langstring $newstring the new strign to store
|
||||
* @param stdClass $component the component target
|
||||
* @return bool if the string can be stored
|
||||
*/
|
||||
private function can_save_string(?stdClass $customlang, langstring $newstring, stdClass $component): bool {
|
||||
$result = false;
|
||||
$message = 'notice_success';
|
||||
if (empty($customlang)) {
|
||||
$message = 'notice_inexitentstring';
|
||||
$this->log[] = new logstatus($message, notification::NOTIFY_ERROR, null, $component->name, $newstring);
|
||||
return $result;
|
||||
}
|
||||
|
||||
switch ($this->importmode) {
|
||||
case self::IMPORTNEW:
|
||||
$result = empty($customlang->local);
|
||||
$warningmessage = 'notice_ignoreupdate';
|
||||
break;
|
||||
case self::IMPORTUPDATE:
|
||||
$result = !empty($customlang->local);
|
||||
$warningmessage = 'notice_ignorenew';
|
||||
break;
|
||||
case self::IMPORTALL:
|
||||
$result = true;
|
||||
break;
|
||||
}
|
||||
if ($result) {
|
||||
$errorlevel = notification::NOTIFY_SUCCESS;
|
||||
} else {
|
||||
$errorlevel = notification::NOTIFY_ERROR;
|
||||
$message = $warningmessage;
|
||||
}
|
||||
$this->log[] = new logstatus($message, $errorlevel, null, $component->name, $newstring);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Language string based on David Mudrak langstring from local_amos.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_customlang\local\mlang;
|
||||
|
||||
use moodle_exception;
|
||||
use stdclass;
|
||||
|
||||
/**
|
||||
* Class containing a lang string cleaned.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a single string
|
||||
*/
|
||||
class langstring {
|
||||
|
||||
/** @var string identifier */
|
||||
public $id = null;
|
||||
|
||||
/** @var string */
|
||||
public $text = '';
|
||||
|
||||
/** @var int the time stamp when this string was saved */
|
||||
public $timemodified = null;
|
||||
|
||||
/** @var bool is deleted */
|
||||
public $deleted = false;
|
||||
|
||||
/** @var stdclass extra information about the string */
|
||||
public $extra = null;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $id string identifier
|
||||
* @param string $text string text
|
||||
* @param int $timemodified
|
||||
* @param int $deleted
|
||||
* @param stdclass $extra
|
||||
*/
|
||||
public function __construct(string $id, string $text = '', int $timemodified = null,
|
||||
int $deleted = 0, stdclass $extra = null) {
|
||||
|
||||
if (is_null($timemodified)) {
|
||||
$timemodified = time();
|
||||
}
|
||||
$this->id = $id;
|
||||
$this->text = $text;
|
||||
$this->timemodified = $timemodified;
|
||||
$this->deleted = $deleted;
|
||||
$this->extra = $extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a string text, returns it being formatted properly for storing in AMOS repository.
|
||||
*
|
||||
* Note: This method is taken directly from local_amos as it is highly tested and robust.
|
||||
* The Moodle 1.x part is keep on puspose to make it easier the copy paste from both codes.
|
||||
* This could change in the future when AMOS stop suporting the 1.x langstrings.
|
||||
*
|
||||
* We need to know for what branch the string should be prepared due to internal changes in
|
||||
* format required by get_string()
|
||||
* - for get_string() in Moodle 1.6 - 1.9 use $format == 1
|
||||
* - for get_string() in Moodle 2.0 and higher use $format == 2
|
||||
*
|
||||
* Typical usages of this methods:
|
||||
* $t = langstring::fix_syntax($t); // sanity new translations of 2.x strings
|
||||
* $t = langstring::fix_syntax($t, 1); // sanity legacy 1.x strings
|
||||
* $t = langstring::fix_syntax($t, 2, 1); // convert format of 1.x strings into 2.x
|
||||
*
|
||||
* Backward converting 2.x format into 1.x is not supported
|
||||
*
|
||||
* @param string $text string text to be fixed
|
||||
* @param int $format target get_string() format version
|
||||
* @param int $from which format version does the text come from, defaults to the same as $format
|
||||
* @return string
|
||||
*/
|
||||
public static function fix_syntax(string $text, int $format = 2, ?int $from = null): string {
|
||||
if (is_null($from)) {
|
||||
$from = $format;
|
||||
}
|
||||
|
||||
// Common filter.
|
||||
$clean = trim($text);
|
||||
$search = [
|
||||
// Remove \r if it is part of \r\n.
|
||||
'/\r(?=\n)/',
|
||||
|
||||
// Control characters to be replaced with \n
|
||||
// LINE TABULATION, FORM FEED, CARRIAGE RETURN, END OF TRANSMISSION BLOCK,
|
||||
// END OF MEDIUM, SUBSTITUTE, BREAK PERMITTED HERE, NEXT LINE, START OF STRING,
|
||||
// STRING TERMINATOR and Unicode character categorys Zl and Zp.
|
||||
'/[\x{0B}-\r\x{17}\x{19}\x{1A}\x{82}\x{85}\x{98}\x{9C}\p{Zl}\p{Zp}]/u',
|
||||
|
||||
// Control characters to be removed
|
||||
// NULL, ENQUIRY, ACKNOWLEDGE, BELL, SHIFT {OUT,IN}, DATA LINK ESCAPE,
|
||||
// DEVICE CONTROL {ONE,TWO,THREE,FOUR}, NEGATIVE ACKNOWLEDGE, SYNCHRONOUS IDLE, ESCAPE,
|
||||
// DELETE, PADDING CHARACTER, HIGH OCTET PRESET, NO BREAK HERE, INDEX,
|
||||
// {START,END} OF SELECTED AREA, CHARACTER TABULATION {SET,WITH JUSTIFICATION},
|
||||
// LINE TABULATION SET, PARTIAL LINE {FORWARD,BACKWARD}, REVERSE LINE FEED,
|
||||
// SINGLE SHIFT {TWO,THREE}, DEVICE CONTROL STRING, PRIVATE USE {ONE,TWO},
|
||||
// SET TRANSMIT STATE, MESSAGE WAITING, {START,END} OF GUARDED AREA,
|
||||
// {SINGLE {GRAPHIC,} CHARACTER,CONTROL SEQUENCE} INTRODUCER, OPERATING SYSTEM COMMAND,
|
||||
// PRIVACY MESSAGE, APPLICATION PROGRAM COMMAND, ZERO WIDTH {,NO-BREAK} SPACE,
|
||||
// REPLACEMENT CHARACTER.
|
||||
'/[\0\x{05}-\x{07}\x{0E}-\x{16}\x{1B}\x{7F}\x{80}\x{81}\x{83}\x{84}\x{86}-\x{93}\x{95}-\x{97}\x{99}-\x{9B}\x{9D}-\x{9F}\x{200B}\x{FEFF}\x{FFFD}]++/u',
|
||||
|
||||
// Remove trailing whitespace at the end of lines in a multiline string.
|
||||
'/[ \t]+(?=\n)/',
|
||||
];
|
||||
$replace = [
|
||||
'',
|
||||
"\n",
|
||||
'',
|
||||
'',
|
||||
];
|
||||
$clean = preg_replace($search, $replace, $clean);
|
||||
|
||||
if (($format === 2) && ($from === 2)) {
|
||||
// Sanity translations of 2.x strings.
|
||||
$clean = preg_replace("/\n{3,}/", "\n\n\n", $clean); // Collapse runs of blank lines.
|
||||
|
||||
} else if (($format === 2) && ($from === 1)) {
|
||||
// Convert 1.x string into 2.x format.
|
||||
$clean = preg_replace("/\n{3,}/", "\n\n\n", $clean); // Collapse runs of blank lines.
|
||||
$clean = preg_replace('/%+/', '%', $clean); // Collapse % characters.
|
||||
$clean = str_replace('\$', '@@@___XXX_ESCAPED_DOLLAR__@@@', $clean); // Remember for later.
|
||||
$clean = str_replace("\\", '', $clean); // Delete all slashes.
|
||||
$clean = preg_replace('/(^|[^{])\$a\b(\->[a-zA-Z0-9_]+)?/', '\\1{$a\\2}', $clean); // Wrap placeholders.
|
||||
$clean = str_replace('@@@___XXX_ESCAPED_DOLLAR__@@@', '$', $clean);
|
||||
$clean = str_replace('$', '$', $clean);
|
||||
|
||||
} else if (($format === 1) && ($from === 1)) {
|
||||
// Sanity legacy 1.x strings.
|
||||
$clean = preg_replace("/\n{3,}/", "\n\n", $clean); // Collapse runs of blank lines.
|
||||
$clean = str_replace('\$', '@@@___XXX_ESCAPED_DOLLAR__@@@', $clean);
|
||||
$clean = str_replace("\\", '', $clean); // Delete all slashes.
|
||||
$clean = str_replace('$', '\$', $clean); // Escape all embedded variables.
|
||||
// Unescape placeholders: only $a and $a->something are allowed. All other $variables are left escaped.
|
||||
$clean = preg_replace('/\\\\\$a\b(\->[a-zA-Z0-9_]+)?/', '$a\\1', $clean); // Unescape placeholders.
|
||||
$clean = str_replace('@@@___XXX_ESCAPED_DOLLAR__@@@', '\$', $clean);
|
||||
$clean = str_replace('"', "\\\"", $clean); // Add slashes for ".
|
||||
$clean = preg_replace('/%+/', '%', $clean); // Collapse % characters.
|
||||
$clean = str_replace('%', '%%', $clean); // Duplicate %.
|
||||
|
||||
} else {
|
||||
throw new moodle_exception('Unknown get_string() format version');
|
||||
}
|
||||
return $clean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Language string based on David Mudrak langstring from local_amos.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_customlang\local\mlang;
|
||||
|
||||
use moodle_exception;
|
||||
use stdclass;
|
||||
|
||||
/**
|
||||
* Class containing a lang string cleaned.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a single string
|
||||
*/
|
||||
class logstatus {
|
||||
|
||||
/** @var langstring the current string */
|
||||
public $langstring = null;
|
||||
|
||||
/** @var string the component */
|
||||
public $component = null;
|
||||
|
||||
/** @var string the string ID */
|
||||
public $stringid = null;
|
||||
|
||||
/** @var string the original filename */
|
||||
public $filename = null;
|
||||
|
||||
/** @var int the error level */
|
||||
public $errorlevel = null;
|
||||
|
||||
/** @var string the message identifier */
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* Class creator.
|
||||
*
|
||||
* @param string $message the message identifier to display
|
||||
* @param string $errorlevel the notice level
|
||||
* @param string|null $filename the filename of this log
|
||||
* @param string|null $component the component of this log
|
||||
* @param langstring|null $langstring the langstring of this log
|
||||
*/
|
||||
public function __construct(string $message, string $errorlevel, ?string $filename = null,
|
||||
?string $component = null, ?langstring $langstring = null) {
|
||||
|
||||
$this->filename = $filename;
|
||||
$this->component = $component;
|
||||
$this->langstring = $langstring;
|
||||
$this->message = $message;
|
||||
$this->errorlevel = $errorlevel;
|
||||
|
||||
if ($langstring) {
|
||||
$this->stringid = $langstring->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log message.
|
||||
*
|
||||
* @return string the log message.
|
||||
*/
|
||||
public function get_message(): string {
|
||||
return get_string($this->message, 'tool_customlang', $this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Mlang PHP based on David Mudrak phpparser for local_amos.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_customlang\local\mlang;
|
||||
|
||||
use coding_exception;
|
||||
use moodle_exception;
|
||||
|
||||
/**
|
||||
* Parser of Moodle strings defined as associative array.
|
||||
*
|
||||
* Moodle core just includes this file format directly as normal PHP code. However
|
||||
* for security reasons, we must not do this for files uploaded by anonymous users.
|
||||
* This parser reconstructs the associative $string array without actually including
|
||||
* the file.
|
||||
*/
|
||||
class phpparser {
|
||||
|
||||
/** @var holds the singleton instance of self */
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Prevents direct creation of object
|
||||
*/
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent from cloning the instance
|
||||
*/
|
||||
public function __clone() {
|
||||
throw new coding_exception('Cloning os singleton is not allowed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singleton instance fo this class
|
||||
*
|
||||
* @return phpparser singleton instance of phpparser
|
||||
*/
|
||||
public static function get_instance(): phpparser {
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new phpparser();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given data in Moodle PHP string format
|
||||
*
|
||||
* Note: This method is adapted from local_amos as it is highly tested and robust.
|
||||
* The priority is keeping it similar to the original one to make it easier to mantain.
|
||||
*
|
||||
* @param string $data definition of the associative array
|
||||
* @param int $format the data format on the input, defaults to the one used since 2.0
|
||||
* @return langstring[] array of langstrings of this file
|
||||
*/
|
||||
public function parse(string $data, int $format = 2): array {
|
||||
$result = [];
|
||||
$strings = $this->extract_strings($data);
|
||||
foreach ($strings as $id => $text) {
|
||||
$cleaned = clean_param($id, PARAM_STRINGID);
|
||||
if ($cleaned !== $id) {
|
||||
continue;
|
||||
}
|
||||
$text = langstring::fix_syntax($text, 2, $format);
|
||||
$result[] = new langstring($id, $text);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Low level parsing method
|
||||
*
|
||||
* Note: This method is adapted from local_amos as it is highly tested and robust.
|
||||
* The priority is keeping it similar to the original one to make it easier to mantain.
|
||||
*
|
||||
* @param string $data
|
||||
* @return string[] the data strings
|
||||
*/
|
||||
protected function extract_strings(string $data): array {
|
||||
|
||||
$strings = []; // To be returned.
|
||||
|
||||
if (empty($data)) {
|
||||
return $strings;
|
||||
}
|
||||
|
||||
// Tokenize data - we expect valid PHP code.
|
||||
$tokens = token_get_all($data);
|
||||
|
||||
// Get rid of all non-relevant tokens.
|
||||
$rubbish = [T_WHITESPACE, T_INLINE_HTML, T_COMMENT, T_DOC_COMMENT, T_OPEN_TAG, T_CLOSE_TAG];
|
||||
foreach ($tokens as $i => $token) {
|
||||
if (is_array($token)) {
|
||||
if (in_array($token[0], $rubbish)) {
|
||||
unset($tokens[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$id = null;
|
||||
$text = null;
|
||||
$line = 0;
|
||||
$expect = 'STRING_VAR'; // The first expected token is '$string'.
|
||||
|
||||
// Iterate over tokens and look for valid $string array assignment patterns.
|
||||
foreach ($tokens as $token) {
|
||||
$foundtype = null;
|
||||
$founddata = null;
|
||||
if (is_array($token)) {
|
||||
$foundtype = $token[0];
|
||||
$founddata = $token[1];
|
||||
if (!empty($token[2])) {
|
||||
$line = $token[2];
|
||||
}
|
||||
|
||||
} else {
|
||||
$foundtype = 'char';
|
||||
$founddata = $token;
|
||||
}
|
||||
|
||||
if ($expect == 'STRING_VAR') {
|
||||
if ($foundtype === T_VARIABLE and $founddata === '$string') {
|
||||
$expect = 'LEFT_BRACKET';
|
||||
continue;
|
||||
} else {
|
||||
// Allow other code at the global level.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($expect == 'LEFT_BRACKET') {
|
||||
if ($foundtype === 'char' and $founddata === '[') {
|
||||
$expect = 'STRING_ID';
|
||||
continue;
|
||||
} else {
|
||||
throw new moodle_exception('Parsing error. Expected character [ at line '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
if ($expect == 'STRING_ID') {
|
||||
if ($foundtype === T_CONSTANT_ENCAPSED_STRING) {
|
||||
$id = $this->decapsulate($founddata);
|
||||
$expect = 'RIGHT_BRACKET';
|
||||
continue;
|
||||
} else {
|
||||
throw new moodle_exception('Parsing error. Expected T_CONSTANT_ENCAPSED_STRING array key at line '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
if ($expect == 'RIGHT_BRACKET') {
|
||||
if ($foundtype === 'char' and $founddata === ']') {
|
||||
$expect = 'ASSIGNMENT';
|
||||
continue;
|
||||
} else {
|
||||
throw new moodle_exception('Parsing error. Expected character ] at line '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
if ($expect == 'ASSIGNMENT') {
|
||||
if ($foundtype === 'char' and $founddata === '=') {
|
||||
$expect = 'STRING_TEXT';
|
||||
continue;
|
||||
} else {
|
||||
throw new moodle_exception('Parsing error. Expected character = at line '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
if ($expect == 'STRING_TEXT') {
|
||||
if ($foundtype === T_CONSTANT_ENCAPSED_STRING) {
|
||||
$text = $this->decapsulate($founddata);
|
||||
$expect = 'SEMICOLON';
|
||||
continue;
|
||||
} else {
|
||||
throw new moodle_exception(
|
||||
'Parsing error. Expected T_CONSTANT_ENCAPSED_STRING array item value at line '.$line
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($expect == 'SEMICOLON') {
|
||||
if (is_null($id) or is_null($text)) {
|
||||
throw new moodle_exception('Parsing error. NULL string id or value at line '.$line);
|
||||
}
|
||||
if ($foundtype === 'char' and $founddata === ';') {
|
||||
if (!empty($id)) {
|
||||
$strings[$id] = $text;
|
||||
}
|
||||
$id = null;
|
||||
$text = null;
|
||||
$expect = 'STRING_VAR';
|
||||
continue;
|
||||
} else {
|
||||
throw new moodle_exception('Parsing error. Expected character ; at line '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one T_CONSTANT_ENCAPSED_STRING, return its value without quotes
|
||||
*
|
||||
* Also processes escaped quotes inside the text.
|
||||
*
|
||||
* Note: This method is taken directly from local_amos as it is highly tested and robust.
|
||||
*
|
||||
* @param string $text value obtained by token_get_all()
|
||||
* @return string value without quotes
|
||||
*/
|
||||
protected function decapsulate(string $text): string {
|
||||
|
||||
if (strlen($text) < 2) {
|
||||
throw new moodle_exception('Parsing error. Expected T_CONSTANT_ENCAPSED_STRING in decapsulate()');
|
||||
}
|
||||
|
||||
if (substr($text, 0, 1) == "'" and substr($text, -1) == "'") {
|
||||
// Single quoted string.
|
||||
$text = trim($text, "'");
|
||||
$text = str_replace("\'", "'", $text);
|
||||
$text = str_replace('\\\\', '\\', $text);
|
||||
return $text;
|
||||
|
||||
} else if (substr($text, 0, 1) == '"' and substr($text, -1) == '"') {
|
||||
// Double quoted string.
|
||||
$text = trim($text, '"');
|
||||
$text = str_replace('\"', '"', $text);
|
||||
$text = str_replace('\\\\', '\\', $text);
|
||||
return $text;
|
||||
|
||||
} else {
|
||||
throw new moodle_exception(
|
||||
'Parsing error. Unexpected quotation in T_CONSTANT_ENCAPSED_STRING in decapsulate(): '.$text
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,9 @@ class renderer extends \plugin_renderer_base {
|
||||
protected function render_tool_customlang_menu(\tool_customlang_menu $menu) {
|
||||
$output = '';
|
||||
foreach ($menu->get_items() as $item) {
|
||||
$output .= $this->single_button($item->url, $item->title, $item->method);
|
||||
$button = $this->single_button($item->url, $item->title, $item->method);
|
||||
$output .= $this->box($button, 'menu');
|
||||
}
|
||||
return $this->box($output, 'menu');
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Export custom language strings to zip files.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @subpackage customlang
|
||||
* @copyright 2020 Thomas Wedekind <thomas.wedekind@univie.ac.at>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->dirroot/$CFG->admin/tool/customlang/locallib.php");
|
||||
|
||||
$usage = <<<EOF
|
||||
"Export custom language files to a target folder.
|
||||
Useful for uploading custom langstrings to AMOS or importing or syncing them to other moodle instances.
|
||||
|
||||
Options:
|
||||
-l, --lang Comma seperated language ids to export, default: all
|
||||
-c, --components Comma seperated components to export, default: all
|
||||
-t, --target Target to copy the zip files to, default: $CFG->tempdir/customlang
|
||||
-o, --overwrite Overwrite existing files in the target folder.
|
||||
Note: If the target is not set, the files are always overwritten!
|
||||
-h, --help Print out this help
|
||||
|
||||
Examples:
|
||||
Export all custom language files to the default folder:
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/customlang/cli/export.php
|
||||
|
||||
Export just the english files of moodle core and the activity 'quiz' in a subfolder in my home folder:
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/customlang/cli/export.php --lang='en' --components='moodle,quiz' --target='~/customdir'
|
||||
|
||||
EOF;
|
||||
|
||||
$dafaulttarget = "$CFG->tempdir/customlang/";
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
[
|
||||
'lang' => '',
|
||||
'components' => '',
|
||||
'target' => $dafaulttarget,
|
||||
'overwrite' => false,
|
||||
'help' => false,
|
||||
],
|
||||
['h' => 'help', 'c' => 'components', 't' => 'target', 'o' => 'overwrite']
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
echo $usage;
|
||||
die;
|
||||
}
|
||||
if (!file_exists($options['target'])) {
|
||||
mkdir($options['target'], 0777, true);
|
||||
}
|
||||
|
||||
cli_writeln(get_string('cliexportheading', 'tool_customlang'));
|
||||
$langs = [];
|
||||
if ($options['lang']) {
|
||||
$langs = explode(',', $options['lang']);
|
||||
} else {
|
||||
// No language set. We export all installed languages.
|
||||
$langs = array_keys(get_string_manager()->get_list_of_translations(true));
|
||||
}
|
||||
|
||||
foreach ($langs as $lang) {
|
||||
$filename = $options['target'] . get_string('exportzipfilename', 'tool_customlang', ['lang' => $lang]);
|
||||
// If the file exists and we are not using the temp folder it requires an ovewrite.
|
||||
if ($options['target'] != $dafaulttarget && file_exists($filename) && !$options['overwrite']) {
|
||||
cli_problem(get_string('cliexportfileexists', 'tool_customlang', $lang));
|
||||
continue;
|
||||
}
|
||||
cli_heading(get_string('cliexportstartexport', 'tool_customlang', $lang));
|
||||
$langdir = tool_customlang_utils::get_localpack_location($lang);
|
||||
if (!file_exists($langdir)) {
|
||||
// No custom files set for this language set.
|
||||
cli_writeln(get_string('cliexportnofilefoundforlang', 'tool_customlang', ['lang' => $lang]));
|
||||
continue;
|
||||
}
|
||||
$zipper = get_file_packer();
|
||||
$tempzip = tempnam($CFG->tempdir . '/', 'tool_customlang_export');
|
||||
$filelist = [];
|
||||
if ($options['components']) {
|
||||
$components = explode(',', $options['components']);
|
||||
foreach ($components as $component) {
|
||||
$filepath = "$langdir/$component.php";
|
||||
if (file_exists($filepath)) {
|
||||
$filelist["$component.php"] = $filepath;
|
||||
} else {
|
||||
cli_problem(
|
||||
get_string('cliexportfilenotfoundforcomponent', 'tool_customlang', ['lang' => $lang, 'file' => $filepath])
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$langfiles = scandir($langdir);
|
||||
foreach ($langfiles as $file) {
|
||||
if (substr($file, 0, 1) != '.') {
|
||||
$filelist[$file] = "$langdir/$file";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($filelist)) {
|
||||
cli_problem(get_string('cliexportnofilefoundforlang', 'tool_customlang', ['lang' => $lang]));
|
||||
continue;
|
||||
}
|
||||
if ($zipper->archive_to_pathname($filelist, $filename)) {
|
||||
cli_writeln(get_string('cliexportzipdone', 'tool_customlang', $filename));
|
||||
} else {
|
||||
cli_problem(get_string('cliexportzipfail', 'tool_customlang', $filename));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* CLI customlang import tool.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use tool_customlang\local\importer;
|
||||
use core\output\notification;
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
|
||||
$usage =
|
||||
"Import lang customization.
|
||||
|
||||
It can get a single file or a folder.
|
||||
If no lang is provided it will try to infere from the filename
|
||||
|
||||
Options:
|
||||
--lang The target language (will get from filename if not provided)
|
||||
--source=path File or folder of the custom lang files (zip or php files)
|
||||
--mode What string should be imported. Options are:
|
||||
- all: all string will be imported (default)
|
||||
- new: only string with no previous customisation
|
||||
- update: only strings already modified
|
||||
--checkin Save strings to the language pack
|
||||
-h, --help Print out this help
|
||||
|
||||
Examples:
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/customlang/cli/import.php --lang=en --source=customlangs.zip
|
||||
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/customlang/cli/import.php --source=/tmp/customlangs --checkin
|
||||
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/customlang/cli/import.php --lang=en --source=/tmp/customlangs
|
||||
|
||||
";
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
[
|
||||
'help' => false,
|
||||
'lang' => false,
|
||||
'source' => false,
|
||||
'mode' => 'all',
|
||||
'checkin' => false,
|
||||
],
|
||||
['h' => 'help']
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
cli_write($usage);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$source = $options['source'] ?? null;
|
||||
$lang = $options['lang'] ?? null;
|
||||
$modeparam = $options['mode'] ?? 'all';
|
||||
$checkin = $options['checkin'] ?? false;
|
||||
|
||||
$modes = [
|
||||
'all' => importer::IMPORTALL,
|
||||
'update' => importer::IMPORTUPDATE,
|
||||
'new' => importer::IMPORTNEW,
|
||||
];
|
||||
if (!isset($modes[$modeparam])) {
|
||||
cli_error(get_string('climissingmode', 'tool_customlang'));
|
||||
}
|
||||
$mode = $modes[$modeparam];
|
||||
|
||||
if (empty($source)) {
|
||||
$source = $CFG->dataroot.'/temp/customlang';
|
||||
}
|
||||
|
||||
if (!file_exists($source)) {
|
||||
cli_error(get_string('climissingsource', 'tool_customlang'));
|
||||
}
|
||||
|
||||
// Emulate normal session - we use admin account by default.
|
||||
cron_setup_user();
|
||||
|
||||
// Get the file list.
|
||||
$files = [];
|
||||
$langfiles = [];
|
||||
|
||||
if (is_file($source)) {
|
||||
$files[] = $source;
|
||||
}
|
||||
if (is_dir($source)) {
|
||||
$filelist = glob("$source/*");
|
||||
foreach ($filelist as $filename) {
|
||||
$files[] = "$filename";
|
||||
}
|
||||
}
|
||||
|
||||
$countfiles = 0;
|
||||
foreach ($files as $filepath) {
|
||||
// Try to get the lang.
|
||||
$filelang = $lang;
|
||||
// Get component from filename.
|
||||
$pathparts = pathinfo($filepath);
|
||||
$filename = $pathparts['filename'];
|
||||
$extension = $pathparts['extension'];
|
||||
if ($extension == 'zip') {
|
||||
if (!$filelang) {
|
||||
// Try to get the lang from the filename.
|
||||
if (strrpos($filename, 'customlang_') === 0) {
|
||||
$parts = explode('_', $filename);
|
||||
if (!empty($parts[1])) {
|
||||
$filelang = $parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($extension != 'php') {
|
||||
// Ignore any other file extension.
|
||||
continue;
|
||||
}
|
||||
if (empty($filelang)) {
|
||||
cli_error(get_string('climissinglang', 'tool_customlang'));
|
||||
}
|
||||
if (!isset($langfiles[$filelang])) {
|
||||
$langfiles[$filelang] = [];
|
||||
}
|
||||
$langfiles[$filelang][] = $filepath;
|
||||
$countfiles ++;
|
||||
}
|
||||
|
||||
if (!$countfiles) {
|
||||
cli_error(get_string('climissingfiles', 'tool_customlang'));
|
||||
}
|
||||
|
||||
foreach ($langfiles as $lng => $files) {
|
||||
$importer = new importer($lng, $mode);
|
||||
$storedfiles = [];
|
||||
$fs = get_file_storage();
|
||||
|
||||
cli_heading(get_string('clifiles', 'tool_customlang', $lng));
|
||||
|
||||
foreach ($files as $file) {
|
||||
// Generate a valid stored_file from this file.
|
||||
$record = (object)[
|
||||
'filearea' => 'draft',
|
||||
'component' => 'user',
|
||||
'filepath' => '/',
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'license' => $CFG->sitedefaultlicense,
|
||||
'author' => '',
|
||||
'filename' => clean_param(basename($file), PARAM_FILE),
|
||||
'contextid' => \context_user::instance($USER->id)->id,
|
||||
'userid' => $USER->id,
|
||||
];
|
||||
cli_writeln($file);
|
||||
$storedfiles[] = $fs->create_file_from_pathname($record, $file);
|
||||
}
|
||||
cli_writeln("");
|
||||
|
||||
// Import files.
|
||||
cli_heading(get_string('cliimporting', 'tool_customlang', $modeparam));
|
||||
$importer->import($storedfiles);
|
||||
// Display logs.
|
||||
$log = $importer->get_log();
|
||||
if (empty($log)) {
|
||||
cli_problem(get_string('clinolog', 'tool_customlang', $lng));
|
||||
}
|
||||
foreach ($log as $message) {
|
||||
if ($message->errorlevel == notification::NOTIFY_ERROR) {
|
||||
cli_problem($message->get_message());
|
||||
} else {
|
||||
cli_writeln($message->get_message());
|
||||
}
|
||||
}
|
||||
// Do the checkin if necessary.
|
||||
if ($checkin) {
|
||||
tool_customlang_utils::checkin($lng);
|
||||
cli_writeln(get_string('savecheckin', 'tool_customlang'));
|
||||
}
|
||||
cli_writeln("");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
@@ -46,5 +46,14 @@ $capabilities = array(
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
/* allows the user to export the current language customization */
|
||||
'tool/customlang:export' => array(
|
||||
'riskbitmask' => RISK_CONFIG,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Performs the custom lang export.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @subpackage customlang
|
||||
* @copyright 2020 Thomas Wedekind <thomas.wedekind@univie.ac.at>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
global $PAGE, $CFG;
|
||||
|
||||
require_login(SITEID, false);
|
||||
require_capability('tool/customlang:export', context_system::instance());
|
||||
|
||||
$lng = required_param('lng', PARAM_LANG);
|
||||
|
||||
admin_externalpage_setup('toolcustomlang', '', null,
|
||||
new moodle_url('/admin/tool/customlang/import.php', ['lng' => $lng]));
|
||||
|
||||
$form = new \tool_customlang\form\export(null, ['lng' => $lng]);
|
||||
|
||||
if ($form->is_cancelled()) {
|
||||
redirect('index.php');
|
||||
die();
|
||||
} else if ($formdata = $form->get_data()) {
|
||||
$tempzip = tempnam($CFG->tempdir . '/', 'tool_customlang_export');
|
||||
$filelist = [];
|
||||
foreach ($formdata->files as $file) {
|
||||
$filepath = tool_customlang_utils::get_localpack_location($lng). '/' . $file;
|
||||
if (file_exists($filepath)) {
|
||||
$filelist[$file] = $filepath;
|
||||
}
|
||||
}
|
||||
$zipper = new zip_packer();
|
||||
|
||||
if (!empty($filelist) && $zipper->archive_to_pathname($filelist, $tempzip)) {
|
||||
// Filename include the lang name so the file can be imported with automatic language detection.
|
||||
send_temp_file($tempzip, "customlang_$lng.zip");
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('tool_customlang');
|
||||
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginname', 'tool_customlang'));
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -32,7 +32,6 @@ class tool_customlang_filter_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
$current = $this->_customdata['current'];
|
||||
|
||||
$mform->addElement('header', 'filtersettings', get_string('filter', 'tool_customlang'));
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Import custom lang files.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @subpackage customlang
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use tool_customlang\form\import;
|
||||
use tool_customlang\local\importer;
|
||||
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_login(SITEID, false);
|
||||
require_capability('tool/customlang:edit', context_system::instance());
|
||||
|
||||
$lng = required_param('lng', PARAM_LANG);
|
||||
|
||||
admin_externalpage_setup('toolcustomlang', '', null,
|
||||
new moodle_url('/admin/tool/customlang/import.php', ['lng' => $lng]));
|
||||
|
||||
$output = $PAGE->get_renderer('tool_customlang');
|
||||
|
||||
$form = new import(null, ['lng' => $lng]);
|
||||
if ($data = $form->get_data()) {
|
||||
require_sesskey();
|
||||
|
||||
// Get the file from the users draft area.
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data->pack, 'id',
|
||||
false);
|
||||
|
||||
// Send files to the importer.
|
||||
$importer = new importer($data->lng, $data->importmode);
|
||||
$importer->import($files);
|
||||
|
||||
echo $output->header();
|
||||
|
||||
// Display logs.
|
||||
$log = $importer->get_log();
|
||||
foreach ($log as $message) {
|
||||
echo $output->notification($message->get_message(), $message->errorlevel);
|
||||
}
|
||||
|
||||
// Show continue button.
|
||||
echo $output->continue_button(new moodle_url('index.php', array('lng' => $lng)));
|
||||
|
||||
} else {
|
||||
echo $output->header();
|
||||
|
||||
$form->display();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -35,6 +35,7 @@ require_capability('tool/customlang:view', context_system::instance());
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
$lng = optional_param('lng', '', PARAM_LANG);
|
||||
$next = optional_param('next', 'edit', PARAM_ALPHA);
|
||||
|
||||
admin_externalpage_setup('toolcustomlang');
|
||||
$langs = get_string_manager()->get_list_of_translations();
|
||||
@@ -59,11 +60,10 @@ if ($action === 'checkout') {
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
tool_customlang_utils::checkout($lng, $progressbar);
|
||||
|
||||
echo $output->continue_button(new moodle_url('/admin/tool/customlang/edit.php', array('lng' => $lng)), 'get');
|
||||
echo $output->continue_button(new moodle_url("/admin/tool/customlang/{$next}.php", array('lng' => $lng)), 'get');
|
||||
echo $output->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === 'checkin') {
|
||||
require_sesskey();
|
||||
require_capability('tool/customlang:edit', context_system::instance());
|
||||
@@ -132,6 +132,21 @@ if (has_capability('tool/customlang:edit', context_system::instance())) {
|
||||
'method' => 'post',
|
||||
);
|
||||
}
|
||||
$menu['import'] = array(
|
||||
'title' => get_string('import', 'tool_customlang'),
|
||||
'url' => new moodle_url($PAGE->url, ['action' => 'checkout', 'lng' => $lng, 'next' => 'import']),
|
||||
'method' => 'post',
|
||||
);
|
||||
}
|
||||
if (has_capability('tool/customlang:export', context_system::instance())) {
|
||||
$langdir = tool_customlang_utils::get_localpack_location($lng);
|
||||
if (check_dir_exists(dirname($langdir)) && count(glob("$langdir/*"))) {
|
||||
$menu['export'] = [
|
||||
'title' => get_string('export', 'tool_customlang'),
|
||||
'url' => new moodle_url("/admin/tool/customlang/export.php", ['lng' => $lng]),
|
||||
'method' => 'post',
|
||||
];
|
||||
}
|
||||
}
|
||||
echo $output->render(new tool_customlang_menu($menu));
|
||||
|
||||
|
||||
@@ -30,9 +30,26 @@ $string['checkin'] = 'Save strings to language pack';
|
||||
$string['checkout'] = 'Open language pack for editing';
|
||||
$string['checkoutdone'] = 'Language pack loaded';
|
||||
$string['checkoutinprogress'] = 'Loading language pack';
|
||||
$string['cliexportfileexists'] = 'File for {$a->lang} already exists, skipping. If you want to overwrite add the --override=true option.';
|
||||
$string['cliexportheading'] = 'Starting to export lang files.';
|
||||
$string['cliexportnofilefoundforlang'] = 'No file found to export. Skipping export for this language.';
|
||||
$string['cliexportfilenotfoundforcomponent'] = 'File {$a->filepath} not found for language {$a->lang}.Skipping this file.';
|
||||
$string['cliexportstartexport'] = 'Exporting language "{$a}"';
|
||||
$string['cliexportzipdone'] = 'Zip created: {$a}';
|
||||
$string['cliexportzipfail'] = 'Cannot create zip {$a}';
|
||||
$string['clifiles'] = 'Files to import into {$a}';
|
||||
$string['cliimporting'] = 'Import files string (mode {$a})';
|
||||
$string['clinolog'] = 'Nothing to import into {$a}';
|
||||
$string['climissinglang'] = 'Missing language';
|
||||
$string['climissingfiles'] = 'Missing valid files';
|
||||
$string['climissingmode'] = 'Missing or invalid mode (valid is all, new or update)';
|
||||
$string['climissingsource'] = 'Missing file or folder';
|
||||
$string['confirmcheckin'] = 'You are about to save modifications to your local language pack. This will export the customised strings from the translator into your site data directory and your site will start using the modified strings. Press \'Continue\' to proceed with saving.';
|
||||
$string['customlang:edit'] = 'Edit local translation';
|
||||
$string['customlang:export'] = 'Export local translation';
|
||||
$string['customlang:view'] = 'View local translation';
|
||||
$string['export'] = 'Export custom strings';
|
||||
$string['exportfilter'] = 'Select component(s) to export';
|
||||
$string['filter'] = 'Filter strings';
|
||||
$string['filtercomponent'] = 'Show strings of these components';
|
||||
$string['filtercustomized'] = 'Customised only';
|
||||
@@ -45,11 +62,24 @@ $string['headingcomponent'] = 'Component';
|
||||
$string['headinglocal'] = 'Local customisation';
|
||||
$string['headingstandard'] = 'Standard text';
|
||||
$string['headingstringid'] = 'String';
|
||||
$string['import'] = 'Import custom strings';
|
||||
$string['import_mode'] = 'Import mode';
|
||||
$string['import_new'] = 'Create only strings without local customisation';
|
||||
$string['import_update'] = 'Update only strings with local customisation';
|
||||
$string['import_all'] = 'Create or update all strings from the component(s)';
|
||||
$string['importfile'] = 'Import file';
|
||||
$string['langpack'] = 'Language component(s)';
|
||||
$string['markinguptodate'] = 'Marking the customisation as up-to-date';
|
||||
$string['markinguptodate_help'] = 'The customised translation may get outdated if either the English original or the master translation has modified since the string was customised on your site. Review the customised translation. If you find it up-to-date, click the checkbox. Edit it otherwise.';
|
||||
$string['markuptodate'] = 'mark as up-to-date';
|
||||
$string['modifiedno'] = 'There are no modified strings to save.';
|
||||
$string['modifiednum'] = 'There are {$a} modified strings. Do you wish to save these changes to your local language pack?';
|
||||
$string['nolocallang'] = 'No local strings found.';
|
||||
$string['notice_ignorenew'] = 'Ignoring string {$a->component}/{$a->stringid} because it is not customised.';
|
||||
$string['notice_ignoreupdate'] = 'Ignoring string {$a->component}/{$a->stringid} because it is already defined.';
|
||||
$string['notice_inexitentstring'] = 'String {$a->component}/{$a->stringid} not found.';
|
||||
$string['notice_missingcomponent'] = 'Missing component {$a->component}.';
|
||||
$string['notice_success'] = 'String {$a->component}/{$a->stringid} updated successfully.';
|
||||
$string['nostringsfound'] = 'No strings found, please modify the filter settings';
|
||||
$string['placeholder'] = 'Placeholders';
|
||||
$string['placeholder_help'] = 'Placeholders are special statements like `{$a}` or `{$a->something}` within the string. They are replaced with a value when the string is actually printed.
|
||||
|
||||
@@ -243,7 +243,7 @@ class tool_customlang_utils {
|
||||
* @param string $lang language code
|
||||
* @return string full path
|
||||
*/
|
||||
protected static function get_localpack_location($lang) {
|
||||
public static function get_localpack_location($lang) {
|
||||
global $CFG;
|
||||
|
||||
return $CFG->langlocalroot.'/'.$lang.'_local';
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<input type="hidden" name="sesskey" value="{{{ sesskey }}}">
|
||||
<input type="hidden" name="p" value="{{ currentpage }}">
|
||||
|
||||
<fieldset class="m-a-1 m-3">
|
||||
<fieldset class="m-3">
|
||||
<button type="submit" name="savecontinue" class="btn btn-secondary">
|
||||
{{#str}}savecontinue, tool_customlang{{/str}}
|
||||
</button>
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
<div class="list-group">
|
||||
<div class="container-fluid d-none d-md-block list-group-item border-bottom-0">
|
||||
<div class="row-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-2">
|
||||
<strong>{{#str}}headingcomponent, tool_customlang{{/str}}</strong>
|
||||
</div>
|
||||
@@ -81,7 +81,7 @@
|
||||
<strong>{{#str}}headingstandard, tool_customlang{{/str}}</strong>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6">
|
||||
<span class="p-l-1 pl-3">
|
||||
<span class="pl-3">
|
||||
<strong>{{#str}}headinglocal, tool_customlang{{/str}}</strong>
|
||||
</span>
|
||||
</div>
|
||||
@@ -96,7 +96,7 @@
|
||||
{{#outdated}}list-group-item-warning{{/outdated}}
|
||||
{{#modified}}list-group-item-info{{/modified}}"
|
||||
>
|
||||
<div class="row-fluid ">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-2">
|
||||
<div class="d-md-none">
|
||||
<strong>{{#str}}headingcomponent, tool_customlang{{/str}}</strong>
|
||||
@@ -129,8 +129,8 @@
|
||||
<strong>{{#str}}headinglocal, tool_customlang{{/str}}</strong>
|
||||
</div>
|
||||
<div class="py-2 py-md-0 px-md-3">
|
||||
<textarea class="form-control w-100 border-box" name="cust[{{id}}]" cols="40" rows="3">{{{ local }}}</textarea>
|
||||
|
||||
<label for="{{id}}" class="sr-only sr-only-focusable">{{{ component }}}/{{{ stringid }}}</label>
|
||||
<textarea class="form-control w-100 border-box" id="{{id}}" name="cust[{{id}}]" cols="40" rows="3">{{{ local }}}</textarea>
|
||||
{{#checkupdated}}
|
||||
<div class="uptodatewrapper">
|
||||
<div class="form-check">
|
||||
@@ -147,7 +147,7 @@
|
||||
{{/strings}}
|
||||
</div>
|
||||
|
||||
<fieldset class="m-a-1 m-3">
|
||||
<fieldset class="m-3">
|
||||
<button type="submit" name="savecontinue" class="btn btn-secondary">
|
||||
{{#str}}savecontinue, tool_customlang{{/str}}
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
@tool @tool_customlang
|
||||
Feature: Within a moodle instance, an administrator should be able to modify langstrings for the entire Moodle installation.
|
||||
In order to change langstrings in the adminsettings of the instance,
|
||||
As an admin
|
||||
I need to be able to access and change values in the the language customisation of the language pack.
|
||||
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
And I press "Open language pack for editing"
|
||||
And I press "Continue"
|
||||
And I set the field "Show strings of these components" to "moodle.php"
|
||||
And I set the field "String identifier" to "administrationsite"
|
||||
And I press "Show strings"
|
||||
And I set the field "core/administrationsite" to "Custom string example"
|
||||
|
||||
@javascript
|
||||
Scenario: Edit an string but don't save it to lang pack.
|
||||
When I press "Apply changes and continue editing"
|
||||
Then I should see "Site administration" in the "page-header" "region"
|
||||
And I should not see "Custom string example" in the "page-header" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Customize an string as admin and save it to lang pack.
|
||||
Given I press "Save changes to the language pack"
|
||||
And I should see "There are 1 modified strings."
|
||||
When I click on "Continue" "button"
|
||||
Then I should see "Custom string example" in the "page-header" "region"
|
||||
And I should not see "Site administration" in the "page-header" "region"
|
||||
@@ -0,0 +1,49 @@
|
||||
@tool @tool_customlang
|
||||
Feature: Within a moodle instance, an administrator should be able to export modified langstrings.
|
||||
In order to export modified langstrings in the adminsettings of the instance,
|
||||
As an admin
|
||||
I need to be able to export the php-files of the language customisation of a language.
|
||||
|
||||
@javascript
|
||||
Scenario: Export button should not appear if no customization is made
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
Then I should see "Open language pack for editing"
|
||||
And I should not see "Export custom strings"
|
||||
|
||||
@javascript
|
||||
Scenario: Export button should not appear if no customization is saved into langpack
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
And I press "Open language pack for editing"
|
||||
And I press "Continue"
|
||||
And I set the field "Show strings of these components" to "moodle.php"
|
||||
And I set the field "String identifier" to "accept"
|
||||
And I press "Show strings"
|
||||
And I set the field "core/accept" to "Accept-custom_export"
|
||||
When I press "Apply changes and continue editing"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
Then I should see "Open language pack for editing"
|
||||
And I should see "There are 1 modified strings."
|
||||
And I should not see "Export custom strings"
|
||||
|
||||
@javascript
|
||||
Scenario: Export the php-file including a customised langstring.
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
And I press "Open language pack for editing"
|
||||
And I press "Continue"
|
||||
And I set the field "Show strings of these components" to "moodle.php"
|
||||
And I set the field "String identifier" to "accept"
|
||||
And I press "Show strings"
|
||||
And I set the field "core/accept" to "Accept-custom_export"
|
||||
When I press "Save changes to the language pack"
|
||||
And I should see "There are 1 modified strings."
|
||||
And I click on "Continue" "button"
|
||||
Then I set the field "lng" to "en"
|
||||
And I click on "Export custom strings" "button"
|
||||
And I set the field "Select component(s) to export" to "moodle.php"
|
||||
@@ -0,0 +1,48 @@
|
||||
@tool @tool_customlang @_file_upload
|
||||
Feature: Within a moodle instance, an administrator should be able to import modified langstrings.
|
||||
In order to import modified langstrings in the adminsettings from one to another instance,
|
||||
As an admin
|
||||
I need to be able to import the zips and php files of the language customisation of a language.
|
||||
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
And I click on "Import custom strings" "button"
|
||||
And I press "Continue"
|
||||
|
||||
@javascript
|
||||
Scenario: Import a PHP file to add a new core lang customization
|
||||
When I upload "admin/tool/customlang/tests/fixtures/tool_customlang.php" file to "Language component(s)" filemanager
|
||||
And I press "Import file"
|
||||
Then I should see "String tool_customlang/pluginname updated successfully."
|
||||
And I should see "String tool_customlang/nonexistentinvetedstring not found."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "There are 1 modified strings."
|
||||
And I click on "Save strings to language pack" "button"
|
||||
And I click on "Continue" "button"
|
||||
And I should see "An amazing import feature" in the "page-header" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Try to import a PHP file from a non existent component
|
||||
When I upload "admin/tool/customlang/tests/fixtures/mod_fakecomponent.php" file to "Language component(s)" filemanager
|
||||
And I press "Import file"
|
||||
Then I should see "Missing component mod_fakecomponent."
|
||||
|
||||
@javascript
|
||||
Scenario: Import a zip file with some PHP files in it.
|
||||
When I upload "admin/tool/customlang/tests/fixtures/customlang.zip" file to "Language component(s)" filemanager
|
||||
And I press "Import file"
|
||||
Then I should see "String core/administrationsite updated successfully."
|
||||
And I should see "String core/language updated successfully."
|
||||
And I should see "String core/nonexistentinvetedstring not found."
|
||||
And I should see "String tool_customlang/pluginname updated successfully."
|
||||
And I should see "String tool_customlang/nonexistentinvetedstring not found."
|
||||
And I should see "Missing component mod_fakecomponent."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "There are 3 modified strings."
|
||||
And I click on "Save strings to language pack" "button"
|
||||
And I click on "Continue" "button"
|
||||
And I should see "Uploaded custom string" in the "page-header" "region"
|
||||
And I should see "Another Uploaded string" in the "page-header" "region"
|
||||
And I should see "An amazing import feature" in the "page-header" "region"
|
||||
@@ -0,0 +1,81 @@
|
||||
@tool @tool_customlang @_file_upload
|
||||
Feature: Within a moodle instance, an administrator should be able to import langstrings with several modes.
|
||||
In order to import modified langstrings in the adminsettings from one to another instance,
|
||||
As an admin
|
||||
I need to be able to import only some language customisation strings depending on some conditions.
|
||||
|
||||
Background:
|
||||
# Add one customization.
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language > Language customisation" in site administration
|
||||
And I set the field "lng" to "en"
|
||||
And I press "Open language pack for editing"
|
||||
And I press "Continue"
|
||||
And I set the field "Show strings of these components" to "moodle.php"
|
||||
And I set the field "String identifier" to "administrationsite"
|
||||
And I press "Show strings"
|
||||
And I set the field "core/administrationsite" to "Custom string example"
|
||||
And I press "Save changes to the language pack"
|
||||
And I should see "There are 1 modified strings."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "Custom string example" in the "page-header" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Update only customized strings
|
||||
When I set the field "lng" to "en"
|
||||
And I click on "Import custom strings" "button"
|
||||
And I press "Continue"
|
||||
And I upload "admin/tool/customlang/tests/fixtures/moodle.php" file to "Language component(s)" filemanager
|
||||
And I set the field "Import mode" to "Update only strings with local customisation"
|
||||
And I press "Import file"
|
||||
Then I should see "String core/administrationsite updated successfully."
|
||||
And I should see "Ignoring string core/language because it is not customised."
|
||||
And I should see "String core/nonexistentinvetedstring not found."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "There are 1 modified strings."
|
||||
And I should not see "Uploaded custom string" in the "page-header" "region"
|
||||
And I click on "Save strings to language pack" "button"
|
||||
And I click on "Continue" "button"
|
||||
And I should not see "Custom string example" in the "page-header" "region"
|
||||
And I should see "Uploaded custom string" in the "page-header" "region"
|
||||
And I should not see "Another Uploaded string" in the "page-header" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Create only new strings
|
||||
When I set the field "lng" to "en"
|
||||
And I click on "Import custom strings" "button"
|
||||
And I press "Continue"
|
||||
And I upload "admin/tool/customlang/tests/fixtures/moodle.php" file to "Language component(s)" filemanager
|
||||
And I set the field "Import mode" to "Create only strings without local customisation"
|
||||
And I press "Import file"
|
||||
Then I should see "Ignoring string core/administrationsite because it is already defined."
|
||||
And I should see "String core/language updated successfully."
|
||||
And I should see "String core/nonexistentinvetedstring not found."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "There are 1 modified strings."
|
||||
And I should not see "Uploaded custom string" in the "page-header" "region"
|
||||
And I click on "Save strings to language pack" "button"
|
||||
And I click on "Continue" "button"
|
||||
And I should see "Custom string example" in the "page-header" "region"
|
||||
And I should not see "Uploaded custom string" in the "page-header" "region"
|
||||
And I should see "Another Uploaded string" in the "page-header" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Import all strings
|
||||
When I set the field "lng" to "en"
|
||||
And I click on "Import custom strings" "button"
|
||||
And I press "Continue"
|
||||
And I upload "admin/tool/customlang/tests/fixtures/moodle.php" file to "Language component(s)" filemanager
|
||||
And I set the field "Import mode" to "Create or update all strings from the component(s)"
|
||||
And I press "Import file"
|
||||
Then I should see "String core/administrationsite updated successfully."
|
||||
And I should see "String core/language updated successfully."
|
||||
And I should see "String core/nonexistentinvetedstring not found."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "There are 2 modified strings."
|
||||
And I should not see "Uploaded custom string" in the "page-header" "region"
|
||||
And I click on "Save strings to language pack" "button"
|
||||
And I click on "Continue" "button"
|
||||
And I should not see "Custom string example" in the "page-header" "region"
|
||||
And I should see "Uploaded custom string" in the "page-header" "region"
|
||||
And I should see "Another Uploaded string" in the "page-header" "region"
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Local language pack.
|
||||
*
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$string['administrationsite'] = 'Uploaded custom string';
|
||||
$string['language'] = 'Another Uploaded string';
|
||||
$string['nonexistentinvetedstring'] = 'This should not be imported';
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Local language pack.
|
||||
*
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['administrationsite'] = 'Uploaded custom string';
|
||||
$string['language'] = 'Another Uploaded string';
|
||||
$string['nonexistentinvetedstring'] = 'This should not be imported';
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Local language pack from http://localhost/m/MDL-69583
|
||||
*
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$string['pluginname'] = 'An amazing import feature';
|
||||
$string['nonexistentinvetedstring'] = 'This string should not be imported';
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,207 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* PHP lang parser test.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_customlang\local\mlang;
|
||||
|
||||
use advanced_testcase;
|
||||
use moodle_exception;
|
||||
|
||||
/**
|
||||
* PHP lang parser test class.
|
||||
*
|
||||
* @package tool_customlang
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class phpparser_testcase extends advanced_testcase {
|
||||
|
||||
|
||||
/**
|
||||
* Test get instance static method.
|
||||
*
|
||||
*/
|
||||
public function test_get_instance(): void {
|
||||
|
||||
$instance = phpparser::get_instance();
|
||||
|
||||
$this->assertInstanceOf('tool_customlang\local\mlang\phpparser', $instance);
|
||||
$this->assertEquals($instance, phpparser::get_instance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get instance parse method.
|
||||
*
|
||||
* @dataProvider parse_provider
|
||||
* @param string $phpcode PHP code to test
|
||||
* @param array $expected Expected result
|
||||
* @param bool $exception if an exception is expected
|
||||
*/
|
||||
public function test_parse(string $phpcode, array $expected, bool $exception): void {
|
||||
|
||||
$instance = phpparser::get_instance();
|
||||
|
||||
if ($exception) {
|
||||
$this->expectException(moodle_exception::class);
|
||||
}
|
||||
|
||||
$strings = $instance->parse($phpcode);
|
||||
|
||||
$this->assertEquals(count($expected), count($strings));
|
||||
foreach ($strings as $key => $langstring) {
|
||||
$this->assertEquals($expected[$key][0], $langstring->id);
|
||||
$this->assertEquals($expected[$key][1], $langstring->text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for the test_parse.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parse_provider() : array {
|
||||
return [
|
||||
'Invalid PHP code' => [
|
||||
'No PHP code', [], false
|
||||
],
|
||||
'No PHP open tag' => [
|
||||
"\$string['example'] = 'text';\n", [], false
|
||||
],
|
||||
'One string code' => [
|
||||
"<?php \$string['example'] = 'text';\n", [['example', 'text']], false
|
||||
],
|
||||
'Extra spaces' => [
|
||||
"<?php \$string['example'] = 'text';\n", [['example', 'text']], false
|
||||
],
|
||||
'Extra tabs' => [
|
||||
"<?php \$string['example']\t=\t'text';\n", [['example', 'text']], false
|
||||
],
|
||||
'Double quote string' => [
|
||||
"<?php
|
||||
\$string['example'] = \"text\";
|
||||
\$string[\"example2\"] = 'text2';
|
||||
\$string[\"example3\"] = \"text3\";
|
||||
", [
|
||||
['example', 'text'],
|
||||
['example2', 'text2'],
|
||||
['example3', 'text3'],
|
||||
], false
|
||||
],
|
||||
'Multiple lines strings' => [
|
||||
"<?php
|
||||
\$string['example'] = 'First line\nsecondline';
|
||||
\$string['example2'] = \"First line\nsecondline2\";
|
||||
", [
|
||||
['example', "First line\nsecondline"],
|
||||
['example2', "First line\nsecondline2"],
|
||||
], false
|
||||
],
|
||||
'Two strings code' => [
|
||||
"<?php
|
||||
\$string['example'] = 'text';
|
||||
\$string['example2'] = 'text2';
|
||||
", [
|
||||
['example', 'text'],
|
||||
['example2', 'text2'],
|
||||
], false
|
||||
],
|
||||
'Scaped characters' => [
|
||||
"<?php
|
||||
\$string['example'] = 'Thos are \\' quotes \" 1';
|
||||
\$string['example2'] = \"Thos are ' quotes \\\" 2\";
|
||||
", [
|
||||
['example', "Thos are ' quotes \" 1"],
|
||||
['example2', "Thos are ' quotes \" 2"],
|
||||
], false
|
||||
],
|
||||
'PHP with single line comments' => [
|
||||
"<?php
|
||||
// This is a comment.
|
||||
\$string['example'] = 'text';
|
||||
// This is another commment.
|
||||
", [
|
||||
['example', 'text'],
|
||||
], false
|
||||
],
|
||||
'PHP with block comments' => [
|
||||
"<?php
|
||||
/* This is a block comment. */
|
||||
\$string['example'] = 'text';
|
||||
/* This is another
|
||||
block comment. */
|
||||
", [
|
||||
['example', 'text'],
|
||||
], false
|
||||
],
|
||||
'Wrong variable name' => [
|
||||
"<?php
|
||||
\$stringwrong['example'] = 'text';
|
||||
\$wringstring['example'] = 'text';
|
||||
", [], false
|
||||
],
|
||||
'Single line commented valid line' => [
|
||||
"<?php
|
||||
// \$string['example'] = 'text';
|
||||
", [], false
|
||||
],
|
||||
'Block commented valid line' => [
|
||||
"<?php
|
||||
/*
|
||||
\$string['example'] = 'text';
|
||||
*/
|
||||
", [], false
|
||||
],
|
||||
'Syntax error 1 (double assignation)' => [
|
||||
"<?php
|
||||
\$string['example'] = 'text' = 'wrong';
|
||||
", [], true
|
||||
],
|
||||
'Syntax error 2 (no closing string)' => [
|
||||
"<?php
|
||||
\$string['example'] = 'wrong;
|
||||
", [], true
|
||||
],
|
||||
'Syntax error 3 (Array without key)' => [
|
||||
"<?php
|
||||
\$string[] = 'wrong';
|
||||
", [], true
|
||||
],
|
||||
'Syntax error 4 (Array not open)' => [
|
||||
"<?php
|
||||
\$string'example'] = 'wrong';
|
||||
", [], true
|
||||
],
|
||||
'Syntax error 5 (Array not closed)' => [
|
||||
"<?php
|
||||
\$string['example' = 'wrong';
|
||||
", [], true
|
||||
],
|
||||
'Syntax error 6 (Missing assignment)' => [
|
||||
"<?php
|
||||
\$string['example'] 'wrong';
|
||||
", [], true
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2020061500;
|
||||
$plugin->version = 2020101300;
|
||||
$plugin->requires = 2020060900;
|
||||
$plugin->component = 'tool_customlang'; // Full name of the plugin (used for diagnostics)
|
||||
|
||||
@@ -1613,7 +1613,7 @@ class external extends external_api {
|
||||
*/
|
||||
private static function get_tree_node_structure($allowchildbranches = true) {
|
||||
$fields = [
|
||||
'text' => new external_value(PARAM_TEXT, 'The node text', VALUE_REQUIRED),
|
||||
'text' => new external_value(PARAM_RAW, 'The node text', VALUE_REQUIRED),
|
||||
'expandcontextid' => new external_value(PARAM_INT, 'The contextid this node expands', VALUE_REQUIRED),
|
||||
'expandelement' => new external_value(PARAM_ALPHA, 'What element is this node expanded to', VALUE_REQUIRED),
|
||||
'contextid' => new external_value(PARAM_INT, 'The node contextid', VALUE_REQUIRED),
|
||||
|
||||
@@ -63,7 +63,6 @@ class renderer extends plugin_renderer_base {
|
||||
$params = [
|
||||
'data-action' => 'contactdpo',
|
||||
'data-replytoemail' => $replytoemail,
|
||||
'class' => 'contactdpo'
|
||||
];
|
||||
return html_writer::link('#', get_string('contactdataprotectionofficer', 'tool_dataprivacy'), $params);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
statuspreprocessing,tool_dataprivacy
|
||||
@@ -135,7 +135,7 @@ $string['effectiveretentionperioduser'] = '{$a} (since the last time the user ac
|
||||
$string['emailsalutation'] = 'Dear {$a},';
|
||||
$string['errorcannotrequestdeleteforself'] = 'You don\'t have permission to create deletion request for yourself.';
|
||||
$string['errorcannotrequestdeleteforother'] = 'You don\'t have permission to create deletion request for this user.';
|
||||
$string['errorinvalidrequestcomments'] = 'Please ensure your comment contains plain text only.';
|
||||
$string['errorinvalidrequestcomments'] = 'The comments field may contain plain text only.';
|
||||
$string['errorinvalidrequestcreationmethod'] = 'Invalid request creation method!';
|
||||
$string['errorinvalidrequeststatus'] = 'Invalid request status!';
|
||||
$string['errorinvalidrequesttype'] = 'Invalid request type!';
|
||||
@@ -344,6 +344,3 @@ $string['role_help'] = 'The role which the override should apply to.';
|
||||
$string['duplicaterole'] = 'Role already specified';
|
||||
$string['purposeoverview'] = 'A purpose describes the intended use and retention policy for stored data. The basis for storing and retaining that data is also described in the purpose.';
|
||||
$string['roleoverrideoverview'] = 'The default retention policy can be overridden for specific user roles, allowing you to specify a longer, or a shorter, retention policy. A user is only expired when all of their roles have expired.';
|
||||
|
||||
// Deprecated since Moodle 3.6.
|
||||
$string['statuspreprocessing'] = 'Pre-processing';
|
||||
|
||||
@@ -50,12 +50,12 @@
|
||||
<hr />
|
||||
<div class="row">
|
||||
{{#compliant}}
|
||||
<a class="component-expand p-l-2" data-component="{{raw_component}}" href='#'>
|
||||
<h4 class=" d-inline p-l-2 " id="{{raw_component}}">{{#pix}}t/collapsed, moodle, {{#str}}expandplugin, tool_dataprivacy{{/str}}{{/pix}}{{component}}</h4>
|
||||
<a class="component-expand pl-5" data-component="{{raw_component}}" href='#'>
|
||||
<h4 class=" d-inline pl-5 " id="{{raw_component}}">{{#pix}}t/collapsed, moodle, {{#str}}expandplugin, tool_dataprivacy{{/str}}{{/pix}}{{component}}</h4>
|
||||
</a>
|
||||
{{/compliant}}
|
||||
{{^compliant}}
|
||||
<h4 class="d-inline p-l-3 " id="{{raw_component}}">{{component}}</h4>
|
||||
<h4 class="d-inline pl-6 " id="{{raw_component}}">{{component}}</h4>
|
||||
<span>{{#pix}}i/risk_xss, moodle, {{#str}}requiresattention, tool_dataprivacy{{/str}}{{/pix}}</span>
|
||||
{{/compliant}}
|
||||
{{#external}}
|
||||
@@ -73,7 +73,7 @@
|
||||
<div class="hide" data-section="{{raw_component}}" aria-expanded="false" role="contentinfo">
|
||||
{{#metadata}}
|
||||
<hr />
|
||||
<div class="p-l-3">
|
||||
<div class="pl-6">
|
||||
<dl class="row">
|
||||
<dt class="col-3">
|
||||
{{#link}}
|
||||
@@ -98,7 +98,7 @@
|
||||
{{/metadata}}
|
||||
{{#nullprovider}}
|
||||
<hr />
|
||||
<div class="p-l-3">
|
||||
<div class="pl-6">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
{{nullprovider}}
|
||||
@@ -108,4 +108,4 @@
|
||||
{{/nullprovider}}
|
||||
</div>
|
||||
{{/compliant}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
<div class="container-fluid mt-2">
|
||||
<div class="row">
|
||||
<div class="col-md-4 p-l-0 nav-pills context-tree">
|
||||
<div class="col-md-4 pl-0 nav-pills context-tree">
|
||||
{{#tree}}
|
||||
{{> tool_dataprivacy/context_tree_node}}
|
||||
{{/tree}}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<h3 id="{{plugin_type_raw}}">{{#pix}}t/collapsed, moodle, {{#str}}expandplugintype, tool_dataprivacy{{/str}}{{/pix}}{{plugin_type}}</h3>
|
||||
</a>
|
||||
</div>
|
||||
<div class="hide p-b-1" data-plugintarget="{{plugin_type_raw}}" aria-expanded="false" role="contentinfo">
|
||||
<div class="hide pb-3" data-plugintarget="{{plugin_type_raw}}" aria-expanded="false" role="contentinfo">
|
||||
{{#plugins}}
|
||||
{{> tool_dataprivacy/component_status}}
|
||||
{{/plugins}}
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
"contextlevel": 70
|
||||
}
|
||||
}}
|
||||
<div class="row-fluid rtl-compatible mt-1 mb-1">
|
||||
<div class="row rtl-compatible mt-1 mb-1">
|
||||
<div class="col-md-9">
|
||||
<div class="row-fluid rtl-compatible mt-1 mb-1">
|
||||
<div class="row rtl-compatible mt-1 mb-1">
|
||||
<div class="col-md-3">
|
||||
<strong>{{#str}}category, tool_dataprivacy{{/str}}</strong>
|
||||
</div>
|
||||
@@ -51,7 +51,7 @@
|
||||
{{category}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid rtl-compatible mt-1 mb-1">
|
||||
<div class="row rtl-compatible mt-1 mb-1">
|
||||
<div class="col-md-3">
|
||||
<strong>{{#str}}purpose, tool_dataprivacy{{/str}}</strong>
|
||||
</div>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
{{#contexts}}
|
||||
<div class="card mb-3">
|
||||
<div class="card-header"><h3>{{contextname}}</h3></div>
|
||||
<div class="card-body p-l-2 p-r-2">
|
||||
<div class="card-body pl-5 pr-5">
|
||||
|
||||
{{#category.name}}
|
||||
<h4>{{#str}}category, tool_dataprivacy{{/str}}</h4>
|
||||
@@ -120,4 +120,4 @@
|
||||
</div>
|
||||
</div>
|
||||
{{/contexts}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -997,8 +997,8 @@ class tool_dataprivacy_api_testcase extends advanced_testcase {
|
||||
$this->assertEquals($subject, $message->subject);
|
||||
$this->assertEquals('tool_dataprivacy', $message->component);
|
||||
$this->assertEquals('contactdataprotectionofficer', $message->eventtype);
|
||||
$this->assertContains(fullname($dpo), $message->fullmessage);
|
||||
$this->assertContains(fullname($user1), $message->fullmessage);
|
||||
$this->assertStringContainsString(fullname($dpo), $message->fullmessage);
|
||||
$this->assertStringContainsString(fullname($user1), $message->fullmessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testc
|
||||
/**
|
||||
* Test tearDown.
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown(): void {
|
||||
\core_privacy\local\request\writer::reset();
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user