Compare commits
1000 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 326a83e109 | |||
| 182e92853e | |||
| dcd74d318f | |||
| 19874f6151 | |||
| b5bbd35f96 | |||
| c2dd7cadf8 | |||
| 801ec7da79 | |||
| 8ffb888712 | |||
| 7a16844405 | |||
| 11e8c61f48 | |||
| 38d5b701af | |||
| 9201c4146f | |||
| b15b35f6e6 | |||
| 5cdfc06bd3 | |||
| 653d21470d | |||
| 53be4b873f | |||
| 18425af78f | |||
| 795a0d8c34 | |||
| c545000a26 | |||
| 0b5657c765 | |||
| ec354d2a91 | |||
| ea7dee0d8a | |||
| 19fc43f5eb | |||
| d985ae5bdd | |||
| ad4dd3d4b8 | |||
| 0e7b1d7ac7 | |||
| 9d3ea5340d | |||
| 513a01bfaf | |||
| 4ee3d4ac06 | |||
| 696f45ea73 | |||
| 3866b318aa | |||
| da4c604c9d | |||
| 348375da21 | |||
| 337b664176 | |||
| 297b1bd905 | |||
| ff1f958c13 | |||
| 3bdb864d50 | |||
| 192f479e2b | |||
| 24644d6a56 | |||
| 231836a596 | |||
| f9fbfb4659 | |||
| 9b00e4cf72 | |||
| 0bf87d3181 | |||
| 5b77a01ea4 | |||
| f0a7c95b24 | |||
| adec76796a | |||
| d8b440ec76 | |||
| 19ff614093 | |||
| 917a1974a3 | |||
| 2c54796fcb | |||
| fab42b82f3 | |||
| 6886a6fc5b | |||
| 240e3cde63 | |||
| d6751efc2b | |||
| f09a285a6a | |||
| 5480a9bee0 | |||
| 3dd1cc23b6 | |||
| edf174b46a | |||
| 15d0d20614 | |||
| 33a50fa858 | |||
| e9bbfc15fc | |||
| 066f42726a | |||
| e2a93751ff | |||
| b06d0196b4 | |||
| 54ccc96b58 | |||
| ef10728a74 | |||
| 0960421191 | |||
| 7cdd2a596f | |||
| a2f89145fd | |||
| d810bd41cb | |||
| f6f75237a9 | |||
| 5402e5dec3 | |||
| 14a62bfcd5 | |||
| 3a4cd9d998 | |||
| 32fd8433d9 | |||
| f9cd1321ac | |||
| 2718918af5 | |||
| 5c578b2bc2 | |||
| 2357b57391 | |||
| bbf1f5d397 | |||
| 8ef0bbf6c3 | |||
| da70138cfa | |||
| 84f7bcc8ee | |||
| 362c2fd638 | |||
| 440d212f5c | |||
| c7c6c2ea0b | |||
| bc63c4bac3 | |||
| 89edf6b390 | |||
| 5d7a6597c1 | |||
| b13cfe12a6 | |||
| a4495be67a | |||
| 0f7cac279c | |||
| eff26434e0 | |||
| 74fe60674c | |||
| e8e05625ec | |||
| 1040d76e82 | |||
| 4531718527 | |||
| d56eaba132 | |||
| a8c20a1629 | |||
| 12ef3b787b | |||
| 4aeab730e9 | |||
| 18a742f9c6 | |||
| 822d3bfdc4 | |||
| b620f6843b | |||
| 6351bf91c9 | |||
| fffe36691f | |||
| 8327b31057 | |||
| 3080f36495 | |||
| 4bb30981a0 | |||
| 423ffdeda2 | |||
| 3f12881e16 | |||
| 4ca8d4783b | |||
| fee8ca9ee9 | |||
| e22ebd9267 | |||
| 81b65d5a10 | |||
| 272871028e | |||
| 48e8c9562e | |||
| 5f118ae0dd | |||
| 2456a9fbf6 | |||
| 5dc9e87812 | |||
| 2143ce3083 | |||
| 94a7364394 | |||
| dc1b9006e5 | |||
| e6c83418a4 | |||
| 7b6c589a50 | |||
| 745c14145b | |||
| b86e99c98d | |||
| 7bead1ecf8 | |||
| 14400b8274 | |||
| 8f8ac09b6d | |||
| 1e1a04a695 | |||
| 55e677148c | |||
| 2fc775008e | |||
| b204171348 | |||
| 0ee781c85a | |||
| 9af0972fd1 | |||
| 447f9047cd | |||
| d61edeec07 | |||
| 5987855a0a | |||
| 86668a76ec | |||
| 855165f531 | |||
| ee766268a3 | |||
| 0a0c56807c | |||
| 3c4d4cd8e7 | |||
| 3d5690d8b0 | |||
| 2aaed68eee | |||
| ca477ee66a | |||
| d535f143ac | |||
| eec943ef26 | |||
| 24fcdd14c0 | |||
| dd08b0d166 | |||
| 3d365baa65 | |||
| 70a892eb51 | |||
| 6ec0b677e7 | |||
| 224a2b4c05 | |||
| ac9bdaadc1 | |||
| 98b4d4d6a8 | |||
| 914a7bcad3 | |||
| 75ad2e9487 | |||
| 6117074c05 | |||
| 02d62036db | |||
| bb19f33228 | |||
| 6b06e02c33 | |||
| 6a66541391 | |||
| 3f62782cd9 | |||
| c848b76045 | |||
| d75825e75b | |||
| 64d92486a5 | |||
| c049c12abf | |||
| fef4937cb1 | |||
| 375a0ea8de | |||
| d4f098178a | |||
| 268ab771b6 | |||
| cb94fd11d5 | |||
| 8ec2d86edf | |||
| ce422c25d6 | |||
| e4af9c32ff | |||
| 94d52f8f02 | |||
| 46b5cf7cb7 | |||
| 856683e596 | |||
| d4d2a5bc3e | |||
| fbda575645 | |||
| 572badbdce | |||
| bcde80f2b3 | |||
| 6b63e3d905 | |||
| 39cbc2bf7b | |||
| 33f0ea4178 | |||
| 992d6a3a44 | |||
| ea0d8cea76 | |||
| 1b6cc50342 | |||
| 3d2e01f6c8 | |||
| 4ae8c9aca1 | |||
| e1088a97ec | |||
| 80006e6017 | |||
| b9f4f2227c | |||
| 509f5d23e0 | |||
| ffd7d3d7c2 | |||
| eb0208d591 | |||
| a32090a4c1 | |||
| 7b66125271 | |||
| 98632cd3c8 | |||
| 0a60ef6e45 | |||
| 49ebbad5fa | |||
| e873787168 | |||
| fb4990ca39 | |||
| 7032c917e3 | |||
| a4a6aafe48 | |||
| 718647bcb1 | |||
| 14a60a077b | |||
| 14e0fcb120 | |||
| 64422b601f | |||
| 8419513e13 | |||
| f990f10f77 | |||
| 4ab16d477d | |||
| 2e633ad500 | |||
| 00ba27c582 | |||
| 6ca5cf268b | |||
| b9bdd0c7b6 | |||
| 594c911aad | |||
| cfca034aed | |||
| 2c669a7383 | |||
| ca72bce30c | |||
| c8f1d1ca37 | |||
| f18c648ae7 | |||
| 2da3d6983b | |||
| 2a02ff39c6 | |||
| 0a69834d90 | |||
| a8fdaa5c38 | |||
| 1387c879d5 | |||
| dfa4dd740a | |||
| 164c865fc7 | |||
| 1dfae875f2 | |||
| ff5d1865c4 | |||
| 29177c6a0d | |||
| 4454213c7b | |||
| e340d9f14b | |||
| d36d45416f | |||
| 3fc2c3c266 | |||
| 008537d5c3 | |||
| f65b8599b5 | |||
| 80161aad61 | |||
| dc77f7b55c | |||
| c83afe4ec2 | |||
| 8aa18dddc8 | |||
| d0f5c048e2 | |||
| 498ce7e832 | |||
| f329c16428 | |||
| 3398e99d5d | |||
| 158210e49f | |||
| 85fb025135 | |||
| 4fbf8bd7b3 | |||
| 1762e9204c | |||
| 5f57a74789 | |||
| f009e194ec | |||
| 9f686c8a69 | |||
| c630b0ba86 | |||
| 38c1666070 | |||
| debad50603 | |||
| a234a89cc8 | |||
| 8583655bf9 | |||
| 1796aa9fcc | |||
| 7c1376125d | |||
| 1c66afe8f1 | |||
| 2989d4cc7c | |||
| f0db2fe9c3 | |||
| 5679493192 | |||
| d6bddd46c6 | |||
| 7ac61104a3 | |||
| 987e0d3be5 | |||
| 7980ea00c3 | |||
| 02cc013abf | |||
| 01b91ac459 | |||
| 4f70e2756a | |||
| f6965dc685 | |||
| 86218462fc | |||
| 383df89595 | |||
| dc7dd83b88 | |||
| a901d8fd4c | |||
| ea8e7f9936 | |||
| 0d2b4325ec | |||
| b1d70beafa | |||
| 3827e2d359 | |||
| 58d079df96 | |||
| b139f7ae4b | |||
| 0e448ae3c0 | |||
| 79fc4a6726 | |||
| 0d3b042fec | |||
| 2864912fe0 | |||
| 5b3a7e59a8 | |||
| 7b0d235253 | |||
| 22c633e8b7 | |||
| 664f80662e | |||
| ac63de90c6 | |||
| 5f4a37b5b2 | |||
| 666ebd7bcf | |||
| 9b4f94bd92 | |||
| a88c450679 | |||
| 6a973240af | |||
| 3e3c6eec08 | |||
| 8de4f2e23e | |||
| 9d3089562a | |||
| 77ec0e627e | |||
| abf39fb332 | |||
| 2877856383 | |||
| f03e81eb03 | |||
| 75e59b1a22 | |||
| e2eb506371 | |||
| 9f811896b8 | |||
| a12743a49b | |||
| e8131aa214 | |||
| faafe84561 | |||
| df8ac6d2e6 | |||
| c98d228b96 | |||
| 9180b308f4 | |||
| 586e08ac32 | |||
| 13ad4e12e1 | |||
| f83a24b87b | |||
| bf08108c94 | |||
| f610ac5e18 | |||
| bfd5c5d7f6 | |||
| 5decc6f064 | |||
| f598a45f2e | |||
| eb9b7f1a3e | |||
| 4508fdd282 | |||
| 6a2f9ca922 | |||
| a565cb2f8e | |||
| bf9cdc2b90 | |||
| 19660487d0 | |||
| 5ab3937c6e | |||
| 22fa4da34f | |||
| 0ee1574512 | |||
| b02b2f70d7 | |||
| 0679583490 | |||
| 5ba8b19939 | |||
| 4d21686218 | |||
| 79cd394c82 | |||
| 18e2de4313 | |||
| 0eeec1a96f | |||
| 4e2cbb28e5 | |||
| 5a521aa30f | |||
| 01b9db69e2 | |||
| 91bfeb65ea | |||
| 16ae471c30 | |||
| e22b34ec32 | |||
| 7025366210 | |||
| e133c32ff3 | |||
| 84e6ee9c38 | |||
| 4c831b7078 | |||
| cd79115069 | |||
| cd1e684b2c | |||
| d67514acb8 | |||
| 0d4537c796 | |||
| fdb76e639f | |||
| e59fded4ef | |||
| 8529d9b6d8 | |||
| c23339e968 | |||
| 5fc3c306f4 | |||
| 207793f82f | |||
| 2b64c31597 | |||
| f7abe85cc0 | |||
| 5cd1517bc3 | |||
| 7ecefcb090 | |||
| 7a23b4d63c | |||
| 00c5890a15 | |||
| 45cd0cfde8 | |||
| 0a861d4506 | |||
| dcd2895639 | |||
| b88378acb9 | |||
| 06bbfff66e | |||
| da4714358a | |||
| 48e2bf159a | |||
| 48b358ba56 | |||
| 029d0a28bd | |||
| c26ac7924f | |||
| 51034f13f8 | |||
| a1ecd20a19 | |||
| a7ea2d7dcc | |||
| 915db857b8 | |||
| 6c05439a08 | |||
| b5c240e397 | |||
| e8e814e5c7 | |||
| 0fc2503718 | |||
| f5c2ff517f | |||
| 74948bb2e7 | |||
| ec7a860ff5 | |||
| 0f69811d98 | |||
| 0b038e2d43 | |||
| 02f0217c20 | |||
| 105a8f399f | |||
| c071606525 | |||
| dfa8b0f06a | |||
| 8953a3b44f | |||
| 6223b2eb1e | |||
| f4f18fb00c | |||
| 98830278dc | |||
| 2928e3d2d6 | |||
| ea07be815b | |||
| 10d7f1525d | |||
| d51d6583a7 | |||
| 6703e4af2d | |||
| 530c61afe7 | |||
| 58c98fa207 | |||
| beb6c6cdb7 | |||
| 964f6d4f17 | |||
| 905c6f3261 | |||
| e1210ad3c3 | |||
| 2492b30859 | |||
| 8e9f9bec69 | |||
| 47c8660050 | |||
| 8860ceb4d2 | |||
| a45c1d139a | |||
| ecdb04ca06 | |||
| 0f7fcc8377 | |||
| 4b8df782c6 | |||
| 3ad4a1097b | |||
| 21c2f2ef29 | |||
| c58f4f10b3 | |||
| 9978506b11 | |||
| 980b1e04bc | |||
| 0fc71cc508 | |||
| 9a0d8fd2b3 | |||
| d2b00aae1d | |||
| 2a94a64a06 | |||
| d7a5c75f30 | |||
| 54ac3dd31a | |||
| be029bdf25 | |||
| b573d77752 | |||
| db5219aacd | |||
| 9a2539db21 | |||
| dd241f341a | |||
| fe2bc06329 | |||
| 58643a8110 | |||
| 1a10d9049f | |||
| 4221b8647c | |||
| 8fd49aa444 | |||
| d91f79789a | |||
| 5eeebefba9 | |||
| 87cb44ac9f | |||
| 644600315c | |||
| 905fdcaa31 | |||
| a97a4a87bd | |||
| c3d36a923f | |||
| 3cfe476b39 | |||
| 146a1735ac | |||
| 8dc6117433 | |||
| 08f72e477c | |||
| d1c93d9605 | |||
| eede7619ef | |||
| bf6f63ae00 | |||
| 2f1dff3561 | |||
| d0b4e8226f | |||
| 889d2b5ead | |||
| 43935e12c9 | |||
| ad44e5c049 | |||
| 4075eb10da | |||
| 10bafd3d21 | |||
| 605737cdfb | |||
| 595eda8d9c | |||
| 56def90b83 | |||
| 74f6a9fb7e | |||
| 8e764b36b1 | |||
| 93f973f08b | |||
| 4e7d821b34 | |||
| 31c46027aa | |||
| 4e2b4b1bc2 | |||
| 2fa6e1ff26 | |||
| e63dc8ea91 | |||
| 8c251d1a93 | |||
| 4985c39b50 | |||
| 4f1c93d6dc | |||
| 96ef5c792a | |||
| e10e4fdd55 | |||
| f2ea23a1bd | |||
| 6b319a8087 | |||
| 172d326c41 | |||
| 8d6c9a68b1 | |||
| e2337127eb | |||
| 462a25fe75 | |||
| 8a774fddb7 | |||
| 059366fe22 | |||
| 834f10e9b2 | |||
| 14080bd00a | |||
| 23ea06dfbe | |||
| 8d2529e59e | |||
| 8f527a42ee | |||
| f8100e3629 | |||
| 25cbc9d08f | |||
| 88e912b1b1 | |||
| 31222bc4ef | |||
| 34db6d30a0 | |||
| 63d337cf47 | |||
| 285105fbf1 | |||
| b1682ee480 | |||
| 226f066ed5 | |||
| 08a1da2bb9 | |||
| 9b2f93bcf3 | |||
| ec64d5223d | |||
| 6ce20e4d58 | |||
| e48bc9eb25 | |||
| 74b29acec4 | |||
| 613b02036f | |||
| 495f166ec4 | |||
| d0f8a899f8 | |||
| 0183254bc5 | |||
| bbdb1c3815 | |||
| e9dbe49121 | |||
| e714706c42 | |||
| f450edd426 | |||
| 09447862c0 | |||
| 96856b5798 | |||
| 28e58deb41 | |||
| ab6508500c | |||
| 0b32ca3ba0 | |||
| 9a2e6ce88c | |||
| 070a7cc0c2 | |||
| 2277cfb8fb | |||
| 551d2b59bf | |||
| 7203acd306 | |||
| 07f579d0bd | |||
| 732581eb56 | |||
| 344c23c0ef | |||
| b515688ddb | |||
| 76f8821cfc | |||
| 95e34d9299 | |||
| bc77686a08 | |||
| 720669a6db | |||
| d6b7aa9c25 | |||
| 4287b1f51b | |||
| 2dc90eb90e | |||
| 243c0e302a | |||
| f392379a36 | |||
| 8fdaba4020 | |||
| 7e1a25bbdd | |||
| d8b7f70be3 | |||
| ca567fc69b | |||
| ef1c5c394e | |||
| f5a4f9a980 | |||
| 905c4d38ad | |||
| 2044f30ec3 | |||
| 52bf72770c | |||
| 3294198a19 | |||
| 68f039dedf | |||
| 8c68b750a8 | |||
| de288c6099 | |||
| 39c18c39d1 | |||
| 05a289bf1f | |||
| 904bd828c7 | |||
| 27b1d9d581 | |||
| cdc03b2a02 | |||
| 87e2569a2b | |||
| e4f8392813 | |||
| ce4af6df62 | |||
| a520b47745 | |||
| e1ddd943fb | |||
| cb43ec58fb | |||
| c72387b7a0 | |||
| 57ba975b11 | |||
| 2cfa6389c8 | |||
| fc62b3ed36 | |||
| 825eadf070 | |||
| 25e80a87f9 | |||
| fdfffda00f | |||
| 173de2e8fa | |||
| 9f1eaeda4f | |||
| daf27b51b4 | |||
| 2fe6249d41 | |||
| 27e7895379 | |||
| 0b7911a748 | |||
| 92a6edf143 | |||
| 4a4c960d99 | |||
| 2f12aae186 | |||
| 1530745ba6 | |||
| bd93091c8a | |||
| 609784e0aa | |||
| 7c58698a8a | |||
| 0cf39f9160 | |||
| e65b5a1dce | |||
| ec4fda2d3d | |||
| e8b5984085 | |||
| 0dafbf714a | |||
| 381cc85743 | |||
| f59c789b28 | |||
| f6c29f43ae | |||
| e99b6fb404 | |||
| a395180a81 | |||
| ce72ff9018 | |||
| 4314bcdd89 | |||
| d23f9f5d48 | |||
| 1eb6f0cd22 | |||
| fee582844b | |||
| 1c813b4080 | |||
| 993d8956ea | |||
| e067c3a1f0 | |||
| 1a833b5836 | |||
| 48653e6c05 | |||
| 804cc92184 | |||
| e5cf77cd19 | |||
| 0ea68a9cdd | |||
| 6d812d61a2 | |||
| a9f56a8f0d | |||
| 2dc8a5c519 | |||
| 7bd9c89714 | |||
| 24999ce035 | |||
| 31053d630f | |||
| 01ac5c3191 | |||
| 6aeb5a1f35 | |||
| a73a0a6d8c | |||
| d3d91e9a72 | |||
| f64475c360 | |||
| 459154ffbd | |||
| b7504102dc | |||
| 4590fe5598 | |||
| f7c1de925b | |||
| 07ccf0a68d | |||
| 6408f30173 | |||
| bdaee88fac | |||
| 552f0e47dc | |||
| 84331e061f | |||
| de43be04ae | |||
| 54374e63f0 | |||
| 294c6adb0a | |||
| 1c05b46ac2 | |||
| ddc6b0e31d | |||
| 1d9a81c347 | |||
| 262ec64be3 | |||
| 4541181369 | |||
| 4d0036e8be | |||
| 0e83e4f5ca | |||
| d40b3e1034 | |||
| 72343793f6 | |||
| d4e8a03c53 | |||
| 6c979e8a24 | |||
| 794e4a05a3 | |||
| d067b2005b | |||
| c6d79e46d9 | |||
| 2b8a5e83ac | |||
| 2a1e7c302c | |||
| 59b4825741 | |||
| 38d0c10e3c | |||
| 50d2685d0e | |||
| f187b7f98b | |||
| 0726456942 | |||
| 1bf6b1cc18 | |||
| efbd1fc514 | |||
| 9900b2f103 | |||
| 2716e73e9e | |||
| abe51bbed9 | |||
| cd09750495 | |||
| 3377c60427 | |||
| 5242595975 | |||
| 2605a5ba8f | |||
| 1aa43ea576 | |||
| f12b2a7d5d | |||
| 834d5863b9 | |||
| c8825cfd2d | |||
| 380b3b305c | |||
| 2ae294c9d6 | |||
| cb82934b8d | |||
| c1c70a909a | |||
| 541ba098e7 | |||
| c298a8b8e0 | |||
| 94863d1946 | |||
| 6b8155d4a8 | |||
| d9e4f9eb2a | |||
| d864c083c2 | |||
| 80970e2938 | |||
| c196e0f3cb | |||
| 5a6dba91bb | |||
| 4600286cd2 | |||
| 4bbd7130f1 | |||
| b862c77e93 | |||
| 1a149c0d33 | |||
| 84f3391271 | |||
| 1f66b55e6e | |||
| 4339f32452 | |||
| 00b8db5f4f | |||
| b0bba0e704 | |||
| d501331e75 | |||
| ac9ed861a4 | |||
| effa8cd5d1 | |||
| 3dbdb64c89 | |||
| 660e6d5f9d | |||
| 277ea82b49 | |||
| dce99d41f4 | |||
| 44c4e47a1c | |||
| ba4f9b230f | |||
| 2ba777cd5a | |||
| 03b40486ca | |||
| ea257a167e | |||
| a666b9dbcf | |||
| 986a50e26d | |||
| 625c8a70aa | |||
| 66a14b7292 | |||
| 0a265f0fcd | |||
| be8137a81b | |||
| 8bdb6d99a8 | |||
| 07c8c52cbf | |||
| b588ef46f4 | |||
| cdb048acd7 | |||
| dd9a68560e | |||
| c731399ff1 | |||
| c8d483b80c | |||
| 75775efcf7 | |||
| de8c6852d3 | |||
| 36d7c02847 | |||
| 64375cb146 | |||
| 1f7569c38a | |||
| d636096334 | |||
| 1f1a9a809c | |||
| fe19f91525 | |||
| aea38264b5 | |||
| 44e2500992 | |||
| ecf140979f | |||
| 9531202c10 | |||
| a5436ee747 | |||
| 826067335c | |||
| d5306794ec | |||
| 89905101b7 | |||
| f6849778a7 | |||
| c0f904046c | |||
| 23da79eff2 | |||
| 176d1229af | |||
| 6aef11722c | |||
| 5218d67aca | |||
| 9b037d3842 | |||
| 6481349eb3 | |||
| 9abb0f813a | |||
| 914d8f5801 | |||
| 7a553f06a3 | |||
| a9fd047eea | |||
| b225c41b53 | |||
| 2d0ee29b15 | |||
| 0bfac2fe7a | |||
| c7d9b99dae | |||
| f87c87b9ba | |||
| 88c0c27c83 | |||
| 395c75becd | |||
| b02e4ee384 | |||
| fae3f45758 | |||
| 5d46f73a3c | |||
| 1ac7d05730 | |||
| 27f60090f6 | |||
| 28dc928f43 | |||
| 7fe8550e18 | |||
| c9aecec6be | |||
| 69b693dbc9 | |||
| 0803379406 | |||
| 4eb4b874ba | |||
| aff589d128 | |||
| c4c9a5d860 | |||
| 805720ebd3 | |||
| af70ea6a96 | |||
| ae8df5acdf | |||
| 1e900c139d | |||
| ef93a24f23 | |||
| 47737013d3 | |||
| 476b3195fa | |||
| ed7ce12186 | |||
| de78b7e81b | |||
| bf48c7abcd | |||
| 26e6e8c048 | |||
| d0bdb4d3c9 | |||
| 7af4d79611 | |||
| 49f020ec0c | |||
| a4bb593422 | |||
| d799a9aef2 | |||
| 6b611eb82d | |||
| 1e04f3179a | |||
| ec7418d3ce | |||
| 6d895ae5e9 | |||
| b194dfbf15 | |||
| 278bd07a17 | |||
| 2aa86d2d33 | |||
| 74e97cf096 | |||
| d86503c7cf | |||
| ee16e98eb1 | |||
| 800085d9ae | |||
| c8937fb8ea | |||
| 08d1ef9d83 | |||
| 2fd3511227 | |||
| 3abe15dd14 | |||
| 213b568441 | |||
| 91a036b599 | |||
| 5484222182 | |||
| 321a23004b | |||
| 272fecfce4 | |||
| ffccc532c6 | |||
| ad6ae2c4e5 | |||
| 76816913ed | |||
| 4c74601224 | |||
| b4c8301258 | |||
| c446109283 | |||
| b4ab174902 | |||
| 2deb9e2501 | |||
| be02c7520a | |||
| 364f1151a6 | |||
| fb3a583b2b | |||
| 83bf9af99e | |||
| a00095da48 | |||
| 3ed4068ee1 | |||
| 949f570992 | |||
| 2bef2c7dca | |||
| 36e32ba459 | |||
| baa1209e37 | |||
| 4878c5a6d2 | |||
| 5d4353a158 | |||
| 446088fa5d | |||
| 33f519119b | |||
| 7acc6626c5 | |||
| e616f403eb | |||
| b51b3dd05c | |||
| e4fd3f4f06 | |||
| bce3627ed9 | |||
| 567596e8c2 | |||
| f703afe925 | |||
| 6483738028 | |||
| 086018ae01 | |||
| ae04fba0cd | |||
| db9529f65f | |||
| 97ae5efdf0 | |||
| a636a125da | |||
| b3ed98f7ba | |||
| 46941b6043 | |||
| 670cced63a | |||
| f6c74641dd | |||
| 3141843a1a | |||
| 4da8b58b36 | |||
| 7c8304a6c9 | |||
| fee588e503 | |||
| 42e2fba317 | |||
| 48c54e90ce | |||
| dad92a063d | |||
| 9033ed3212 | |||
| 146132bffc | |||
| 331c6f4620 | |||
| ed501d3e98 | |||
| d2780b2594 | |||
| 3054f2faf2 | |||
| 3c0fd35102 | |||
| 67e55d7e0b | |||
| 5b0d565bcd | |||
| ade83600e1 | |||
| b87862b89a | |||
| 30faf003ba | |||
| c9a53bb206 | |||
| 6fb6c9d960 | |||
| 5d502dc3e4 | |||
| 30d36e2f3e | |||
| 989e230b3d | |||
| f45b5a05c0 | |||
| 48cd99809d | |||
| 6ebca3c77e | |||
| 2e311d898c | |||
| a87bbde1a1 | |||
| 71777355b1 | |||
| 01d50616ee | |||
| d44136dee7 | |||
| 5c9fe50894 | |||
| e620c033cb | |||
| d3b5c5f081 | |||
| 6936ef91df | |||
| 3f94709321 | |||
| 6428434a5f | |||
| 9bb14972af | |||
| 01f3128264 | |||
| 3e55705455 | |||
| 889209d1fa | |||
| efc346b5ca | |||
| 5eb64d447e | |||
| 9446d15749 | |||
| dc28278d18 | |||
| d04f1621e8 | |||
| ef38765d91 | |||
| 7c3c8b7249 | |||
| eb676fdf9a | |||
| bf55369e5d | |||
| 56a6a9ff49 | |||
| 91e4976c08 | |||
| 299560a9fc | |||
| 23cb8a304c | |||
| 9c71eb42b8 | |||
| f642809590 | |||
| 3edb646260 | |||
| 7828580904 | |||
| 2711fbb039 | |||
| d226adef8b | |||
| 88aba6189b | |||
| e371190c10 | |||
| dd3b147a87 | |||
| 653c70a063 | |||
| bb75ef114c | |||
| f220d982f2 | |||
| 1db555e84d | |||
| 2c97ca5d59 | |||
| 4a1f1588f0 | |||
| 2b5c23c82b | |||
| e1b8eb512c | |||
| fca3ef18aa | |||
| d2c77a0dc0 | |||
| f76e87652c | |||
| 108145970d | |||
| d4d1873933 | |||
| 52a85b5475 | |||
| 6f1c69ec02 | |||
| f184d1610b | |||
| 7832d94156 | |||
| 289b648803 | |||
| c86c9b30c5 | |||
| a722923c62 | |||
| ae3f15fac1 | |||
| d5b0187a32 | |||
| 100aa1d7be | |||
| 4ff35d69bc | |||
| ec29c403be | |||
| a576feacb8 | |||
| 9c44a6972c | |||
| 1ce5928d35 | |||
| 35c30e915e | |||
| f59139d640 | |||
| b4bdcbe535 | |||
| b6d175eeb7 | |||
| a7084ab10b | |||
| 6a4c28904a | |||
| d0e1fd06c5 | |||
| 287a93580b | |||
| 53fedccb0b | |||
| a08ccf0a61 | |||
| df8baa04c3 | |||
| 3b0e0d4df4 | |||
| 250ea6271e | |||
| f356fbe45e | |||
| 37f401637b | |||
| 13f944bc55 | |||
| 3e21f15895 | |||
| fc410020b8 | |||
| 200460b0c8 | |||
| d1014faf32 | |||
| b692cb65b7 | |||
| 3f566d8f2e | |||
| 46beca01b3 | |||
| 0257c6d6b0 | |||
| b10192c1e4 | |||
| 0772879f24 | |||
| 5563b4e151 | |||
| ffcce04152 | |||
| b374d60430 | |||
| 848e124eab | |||
| a53b09c16b | |||
| 8374432bdb | |||
| 18ab64ef11 | |||
| e1b6fbf2eb | |||
| a37df0735f | |||
| 8b0c3b6551 | |||
| 5ee7e12e26 | |||
| f4aaf2f7b5 | |||
| c385f70296 | |||
| 00fe4b8045 | |||
| 0472d056f6 | |||
| 07f8831194 | |||
| a7f53e74f6 | |||
| 8a6733ead1 | |||
| e5bafac7d2 | |||
| f101e4f736 | |||
| 53b824ef1f | |||
| 672007443c | |||
| 1180c98509 | |||
| 337f36b459 | |||
| be1ed90464 | |||
| 55c0d5b8a4 | |||
| aa912c49e2 | |||
| 8abfee6962 | |||
| f1068df6c6 | |||
| 3b438e0db9 | |||
| 6d699a924d | |||
| f6de1e03d7 | |||
| 0416a3be25 | |||
| 1e4f7f125b | |||
| 1b2472e584 | |||
| 51aca6a92f | |||
| 04803a039d | |||
| 8d101bc522 | |||
| 474c8d3f00 | |||
| e48f4e502d | |||
| 00b9ff724b | |||
| d5be1194cb | |||
| d3176779c8 | |||
| 8e4485c69b | |||
| e565767d24 | |||
| aca29171b4 | |||
| 1710f639ae | |||
| 711d6de23f | |||
| fdee3caacb | |||
| 0c19b8fd99 | |||
| 1bad990a14 | |||
| 155a4e17a2 | |||
| 11a5d6c147 | |||
| ca5b6b6506 | |||
| d0fcd925f9 | |||
| b985f62858 | |||
| e793cddc22 |
@@ -1,86 +0,0 @@
|
||||
# Generated by "grunt ignorefiles"
|
||||
*/**/yui/src/*/meta/
|
||||
*/**/build/
|
||||
node_modules/
|
||||
vendor/
|
||||
admin/tool/usertours/amd/src/tour.js
|
||||
admin/tool/usertours/amd/src/popper.js
|
||||
auth/cas/CAS/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
filter/tex/mimetex.*
|
||||
lib/editor/atto/yui/src/rangy/js/*.*
|
||||
lib/editor/tinymce/plugins/pdw/tinymce/
|
||||
lib/editor/tinymce/plugins/spellchecker/rpc.php
|
||||
lib/editor/tinymce/tiny_mce/
|
||||
lib/mlbackend/php/phpml/
|
||||
lib/adodb/
|
||||
lib/bennu/
|
||||
lib/evalmath/
|
||||
lib/lessphp/
|
||||
lib/phpexcel/
|
||||
lib/google/
|
||||
lib/htmlpurifier/
|
||||
lib/jabber/
|
||||
lib/minify/matthiasmullie-minify/
|
||||
lib/minify/matthiasmullie-pathconverter/
|
||||
lib/pear/Auth/RADIUS.php
|
||||
lib/pear/Crypt/CHAP.php
|
||||
lib/pear/HTML/Common.php
|
||||
lib/pear/HTML/QuickForm.php
|
||||
lib/pear/HTML/QuickForm/
|
||||
lib/pear/PEAR.php
|
||||
lib/phpmailer/
|
||||
lib/simplepie/
|
||||
lib/tcpdf/
|
||||
lib/typo3/
|
||||
lib/yuilib/
|
||||
lib/yuilib/gallery/
|
||||
lib/jquery/
|
||||
lib/html2text/
|
||||
lib/markdown/
|
||||
lib/recaptchalib.php
|
||||
lib/xhprof/
|
||||
lib/xmlize.php
|
||||
lib/horde/
|
||||
lib/requirejs/
|
||||
lib/amd/src/loglevel.js
|
||||
lib/mustache/
|
||||
lib/amd/src/mustache.js
|
||||
lib/graphlib.php
|
||||
lib/php-css-parser/
|
||||
lib/rtlcss/
|
||||
lib/scssphp/
|
||||
lib/spout/
|
||||
lib/amd/src/chartjs-lazy.js
|
||||
lib/maxmind/GeoIp2/
|
||||
lib/maxmind/MaxMind/
|
||||
lib/ltiprovider/
|
||||
lib/amd/src/truncate.js
|
||||
lib/fonts/
|
||||
lib/validateurlsyntax.php
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
media/player/videojs/amd/src/videojs-flash-lazy.js
|
||||
media/player/videojs/videojs/video-js.swf
|
||||
mod/assign/feedback/editpdf/fpdi/
|
||||
repository/s3/S3.php
|
||||
theme/boost/scss/bootstrap/
|
||||
theme/boost/amd/src/alert.js
|
||||
theme/boost/amd/src/button.js
|
||||
theme/boost/amd/src/carousel.js
|
||||
theme/boost/amd/src/collapse.js
|
||||
theme/boost/amd/src/dropdown.js
|
||||
theme/boost/amd/src/modal.js
|
||||
theme/boost/amd/src/popover.js
|
||||
theme/boost/amd/src/scrollspy.js
|
||||
theme/boost/amd/src/tab.js
|
||||
theme/boost/amd/src/tooltip.js
|
||||
theme/boost/amd/src/util.js
|
||||
theme/boost/amd/src/tether.js
|
||||
theme/boost/scss/fontawesome/
|
||||
theme/bootstrapbase/less/bootstrap/
|
||||
theme/bootstrapbase/javascript/html5shiv.js
|
||||
theme/bootstrapbase/amd/src/bootstrap.js
|
||||
theme/bootstrapbase/less/fontawesome/
|
||||
@@ -1,214 +0,0 @@
|
||||
{
|
||||
'plugins': [
|
||||
'promise',
|
||||
],
|
||||
'env': {
|
||||
'browser': true,
|
||||
'amd': true
|
||||
},
|
||||
'globals': {
|
||||
'M': true,
|
||||
'Y': true
|
||||
},
|
||||
'rules': {
|
||||
// See http://eslint.org/docs/rules/ for all rules and explanations of all
|
||||
// rules.
|
||||
|
||||
// === Possible Errors ===
|
||||
'comma-dangle': 'off',
|
||||
'no-compare-neg-zero': 'error',
|
||||
'no-cond-assign': 'error',
|
||||
'no-console': 'error',
|
||||
'no-constant-condition': 'error',
|
||||
'no-control-regex': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-dupe-args': 'error',
|
||||
'no-dupe-keys': 'error',
|
||||
'no-duplicate-case': 'error',
|
||||
'no-empty': 'warn',
|
||||
'no-empty-character-class': 'error',
|
||||
'no-ex-assign': 'error',
|
||||
'no-extra-boolean-cast': 'error',
|
||||
'no-extra-parens': 'off',
|
||||
'no-extra-semi': 'error',
|
||||
'no-func-assign': 'error',
|
||||
'no-inner-declarations': 'error',
|
||||
'no-invalid-regexp': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-obj-calls': 'error',
|
||||
'no-prototype-builtins': 'off',
|
||||
'no-regex-spaces': 'error',
|
||||
'no-sparse-arrays': 'error',
|
||||
'no-unexpected-multiline': 'error',
|
||||
'no-unreachable': 'warn',
|
||||
'no-unsafe-finally': 'error',
|
||||
'no-unsafe-negation': 'error',
|
||||
'use-isnan': 'error',
|
||||
'valid-jsdoc': ['warn', { 'requireReturn': false, 'requireParamDescription': false, 'requireReturnDescription': false }],
|
||||
'valid-typeof': 'error',
|
||||
|
||||
// === Best Practices ===
|
||||
// (these mostly match our jshint config)
|
||||
'array-callback-return': 'warn',
|
||||
'block-scoped-var': 'warn',
|
||||
'complexity': 'warn',
|
||||
'consistent-return': 'warn',
|
||||
'curly': 'error',
|
||||
'dot-notation': 'warn',
|
||||
'no-alert': 'warn',
|
||||
'no-caller': 'error',
|
||||
'no-case-declarations': 'error',
|
||||
'no-div-regex': 'error',
|
||||
'no-empty-pattern': 'error',
|
||||
'no-empty-function': 'warn',
|
||||
'no-eq-null': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-bind': 'warn',
|
||||
'no-fallthrough': 'error',
|
||||
'no-floating-decimal': 'warn',
|
||||
'no-global-assign': 'warn',
|
||||
'no-implied-eval': 'error',
|
||||
'no-invalid-this': 'error',
|
||||
'no-iterator': 'error',
|
||||
'no-labels': 'error',
|
||||
'no-loop-func': 'error',
|
||||
'no-multi-spaces': 'warn',
|
||||
'no-multi-str': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-new-wrappers': 'error',
|
||||
'no-octal': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
'no-proto': 'error',
|
||||
'no-redeclare': 'warn',
|
||||
'no-return-assign': 'error',
|
||||
'no-script-url': 'error',
|
||||
'no-self-assign': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-sequences': 'warn',
|
||||
'no-throw-literal': 'warn',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unused-expressions': 'error',
|
||||
'no-unused-labels': 'error',
|
||||
'no-useless-call': 'warn',
|
||||
'no-useless-escape': 'warn',
|
||||
'no-with': 'error',
|
||||
'wrap-iife': ['error', 'any'],
|
||||
|
||||
// === Variables ===
|
||||
'no-delete-var': 'error',
|
||||
'no-undef': 'error',
|
||||
'no-undef-init': 'error',
|
||||
'no-unused-vars': ['error', { 'caughtErrors': 'none' }],
|
||||
|
||||
// === Stylistic Issues ===
|
||||
'array-bracket-spacing': 'warn',
|
||||
'block-spacing': 'warn',
|
||||
'brace-style': ['warn', '1tbs'],
|
||||
'camelcase': 'warn',
|
||||
'capitalized-comments': ['warn', 'always', { 'ignoreConsecutiveComments': true }],
|
||||
'comma-spacing': ['warn', { 'before': false, 'after': true }],
|
||||
'comma-style': ['warn', 'last'],
|
||||
'computed-property-spacing': 'error',
|
||||
'consistent-this': 'off',
|
||||
'eol-last': 'off',
|
||||
'func-call-spacing': ['warn', 'never'],
|
||||
'func-names': 'off',
|
||||
'func-style': 'off',
|
||||
// indent currently not doing well with our wrapping style, so disabled.
|
||||
'indent': ['off', 4, { 'SwitchCase': 1 }],
|
||||
'key-spacing': ['warn', { 'beforeColon': false, 'afterColon': true, 'mode': minimum }],
|
||||
'keyword-spacing': 'warn',
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
'lines-around-comment': 'off',
|
||||
'max-len': ['error', 132],
|
||||
'max-lines': 'off',
|
||||
'max-depth': 'warn',
|
||||
'max-nested-callbacks': ['warn', 5],
|
||||
'max-params': 'off',
|
||||
'max-statements': 'off',
|
||||
'max-statements-per-line': ['warn', { max: 2 }],
|
||||
'new-cap': ['warn', { 'properties': false }],
|
||||
'new-parens': 'warn',
|
||||
'newline-after-var': 'off',
|
||||
'newline-before-return': 'off',
|
||||
'newline-per-chained-call': 'off',
|
||||
'no-array-constructor': 'off',
|
||||
'no-bitwise': 'error',
|
||||
'no-continue': 'off',
|
||||
'no-inline-comments': 'off',
|
||||
'no-lonely-if': 'off',
|
||||
'no-mixed-operators': 'off',
|
||||
'no-mixed-spaces-and-tabs': 'error',
|
||||
'no-multiple-empty-lines': 'warn',
|
||||
'no-negated-condition': 'off',
|
||||
'no-nested-ternary': 'warn',
|
||||
'no-new-object': 'off',
|
||||
'no-plusplus': 'off',
|
||||
'no-tabs': 'error',
|
||||
'no-ternary': 'off',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-underscore-dangle': 'off',
|
||||
'no-unneeded-ternary': 'off',
|
||||
'no-whitespace-before-property': 'warn',
|
||||
'object-curly-newline': 'off',
|
||||
'object-curly-spacing': 'warn',
|
||||
'object-property-newline': 'off',
|
||||
'one-var': 'off',
|
||||
'one-var-declaration-per-line': ['warn', 'initializations'],
|
||||
'operator-assignment': 'off',
|
||||
'operator-linebreak': 'off',
|
||||
'padded-blocks': 'off',
|
||||
'quote-props': ['warn', 'as-needed', {'unnecessary': false, 'keywords': true, 'numbers': true}],
|
||||
'quotes': 'off',
|
||||
'require-jsdoc': 'warn',
|
||||
'semi': 'error',
|
||||
'semi-spacing': ['warn', {'before': false, 'after': true}],
|
||||
'sort-vars': 'off',
|
||||
'space-before-blocks': 'warn',
|
||||
'space-before-function-paren': ['warn', 'never'],
|
||||
'space-in-parens': 'warn',
|
||||
'space-infix-ops': 'warn',
|
||||
'space-unary-ops': 'warn',
|
||||
'spaced-comment': 'warn',
|
||||
'unicode-bom': 'error',
|
||||
'wrap-regex': 'off',
|
||||
|
||||
// === Promises ===
|
||||
'promise/always-return': 'warn',
|
||||
'promise/no-return-wrap': 'warn',
|
||||
'promise/param-names': 'warn',
|
||||
'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail']}],
|
||||
'promise/no-native': 'warn',
|
||||
'promise/no-promise-in-callback': 'warn',
|
||||
'promise/no-callback-in-promise': 'warn',
|
||||
'promise/avoid-new': 'warn',
|
||||
|
||||
// === Deprecations ===
|
||||
"no-restricted-properties": ['warn', {
|
||||
'object': 'M',
|
||||
'property': 'str',
|
||||
'message': 'Use AMD module "core/str" or M.util.get_string()'
|
||||
}],
|
||||
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["**/yui/src/**/*.js"],
|
||||
// Disable some rules which we can't safely define for YUI rollups.
|
||||
rules: {
|
||||
'no-undef': 'off',
|
||||
'no-unused-vars': 'off',
|
||||
'no-unused-expressions': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["**/amd/src/*.js"],
|
||||
// Check AMD with some slightly stricter rules.
|
||||
rules: {
|
||||
'no-unused-vars': 'error',
|
||||
'no-implicit-globals': 'error'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"indentation": ["on",{
|
||||
"Feature": 0,
|
||||
"Background": 2,
|
||||
"Scenario": 2,
|
||||
"Step": 4,
|
||||
"given": 4,
|
||||
"and": 4
|
||||
}],
|
||||
"no-dupe-feature-names": "on",
|
||||
"no-dupe-scenario-names": "off",
|
||||
"no-empty-file": "on",
|
||||
"no-files-without-scenarios": "on",
|
||||
"no-multiple-empty-lines": "on",
|
||||
"no-partially-commented-tag-lines": "on",
|
||||
"no-trailing-spaces": "on",
|
||||
"no-unamed-features": "on",
|
||||
"no-unamed-scenarios": "on",
|
||||
"no-scenario-outlines-without-examples": "on"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
**/yui/build/** -diff
|
||||
**/amd/build/** -diff
|
||||
lib/dml/oci_native_moodle_package.sql text eol=lf
|
||||
theme/bootstrapbase/style/editor.css -diff
|
||||
theme/bootstrapbase/style/moodle.css -diff
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
# This file specifies intentionally untracked files that all Moodle git
|
||||
# repositories should ignore. It is recommended not to modify this file in your
|
||||
# local clone. Instead, use .git/info/exclude and add new records there as
|
||||
# needed.
|
||||
#
|
||||
# Example: if you deploy a contributed plugin mod/foobar into your site, put
|
||||
# the following line into .git/info/exclude file in your Moodle clone:
|
||||
# /mod/foobar/
|
||||
#
|
||||
# See gitignore(5) man page for more details
|
||||
#
|
||||
/config.php
|
||||
/lib/editor/tinymce/extra/tools/temp/
|
||||
*~
|
||||
*.swp
|
||||
/tags
|
||||
/TAGS
|
||||
/cscope.*
|
||||
/.patches/
|
||||
/.idea/
|
||||
/nbproject/
|
||||
CVS
|
||||
.DS_Store
|
||||
/.settings/
|
||||
/.project
|
||||
/.buildpath
|
||||
/.cache
|
||||
phpunit.xml
|
||||
# Composer support. Do not ignore composer.json, or composer.lock. These should be shipped by us.
|
||||
composer.phar
|
||||
/vendor/
|
||||
/behat.yml
|
||||
*/yui/build/*/*-coverage.js
|
||||
/lib/yuilib/*/build/*/*-coverage.js
|
||||
# lib/yuilib/version/module/module-coverage.js
|
||||
/lib/yuilib/*/*/*-coverage.js
|
||||
atlassian-ide-plugin.xml
|
||||
/node_modules/
|
||||
@@ -1,58 +0,0 @@
|
||||
// NOTE: We use eslint now. This file is used only by shifter. We keep the configuration
|
||||
// here because shifter uses jshint after modules have been concating. Eslint can't
|
||||
// currently do this.
|
||||
{
|
||||
"asi": false,
|
||||
"bitwise": true,
|
||||
"boss": false,
|
||||
"browser": true,
|
||||
"curly": true,
|
||||
"debug": false,
|
||||
"eqeqeq": false,
|
||||
"eqnull": false,
|
||||
"es5": false,
|
||||
"esnext": false,
|
||||
"evil": false,
|
||||
"expr": false,
|
||||
"forin": false,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"immed": true,
|
||||
"indent": 4,
|
||||
"iterator": false,
|
||||
"lastsemic": false,
|
||||
"latedef": true,
|
||||
"laxbreak": true,
|
||||
"laxcomma": false,
|
||||
"loopfunc": false,
|
||||
"maxerr": 500,
|
||||
"maxlen": 132,
|
||||
"multistr": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nomen": false,
|
||||
"onecase": false,
|
||||
"onevar": false,
|
||||
"passfail": false,
|
||||
"plusplus": false,
|
||||
"predef": [
|
||||
"M",
|
||||
"define",
|
||||
"require"
|
||||
],
|
||||
"proto": false,
|
||||
"regexdash": false,
|
||||
"regexp": false,
|
||||
"scripturl": false,
|
||||
"shadow": false,
|
||||
"smarttabs": false,
|
||||
"strict": false,
|
||||
"sub": false,
|
||||
"supernew": false,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"white": false,
|
||||
"yui": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"coverage": false,
|
||||
"lint": "config",
|
||||
"clean": true
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
# Generated by "grunt ignorefiles"
|
||||
theme/bootstrapbase/style/
|
||||
theme/clean/style/custom.css
|
||||
theme/more/style/custom.css
|
||||
node_modules/
|
||||
vendor/
|
||||
admin/tool/usertours/amd/src/tour.js
|
||||
admin/tool/usertours/amd/src/popper.js
|
||||
auth/cas/CAS/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
filter/tex/mimetex.*
|
||||
lib/editor/atto/yui/src/rangy/js/*.*
|
||||
lib/editor/tinymce/plugins/pdw/tinymce/
|
||||
lib/editor/tinymce/plugins/spellchecker/rpc.php
|
||||
lib/editor/tinymce/tiny_mce/
|
||||
lib/mlbackend/php/phpml/
|
||||
lib/adodb/
|
||||
lib/bennu/
|
||||
lib/evalmath/
|
||||
lib/lessphp/
|
||||
lib/phpexcel/
|
||||
lib/google/
|
||||
lib/htmlpurifier/
|
||||
lib/jabber/
|
||||
lib/minify/matthiasmullie-minify/
|
||||
lib/minify/matthiasmullie-pathconverter/
|
||||
lib/pear/Auth/RADIUS.php
|
||||
lib/pear/Crypt/CHAP.php
|
||||
lib/pear/HTML/Common.php
|
||||
lib/pear/HTML/QuickForm.php
|
||||
lib/pear/HTML/QuickForm/
|
||||
lib/pear/PEAR.php
|
||||
lib/phpmailer/
|
||||
lib/simplepie/
|
||||
lib/tcpdf/
|
||||
lib/typo3/
|
||||
lib/yuilib/
|
||||
lib/yuilib/gallery/
|
||||
lib/jquery/
|
||||
lib/html2text/
|
||||
lib/markdown/
|
||||
lib/recaptchalib.php
|
||||
lib/xhprof/
|
||||
lib/xmlize.php
|
||||
lib/horde/
|
||||
lib/requirejs/
|
||||
lib/amd/src/loglevel.js
|
||||
lib/mustache/
|
||||
lib/amd/src/mustache.js
|
||||
lib/graphlib.php
|
||||
lib/php-css-parser/
|
||||
lib/rtlcss/
|
||||
lib/scssphp/
|
||||
lib/spout/
|
||||
lib/amd/src/chartjs-lazy.js
|
||||
lib/maxmind/GeoIp2/
|
||||
lib/maxmind/MaxMind/
|
||||
lib/ltiprovider/
|
||||
lib/amd/src/truncate.js
|
||||
lib/fonts/
|
||||
lib/validateurlsyntax.php
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
media/player/videojs/amd/src/videojs-flash-lazy.js
|
||||
media/player/videojs/videojs/video-js.swf
|
||||
mod/assign/feedback/editpdf/fpdi/
|
||||
repository/s3/S3.php
|
||||
theme/boost/scss/bootstrap/
|
||||
theme/boost/amd/src/alert.js
|
||||
theme/boost/amd/src/button.js
|
||||
theme/boost/amd/src/carousel.js
|
||||
theme/boost/amd/src/collapse.js
|
||||
theme/boost/amd/src/dropdown.js
|
||||
theme/boost/amd/src/modal.js
|
||||
theme/boost/amd/src/popover.js
|
||||
theme/boost/amd/src/scrollspy.js
|
||||
theme/boost/amd/src/tab.js
|
||||
theme/boost/amd/src/tooltip.js
|
||||
theme/boost/amd/src/util.js
|
||||
theme/boost/amd/src/tether.js
|
||||
theme/boost/scss/fontawesome/
|
||||
theme/bootstrapbase/less/bootstrap/
|
||||
theme/bootstrapbase/javascript/html5shiv.js
|
||||
theme/bootstrapbase/amd/src/bootstrap.js
|
||||
theme/bootstrapbase/less/fontawesome/
|
||||
@@ -1,95 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"stylelint-csstree-validator"
|
||||
],
|
||||
"rules": {
|
||||
"csstree/validator": true,
|
||||
"at-rule-empty-line-before": [ "always",
|
||||
{"except": [ "blockless-after-blockless"], ignore: ["after-comment", "inside-block"]}
|
||||
],
|
||||
"at-rule-name-case": "lower",
|
||||
"at-rule-name-space-after": "always-single-line",
|
||||
"at-rule-no-unknown": null, # Enabled for non-scss in grunt.
|
||||
"at-rule-semicolon-newline-after": "always",
|
||||
"at-rule-semicolon-space-before": "never",
|
||||
"block-closing-brace-newline-after": "always",
|
||||
"block-closing-brace-newline-before": "always",
|
||||
"block-closing-brace-space-before": "always-single-line",
|
||||
"block-no-empty": true,
|
||||
"block-opening-brace-newline-after": "always",
|
||||
"block-opening-brace-space-after": "always-single-line",
|
||||
"block-opening-brace-space-before": "always",
|
||||
"color-hex-case": ["lower", { "severity": "warning" }],
|
||||
"color-hex-length": ["short", { "severity": "warning" }],
|
||||
"color-no-invalid-hex": true,
|
||||
"declaration-bang-space-after": "never",
|
||||
"declaration-bang-space-before": "always",
|
||||
"declaration-block-no-duplicate-properties": true,
|
||||
"declaration-block-no-shorthand-property-overrides": true,
|
||||
"declaration-block-semicolon-newline-after": "always-multi-line",
|
||||
"declaration-block-semicolon-space-after": "always-single-line",
|
||||
"declaration-block-semicolon-space-before": "never",
|
||||
"declaration-block-single-line-max-declarations": 1,
|
||||
"declaration-block-trailing-semicolon": "always",
|
||||
"declaration-colon-newline-after": "always-multi-line",
|
||||
"declaration-colon-space-after": "always-single-line",
|
||||
"declaration-colon-space-before": "never",
|
||||
"declaration-no-important": true,
|
||||
"font-family-no-duplicate-names": true,
|
||||
"function-calc-no-unspaced-operator": true,
|
||||
"function-comma-newline-after": "always-multi-line",
|
||||
"function-comma-space-after": "always-single-line",
|
||||
"function-comma-space-before": "never",
|
||||
"function-linear-gradient-no-nonstandard-direction": true,
|
||||
"function-max-empty-lines": 0,
|
||||
"function-name-case": "lower",
|
||||
"function-parentheses-newline-inside": "always-multi-line",
|
||||
"function-parentheses-space-inside": "never-single-line",
|
||||
"function-url-scheme-blacklist": ["data"],
|
||||
"function-whitespace-after": "always",
|
||||
"indentation": 4,
|
||||
"keyframe-declaration-no-important": true,
|
||||
"length-zero-no-unit": [true, { "severity": "warning" }],
|
||||
"max-empty-lines": 2,
|
||||
"max-line-length": [132, { "severity": "warning" }],
|
||||
"media-feature-colon-space-after": "always",
|
||||
"media-feature-colon-space-before": "never",
|
||||
"media-feature-parentheses-space-inside": "never",
|
||||
"media-feature-range-operator-space-after": "always",
|
||||
"media-feature-range-operator-space-before": "always",
|
||||
"media-query-list-comma-newline-after": "always-multi-line",
|
||||
"media-query-list-comma-space-after": "always-single-line",
|
||||
"media-query-list-comma-space-before": "never",
|
||||
"no-empty-source": true,
|
||||
"no-eol-whitespace": true,
|
||||
"no-extra-semicolons": [true, { "severity": "warning" }],
|
||||
"no-invalid-double-slash-comments": true,
|
||||
"no-unknown-animations": true,
|
||||
"property-case": "lower",
|
||||
"property-no-unknown": true,
|
||||
"selector-attribute-brackets-space-inside": "never",
|
||||
"selector-attribute-operator-space-after": "never",
|
||||
"selector-attribute-operator-space-before": "never",
|
||||
"selector-combinator-space-after": "always",
|
||||
"selector-combinator-space-before": "always",
|
||||
"selector-list-comma-newline-after": "always",
|
||||
"selector-list-comma-space-before": "never",
|
||||
"selector-max-empty-lines": 0,
|
||||
"selector-pseudo-class-case": "lower",
|
||||
"selector-pseudo-class-no-unknown": true,
|
||||
"selector-pseudo-class-parentheses-space-inside": "never",
|
||||
"selector-pseudo-element-case": "lower",
|
||||
"selector-pseudo-element-no-unknown": true,
|
||||
"selector-type-case": "lower",
|
||||
"selector-type-no-unknown": true,
|
||||
"string-no-newline": true,
|
||||
"time-min-milliseconds": 100,
|
||||
"unit-blacklist": ["pt"],
|
||||
"unit-case": "lower",
|
||||
"unit-no-unknown": true,
|
||||
"value-keyword-case": ["lower", {"ignoreKeywords": ["/(@|$)/"]}],
|
||||
"value-list-comma-newline-after": "always-multi-line",
|
||||
"value-list-comma-space-after": "always-single-line",
|
||||
"value-list-comma-space-before": "never",
|
||||
}
|
||||
}
|
||||
-285
@@ -1,285 +0,0 @@
|
||||
# PLEASE NOTE: Travis is not currently utilised by the Moodle core integration
|
||||
# process (which uses our internal CI system) this file is here for the benefit
|
||||
# of community developers git clones - see MDL-51458.
|
||||
|
||||
sudo: required
|
||||
|
||||
# We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976
|
||||
# is fixed.
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
language: php
|
||||
|
||||
php:
|
||||
# We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
|
||||
- 7.2
|
||||
- 7.0
|
||||
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
packages:
|
||||
- mysql-server-5.6
|
||||
- mysql-client-core-5.6
|
||||
- mysql-client-5.6
|
||||
|
||||
# Redis tests are currently failing on php 7.2 due to https://bugs.php.net/bug.php?id=75628
|
||||
# services:
|
||||
# - redis-server
|
||||
|
||||
env:
|
||||
# Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
|
||||
# start first so that the total run time is not too high.
|
||||
#
|
||||
# We only run MySQL on PHP 7.2, so run that first.
|
||||
# CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances.
|
||||
# Postgres is significantly is pretty reasonable in its run-time.
|
||||
|
||||
# Run unit tests on MySQL
|
||||
- DB=mysqli TASK=PHPUNIT
|
||||
|
||||
# Run CI Tests without running PHPUnit.
|
||||
- DB=none TASK=CITEST
|
||||
|
||||
# Run unit tests on Postgres
|
||||
- DB=pgsql TASK=PHPUNIT
|
||||
|
||||
# Perform an upgrade test too.
|
||||
- DB=pgsql TASK=UPGRADE
|
||||
|
||||
matrix:
|
||||
# Enable fast finish.
|
||||
# This will fail the build if a single job fails (except those in allow_failures).
|
||||
# It will not stop the jobs from running.
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
# Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
|
||||
- php: 7.2
|
||||
env: DB=none TASK=GRUNT NVM_VERSION='8.9'
|
||||
|
||||
exclude:
|
||||
# MySQL - it's just too slow.
|
||||
# Exclude it on all versions except for 7.2
|
||||
|
||||
- env: DB=mysqli TASK=PHPUNIT
|
||||
php: 7.0
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.npm
|
||||
|
||||
install:
|
||||
- >
|
||||
if [ "$DB" = 'mysqli' ];
|
||||
then
|
||||
sudo mkdir /mnt/ramdisk
|
||||
sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
|
||||
sudo stop mysql
|
||||
sudo mv /var/lib/mysql /mnt/ramdisk
|
||||
sudo ln -s /mnt/ramdisk/mysql /var/lib/mysql
|
||||
sudo start mysql
|
||||
fi
|
||||
- >
|
||||
if [ "$DB" = 'pgsql' ];
|
||||
then
|
||||
sudo mkdir /mnt/ramdisk
|
||||
sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
|
||||
sudo service postgresql stop
|
||||
sudo mv /var/lib/postgresql /mnt/ramdisk
|
||||
sudo ln -s /mnt/ramdisk/postgresql /var/lib/postgresql
|
||||
sudo service postgresql start 9.6
|
||||
fi
|
||||
- >
|
||||
if [ "$TASK" = 'PHPUNIT' ];
|
||||
then
|
||||
if [ -n "$GITHUB_APITOKEN" ]; then
|
||||
composer config github-oauth.github.com $GITHUB_APITOKEN;
|
||||
echo 'auth.json' >> .git/info/exclude
|
||||
fi
|
||||
|
||||
# Enable Redis.
|
||||
# Redis tests are currently failing on php 7.2 due to https://bugs.php.net/bug.php?id=75628
|
||||
# echo 'extension="redis.so"' > /tmp/redis.ini
|
||||
# phpenv config-add /tmp/redis.ini
|
||||
|
||||
# Install composer dependencies.
|
||||
# We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
|
||||
# Typically it should be able to use the Composer cache if any other job has already completed before we started here.
|
||||
travis_retry composer install --prefer-dist --no-interaction;
|
||||
fi
|
||||
|
||||
- >
|
||||
if [ "$TASK" = 'GRUNT' ];
|
||||
then
|
||||
nvm install $NVM_VERSION ;
|
||||
nvm use $NVM_VERSION ;
|
||||
fi
|
||||
|
||||
before_script:
|
||||
- phpenv config-rm xdebug.ini
|
||||
- >
|
||||
if [ "$TASK" = 'PHPUNIT' -o "$TASK" = 'UPGRADE' ];
|
||||
then
|
||||
# Copy generic configuration in place.
|
||||
cp config-dist.php config.php ;
|
||||
|
||||
# Create the moodledata directory.
|
||||
mkdir -p "$HOME"/roots/base
|
||||
|
||||
# The database name and password.
|
||||
sed -i \
|
||||
-e "s%= 'moodle'%= 'travis_ci_test'%" \
|
||||
-e "s%= 'password'%= ''%" \
|
||||
config.php ;
|
||||
|
||||
# The wwwroot and dataroot.
|
||||
sed -i \
|
||||
-e "s%http://example.com/moodle%https://localhost%" \
|
||||
-e "s%/home/example/moodledata%/home/travis/roots/base%" \
|
||||
config.php ;
|
||||
|
||||
if [ "$DB" = 'pgsql' ];
|
||||
then
|
||||
# Postgres-specific setup.
|
||||
sed -i \
|
||||
-e "s%= 'username'%= 'postgres'%" \
|
||||
config.php ;
|
||||
|
||||
psql -c 'CREATE DATABASE travis_ci_test;' -U postgres;
|
||||
fi
|
||||
|
||||
if [ "$DB" = 'mysqli' ];
|
||||
then
|
||||
# MySQL-specific setup.
|
||||
sed -i \
|
||||
-e "s%= 'pgsql'%= 'mysqli'%" \
|
||||
-e "s%= 'username'%= 'travis'%" \
|
||||
-e "s%=> 'utf8mb4_unicode_ci'%=> 'utf8mb4_bin'%" \
|
||||
config.php;
|
||||
|
||||
mysql -u root -e 'SET GLOBAL innodb_file_format=barracuda;' ;
|
||||
mysql -u root -e 'SET GLOBAL innodb_file_per_table=ON;' ;
|
||||
mysql -u root -e 'SET GLOBAL innodb_large_prefix=ON;' ;
|
||||
mysql -e 'CREATE DATABASE travis_ci_test DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin;' ;
|
||||
fi
|
||||
fi
|
||||
|
||||
- >
|
||||
if [ "$TASK" = 'PHPUNIT' ];
|
||||
then
|
||||
# Create a directory for the phpunit dataroot.
|
||||
mkdir -p "$HOME"/roots/phpunit
|
||||
|
||||
# The phpunit dataroot and prefix..
|
||||
# Redis tests are currently failing on php 7.2 due to https://bugs.php.net/bug.php?id=75628
|
||||
# -e "/require_once/i \\define('TEST_SESSION_REDIS_HOST', '127.0.0.1');" \
|
||||
sed -i \
|
||||
-e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
|
||||
-e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
|
||||
config.php ;
|
||||
|
||||
# Initialise PHPUnit for Moodle.
|
||||
php admin/tool/phpunit/cli/init.php
|
||||
fi
|
||||
|
||||
- >
|
||||
if [ "$TASK" = 'GRUNT' ];
|
||||
then
|
||||
npm install --no-spin;
|
||||
npm install --no-spin -g grunt ;
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
# CI Tests
|
||||
########################################################################
|
||||
- >
|
||||
if [ "$TASK" = 'CITEST' ];
|
||||
then
|
||||
# Note - this is deliberately placed in the script section as we
|
||||
# should not add any code until after phpunit has run.
|
||||
|
||||
# The following repositories are required.
|
||||
# The local_ci repository does the actual checking.
|
||||
git clone https://github.com/moodlehq/moodle-local_ci.git local/ci
|
||||
|
||||
# We need the official upstream for comparison
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
git fetch upstream MOODLE_34_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`
|
||||
|
||||
# Variables required by our linter.
|
||||
export gitcmd=`which git`;
|
||||
export gitdir="$TRAVIS_BUILD_DIR";
|
||||
export phpcmd=`which php`;
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
# Upgrade test
|
||||
########################################################################
|
||||
- >
|
||||
if [ "$TASK" = 'UPGRADE' ];
|
||||
then
|
||||
# We need the official upstream.
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
# Checkout 30 STABLE branch (the first version compatible with PHP 7.x)
|
||||
git fetch upstream MOODLE_30_STABLE;
|
||||
git checkout MOODLE_30_STABLE;
|
||||
|
||||
# Perform the upgrade
|
||||
php admin/cli/install_database.php --agree-license --adminpass=Password --adminemail=admin@example.com --fullname="Upgrade test" --shortname=Upgrade;
|
||||
|
||||
# Return to the previous commit
|
||||
git checkout -;
|
||||
|
||||
# Perform the upgrade
|
||||
php admin/cli/upgrade.php --non-interactive --allow-unstable ;
|
||||
|
||||
# The local_ci repository can be used to check upgrade savepoints.
|
||||
git clone https://github.com/moodlehq/moodle-local_ci.git local/ci ;
|
||||
fi
|
||||
|
||||
script:
|
||||
- >
|
||||
if [ "$TASK" = 'PHPUNIT' ];
|
||||
then
|
||||
vendor/bin/phpunit;
|
||||
fi
|
||||
|
||||
- >
|
||||
if [ "$TASK" = 'CITEST' ];
|
||||
then
|
||||
bash local/ci/php_lint/php_lint.sh;
|
||||
fi
|
||||
|
||||
- >
|
||||
if [ "$TASK" = 'GRUNT' ];
|
||||
then
|
||||
grunt ;
|
||||
# Add all files to the git index and then run diff --cached to see all changes.
|
||||
# This ensures that we get the status of all files, including new files.
|
||||
git add . ;
|
||||
git diff --cached --exit-code ;
|
||||
fi
|
||||
|
||||
########################################################################
|
||||
# Upgrade test
|
||||
########################################################################
|
||||
- >
|
||||
if [ "$TASK" = 'UPGRADE' ];
|
||||
then
|
||||
cp local/ci/check_upgrade_savepoints/check_upgrade_savepoints.php ./check_upgrade_savepoints.php
|
||||
result=`php check_upgrade_savepoints.php`;
|
||||
# Check if there are problems
|
||||
count=`echo "$result" | grep -P "ERROR|WARN" | wc -l` ;
|
||||
if (($count > 0));
|
||||
then
|
||||
echo "$result"
|
||||
exit 1 ;
|
||||
fi
|
||||
fi
|
||||
@@ -1,56 +0,0 @@
|
||||
CONTRIBUTING TO MOODLE
|
||||
======================
|
||||
|
||||
Moodle is made by people like you. We are members of a big worldwide community
|
||||
of developers, designers, teachers, testers, translators and other users. We
|
||||
work in universities, schools, companies and other places. You are very welcome
|
||||
to join us and contribute to the project.
|
||||
|
||||
See <https://docs.moodle.org/dev/Contributing_to_Moodle> for the many ways you
|
||||
can help, not only with coding.
|
||||
|
||||
Moodle is open to community contributions to core, though all code must go
|
||||
through peer-review, automated behaviour testing, continuous integration and
|
||||
human post-integration checks.
|
||||
|
||||
Pull requests
|
||||
-------------
|
||||
|
||||
Please do not open pull requests via Github. The repository there is just a
|
||||
mirror of the official repository at <https://git.moodle.org>. Issues are
|
||||
reported and patches provided via <https://tracker.moodle.org>. See below for
|
||||
more information.
|
||||
|
||||
Moodle core bug fixes and new features
|
||||
--------------------------------------
|
||||
|
||||
During the years of intensive development, a mature process of including
|
||||
submitted patches has evolved.
|
||||
|
||||
* Every bug fix or new feature must have a tracker issue.
|
||||
* You publish the branch implementing the fix or new feature in your public
|
||||
clone of the moodle.git repository (typically on Github).
|
||||
* Your patch is peer-reviewed, discussed, integrated, tested and then released
|
||||
as a part of moodle.git.
|
||||
* New features are developed on the master branch. Bug fixes are also
|
||||
backported to currently supported maintenance (stable) branches.
|
||||
|
||||
For further details, see <https://docs.moodle.org/dev/Process>.
|
||||
|
||||
Moodle plugins
|
||||
--------------
|
||||
|
||||
Moodle has a framework for additional plugins to extend its functionality. We
|
||||
have a Moodle plugins directory <https://moodle.org/plugins/> where you can
|
||||
register and maintain your plugin. Plugins hosted in the plugins directory can
|
||||
be easily installed and updated via the Moodle administration interface.
|
||||
|
||||
* You are expected to have a public source code repository with your plugin
|
||||
code.
|
||||
* After registering your plugin in the plugins directory it is reviewed before
|
||||
being published.
|
||||
* You are expected to continuously release updated versions of the plugin via
|
||||
the plugins directory. We do not pull from your code repository; you must do
|
||||
it explicitly.
|
||||
|
||||
For further details, see <https://docs.moodle.org/dev/Plugin_contribution>.
|
||||
-674
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
-384
@@ -1,384 +0,0 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* jshint node: true, browser: false */
|
||||
/* eslint-env node */
|
||||
|
||||
/**
|
||||
* @copyright 2014 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Grunt configuration
|
||||
*/
|
||||
|
||||
module.exports = function(grunt) {
|
||||
var path = require('path'),
|
||||
tasks = {},
|
||||
cwd = process.env.PWD || process.cwd(),
|
||||
async = require('async'),
|
||||
DOMParser = require('xmldom').DOMParser,
|
||||
xpath = require('xpath'),
|
||||
semver = require('semver');
|
||||
|
||||
// Verify the node version is new enough.
|
||||
var expected = semver.validRange(grunt.file.readJSON('package.json').engines.node);
|
||||
var actual = semver.valid(process.version);
|
||||
if (!semver.satisfies(actual, expected)) {
|
||||
grunt.fail.fatal('Node version too old. Require ' + expected + ', version installed: ' + actual);
|
||||
}
|
||||
|
||||
// Windows users can't run grunt in a subdirectory, so allow them to set
|
||||
// the root by passing --root=path/to/dir.
|
||||
if (grunt.option('root')) {
|
||||
var root = grunt.option('root');
|
||||
if (grunt.file.exists(__dirname, root)) {
|
||||
cwd = path.join(__dirname, root);
|
||||
grunt.log.ok('Setting root to ' + cwd);
|
||||
} else {
|
||||
grunt.fail.fatal('Setting root to ' + root + ' failed - path does not exist');
|
||||
}
|
||||
}
|
||||
|
||||
var inAMD = path.basename(cwd) == 'amd';
|
||||
|
||||
// Globbing pattern for matching all AMD JS source files.
|
||||
var amdSrc = [inAMD ? cwd + '/src/*.js' : '**/amd/src/*.js'];
|
||||
|
||||
/**
|
||||
* Function to generate the destination for the uglify task
|
||||
* (e.g. build/file.min.js). This function will be passed to
|
||||
* the rename property of files array when building dynamically:
|
||||
* http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
|
||||
*
|
||||
* @param {String} destPath the current destination
|
||||
* @param {String} srcPath the matched src path
|
||||
* @return {String} The rewritten destination path.
|
||||
*/
|
||||
var uglifyRename = function(destPath, srcPath) {
|
||||
destPath = srcPath.replace('src', 'build');
|
||||
destPath = destPath.replace('.js', '.min.js');
|
||||
destPath = path.resolve(cwd, destPath);
|
||||
return destPath;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find thirdpartylibs.xml and generate an array of paths contained within
|
||||
* them (used to generate ignore files and so on).
|
||||
*
|
||||
* @return {array} The list of thirdparty paths.
|
||||
*/
|
||||
var getThirdPartyPathsFromXML = function() {
|
||||
var thirdpartyfiles = grunt.file.expand('*/**/thirdpartylibs.xml');
|
||||
var libs = ['node_modules/', 'vendor/'];
|
||||
|
||||
thirdpartyfiles.forEach(function(file) {
|
||||
var dirname = path.dirname(file);
|
||||
|
||||
var doc = new DOMParser().parseFromString(grunt.file.read(file));
|
||||
var nodes = xpath.select("/libraries/library/location/text()", doc);
|
||||
|
||||
nodes.forEach(function(node) {
|
||||
var lib = path.join(dirname, node.toString());
|
||||
if (grunt.file.isDir(lib)) {
|
||||
// Ensure trailing slash on dirs.
|
||||
lib = lib.replace(/\/?$/, '/');
|
||||
}
|
||||
|
||||
// Look for duplicate paths before adding to array.
|
||||
if (libs.indexOf(lib) === -1) {
|
||||
libs.push(lib);
|
||||
}
|
||||
});
|
||||
});
|
||||
return libs;
|
||||
};
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
eslint: {
|
||||
// Even though warnings dont stop the build we don't display warnings by default because
|
||||
// at this moment we've got too many core warnings.
|
||||
options: {quiet: !grunt.option('show-lint-warnings')},
|
||||
amd: {src: amdSrc},
|
||||
// Check YUI module source files.
|
||||
yui: {src: ['**/yui/src/**/*.js', '!*/**/yui/src/*/meta/*.js']}
|
||||
},
|
||||
uglify: {
|
||||
amd: {
|
||||
files: [{
|
||||
expand: true,
|
||||
src: amdSrc,
|
||||
rename: uglifyRename
|
||||
}],
|
||||
options: {report: 'none'}
|
||||
}
|
||||
},
|
||||
less: {
|
||||
bootstrapbase: {
|
||||
files: {
|
||||
"theme/bootstrapbase/style/moodle.css": "theme/bootstrapbase/less/moodle.less",
|
||||
"theme/bootstrapbase/style/editor.css": "theme/bootstrapbase/less/editor.less",
|
||||
},
|
||||
options: {
|
||||
compress: false // We must not compress to keep the comments.
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
nospawn: true // We need not to spawn so config can be changed dynamically.
|
||||
},
|
||||
amd: {
|
||||
files: ['**/amd/src/**/*.js'],
|
||||
tasks: ['amd']
|
||||
},
|
||||
bootstrapbase: {
|
||||
files: ["theme/bootstrapbase/less/**/*.less"],
|
||||
tasks: ["css"]
|
||||
},
|
||||
yui: {
|
||||
files: ['**/yui/src/**/*.js'],
|
||||
tasks: ['yui']
|
||||
},
|
||||
gherkinlint: {
|
||||
files: ['**/tests/behat/*.feature'],
|
||||
tasks: ['gherkinlint']
|
||||
}
|
||||
},
|
||||
shifter: {
|
||||
options: {
|
||||
recursive: true,
|
||||
paths: [cwd]
|
||||
}
|
||||
},
|
||||
gherkinlint: {
|
||||
options: {
|
||||
files: ['**/tests/behat/*.feature'],
|
||||
}
|
||||
},
|
||||
stylelint: {
|
||||
less: {
|
||||
options: {
|
||||
syntax: 'less',
|
||||
configOverrides: {
|
||||
rules: {
|
||||
// These rules have to be disabled in .stylelintrc for scss compat.
|
||||
"at-rule-no-unknown": true,
|
||||
}
|
||||
}
|
||||
},
|
||||
src: ['theme/**/*.less']
|
||||
},
|
||||
scss: {
|
||||
options: {syntax: 'scss'},
|
||||
src: ['*/**/*.scss']
|
||||
},
|
||||
css: {
|
||||
src: ['*/**/*.css'],
|
||||
options: {
|
||||
configOverrides: {
|
||||
rules: {
|
||||
// These rules have to be disabled in .stylelintrc for scss compat.
|
||||
"at-rule-no-unknown": true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Generate ignore files (utilising thirdpartylibs.xml data)
|
||||
*/
|
||||
tasks.ignorefiles = function() {
|
||||
// An array of paths to third party directories.
|
||||
var thirdPartyPaths = getThirdPartyPathsFromXML();
|
||||
// Generate .eslintignore.
|
||||
var eslintIgnores = ['# Generated by "grunt ignorefiles"', '*/**/yui/src/*/meta/', '*/**/build/'].concat(thirdPartyPaths);
|
||||
grunt.file.write('.eslintignore', eslintIgnores.join('\n'));
|
||||
// Generate .stylelintignore.
|
||||
var stylelintIgnores = [
|
||||
'# Generated by "grunt ignorefiles"',
|
||||
'theme/bootstrapbase/style/',
|
||||
'theme/clean/style/custom.css',
|
||||
'theme/more/style/custom.css'
|
||||
].concat(thirdPartyPaths);
|
||||
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n'));
|
||||
};
|
||||
|
||||
/**
|
||||
* Shifter task. Is configured with a path to a specific file or a directory,
|
||||
* in the case of a specific file it will work out the right module to be built.
|
||||
*
|
||||
* Note that this task runs the invidiaul shifter jobs async (becase it spawns
|
||||
* so be careful to to call done().
|
||||
*/
|
||||
tasks.shifter = function() {
|
||||
var done = this.async(),
|
||||
options = grunt.config('shifter.options');
|
||||
|
||||
// Run the shifter processes one at a time to avoid confusing output.
|
||||
async.eachSeries(options.paths, function(src, filedone) {
|
||||
var args = [];
|
||||
args.push(path.normalize(__dirname + '/node_modules/shifter/bin/shifter'));
|
||||
|
||||
// Always ignore the node_modules directory.
|
||||
args.push('--excludes', 'node_modules');
|
||||
|
||||
// Determine the most appropriate options to run with based upon the current location.
|
||||
if (grunt.file.isMatch('**/yui/**/*.js', src)) {
|
||||
// When passed a JS file, build our containing module (this happen with
|
||||
// watch).
|
||||
grunt.log.debug('Shifter passed a specific JS file');
|
||||
src = path.dirname(path.dirname(src));
|
||||
options.recursive = false;
|
||||
} else if (grunt.file.isMatch('**/yui/src', src)) {
|
||||
// When in a src directory --walk all modules.
|
||||
grunt.log.debug('In a src directory');
|
||||
args.push('--walk');
|
||||
options.recursive = false;
|
||||
} else if (grunt.file.isMatch('**/yui/src/*', src)) {
|
||||
// When in module, only build our module.
|
||||
grunt.log.debug('In a module directory');
|
||||
options.recursive = false;
|
||||
} else if (grunt.file.isMatch('**/yui/src/*/js', src)) {
|
||||
// When in module src, only build our module.
|
||||
grunt.log.debug('In a source directory');
|
||||
src = path.dirname(src);
|
||||
options.recursive = false;
|
||||
}
|
||||
|
||||
if (grunt.option('watch')) {
|
||||
grunt.fail.fatal('The --watch option has been removed, please use `grunt watch` instead');
|
||||
}
|
||||
|
||||
// Add the stderr option if appropriate
|
||||
if (grunt.option('verbose')) {
|
||||
args.push('--lint-stderr');
|
||||
}
|
||||
|
||||
if (grunt.option('no-color')) {
|
||||
args.push('--color=false');
|
||||
}
|
||||
|
||||
var execShifter = function() {
|
||||
|
||||
grunt.log.ok("Running shifter on " + src);
|
||||
grunt.util.spawn({
|
||||
cmd: "node",
|
||||
args: args,
|
||||
opts: {cwd: src, stdio: 'inherit', env: process.env}
|
||||
}, function(error, result, code) {
|
||||
if (code) {
|
||||
grunt.fail.fatal('Shifter failed with code: ' + code);
|
||||
} else {
|
||||
grunt.log.ok('Shifter build complete.');
|
||||
filedone();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Actually run shifter.
|
||||
if (!options.recursive) {
|
||||
execShifter();
|
||||
} else {
|
||||
// Check that there are yui modules otherwise shifter ends with exit code 1.
|
||||
if (grunt.file.expand({cwd: src}, '**/yui/src/**/*.js').length > 0) {
|
||||
args.push('--recursive');
|
||||
execShifter();
|
||||
} else {
|
||||
grunt.log.ok('No YUI modules to build.');
|
||||
filedone();
|
||||
}
|
||||
}
|
||||
}, done);
|
||||
};
|
||||
|
||||
tasks.gherkinlint = function() {
|
||||
var done = this.async(),
|
||||
options = grunt.config('gherkinlint.options');
|
||||
|
||||
var args = grunt.file.expand(options.files);
|
||||
args.unshift(path.normalize(__dirname + '/node_modules/.bin/gherkin-lint'));
|
||||
grunt.util.spawn({
|
||||
cmd: 'node',
|
||||
args: args,
|
||||
opts: {stdio: 'inherit', env: process.env}
|
||||
}, function(error, result, code) {
|
||||
// Propagate the exit code.
|
||||
done(code === 0);
|
||||
});
|
||||
};
|
||||
|
||||
tasks.startup = function() {
|
||||
// Are we in a YUI directory?
|
||||
if (path.basename(path.resolve(cwd, '../../')) == 'yui') {
|
||||
grunt.task.run('yui');
|
||||
// Are we in an AMD directory?
|
||||
} else if (inAMD) {
|
||||
grunt.task.run('amd');
|
||||
} else {
|
||||
// Run them all!.
|
||||
grunt.task.run('css');
|
||||
grunt.task.run('js');
|
||||
grunt.task.run('gherkinlint');
|
||||
}
|
||||
};
|
||||
|
||||
// On watch, we dynamically modify config to build only affected files. This
|
||||
// method is slightly complicated to deal with multiple changed files at once (copied
|
||||
// from the grunt-contrib-watch readme).
|
||||
var changedFiles = Object.create(null);
|
||||
var onChange = grunt.util._.debounce(function() {
|
||||
var files = Object.keys(changedFiles);
|
||||
grunt.config('eslint.amd.src', files);
|
||||
grunt.config('eslint.yui.src', files);
|
||||
grunt.config('uglify.amd.files', [{expand: true, src: files, rename: uglifyRename}]);
|
||||
grunt.config('shifter.options.paths', files);
|
||||
grunt.config('stylelint.less.src', files);
|
||||
grunt.config('gherkinlint.options.files', files);
|
||||
changedFiles = Object.create(null);
|
||||
}, 200);
|
||||
|
||||
grunt.event.on('watch', function(action, filepath) {
|
||||
changedFiles[filepath] = action;
|
||||
onChange();
|
||||
});
|
||||
|
||||
// Register NPM tasks.
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-less');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-eslint');
|
||||
grunt.loadNpmTasks('grunt-stylelint');
|
||||
|
||||
// Register JS tasks.
|
||||
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);
|
||||
grunt.registerTask('gherkinlint', 'Run gherkinlint against the current directory', tasks.gherkinlint);
|
||||
grunt.registerTask('ignorefiles', 'Generate ignore files for linters', tasks.ignorefiles);
|
||||
grunt.registerTask('yui', ['eslint:yui', 'shifter']);
|
||||
grunt.registerTask('amd', ['eslint:amd', 'uglify']);
|
||||
grunt.registerTask('js', ['amd', 'yui']);
|
||||
|
||||
// Register CSS taks.
|
||||
grunt.registerTask('css', ['stylelint:scss', 'stylelint:less', 'less:bootstrapbase', 'stylelint:css']);
|
||||
|
||||
// Register the startup task.
|
||||
grunt.registerTask('startup', 'Run the correct tasks for the current directory', tasks.startup);
|
||||
|
||||
// Register the default task.
|
||||
grunt.registerTask('default', ['startup']);
|
||||
};
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
MOODLE INSTALLATION
|
||||
===================
|
||||
|
||||
Here is a short summary of the installation process (which can take just a few
|
||||
minutes):
|
||||
|
||||
1. Move the Moodle files into your web directory.
|
||||
|
||||
2. Create a single database for Moodle to store all its tables in (or choose an
|
||||
existing database).
|
||||
|
||||
3. Visit your Moodle site with a browser. You should be taken to the
|
||||
install.php script, which will lead you through creating a config.php file
|
||||
and then setting up Moodle, creating an admin account etc.
|
||||
|
||||
4. Set up a cron task to call the file admin/cron.php every minute.
|
||||
|
||||
For more information, see <https://docs.moodle.org/en/Installing_Moodle>.
|
||||
|
||||
Good luck and have fun!
|
||||
@@ -1,7 +0,0 @@
|
||||
*** PLEASE DO NOT OPEN PULL REQUESTS VIA GITHUB ***
|
||||
|
||||
The moodle.git repository at Github is just a mirror of the official repository. We do not accept pull requests at Github.
|
||||
|
||||
See CONTRIBUTING.txt guidelines for how to contribute patches for Moodle. Thank you.
|
||||
|
||||
--
|
||||
+29
-21
@@ -1,28 +1,36 @@
|
||||
.-..-.
|
||||
_____ | || |
|
||||
/____/-.---_ .---. .---. .-.| || | .---.
|
||||
| | _ _ |/ _ \/ _ \/ _ || |/ __ \
|
||||
* | | | | | || |_| || |_| || |_| || || |___/
|
||||
|_| |_| |_|\_____/\_____/\_____||_|\_____)
|
||||
README $Id$
|
||||
------
|
||||
|
||||
Moodle - the world's open source learning platform
|
||||
QUICK INSTALL
|
||||
=============
|
||||
|
||||
Moodle <https://moodle.org> is a learning platform designed to provide
|
||||
educators, administrators and learners with a single robust, secure and
|
||||
integrated system to create personalised learning environments.
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
a few minutes:
|
||||
|
||||
You can download Moodle <https://download.moodle.org> and run it on your own
|
||||
web server, ask one of our Moodle Partners <https://moodle.com/partners/> to
|
||||
assist you, or have a MoodleCloud site <https://moodle.com/cloud/> set up for
|
||||
you.
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
Moodle is widely used around the world by universities, schools, companies and
|
||||
all manner of organisations and individuals.
|
||||
2) Create a single database for Moodle to store all
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
Moodle is provided freely as open source software, under the GNU General Public
|
||||
License <https://docs.moodle.org/dev/License>.
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
be taken to the install.php script, which will lead
|
||||
you through creating a config.php file and then
|
||||
setting up Moodle, creating an admin account etc.
|
||||
|
||||
Moodle is written in PHP and JavaScript and uses an SQL database for storing
|
||||
the data.
|
||||
4) Set up a cron task to call the file admin/cron.php
|
||||
every five minutes or so.
|
||||
|
||||
|
||||
For more information, see the INSTALL DOCUMENTATION:
|
||||
|
||||
http://docs.moodle.org/en/Installing_Moodle
|
||||
|
||||
A local copy can also be found in
|
||||
|
||||
lang/en_utf8/help/install.html (or your language)
|
||||
|
||||
|
||||
Good luck and have fun!
|
||||
Martin Dougiamas, Lead Developer
|
||||
|
||||
See <https://docs.moodle.org> for details of Moodle's many features.
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
MOODLE TRADEMARKS POLICY
|
||||
========================
|
||||
|
||||
The word "Moodle" is trademarked in many countries around the world. The word
|
||||
was originally an acronym: Modular Object-Oriented Dynamic Learning
|
||||
Environment. The trademark is owned by Martin Dougiamas, Founder and Director
|
||||
of Moodle.
|
||||
|
||||
The law obligates trademark owners to police their marks and prevent the use of
|
||||
confusingly similar names by third parties. Through this policy we’d like to
|
||||
make it clear how Moodle-related projects, organisations, and people can use
|
||||
the Moodle trademark. We’d also like to be clear about how use of the word is
|
||||
restricted when used to promote commercial Moodle services. We do this to
|
||||
protect the very business model that allows us to continue developing Moodle
|
||||
for you.
|
||||
|
||||
Allowed uses
|
||||
------------
|
||||
|
||||
The following uses don’t require any permission at all:
|
||||
|
||||
* Referring to the software or the Moodle project.
|
||||
* Describing your own Moodle implementation (including within corporate
|
||||
settings).
|
||||
* Describing a Moodle-based community hub.
|
||||
* Describing some software you’ve made that integrates with Moodle
|
||||
(eg a Moodle integration feature on another system).
|
||||
|
||||
Restricted uses
|
||||
---------------
|
||||
|
||||
The following uses are generally prohibited without explicit and direct
|
||||
permission being granted to you by Moodle Pty Ltd. We do this to protect the
|
||||
Moodle project from software and sites which could confuse people. Please
|
||||
contact us to ask for permission in writing.
|
||||
|
||||
* You can’t use "Moodle" in the name of your software (including Mobile apps)
|
||||
* You can’t use "Moodle" in your company name
|
||||
* You can’t use "Moodle" in your domain name
|
||||
* You can’t use "Moodle" in advertising-related keywords (such as Adsense)
|
||||
* You can’t use "Moodle" to describe services around Moodle (such as hosting,
|
||||
training, support, consulting, course creation services, theme development,
|
||||
customisation, installation, integration and certification). This applies
|
||||
even if you do not charge for the services. Note that usually only Moodle
|
||||
Partners have this permission.
|
||||
|
||||
For information about the Moodle Partner Certification Mark as well as for how
|
||||
to contact us, please see <https://moodle.com/trademarks/>.
|
||||
@@ -0,0 +1,103 @@
|
||||
|
||||
<form name="adminform" id="adminform" method="post" action="admin.php">
|
||||
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = count($admins);
|
||||
$a->items = $strexistingadmins;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = $usercount;
|
||||
$a->items = $strpotentialadmins;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple
|
||||
onFocus="document.adminform.add.disabled=true;
|
||||
document.adminform.remove.disabled=false;
|
||||
document.adminform.addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
if (count($admins) == 1) {
|
||||
$disabled = 'disabled';
|
||||
$removebuttontype = 'hidden';
|
||||
} else {
|
||||
$disabled = '';
|
||||
$removebuttontype = 'submit';
|
||||
}
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$fullname = fullname($admin, true);
|
||||
echo "<option value=\"$admin->id\" $disabled>".$fullname.", ".$admin->email."</option>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="<?php echo $removebuttontype ?>" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple
|
||||
onFocus="document.adminform.add.disabled=false;
|
||||
document.adminform.remove.disabled=true;
|
||||
document.adminform.removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
|
||||
foreach ($searchusers as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
} else {
|
||||
if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onFocus ="document.adminform.add.disabled=true;
|
||||
document.adminform.remove.disabled=true;
|
||||
document.adminform.removeselect.selectedIndex=-1;
|
||||
document.adminform.addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
document.adminform.previoussearch.value=1;
|
||||
document.adminform.submit();
|
||||
} " />
|
||||
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign administrative rights to users
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// If you want any administrator to have the ability to assign admin
|
||||
/// rights, then comment out the following if statement
|
||||
if ($primaryadmin->id != $USER->id) {
|
||||
error("You must be the primary administrator to use this page.");
|
||||
}
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
$stringstoload = array (
|
||||
"assignadmins",
|
||||
"administration",
|
||||
"existingadmins",
|
||||
"potentialadmins",
|
||||
"search",
|
||||
"users",
|
||||
"searchresults",
|
||||
"showall"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
$strstringtoload = "str" . $stringtoload;
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassignadmins",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strassignadmins", "adminform.searchtext");
|
||||
|
||||
|
||||
if (!$frm = data_submitted()) {
|
||||
print_simple_box("<center>".get_string("adminhelpassignadmins")."</center>", "center", "50%");
|
||||
|
||||
/// A form was submitted so process the input
|
||||
|
||||
} else {
|
||||
if (!empty($frm->add) and !empty($frm->addselect)) {
|
||||
foreach ($frm->addselect as $addadmin) {
|
||||
if (! add_admin($addadmin)) {
|
||||
error("Could not add admin with user id $addadmin!");
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
|
||||
$admins = get_admins();
|
||||
if (count($admins) > count($frm->removeselect)) {
|
||||
foreach ($frm->removeselect as $removeadmin) {
|
||||
if (! remove_admin($removeadmin)) {
|
||||
error("Could not remove admin with user id $removeadmin!");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->showall)) {
|
||||
unset($frm->searchtext);
|
||||
$frm->previoussearch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Is there a current search?
|
||||
$previoussearch = (!empty($frm->search) or (isset($frm->previoussearch) and $frm->previoussearch == 1)) ;
|
||||
|
||||
/// Get all existing admins
|
||||
$admins = get_admins();
|
||||
|
||||
|
||||
$adminarray = array();
|
||||
foreach ($admins as $admin) {
|
||||
$adminarray[] = $admin->id;
|
||||
}
|
||||
$adminlist = implode(',', $adminarray);
|
||||
|
||||
unset($adminarray);
|
||||
|
||||
|
||||
/// Get search results excluding any current admins
|
||||
if (!empty($frm->searchtext) and $previoussearch) {
|
||||
$searchusers = get_users(true, $frm->searchtext, true, $adminlist, 'firstname ASC, lastname ASC',
|
||||
'', '', 0, 99999, 'id, firstname, lastname, email');
|
||||
$usercount = get_users(false, '', true, $adminlist);
|
||||
}
|
||||
|
||||
/// If no search results then get potential users excluding current admins
|
||||
if (empty($searchusers)) {
|
||||
|
||||
$usercount = get_users(false, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email');
|
||||
|
||||
$users = array();
|
||||
|
||||
if ($usercount <= MAX_USERS_PER_PAGE) {
|
||||
if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email') ) {
|
||||
$users = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
|
||||
$previoussearch = ($previoussearch) ? '1' : '0';
|
||||
|
||||
include('./admin.html');
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Admin settings search form
|
||||
*
|
||||
* @package admin
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
/**
|
||||
* Admin settings search form
|
||||
*
|
||||
* @package admin
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_settings_search_form extends moodleform {
|
||||
function definition () {
|
||||
$mform = $this->_form;
|
||||
|
||||
//$mform->addElement('header', 'settingsheader', get_string('search', 'admin'));
|
||||
$elements = [];
|
||||
$elements[] = $mform->createElement('text', 'query', get_string('query', 'admin'));
|
||||
$elements[] = $mform->createElement('submit', 'search', get_string('search'));
|
||||
$mform->addGroup($elements);
|
||||
$mform->setType('query', PARAM_RAW);
|
||||
$mform->setDefault('query', optional_param('query', '', PARAM_RAW));
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows admin to configure antiviruses.
|
||||
*
|
||||
* @package core_antivirus
|
||||
* @copyright 2015 Ruslan Kabalin, Lancaster University.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$antivirus = required_param('antivirus', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/antiviruses.php', array('action' => $action, 'antivirus' => $antivirus));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageantiviruses";
|
||||
|
||||
// Get currently installed and enabled antivirus plugins.
|
||||
$availableantiviruses = \core\antivirus\manager::get_available();
|
||||
if (!empty($antivirus) and empty($availableantiviruses[$antivirus])) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
|
||||
$activeantiviruses = explode(',', $CFG->antiviruses);
|
||||
foreach ($activeantiviruses as $key => $active) {
|
||||
if (empty($availableantiviruses[$active])) {
|
||||
unset($activeantiviruses[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
// Remove from enabled list.
|
||||
$key = array_search($antivirus, $activeantiviruses);
|
||||
unset($activeantiviruses[$key]);
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
// Add to enabled list.
|
||||
if (!in_array($antivirus, $activeantiviruses)) {
|
||||
$activeantiviruses[] = $antivirus;
|
||||
$activeantiviruses = array_unique($activeantiviruses);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($antivirus, $activeantiviruses);
|
||||
// Check auth plugin is valid.
|
||||
if ($key !== false) {
|
||||
// Move down the list.
|
||||
if ($key < (count($activeantiviruses) - 1)) {
|
||||
$fsave = $activeantiviruses[$key];
|
||||
$activeantiviruses[$key] = $activeantiviruses[$key + 1];
|
||||
$activeantiviruses[$key + 1] = $fsave;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key = array_search($antivirus, $activeantiviruses);
|
||||
// Check auth is valid.
|
||||
if ($key !== false) {
|
||||
// Move up the list.
|
||||
if ($key >= 1) {
|
||||
$fsave = $activeantiviruses[$key];
|
||||
$activeantiviruses[$key] = $activeantiviruses[$key - 1];
|
||||
$activeantiviruses[$key - 1] = $fsave;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
set_config('antiviruses', implode(',', $activeantiviruses));
|
||||
core_plugin_manager::reset_caches();
|
||||
|
||||
redirect ($returnurl);
|
||||
+325
-96
@@ -1,105 +1,334 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
/**
|
||||
* Allows admin to edit all auth plugin settings.
|
||||
*
|
||||
* JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
|
||||
*
|
||||
*/
|
||||
require_once('../config.php');
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_login();
|
||||
|
||||
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$PAGE->set_url($returnurl);
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$auth = optional_param('auth', '', PARAM_PLUGIN);
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
$authsenabled = array();
|
||||
} else {
|
||||
$authsenabled = explode(',', $CFG->auth);
|
||||
$focus = '';
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
$config = (array)$config;
|
||||
|
||||
// extract and sanitize the auth key explicitly
|
||||
$modules = get_list_of_plugins("auth");
|
||||
if (in_array($config['auth'], $modules)) {
|
||||
$auth = $config['auth'];
|
||||
} else {
|
||||
notify("Error defining the authentication method");
|
||||
}
|
||||
|
||||
// load the auth plugin library
|
||||
require_once("{$CFG->dirroot}/auth/$auth/lib.php");
|
||||
|
||||
$err = array();
|
||||
if (function_exists('auth_validate_form')) {
|
||||
auth_validate_form($config, $err);
|
||||
}
|
||||
|
||||
if (count($err) == 0) {
|
||||
foreach ($config as $name => $value) {
|
||||
if (preg_match('/^pluginconfig_(.+?)$/', $name, $matches)) {
|
||||
$plugin = "auth/$auth";
|
||||
$name = $matches[1];
|
||||
if (! set_config($name, $value, $plugin)) {
|
||||
notify("Problem saving config $name as $value for plugin $plugin");
|
||||
}
|
||||
} else { // normal handling for
|
||||
if (! set_config($name, $value)) {
|
||||
notify("Problem saving config $name as $value");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect("auth.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
}
|
||||
|
||||
$modules = get_list_of_plugins("auth");
|
||||
$options = array();
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("auth_$module"."title", "auth");
|
||||
}
|
||||
asort($options);
|
||||
if (!empty($auth) && in_array($auth, $modules)) {
|
||||
} else {
|
||||
$auth = $config->auth;
|
||||
}
|
||||
|
||||
// changepassword link replaced by individual auth setting
|
||||
if (!empty($config->changepassword)) {
|
||||
if (empty($config->{'auth_'.$auth.'_changepasswordurl'})) {
|
||||
$config->{'auth_'.$auth.'_changepasswordurl'} = $config->changepassword;
|
||||
}
|
||||
set_config('changepassword','');
|
||||
}
|
||||
|
||||
$auth = clean_param($auth,PARAM_SAFEDIR);
|
||||
require_once("$CFG->dirroot/auth/$auth/lib.php"); //just to make sure that current authentication functions are loaded
|
||||
if (! isset($config->guestloginbutton)) {
|
||||
$config->guestloginbutton = 1;
|
||||
}
|
||||
if (! isset($config->alternateloginurl)) {
|
||||
$config->alternateloginurl = '';
|
||||
}
|
||||
if (! isset($config->auth_instructions)) {
|
||||
$config->auth_instructions = "";
|
||||
}
|
||||
if (! isset($config->changepassword)) {
|
||||
$config->changepassword = "";
|
||||
}
|
||||
if (! isset($config->{'auth_'.$auth.'_changepasswordurl'})) {
|
||||
$config->{'auth_'.$auth.'_changepasswordurl'} = '';
|
||||
}
|
||||
if (! isset($config->{'auth_'.$auth.'_changepasswordhelp'})) {
|
||||
$config->{'auth_'.$auth.'_changepasswordhelp'} = '';
|
||||
}
|
||||
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
|
||||
$createoptions[0] = get_string("no");
|
||||
$createoptions[1] = get_string("yes");
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strauthentication = get_string("authentication");
|
||||
$strauthenticationoptions = get_string("authenticationoptions","auth");
|
||||
$strsettings = get_string("settings");
|
||||
$strusers = get_string("users");
|
||||
|
||||
print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strauthenticationoptions", "$focus");
|
||||
|
||||
echo "<center><b>";
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
print_string("chooseauthmethod","auth");
|
||||
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
|
||||
echo "</b></center>";
|
||||
|
||||
print_simple_box_start("center", "100%");
|
||||
print_heading($options[$auth]);
|
||||
|
||||
print_simple_box_start("center", "60%", '', 5, 'informationbox');
|
||||
print_string("auth_$auth"."description", "auth");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
print_heading($strsettings);
|
||||
|
||||
echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
|
||||
|
||||
require_once("$CFG->dirroot/auth/$auth/config.html");
|
||||
$CFG->pagepath = 'auth/' . $auth;
|
||||
|
||||
echo '<tr><td colspan="3">';
|
||||
print_heading(get_string('auth_common_settings', 'auth'));
|
||||
echo '<td/></tr>';
|
||||
|
||||
if ($auth != "email" and $auth != "none" and $auth != "manual") {
|
||||
// display box for URL to change password. NB now on a per-method basis (multiple auth)
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\" nowrap=\"nowrap\">";
|
||||
print_string("changepassword", "auth");
|
||||
echo ":</td>";
|
||||
echo "<td>";
|
||||
$passurl = $config->{'auth_'.$auth.'_changepasswordurl'};
|
||||
echo "<input type=\"text\" name=\"auth_{$auth}_changepasswordurl\" size=\"40\" value=\"$passurl\" />";
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("auth_changepasswordurl_expl","auth",$auth);
|
||||
echo "</td></tr>";
|
||||
|
||||
// display textbox for lost password help. NB now on a per-method basis (multiple auth)
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\" nowrap=\"nowrap\">";
|
||||
print_string("auth_changepasswordhelp", "auth");
|
||||
echo ":</td>";
|
||||
echo "<td>";
|
||||
$passhelp = $config->{'auth_'.$auth.'_changepasswordhelp'};
|
||||
echo "<textarea name=\"auth_{$auth}_changepasswordhelp\" cols=\"30\" rows=\"10\" wrap=\"virtual\">";
|
||||
echo $passhelp;
|
||||
echo "</textarea>\n";
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("auth_changepasswordhelp_expl","auth",$auth);
|
||||
echo "</td></tr>";
|
||||
|
||||
}
|
||||
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\" nowrap=\"nowrap\">";
|
||||
print_string("guestloginbutton", "auth");
|
||||
echo ":</td>";
|
||||
echo "<td>";
|
||||
choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("showguestlogin","auth");
|
||||
echo "</td></tr>";
|
||||
|
||||
if (function_exists('auth_user_create')){
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\" nowrap=\"nowrap\">";
|
||||
print_string("auth_user_create", "auth");
|
||||
echo ":</td>";
|
||||
echo "<td>";
|
||||
choose_from_menu($createoptions, "auth_user_create", $config->auth_user_create, "");
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("auth_user_creation","auth");
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
/// An alternate url for the login form. It means we can use login forms that are integrated
|
||||
/// into non-moodle pages
|
||||
echo '<tr valign="top">';
|
||||
echo '<td algin="right" nowrap="nowrap">';
|
||||
print_string('alternateloginurl', 'auth');
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
echo '<input type="text" size="40" name="alternateloginurl" alt="'.get_string('alternateloginurl', 'auth').'" value="'.$config->alternateloginurl.'" />';
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
print_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot.'/login/index.php'));
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
echo '</table>';
|
||||
echo '<p align="center"><input type="submit" value="'.get_string('savechanges').'"></p>';
|
||||
echo '</form>';
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Good enough for most auth plugins
|
||||
// but some may want a custom one if they are offering
|
||||
// other options
|
||||
// Note: pluginconfig_ fields have special handling.
|
||||
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
|
||||
|
||||
echo '<tr><td colspan="3">';
|
||||
if ($retrieveopts) {
|
||||
print_heading(get_string('auth_data_mapping', 'auth'));
|
||||
} else {
|
||||
print_heading(get_string('auth_fieldlocks', 'auth'));
|
||||
}
|
||||
echo '<td/></tr>';
|
||||
|
||||
$lockoptions = array ('unlocked' => get_string('unlocked', 'auth'),
|
||||
'unlockedifempty' => get_string('unlockedifempty', 'auth'),
|
||||
'locked' => get_string('locked', 'auth'));
|
||||
$updatelocaloptions = array('oncreate' => get_string('update_oncreate', 'auth'),
|
||||
'onlogin' => get_string('update_onlogin', 'auth'));
|
||||
$updateextoptions = array('0' => get_string('update_never', 'auth'),
|
||||
'1' => get_string('update_onupdate', 'auth'));
|
||||
|
||||
$pluginconfig = get_config("auth/$auth");
|
||||
|
||||
// helptext is on a field with rowspan
|
||||
if (empty($helptext)) {
|
||||
$helptext = ' ';
|
||||
}
|
||||
|
||||
foreach ($user_fields as $field) {
|
||||
|
||||
// Define some vars we'll work with
|
||||
if(empty($pluginconfig->{"field_map_$field"})) {
|
||||
$pluginconfig->{"field_map_$field"} = '';
|
||||
}
|
||||
if(empty($pluginconfig->{"field_updatelocal_$field"})) {
|
||||
$pluginconfig->{"field_updatelocal_$field"} = '';
|
||||
}
|
||||
if (empty($pluginconfig->{"field_updateremote_$field"})) {
|
||||
$pluginconfig->{"field_updateremote_$field"} = '';
|
||||
}
|
||||
if (empty($pluginconfig->{"field_lock_$field"})) {
|
||||
$pluginconfig->{"field_lock_$field"} = '';
|
||||
}
|
||||
|
||||
// define the fieldname we display to the user
|
||||
$fieldname = $field;
|
||||
if ($fieldname === 'lang') {
|
||||
$fieldname = get_string('language');
|
||||
} elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
|
||||
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
|
||||
} else {
|
||||
$fieldname = get_string($fieldname);
|
||||
}
|
||||
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo $fieldname;
|
||||
echo '</td><td>';
|
||||
|
||||
if ($retrieveopts) {
|
||||
$varname = 'field_map_' . $field;
|
||||
|
||||
echo "<input name=\"pluginconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\">";
|
||||
echo '<div align="right">';
|
||||
echo get_string('auth_updatelocal', 'auth') . ' ';
|
||||
choose_from_menu($updatelocaloptions, "pluginconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, "");
|
||||
echo '<br />';
|
||||
if ($updateopts) {
|
||||
echo get_string('auth_updateremote', 'auth') . ' ';
|
||||
' ';
|
||||
choose_from_menu($updateextoptions, "pluginconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, "");
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo get_string('auth_fieldlock', 'auth') . ' ';
|
||||
choose_from_menu($lockoptions, "pluginconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
echo '</div>';
|
||||
} else {
|
||||
choose_from_menu($lockoptions, "pluginconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
}
|
||||
echo '</td>';
|
||||
if (!empty($helptext)) {
|
||||
echo '<td rowspan="' . count($user_fields) . '">' . $helptext . '</td>';
|
||||
$helptext = '';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
// remove from enabled list
|
||||
$key = array_search($auth, $authsenabled);
|
||||
if ($key !== false) {
|
||||
unset($authsenabled[$key]);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
|
||||
if ($auth == $CFG->registerauth) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
// add to enabled list
|
||||
if (!in_array($auth, $authsenabled)) {
|
||||
$authsenabled[] = $auth;
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
}
|
||||
// move down the list
|
||||
if ($key < (count($authsenabled) - 1)) {
|
||||
$fsave = $authsenabled[$key];
|
||||
$authsenabled[$key] = $authsenabled[$key + 1];
|
||||
$authsenabled[$key + 1] = $fsave;
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
}
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
$fsave = $authsenabled[$key];
|
||||
$authsenabled[$key] = $authsenabled[$key - 1];
|
||||
$authsenabled[$key - 1] = $fsave;
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
redirect($returnurl);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Edit configuration for an individual auth plugin
|
||||
*/
|
||||
|
||||
require_once '../config.php';
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
|
||||
$auth = required_param('auth', PARAM_PLUGIN);
|
||||
$PAGE->set_pagetype('admin-auth-' . $auth);
|
||||
|
||||
admin_externalpage_setup('authsetting'.$auth);
|
||||
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
$err = array();
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
|
||||
debugging("Use of config.html files in authentication plugins have been deprecated. " .
|
||||
" Please migrate your plugin to use the admin settings API", DEBUG_DEVELOPER);
|
||||
|
||||
// save configuration changes
|
||||
if ($frm = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$authplugin->validate_form($frm, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
|
||||
// save plugin config
|
||||
if ($authplugin->process_config($frm)) {
|
||||
|
||||
// save field lock configuration
|
||||
foreach ($frm as $name => $value) {
|
||||
if (preg_match('/^lockconfig_(.+?)$/', $name, $matches)) {
|
||||
$plugin = "auth/$auth";
|
||||
$name = $matches[1];
|
||||
set_config($name, $value, $plugin);
|
||||
}
|
||||
}
|
||||
redirect($returnurl);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$frmlegacystyle = get_config('auth/'.$auth);
|
||||
$frmnewstyle = get_config('auth_'.$auth);
|
||||
$frm = (object)array_merge((array)$frmlegacystyle, (array)$frmnewstyle);
|
||||
}
|
||||
|
||||
$user_fields = $authplugin->userfields;
|
||||
//$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "institution", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
|
||||
/// Get the auth title (from core or own auth lang files)
|
||||
$authtitle = $authplugin->get_title();
|
||||
/// Get the auth descriptions (from core or own auth lang files)
|
||||
$authdescription = $authplugin->get_description();
|
||||
|
||||
// output configuration form
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// choose an authentication method
|
||||
echo "<form id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
|
||||
echo "<div>\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"auth\" value=\"".$auth."\" />\n";
|
||||
|
||||
// auth plugin description
|
||||
echo $OUTPUT->box_start();
|
||||
echo $OUTPUT->heading($authtitle);
|
||||
echo $OUTPUT->box_start('informationbox');
|
||||
echo $authdescription;
|
||||
echo $OUTPUT->box_end();
|
||||
echo "<hr />\n";
|
||||
$authplugin->config_form($frm, $err, $user_fields);
|
||||
echo $OUTPUT->box_end();
|
||||
echo '<p style="text-align: center"><input type="submit" value="' . get_string("savechanges") . "\" /></p>\n";
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
$PAGE->requires->string_for_js('unmaskpassword', 'core_form');
|
||||
$PAGE->requires->yui_module('moodle-auth-passwordunmask', 'M.auth.passwordunmask');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* auth field locking
|
||||
* Good enough for most auth plugins
|
||||
* but some may want a custom one if they are offering
|
||||
* other options
|
||||
* Note: lockconfig_ fields have special handling.
|
||||
*
|
||||
* @param string $auth authentication plugin shortname
|
||||
* @param array $user_fields user profile fields
|
||||
* @param string $helptext help text to be displayed at top of form
|
||||
* @param boolean $retrieveopts Map fields or lock only.
|
||||
* @param boolean $updateopts Allow remote updates
|
||||
* @param array $customfields list of custom profile fields
|
||||
* @deprecated since Moodle 3.3
|
||||
*/
|
||||
function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts, $updateopts, $customfields = array()) {
|
||||
global $DB, $OUTPUT;
|
||||
debugging("The function 'print_auth_lock_options' has been deprecated, " .
|
||||
"Please migrate your code to use the admin settings API and use the function 'display_auth_lock_options' instead. ",
|
||||
DEBUG_DEVELOPER);
|
||||
|
||||
echo '<tr><td colspan="3">';
|
||||
if ($retrieveopts) {
|
||||
echo $OUTPUT->heading(get_string('auth_data_mapping', 'auth'));
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('auth_fieldlocks', 'auth'));
|
||||
}
|
||||
echo '</td></tr>';
|
||||
|
||||
$lockoptions = array ('unlocked' => get_string('unlocked', 'auth'),
|
||||
'unlockedifempty' => get_string('unlockedifempty', 'auth'),
|
||||
'locked' => get_string('locked', 'auth'));
|
||||
$updatelocaloptions = array('oncreate' => get_string('update_oncreate', 'auth'),
|
||||
'onlogin' => get_string('update_onlogin', 'auth'));
|
||||
$updateextoptions = array('0' => get_string('update_never', 'auth'),
|
||||
'1' => get_string('update_onupdate', 'auth'));
|
||||
|
||||
$pluginconfig = get_config("auth/$auth");
|
||||
|
||||
// Helptext is on a field with rowspan.
|
||||
if (empty($helptext)) {
|
||||
$helptext = ' ';
|
||||
}
|
||||
|
||||
// If we have custom fields then merge them with user fields.
|
||||
if (!empty($customfields)) {
|
||||
$user_fields = array_merge($user_fields, $customfields);
|
||||
}
|
||||
|
||||
if (!empty($customfields)) {
|
||||
$customfieldname = $DB->get_records('user_info_field', null, '', 'shortname, name');
|
||||
}
|
||||
foreach ($user_fields as $field) {
|
||||
// Define some vars we'll work with.
|
||||
if (!isset($pluginconfig->{"field_map_$field"})) {
|
||||
$pluginconfig->{"field_map_$field"} = '';
|
||||
}
|
||||
if (!isset($pluginconfig->{"field_updatelocal_$field"})) {
|
||||
$pluginconfig->{"field_updatelocal_$field"} = '';
|
||||
}
|
||||
if (!isset($pluginconfig->{"field_updateremote_$field"})) {
|
||||
$pluginconfig->{"field_updateremote_$field"} = '';
|
||||
}
|
||||
if (!isset($pluginconfig->{"field_lock_$field"})) {
|
||||
$pluginconfig->{"field_lock_$field"} = '';
|
||||
}
|
||||
|
||||
// Define the fieldname we display to the user.
|
||||
$fieldname = $field;
|
||||
if ($fieldname === 'lang') {
|
||||
$fieldname = get_string('language');
|
||||
} elseif (!empty($customfields) && in_array($field, $customfields)) {
|
||||
// If custom field then pick name from database.
|
||||
$fieldshortname = str_replace('profile_field_', '', $fieldname);
|
||||
$fieldname = $customfieldname[$fieldshortname]->name;
|
||||
if (core_text::strlen($fieldshortname) > 67) {
|
||||
// If custom profile field name is longer than 67 characters we will not be able to store the setting
|
||||
// such as 'field_updateremote_profile_field_NOTSOSHORTSHORTNAME' in the database because the character
|
||||
// limit for the setting name is 100.
|
||||
continue;
|
||||
}
|
||||
} elseif ($fieldname == 'url') {
|
||||
$fieldname = get_string('webpage');
|
||||
} else {
|
||||
$fieldname = get_string($fieldname);
|
||||
}
|
||||
if ($retrieveopts) {
|
||||
$varname = 'field_map_' . $field;
|
||||
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="lockconfig_'.$varname.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
|
||||
echo "<input id=\"lockconfig_{$varname}\" name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\" />";
|
||||
echo '<div style="text-align: right">';
|
||||
echo '<label for="menulockconfig_field_updatelocal_'.$field.'">'.get_string('auth_updatelocal', 'auth') . '</label> ';
|
||||
echo html_writer::select($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, false);
|
||||
echo '<br />';
|
||||
if ($updateopts) {
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
echo html_writer::select($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, false);
|
||||
echo '<br />';
|
||||
}
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
|
||||
}
|
||||
echo '</td>';
|
||||
if (!empty($helptext)) {
|
||||
echo '<td rowspan="' . count($user_fields) . '">' . $helptext . '</td>';
|
||||
$helptext = '';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?PHP // $Id$
|
||||
// backup.php - allows admin to edit all configuration variables for scheduled backups
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("../backup/lib.php");
|
||||
require_once("../backup/backup_scheduled.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only an admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
//Initialise error variables
|
||||
$error = false;
|
||||
$sche_destination_error = "";
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (($config = data_submitted()) && confirm_sesskey()) {
|
||||
|
||||
//First of all we check that everything is correct
|
||||
//Check for trailing slash and backslash in backup_sche_destination
|
||||
if (!empty($backup_sche_destination) and
|
||||
(substr($backup_sche_destination,-1) == "/" or substr($backup_sche_destination,-1) == "\\")) {
|
||||
$error = true;
|
||||
$sche_destination_error = get_string("pathslasherror");
|
||||
//Now check that backup_sche_destination dir exists
|
||||
} else if (!empty($backup_sche_destination) and
|
||||
!is_dir($backup_sche_destination)) {
|
||||
$error = true;
|
||||
$sche_destination_error = get_string("pathnotexists");
|
||||
}
|
||||
|
||||
//We need to do some weekdays conversions prior to continue
|
||||
$i = 0;
|
||||
$temp = "";
|
||||
$a_config = (array)$config;
|
||||
while ($i<7) {
|
||||
$tocheck = "dayofweek_".$i;
|
||||
if (isset($a_config[$tocheck])) {
|
||||
$temp .= "1";
|
||||
} else {
|
||||
$temp .= "0";
|
||||
}
|
||||
unset($a_config[$tocheck]);
|
||||
$i++;
|
||||
}
|
||||
$a_config['backup_sche_weekdays'] = $temp;
|
||||
$config = (object)$a_config;
|
||||
//weekdays conversions done. Continue
|
||||
|
||||
foreach ($config as $name => $value) {
|
||||
backup_set_config($name, $value);
|
||||
}
|
||||
|
||||
//And now, we execute schedule_backup_next_execution() for each course in the server to have the next
|
||||
//execution time updated automatically everytime it's changed.
|
||||
$status = true;
|
||||
//get admin
|
||||
$admin = get_admin();
|
||||
if (!$admin) {
|
||||
$status = false;
|
||||
}
|
||||
//get backup config
|
||||
if (! $backup_config = backup_get_config()) {
|
||||
$status = false;
|
||||
}
|
||||
if ($status) {
|
||||
//get courses
|
||||
if ($courses = get_records('course', '', '', '', 'id,shortname')) {
|
||||
//For each course, we check (insert, update) the backup_course table
|
||||
//with needed data
|
||||
foreach ($courses as $course) {
|
||||
//We check if the course exists in backup_course
|
||||
$backup_course = get_record("backup_courses","courseid",$course->id);
|
||||
//If it doesn't exist, create
|
||||
if (!$backup_course) {
|
||||
$temp_backup_course->courseid = $course->id;
|
||||
$newid = insert_record("backup_courses",$temp_backup_course);
|
||||
//And get it from db
|
||||
$backup_course = get_record("backup_courses","id",$newid);
|
||||
}
|
||||
//Now, calculate next execution of the course
|
||||
$nextstarttime = schedule_backup_next_execution ($backup_course,$backup_config,time(),$admin->timezone);
|
||||
//Save it to db
|
||||
set_field("backup_courses","nextstarttime",$nextstarttime,"courseid",$backup_course->courseid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strbackup = get_string("backup");
|
||||
|
||||
print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
$strbackup);
|
||||
|
||||
echo "<p align=\"right\"><a href=\"../backup/log.php\">".get_string("logs")."</a></p>";
|
||||
|
||||
print_heading($strbackup);
|
||||
|
||||
print_simple_box("<center>".get_string("adminhelpbackup")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center");
|
||||
|
||||
//Check for required functions...
|
||||
if (!function_exists('utf8_encode')) {
|
||||
notify("You need to add XML support to your PHP installation");
|
||||
}
|
||||
include ("$CFG->dirroot/backup/config.html");
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,85 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// block.php - allows admin to edit all local configuration variables for a block
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only an admin can use this page');
|
||||
}
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
|
||||
if(($blockrecord = blocks_get_record($blockid)) === false) {
|
||||
error('This block does not exist');
|
||||
}
|
||||
|
||||
$block = block_instance($blockrecord->name);
|
||||
if($block === false) {
|
||||
error('Problem in instantiating block object');
|
||||
}
|
||||
|
||||
// Define the data we're going to silently include in the instance config form here,
|
||||
// so we can strip them from the submitted data BEFORE handling it.
|
||||
$hiddendata = array(
|
||||
'block' => $blockid,
|
||||
'sesskey' => $USER->sesskey
|
||||
);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
error('This block does not support global configuration');
|
||||
}
|
||||
$remove = array_keys($hiddendata);
|
||||
foreach($remove as $item) {
|
||||
unset($config->$item);
|
||||
}
|
||||
$block->config_save($config);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'block/' . $block->name() . '/config';
|
||||
|
||||
print_header($site->shortname.': '.$strblockname.": $strconfiguration", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"blocks.php\">$strmanageblocks</a> -> ".$strblockname);
|
||||
|
||||
print_heading($strblockname);
|
||||
|
||||
print_simple_box('<center>'.get_string('configwarning', 'admin').'</center>', 'center', '50%');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
echo '<p>';
|
||||
foreach($hiddendata as $name => $val) {
|
||||
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
|
||||
}
|
||||
echo '</p>';
|
||||
$block->config_print();
|
||||
echo '</form>';
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+161
-159
@@ -1,238 +1,240 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure blocks (hide/show, uninstall and configure)
|
||||
// Allows the admin to configure blocks (hide/show, delete and configure)
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('manageblocks');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$unprotect = optional_param('unprotect', 0, PARAM_INT);
|
||||
$protect = optional_param('protect', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
$strdelete = get_string('delete');
|
||||
$strversion = get_string('version');
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
$strsettings = get_string('settings');
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
$strprotecthdr = get_string('blockprotect', 'admin'). $OUTPUT->help_icon('blockprotect','admin');
|
||||
$strprotect = get_string('blockprotect', 'admin');
|
||||
$strunprotect = get_string('blockunprotect', 'admin');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
|
||||
print_header("$site->shortname: $strmanageblocks", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanageblocks");
|
||||
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) && confirm_sesskey()) {
|
||||
if (!$block = $DB->get_record('block', array('id'=>$hide))) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
if (!$block = get_record('block', 'id', $hide)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
|
||||
add_to_config_log('block_visibility', $block->visible, '0', $block->name);
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
set_field('block', 'visible', '0', 'id', $block->id); // Hide block
|
||||
}
|
||||
|
||||
if (!empty($show) && confirm_sesskey() ) {
|
||||
if (!$block = $DB->get_record('block', array('id'=>$show))) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
if (!$block = get_record('block', 'id', $show)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
|
||||
add_to_config_log('block_visibility', $block->visible, '1', $block->name);
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
set_field('block', 'visible', '1', 'id', $block->id); // Show block
|
||||
}
|
||||
|
||||
if (!empty($protect) && confirm_sesskey()) {
|
||||
block_manager::protect_block((int)$protect);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
if (!empty($multiple) && confirm_sesskey()) {
|
||||
if (!$block = blocks_get_record($multiple)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
}
|
||||
|
||||
if (!empty($unprotect) && confirm_sesskey()) {
|
||||
block_manager::unprotect_block((int)$unprotect);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
|
||||
if (!block_is_compatible($block->name)) {
|
||||
$strblockname = $block->name;
|
||||
}
|
||||
else {
|
||||
$blockobject = block_instance($block->name);
|
||||
$strblockname = $blockobject->get_title();
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php');
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// Delete block
|
||||
if (!delete_records('block', 'id', $block->id)) {
|
||||
notify("Error occurred while deleting the $strblockname record from blocks table");
|
||||
}
|
||||
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$block->name;
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table, $prefix) === 0) {
|
||||
if (!execute_sql("DROP TABLE $table", false)) {
|
||||
notify("ERROR: while trying to drop table $table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$a->block = $strblockname;
|
||||
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
|
||||
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
|
||||
}
|
||||
}
|
||||
|
||||
$undeletableblocktypes = block_manager::get_undeletable_block_types();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
|
||||
/// Main display starts here
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (!$blocks = $DB->get_records('block', array(), 'name ASC')) {
|
||||
print_error('noblocks', 'error'); // Should never happen
|
||||
if (false === ($blocks = get_records('block'))) {
|
||||
error('No blocks found!'); // Should never happen
|
||||
}
|
||||
|
||||
$incompatible = array();
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
notify('Block '. $block->name .' is not compatible with the current version of Mooodle and needs to be updated by a programmer.');
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
if(($blockobject = block_instance($block->name)) === false) {
|
||||
// Failed to load
|
||||
continue;
|
||||
}
|
||||
$blockbyname[$blockobject->get_title()] = $block->id;
|
||||
$blockobjects[$block->id] = $blockobject;
|
||||
}
|
||||
|
||||
if(empty($blockbyname)) {
|
||||
error('One or more blocks are registered in the database, but they all failed to load!');
|
||||
}
|
||||
|
||||
ksort($blockbyname);
|
||||
|
||||
/// Print the table of all blocks
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strsettings, $struninstall));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'multiple', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('class', 'admintable blockstable generaltable');
|
||||
$table->set_attribute('id', 'compatibleblockstable');
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->setup();
|
||||
$tablerows = array();
|
||||
|
||||
// Sort blocks using current locale.
|
||||
$blocknames = array();
|
||||
foreach ($blocks as $blockid=>$block) {
|
||||
$blockname = $block->name;
|
||||
if (file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blocknames[$blockid] = get_string('pluginname', 'block_'.$blockname);
|
||||
} else {
|
||||
$blocknames[$blockid] = $blockname;
|
||||
}
|
||||
}
|
||||
core_collator::asort($blocknames);
|
||||
foreach ($blockbyname as $blockname => $blockid) {
|
||||
|
||||
foreach ($blocknames as $blockid=>$strblockname) {
|
||||
$block = $blocks[$blockid];
|
||||
$blockname = $block->name;
|
||||
$dbversion = get_config('block_'.$block->name, 'version');
|
||||
$blockobject = $blockobjects[$blockid];
|
||||
|
||||
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blockobject = false;
|
||||
$strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = $dbversion;
|
||||
|
||||
} else {
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = '???';
|
||||
if (file_exists("$CFG->dirroot/blocks/$blockname/version.php")) {
|
||||
include("$CFG->dirroot/blocks/$blockname/version.php");
|
||||
}
|
||||
|
||||
if (!$blockobject = block_instance($block->name)) {
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$blockname, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
} else {
|
||||
$uninstall = '';
|
||||
}
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if ($blockobject and $blockobject->has_config()) {
|
||||
$blocksettings = admin_get_root()->locate('blocksetting' . $block->name);
|
||||
|
||||
if ($blocksettings instanceof admin_externalpage) {
|
||||
$settings = '<a href="' . $blocksettings->url . '">' . get_string('settings') . '</a>';
|
||||
} else if ($blocksettings instanceof admin_settingpage) {
|
||||
$settings = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=blocksetting'.$block->name.'">'.$strsettings.'</a>';
|
||||
} else if (!file_exists($CFG->dirroot.'/blocks/'.$block->name.'/settings.php')) {
|
||||
// If the block's settings node was not found, we check that the block really provides the settings.php file.
|
||||
// Note that blocks can inject their settings to other nodes in the admin tree without using the default locations.
|
||||
// This can be done by assigning null to $setting in settings.php and it is a valid case.
|
||||
debugging('Warning: block_'.$block->name.' returns true in has_config() but does not provide a settings.php file',
|
||||
DEBUG_DEVELOPER);
|
||||
}
|
||||
if($blockobject->has_config()) {
|
||||
$settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
|
||||
}
|
||||
|
||||
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
|
||||
// and it should not show up on course search page
|
||||
|
||||
$totalcount = $DB->count_records('block_instances', array('blockname'=>$blockname));
|
||||
$count = $DB->count_records('block_instances', array('blockname'=>$blockname, 'pagetypepattern'=>'course-view-*'));
|
||||
|
||||
if ($count>0) {
|
||||
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&sesskey=".sesskey()."\" ";
|
||||
$blocklist .= "title=\"$strshowblockcourse\" >$totalcount</a>";
|
||||
}
|
||||
else {
|
||||
$blocklist = "$totalcount";
|
||||
}
|
||||
$count = count_records('block_instance', 'blockid', $blockid);
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if (!$blockobject) {
|
||||
// ignore
|
||||
$visible = '';
|
||||
} else if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.sesskey().'" title="'.$strhide.'">'.
|
||||
$OUTPUT->pix_icon('t/hide', $strhide) . '</a>';
|
||||
if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" alt="" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.sesskey().'" title="'.$strshow.'">'.
|
||||
$OUTPUT->pix_icon('t/show', $strshow) . '</a>';
|
||||
$class = 'dimmed_text';
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" alt="" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
if ($blockobject->instance_allow_multiple()) {
|
||||
if($blocks[$blockid]->multiple) {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('yes').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
else {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('no').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$multiple = '';
|
||||
}
|
||||
|
||||
if ($dbversion == $plugin->version) {
|
||||
$version = $dbversion;
|
||||
} else {
|
||||
$version = "$dbversion ($plugin->version)";
|
||||
}
|
||||
|
||||
if (!$blockobject) {
|
||||
// ignore
|
||||
$undeletable = '';
|
||||
} else if (in_array($blockname, $undeletableblocktypes)) {
|
||||
$undeletable = '<a href="blocks.php?unprotect='.$blockid.'&sesskey='.sesskey().'" title="'.$strunprotect.'">'.
|
||||
$OUTPUT->pix_icon('t/unlock', $strunprotect) . '</a>';
|
||||
} else {
|
||||
$undeletable = '<a href="blocks.php?protect='.$blockid.'&sesskey='.sesskey().'" title="'.$strprotect.'">'.
|
||||
$OUTPUT->pix_icon('t/lock', $strprotect) . '</a>';
|
||||
}
|
||||
|
||||
$row = array(
|
||||
$strblockname,
|
||||
$blocklist,
|
||||
$version,
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$blockobject->get_title().'</span>',
|
||||
$count,
|
||||
$blockobject->get_version(),
|
||||
$visible,
|
||||
$undeletable,
|
||||
$settings,
|
||||
$uninstall,
|
||||
);
|
||||
$table->add_data($row, $class);
|
||||
$multiple,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
if (!empty($incompatible)) {
|
||||
echo $OUTPUT->heading(get_string('incompatibleblocks', 'blockstable', 'admin'));
|
||||
if(!empty($incompatible)) {
|
||||
print_heading(get_string('incompatibleblocks', 'admin'));
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
$table->define_columns(array('block', 'uninstall'));
|
||||
$table->define_headers(array($strname, $struninstall));
|
||||
|
||||
$table->define_columns(array('block', 'delete'));
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('class', 'incompatibleblockstable generaltable');
|
||||
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'incompatible');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$block->name, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
} else {
|
||||
$uninstall = '';
|
||||
}
|
||||
$table->add_data(array(
|
||||
$block->name,
|
||||
$uninstall,
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>',
|
||||
));
|
||||
}
|
||||
$table->print_html();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
<form method="post" action="calendar.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<table class="formtable">
|
||||
<tr>
|
||||
<th>adminseesall:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpadminseesall', 'admin'); ?></div>
|
||||
<p>
|
||||
<select name="adminseesallcourses">
|
||||
<option value="0" <?php if(empty($CFG->calendar_adminseesall)) echo "selected='selected'"; ?>><?php print_string('adminseesownevents', 'admin'); ?></option>
|
||||
<option value="1" <?php if(!empty($CFG->calendar_adminseesall)) echo "selected='selected'"; ?>><?php print_string('adminseesallevents', 'admin'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>startwday:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpstartofweek', 'admin'); ?></div>
|
||||
<p><?php choose_from_menu($weekdays, 'startwday', empty($CFG->calendar_startwday) ? 0 : $CFG->calendar_startwday, ''); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>weekenddays:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpweekenddays', 'admin'); ?></div>
|
||||
<p>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="1" id="weekend1" <?php if(CALENDAR_WEEKEND & 2) echo 'checked="checked"'; ?> /> <label for="weekend1"><?php print_string('monday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="2" id="weekend2" <?php if(CALENDAR_WEEKEND & 4) echo 'checked="checked"'; ?> /> <label for="weekend2"><?php print_string('tuesday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="3" id="weekend3" <?php if(CALENDAR_WEEKEND & 8) echo 'checked="checked"'; ?> /> <label for="weekend3"><?php print_string('wednesday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="4" id="weekend4" <?php if(CALENDAR_WEEKEND & 16) echo 'checked="checked"'; ?> /> <label for="weekend4"><?php print_string('thursday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="5" id="weekend5" <?php if(CALENDAR_WEEKEND & 32) echo 'checked="checked"'; ?> /> <label for="weekend5"><?php print_string('friday', 'calendar'); ?></label></span>
|
||||
<br />
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="6" id="weekend6" <?php if(CALENDAR_WEEKEND & 64) echo 'checked="checked"'; ?> /> <label for="weekend6"><?php print_string('saturday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="0" id="weekend0" <?php if(CALENDAR_WEEKEND & 1) echo 'checked="checked"'; ?> /> <label for="weekend0"><?php print_string('sunday', 'calendar'); ?></label></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>upcoming_lookahead:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpupcominglookahead', 'admin'); ?></div>
|
||||
<p><input type="text" name="lookahead" size="3" value="<?php echo CALENDAR_UPCOMING_DAYS; ?>" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>upcoming_maxevents:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpupcomingmaxevents', 'admin'); ?></div>
|
||||
<p><input type="text" name="maxevents" size="3" value="<?php echo CALENDAR_UPCOMING_MAXEVENTS; ?>" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>timezones:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpforcetimezone', 'admin'); ?></div>
|
||||
<p><?php choose_from_menu($timezones, 'forcetimezone', $CFG->forcetimezone, get_string('timezonenotforced', 'admin'), '', '99'); ?></p>
|
||||
<p><a href="timezoneimport.php"><?php print_string('importtimezones', 'admin'); ?>...</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center">
|
||||
<input type="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure calendar and date/time stuff
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only administrators can use this page!');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error('Site isn\'t defined!');
|
||||
}
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strcalendarsettings = get_string('calendarsettings', 'admin');
|
||||
|
||||
print_header("$site->shortname: $strcalendarsettings", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strcalendarsettings");
|
||||
|
||||
print_heading($strcalendarsettings);
|
||||
|
||||
/// If data submitted, process and store
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
if(isset($form->adminseesallcourses)) {
|
||||
set_config('calendar_adminseesall', intval($form->adminseesallcourses) != 0);
|
||||
unset($SESSION->cal_courses_shown);
|
||||
}
|
||||
if(isset($form->forcetimezone)) {
|
||||
// To protect from SQL injections ...
|
||||
$form->timezone = clean_param($form->timezone, PARAM_PATH); //not a path, but it looks like it anyway
|
||||
set_config('forcetimezone', $form->forcetimezone);
|
||||
}
|
||||
if(isset($form->startwday)) {
|
||||
$startwday = intval($form->startwday);
|
||||
if($startwday >= 0 && $startwday <= 6) {
|
||||
set_config('calendar_startwday', $startwday);
|
||||
}
|
||||
}
|
||||
if(isset($form->weekend)) {
|
||||
if(is_array($form->weekend)) {
|
||||
// Creating a packed bitfield; look at /calendar/lib.php if you can't figure it out
|
||||
$bitfield = 0;
|
||||
foreach($form->weekend as $day) {
|
||||
$bitfield |= (1 << (intval($day) % 7));
|
||||
}
|
||||
if($bitfield > 0) {
|
||||
set_config('calendar_weekend', $bitfield);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($form->lookahead)) {
|
||||
$lookahead = intval($form->lookahead);
|
||||
if($lookahead > 0) {
|
||||
set_config('calendar_lookahead', $lookahead);
|
||||
}
|
||||
}
|
||||
if(isset($form->maxevents)) {
|
||||
$maxevents = intval($form->maxevents);
|
||||
if($maxevents > 0) {
|
||||
set_config('calendar_maxevents', $maxevents);
|
||||
}
|
||||
}
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
// Include the calendar library AFTER modifying the data, so we read the latest values
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
// Populate some variables we 're going to need in calendar.html
|
||||
$timezones = get_list_of_timezones();
|
||||
|
||||
$weekdays = array(
|
||||
0 => get_string('sunday', 'calendar'),
|
||||
1 => get_string('monday', 'calendar'),
|
||||
2 => get_string('tuesday', 'calendar'),
|
||||
3 => get_string('wednesday', 'calendar'),
|
||||
4 => get_string('thursday', 'calendar'),
|
||||
5 => get_string('friday', 'calendar'),
|
||||
6 => get_string('saturday', 'calendar')
|
||||
);
|
||||
|
||||
// Main display starts here
|
||||
|
||||
print_simple_box_start("center", "80%");
|
||||
include('./calendar.html');
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,160 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file is used to display a categories sub categories, external pages, and settings.
|
||||
*
|
||||
* @since Moodle 2.3
|
||||
* @package admin
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$category = required_param('category', PARAM_SAFEDIR);
|
||||
$return = optional_param('return','', PARAM_ALPHA);
|
||||
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
|
||||
/// no guest autologin
|
||||
require_login(0, false);
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url('/admin/category.php', array('category' => $category));
|
||||
$PAGE->set_pagetype('admin-setting-' . $category);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->navigation->clear_cache();
|
||||
|
||||
$adminroot = admin_get_root(); // need all settings
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
|
||||
if (empty($settingspage) or !($settingspage instanceof admin_category)) {
|
||||
print_error('categoryerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
}
|
||||
|
||||
if (!($settingspage->check_access())) {
|
||||
print_error('accessdenied', 'admin');
|
||||
}
|
||||
|
||||
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
$count = admin_write_settings($data);
|
||||
if (empty($adminroot->errors)) {
|
||||
// No errors. Did we change any setting? If so, then indicate success.
|
||||
if ($count) {
|
||||
$statusmsg = get_string('changessaved');
|
||||
} else {
|
||||
switch ($return) {
|
||||
case 'site': redirect("$CFG->wwwroot/");
|
||||
case 'admin': redirect("$CFG->wwwroot/$CFG->admin/");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
}
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
}
|
||||
|
||||
if ($PAGE->user_allowed_editing() && $adminediting != -1) {
|
||||
$USER->editing = $adminediting;
|
||||
}
|
||||
|
||||
if ($PAGE->user_allowed_editing()) {
|
||||
$url = clone($PAGE->url);
|
||||
if ($PAGE->user_is_editing()) {
|
||||
$caption = get_string('blockseditoff');
|
||||
$url->param('adminedit', 'off');
|
||||
} else {
|
||||
$caption = get_string('blocksediton');
|
||||
$url->param('adminedit', 'on');
|
||||
}
|
||||
$buttons = $OUTPUT->single_button($url, $caption, 'get');
|
||||
}
|
||||
|
||||
$savebutton = false;
|
||||
$outputhtml = '';
|
||||
foreach ($settingspage->children as $childpage) {
|
||||
if ($childpage->is_hidden() || !$childpage->check_access()) {
|
||||
continue;
|
||||
}
|
||||
if ($childpage instanceof admin_externalpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link($childpage->url, $childpage->visiblename), 3);
|
||||
} else if ($childpage instanceof admin_settingpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/settings.php', array('section' => $childpage->name)), $childpage->visiblename), 3);
|
||||
// If its a settings page and has settings lets display them.
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
} else if ($childpage instanceof admin_category) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/category.php', array('category' => $childpage->name)), get_string('admincategory', 'admin', $childpage->visiblename)), 3);
|
||||
}
|
||||
}
|
||||
if ($savebutton) {
|
||||
$outputhtml .= html_writer::start_tag('div', array('class' => 'form-buttons'));
|
||||
$outputhtml .= html_writer::empty_tag('input', array('class' => 'btn btn-primary form-submit', 'type' => 'submit', 'value' => get_string('savechanges','admin')));
|
||||
$outputhtml .= html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
$visiblepathtosection = array_reverse($settingspage->visiblepath);
|
||||
$PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection));
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_button($buttons);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($errormsg !== '') {
|
||||
echo $OUTPUT->notification($errormsg);
|
||||
} else if ($statusmsg !== '') {
|
||||
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
$path = array_reverse($settingspage->visiblepath);
|
||||
if (is_array($path)) {
|
||||
$visiblename = join(' / ', $path);
|
||||
} else {
|
||||
$visiblename = $path;
|
||||
}
|
||||
echo $OUTPUT->heading(get_string('admincategory', 'admin', $visiblename), 2);
|
||||
|
||||
echo html_writer::start_tag('form', array('action' => '', 'method' => 'post', 'id' => 'adminsettings'));
|
||||
echo html_writer::start_tag('div');
|
||||
echo html_writer::input_hidden_params(new moodle_url($PAGE->url, array('sesskey' => sesskey(), 'return' => $return)));
|
||||
echo html_writer::end_tag('div');
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
echo $outputhtml;
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This hack is intended for clustered sites that do not want
|
||||
* to use shared cachedir for component cache.
|
||||
*
|
||||
* This file needs to be called after any change in PHP files in dataroot,
|
||||
* that is before upgrade and install.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Petr Skoda (skodak) {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('ABORT_AFTER_CONFIG', true); // We need just the values from config.php.
|
||||
define('CACHE_DISABLE_ALL', true); // This prevents reading of existing caches.
|
||||
define('IGNORE_COMPONENT_CACHE', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'file' => false,
|
||||
'rebuild' => false,
|
||||
'print' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
|
||||
}
|
||||
|
||||
if (!$options['rebuild'] and !$options['file'] and !$options['print']) {
|
||||
$help =
|
||||
"Create alternative component cache file
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
--rebuild Rebuild \$CFG->alternative_component_cache file
|
||||
--file=filepath Save component cache to file
|
||||
--print Print component cache file content
|
||||
|
||||
Example:
|
||||
\$ php admin/cli/rebuild_alternative_component_cache.php --rebuild
|
||||
";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$content = core_component::get_cache_content();
|
||||
|
||||
if ($options['print']) {
|
||||
echo $content;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['rebuild']) {
|
||||
if (empty($CFG->alternative_component_cache)) {
|
||||
fwrite(STDERR, 'config.php does not contain $CFG->alternative_component_cache setting');
|
||||
fwrite(STDERR, "\n");
|
||||
exit(2);
|
||||
}
|
||||
$target = $CFG->alternative_component_cache;
|
||||
} else {
|
||||
$target = $options['file'];
|
||||
}
|
||||
|
||||
if (!$target) {
|
||||
fwrite(STDERR, "Invalid target file $target");
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$bytes = file_put_contents($target, $content);
|
||||
|
||||
if (!$bytes) {
|
||||
fwrite(STDERR, "Error writing to $target");
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Success.
|
||||
echo "File $target was updated\n";
|
||||
exit(0);
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automated backups CLI cron
|
||||
*
|
||||
* This script executes
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2010 Sam Hemelryk
|
||||
* @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'); // cli only functions
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Execute automated backups.
|
||||
|
||||
This script executes automated backups completely and is designed to be
|
||||
called via cron.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/automated_backups.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
if (CLI_MAINTENANCE) {
|
||||
echo "CLI maintenance mode active, backup execution suspended.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (moodle_needs_upgrading()) {
|
||||
echo "Moodle upgrade pending, backup execution suspended.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if (!empty($CFG->showcronsql)) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
}
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
/// emulate normal session
|
||||
cron_setup_user();
|
||||
|
||||
/// Start output log
|
||||
$timenow = time();
|
||||
|
||||
mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
|
||||
// Run automated backups if required.
|
||||
require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php');
|
||||
require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php');
|
||||
backup_cron_automated_helper::run_automated_backup(backup_cron_automated_helper::RUN_IMMEDIATELY);
|
||||
|
||||
mtrace("Automated cron backups completed correctly");
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script allows to do backup.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Lancaster University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', 1);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array(
|
||||
'courseid' => false,
|
||||
'courseshortname' => '',
|
||||
'destination' => '',
|
||||
'help' => false,
|
||||
), array('h' => 'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help'] || !($options['courseid'] || $options['courseshortname'])) {
|
||||
$help = <<<EOL
|
||||
Perform backup of the given course.
|
||||
|
||||
Options:
|
||||
--courseid=INTEGER Course ID for backup.
|
||||
--courseshortname=STRING Course shortname for backup.
|
||||
--destination=STRING Path where to store backup file. If not set the backup
|
||||
will be stored within the course backup file area.
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/\n
|
||||
EOL;
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
$admin = get_admin();
|
||||
if (!$admin) {
|
||||
mtrace("Error: No admin account was found");
|
||||
die;
|
||||
}
|
||||
|
||||
// Do we need to store backup somewhere else?
|
||||
$dir = rtrim($options['destination'], '/');
|
||||
if (!empty($dir)) {
|
||||
if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
|
||||
mtrace("Destination directory does not exists or not writable.");
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the course exists.
|
||||
if ($options['courseid']) {
|
||||
$course = $DB->get_record('course', array('id' => $options['courseid']), '*', MUST_EXIST);
|
||||
} else if ($options['courseshortname']) {
|
||||
$course = $DB->get_record('course', array('shortname' => $options['courseshortname']), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
cli_heading('Performing backup...');
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE,
|
||||
backup::INTERACTIVE_YES, backup::MODE_GENERAL, $admin->id);
|
||||
// Set the default filename.
|
||||
$format = $bc->get_format();
|
||||
$type = $bc->get_type();
|
||||
$id = $bc->get_id();
|
||||
$users = $bc->get_plan()->get_setting('users')->get_value();
|
||||
$anonymised = $bc->get_plan()->get_setting('anonymize')->get_value();
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $id, $users, $anonymised);
|
||||
$bc->get_plan()->get_setting('filename')->set_value($filename);
|
||||
|
||||
// Execution.
|
||||
$bc->finish_ui();
|
||||
$bc->execute_plan();
|
||||
$results = $bc->get_results();
|
||||
$file = $results['backup_destination']; // May be empty if file already moved to target location.
|
||||
|
||||
// Do we need to store backup somewhere else?
|
||||
if (!empty($dir)) {
|
||||
if ($file) {
|
||||
mtrace("Writing " . $dir.'/'.$filename);
|
||||
if ($file->copy_content_to($dir.'/'.$filename)) {
|
||||
$file->delete();
|
||||
mtrace("Backup completed.");
|
||||
} else {
|
||||
mtrace("Destination directory does not exist or is not writable. Leaving the backup in the course backup file area.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mtrace("Backup completed, the new file is listed in the backup area of the given course");
|
||||
}
|
||||
$bc->destroy();
|
||||
exit(0);
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Build and store theme CSS.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2017 Ryan Wyllie <ryan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/csslib.php");
|
||||
require_once("$CFG->libdir/outputlib.php");
|
||||
|
||||
$longparams = [
|
||||
'themes' => null,
|
||||
'direction' => null,
|
||||
'help' => false,
|
||||
'verbose' => false
|
||||
];
|
||||
|
||||
$shortmappings = [
|
||||
't' => 'themes',
|
||||
'd' => 'direction',
|
||||
'h' => 'help',
|
||||
'v' => 'verbose'
|
||||
];
|
||||
|
||||
// Get CLI params.
|
||||
list($options, $unrecognized) = cli_get_params($longparams, $shortmappings);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
echo
|
||||
"Compile the CSS for one or more installed themes.
|
||||
Existing CSS caches will replaced.
|
||||
By default all themes will be recompiled unless otherwise specified.
|
||||
|
||||
Options:
|
||||
-t, --themes A comma separated list of themes to be compiled
|
||||
-d, --direction Only compile a single direction (either ltr or rtl)
|
||||
-v, --verbose Print info comments to stdout
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/build_theme_css.php --themes=boost --direction=ltr
|
||||
";
|
||||
|
||||
die;
|
||||
}
|
||||
|
||||
if (empty($options['verbose'])) {
|
||||
$trace = new null_progress_trace();
|
||||
} else {
|
||||
$trace = new text_progress_trace();
|
||||
}
|
||||
|
||||
cli_heading('Build theme css');
|
||||
|
||||
// Determine which themes we need to build.
|
||||
$themenames = [];
|
||||
if (is_null($options['themes'])) {
|
||||
$trace->output('No themes specified. Finding all installed themes.');
|
||||
$themenames = array_keys(core_component::get_plugin_list('theme'));
|
||||
} else {
|
||||
if (is_string($options['themes'])) {
|
||||
$themenames = explode(',', $options['themes']);
|
||||
} else {
|
||||
cli_error('--themes must be a comma separated list of theme names');
|
||||
}
|
||||
}
|
||||
|
||||
$trace->output('Checking that each theme is correctly installed...');
|
||||
$themeconfigs = [];
|
||||
foreach ($themenames as $themename) {
|
||||
if (is_null(theme_get_config_file_path($themename))) {
|
||||
cli_error("Unable to find theme config for {$themename}");
|
||||
}
|
||||
|
||||
// Load the config for the theme.
|
||||
$themeconfigs[] = theme_config::load($themename);
|
||||
}
|
||||
|
||||
$directions = ['ltr', 'rtl'];
|
||||
|
||||
if (!is_null($options['direction'])) {
|
||||
if (!in_array($options['direction'], $directions)) {
|
||||
cli_error("--direction must be either ltr or rtl");
|
||||
}
|
||||
|
||||
$directions = [$options['direction']];
|
||||
}
|
||||
|
||||
$trace->output('Building CSS for themes: ' . implode(', ', $themenames));
|
||||
theme_build_css_for_themes($themeconfigs, $directions);
|
||||
|
||||
exit(0);
|
||||
@@ -1,173 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI script allowing to get and set config values.
|
||||
*
|
||||
* This is technically just a thin wrapper for {@link get_config()} and
|
||||
* {@link set_config()} functions.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2017 David Mudrák <david@moodle.com>
|
||||
* @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');
|
||||
|
||||
$usage = "Displays the current value of the given site setting. Allows to set it to the given value, too.
|
||||
|
||||
Usage:
|
||||
# php cfg.php [--component=<componentname>] [--json] [--shell-arg]
|
||||
# php cfg.php --name=<configname> [--component=<componentname>] [--shell-arg] [--no-eol]
|
||||
# php cfg.php --name=<configname> [--component=<componentname>] --set=<value>
|
||||
# php cfg.php --name=<configname> [--component=<componentname>] --unset
|
||||
# php cfg.php [--help|-h]
|
||||
|
||||
Options:
|
||||
-h --help Print this help.
|
||||
--component=<frankenstyle> Name of the component the variable is part of. Defaults to core.
|
||||
--name=<configname> Name of the configuration variable to get/set. If missing, print all
|
||||
configuration variables of the given component.
|
||||
--set=<value> Set the given variable to this value.
|
||||
--unset Unset the given variable.
|
||||
--shell-arg Escape output values so that they can be directly used as shell script arguments.
|
||||
--json Encode output list of values using JSON notation.
|
||||
--no-eol Do not include the trailing new line character when printing the value.
|
||||
|
||||
The list of all variables of the given component can be printed as
|
||||
tab-separated list (default) or JSON object (--json). Particular values are
|
||||
printed as raw text values, optionally escaped so that they can be directly
|
||||
used as shell script arguments (--shell-arg). Single values are displayed with
|
||||
trailing new line by default, unless explicitly disabled (--no-eol).
|
||||
|
||||
In the read mode, the script exits with success status 0 if the requested value
|
||||
is found. If the requested variable is not set, the script exits with status 3.
|
||||
When listing all variables of the component, the exit status is always 0 even
|
||||
if no variables for the given component are found. When setting/unsetting a
|
||||
value, the exit status is 0. When attempting to set/unset a value that has
|
||||
already been hard-set in config.php, the script exits with error status 4. In
|
||||
case of unexpected error, the script exits with error status 1.
|
||||
|
||||
Examples:
|
||||
|
||||
# php cfg.php
|
||||
Prints tab-separated list of all core configuration variables and their values.
|
||||
|
||||
# php cfg.php --json
|
||||
Prints list of all core configuration variables and their values as a JSON object.
|
||||
|
||||
# php cfg.php --name=release
|
||||
Prints the given configuration variable - e.g. \$CFG->release in this case.
|
||||
|
||||
# php cfg.php --component=tool_recyclebin
|
||||
# Prints tab-separated list of the plugin's configuration variables.
|
||||
|
||||
# export DATAROOT=\$(php cfg.php --name=dataroot --shell-arg --no-eol)
|
||||
Stores the given configuration variable in the shell variable, escaped
|
||||
so that it can be safely used as a shell argument.
|
||||
|
||||
# php cfg.php --name=theme --set=clean
|
||||
Sets the given configuration variable to the given value.
|
||||
|
||||
# php cfg.php --name=noemailever --unset
|
||||
Unsets the previously configured variable.
|
||||
";
|
||||
|
||||
list($options, $unrecognised) = cli_get_params([
|
||||
'help' => false,
|
||||
'component' => null,
|
||||
'name' => null,
|
||||
'set' => null,
|
||||
'unset' => false,
|
||||
'shell-arg' => false,
|
||||
'json' => false,
|
||||
'no-eol' => false,
|
||||
], [
|
||||
'h' => 'help'
|
||||
]);
|
||||
|
||||
if ($unrecognised) {
|
||||
$unrecognised = implode(PHP_EOL.' ', $unrecognised);
|
||||
cli_error(get_string('cliunknowoption', 'core_admin', $unrecognised));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
cli_writeln($usage);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ($options['unset'] || $options['set'] !== null) {
|
||||
// Unset the variable or set it to the given value.
|
||||
if (empty($options['name'])) {
|
||||
cli_error('Missing configuration variable name', 2);
|
||||
}
|
||||
|
||||
// Check that the variable is not hard-set in the main config.php already.
|
||||
if (array_key_exists($options['name'], $CFG->config_php_settings)) {
|
||||
cli_error('The configuration variable is hard-set in the config.php, unable to change.', 4);
|
||||
}
|
||||
|
||||
set_config($options['name'], $options['set'], $options['component']);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['name'] === null) {
|
||||
// List all variables provided by the component (defaults to core).
|
||||
$got = get_config($options['component']);
|
||||
|
||||
if ($options['json']) {
|
||||
cli_writeln(json_encode($got));
|
||||
|
||||
} else {
|
||||
foreach ($got as $name => $value) {
|
||||
if ($options['shell-arg']) {
|
||||
$value = escapeshellarg($value);
|
||||
}
|
||||
cli_writeln($name."\t".$value);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
// Display the value of a single variable.
|
||||
|
||||
$got = get_config($options['component'], $options['name']);
|
||||
|
||||
if ($got === false) {
|
||||
cli_error('No such configuration variable found.', 3);
|
||||
}
|
||||
|
||||
if ($options['shell-arg']) {
|
||||
$got = escapeshellarg($got);
|
||||
}
|
||||
|
||||
if ($options['json']) {
|
||||
$got = json_encode($got);
|
||||
}
|
||||
|
||||
if ($options['no-eol']) {
|
||||
cli_write($got);
|
||||
} else {
|
||||
cli_writeln($got);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Validate that the current db structure matches the install.xml files.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Petr Skoda <petr.skoda@totaralms.com>
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
$help = "Validate database structure
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/check_database_schema.php
|
||||
";
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
echo "Database is not yet installed.\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$dbmanager = $DB->get_manager();
|
||||
$schema = $dbmanager->get_install_xml_schema();
|
||||
|
||||
if (!$errors = $dbmanager->check_database_schema($schema)) {
|
||||
echo "Database structure is ok.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
foreach ($errors as $table => $items) {
|
||||
cli_separator();
|
||||
echo "$table\n";
|
||||
foreach ($items as $item) {
|
||||
echo " * $item\n";
|
||||
}
|
||||
}
|
||||
cli_separator();
|
||||
|
||||
exit(1);
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI cron
|
||||
*
|
||||
* This script looks through all the module directories for cron.php files
|
||||
* and runs them. These files can contain cleanup functions, email functions
|
||||
* or anything that needs to be run on a regular basis.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Execute periodic cron actions.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/cron.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cron_run();
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixed incorrectly deleted users.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'courses' => false,
|
||||
'fix' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
'c' => 'courses',
|
||||
'f' => 'fix'
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['help'] || empty($options['courses'])) {
|
||||
$help =
|
||||
"Checks and fixes that course modules and sections reference each other correctly.
|
||||
|
||||
Compares DB fields course_sections.sequence and course_modules.section
|
||||
checking that:
|
||||
- course_sections.sequence contains each module id not more than once in the course
|
||||
- for each moduleid from course_sections.sequence the field course_modules.section
|
||||
refers to the same section id (this means course_sections.sequence is more
|
||||
important if they are different)
|
||||
- each module in the course is present in one of course_sections.sequence
|
||||
- section sequences do not contain non-existing course modules
|
||||
|
||||
If there are any mismatches, the message is displayed. If --fix is specified,
|
||||
the records in DB are corrected.
|
||||
|
||||
This script may run for a long time on big systems if called for all courses.
|
||||
|
||||
Avoid executing the script when another user may simultaneously edit any of the
|
||||
courses being checked (recommended to run in mainenance mode).
|
||||
|
||||
Options:
|
||||
-c, --courses List courses that need to be checked (comma-separated
|
||||
values or * for all). Required
|
||||
-f, --fix Fix the mismatches in DB. If not specified check only and
|
||||
report problems to STDERR
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=*
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=2,3,4 --fix
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
$courseslist = preg_split('/\s*,\s*/', $options['courses'], -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (in_array('*', $courseslist)) {
|
||||
$where = '';
|
||||
$params = array();
|
||||
} else {
|
||||
list($sql, $params) = $DB->get_in_or_equal($courseslist, SQL_PARAMS_NAMED, 'id');
|
||||
$where = 'WHERE id '. $sql;
|
||||
}
|
||||
$coursescount = $DB->get_field_sql('SELECT count(id) FROM {course} '. $where, $params);
|
||||
|
||||
if (!$coursescount) {
|
||||
cli_error('No courses found');
|
||||
}
|
||||
echo "Checking $coursescount courses...\n\n";
|
||||
|
||||
require_once($CFG->dirroot. '/course/lib.php');
|
||||
|
||||
$problems = array();
|
||||
$courses = $DB->get_fieldset_sql('SELECT id FROM {course} '. $where, $params);
|
||||
foreach ($courses as $courseid) {
|
||||
$errors = course_integrity_check($courseid, null, null, true, empty($options['fix']));
|
||||
if ($errors) {
|
||||
if (!empty($options['fix'])) {
|
||||
// Reset the course cache to make sure cache is recalculated next time the course is viewed.
|
||||
rebuild_course_cache($courseid, true);
|
||||
}
|
||||
foreach ($errors as $error) {
|
||||
cli_problem($error);
|
||||
}
|
||||
$problems[] = $courseid;
|
||||
} else {
|
||||
echo "Course [$courseid] is OK\n";
|
||||
}
|
||||
}
|
||||
if (!count($problems)) {
|
||||
echo "\n...All courses are OK\n";
|
||||
} else {
|
||||
if (!empty($options['fix'])) {
|
||||
echo "\n...Found and fixed ".count($problems)." courses with problems". "\n";
|
||||
} else {
|
||||
echo "\n...Found ".count($problems)." courses with problems. To fix run:\n";
|
||||
echo "\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=".join(',', $problems)." --fix". "\n";
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixed incorrectly deleted users.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Fix incorrectly deleted users.
|
||||
|
||||
This scripts detects users that are marked as deleted instead
|
||||
of calling delete_user().
|
||||
|
||||
Deleted users do not have original username, idnumber or email,
|
||||
we must also delete all roles, enrolments, group memberships, etc.
|
||||
|
||||
Please note this script does not delete any public information
|
||||
such as forum posts.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_deleted_users.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading('Looking for sloppy user deletes');
|
||||
|
||||
// Look for sloppy deleted users where somebody only flipped the deleted flag.
|
||||
$sql = "SELECT *
|
||||
FROM {user}
|
||||
WHERE deleted = 1 AND email LIKE '%@%' AND username NOT LIKE '%@%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $user) {
|
||||
echo "Redeleting user $user->id: $user->username ($user->email)\n";
|
||||
delete_user($user);
|
||||
}
|
||||
|
||||
cli_heading('Deleting all leftovers');
|
||||
|
||||
$DB->set_field('user', 'idnumber', '', array('deleted'=>1));
|
||||
|
||||
$DB->delete_records_select('role_assignments', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('cohort_members', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('groups_members', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_enrolments', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_preferences', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_info_data', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_lastaccess', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('external_tokens', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('external_services_users', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
|
||||
exit(0);
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixes orphaned question categories.
|
||||
*
|
||||
* Orphaned question categories have had their associated context deleted
|
||||
* but the category itself remains in the database with an invalid context.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Tyler Bannister (tyler.bannister@remote-learner.net)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/questionlib.php');
|
||||
|
||||
$long = array('fix' => false, 'help' => false);
|
||||
$short = array('f' => 'fix', 'h' => 'help');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params($long, $short);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Fix orphaned question categories.
|
||||
|
||||
This scripts detects question categories that have had their
|
||||
context deleted, thus severing them from their original purpose.
|
||||
|
||||
This script will find the orphaned categories and delete the unused
|
||||
questions in each category found. Used questions will not be
|
||||
deleted, instead they will be moved to a rescue question category.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-f, --fix Fix the orphaned question categories in the DB.
|
||||
If not specified only check and report problems to STDERR.
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_orphaned_question_categories.php
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_orphaned_question_categories.php -f
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading('Checking for orphaned categories');
|
||||
|
||||
|
||||
$sql = 'SELECT qc.id, qc.contextid, qc.name
|
||||
FROM {question_categories} qc
|
||||
LEFT JOIN {context} c ON qc.contextid = c.id
|
||||
WHERE c.id IS NULL';
|
||||
$categories = $DB->get_recordset_sql($sql);
|
||||
|
||||
$i = 0;
|
||||
foreach ($categories as $category) {
|
||||
$i += 1;
|
||||
echo "Found orphaned category: {$category->name}\n";
|
||||
if (!empty($options['fix'])) {
|
||||
echo "Cleaning...";
|
||||
// One transaction per category.
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
question_category_delete_safe($category);
|
||||
$transaction->allow_commit();
|
||||
echo " Done!\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (($i > 0) && !empty($options['fix'])) {
|
||||
echo "Found and removed {$i} orphaned question categories\n";
|
||||
} else if ($i > 0) {
|
||||
echo "Found {$i} orphaned question categories. To fix, run:\n";
|
||||
echo "\$sudo -u www-data /usr/bin/php admin/cli/fix_orphaned_question_categories.php --fix\n";
|
||||
} else {
|
||||
echo "No orphaned question categories found.\n";
|
||||
}
|
||||
|
||||
|
||||
$categories->close();
|
||||
@@ -1,817 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script creates config.php file and prepares database.
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - su to apache account or sudo before execution
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when preparing test environment.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
$help =
|
||||
"Command line Moodle installer, creates config.php and initializes database.
|
||||
Please note you must execute this script with the same uid as apache
|
||||
or use chmod/chown after installation.
|
||||
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--chmod=OCTAL-MODE Permissions of new directories created within dataroot.
|
||||
Default is 2777. You may want to change it to 2770
|
||||
or 2750 or 750. See chmod man page for details.
|
||||
--lang=CODE Installation and default site language.
|
||||
--wwwroot=URL Web address for the Moodle site,
|
||||
required in non-interactive mode.
|
||||
--dataroot=DIR Location of the moodle data folder,
|
||||
must not be web accessible. Default is moodledata
|
||||
in the parent directory.
|
||||
--dbtype=TYPE Database type. Default is mysqli
|
||||
--dbhost=HOST Database host. Default is localhost
|
||||
--dbname=NAME Database name. Default is moodle
|
||||
--dbuser=USERNAME Database user. Default is root
|
||||
--dbpass=PASSWORD Database password. Default is blank
|
||||
--dbport=NUMBER Use database port.
|
||||
--dbsocket=PATH Use database socket, 1 means default. Available for some databases only.
|
||||
--prefix=STRING Table prefix for above database tables. Default is mdl_
|
||||
--fullname=STRING The fullname of the site
|
||||
--shortname=STRING The shortname of the site
|
||||
--summary=STRING The summary to be displayed on the front page
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin
|
||||
--adminpass=PASSWORD Password for the moodle admin account,
|
||||
required in non-interactive mode.
|
||||
--adminemail=STRING Email address for the moodle admin account.
|
||||
--upgradekey=STRING The upgrade key to be set in the config.php, leave empty to not set it.
|
||||
--non-interactive No interactive questions, installation fails if any
|
||||
problem encountered.
|
||||
--agree-license Indicates agreement with software license,
|
||||
required in non-interactive mode.
|
||||
--allow-unstable Install even if the version is not marked as stable yet,
|
||||
required in non-interactive mode.
|
||||
--skip-database Stop the installation before installing the database.
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/install.php --lang=cs
|
||||
"; //TODO: localize, mark as needed in install - to be translated later when everything is finished
|
||||
|
||||
|
||||
// distro specific customisation
|
||||
$distrolibfile = __DIR__.'/../../install/distrolib.php';
|
||||
$distro = null;
|
||||
if (file_exists($distrolibfile)) {
|
||||
require_once($distrolibfile);
|
||||
if (function_exists('distro_get_config')) {
|
||||
$distro = distro_get_config();
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing to do if config.php exists
|
||||
$configfile = __DIR__.'/../../config.php';
|
||||
if (file_exists($configfile)) {
|
||||
require($configfile);
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false), array('h'=>'help'));
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
echo "\n\n";
|
||||
}
|
||||
|
||||
if ($DB->get_manager()->table_exists('config')) {
|
||||
cli_error(get_string('clialreadyinstalled', 'install'));
|
||||
} else {
|
||||
cli_error(get_string('clialreadyconfigured', 'install'));
|
||||
}
|
||||
}
|
||||
|
||||
$olddir = getcwd();
|
||||
|
||||
// change directory so that includes below work properly
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
|
||||
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
|
||||
if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
|
||||
fwrite(STDERR, "Timezone functions are not available.\n");
|
||||
exit(1);
|
||||
}
|
||||
date_default_timezone_set(@date_default_timezone_get());
|
||||
|
||||
// make sure PHP errors are displayed - helps with diagnosing of problems
|
||||
@error_reporting(E_ALL);
|
||||
@ini_set('display_errors', '1');
|
||||
// we need a lot of memory
|
||||
@ini_set('memory_limit', '128M');
|
||||
|
||||
/** Used by library scripts to check they are being called by Moodle */
|
||||
define('MOODLE_INTERNAL', true);
|
||||
|
||||
// Disables all caching.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
define('PHPUNIT_TEST', false);
|
||||
|
||||
define('IGNORE_COMPONENT_CACHE', true);
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible.
|
||||
require_once(__DIR__.'/../../lib/phpminimumversionlib.php');
|
||||
moodle_require_minimum_php_version();
|
||||
|
||||
// set up configuration
|
||||
global $CFG;
|
||||
$CFG = new stdClass();
|
||||
$CFG->lang = 'en';
|
||||
$CFG->dirroot = dirname(dirname(__DIR__));
|
||||
$CFG->libdir = "$CFG->dirroot/lib";
|
||||
$CFG->wwwroot = "http://localhost";
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
$CFG->dboptions = array();
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugdeveloper = true;
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', dirname(__DIR__)));
|
||||
$CFG->admin = array_pop($parts);
|
||||
|
||||
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
|
||||
//the problem is that we need specific version of quickforms and hacked excel files :-(
|
||||
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
|
||||
|
||||
require_once($CFG->libdir.'/classes/component.php');
|
||||
require_once($CFG->libdir.'/classes/text.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager_install.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager_standard.php');
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/setuplib.php');
|
||||
require_once($CFG->libdir.'/weblib.php');
|
||||
require_once($CFG->libdir.'/dmllib.php');
|
||||
require_once($CFG->libdir.'/moodlelib.php');
|
||||
require_once($CFG->libdir.'/deprecatedlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
require_once($CFG->dirroot.'/cache/lib.php');
|
||||
|
||||
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
|
||||
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
|
||||
if (defined('COMPONENT_CLASSLOADER')) {
|
||||
spl_autoload_register(COMPONENT_CLASSLOADER);
|
||||
} else {
|
||||
spl_autoload_register('core_component::classloader');
|
||||
}
|
||||
|
||||
require($CFG->dirroot.'/version.php');
|
||||
$CFG->target_release = $release;
|
||||
|
||||
\core\session\manager::init_empty_session();
|
||||
global $SESSION;
|
||||
global $USER;
|
||||
|
||||
global $COURSE;
|
||||
$COURSE = new stdClass();
|
||||
$COURSE->id = 1;
|
||||
|
||||
global $SITE;
|
||||
$SITE = $COURSE;
|
||||
define('SITEID', 1);
|
||||
|
||||
//Database types
|
||||
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
|
||||
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
|
||||
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
|
||||
'oci' => moodle_database::get_driver_instance('oci', 'native'),
|
||||
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
|
||||
'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
|
||||
);
|
||||
foreach ($databases as $type=>$database) {
|
||||
if ($database->driver_installed() !== true) {
|
||||
unset($databases[$type]);
|
||||
}
|
||||
}
|
||||
if (empty($databases)) {
|
||||
$defaultdb = '';
|
||||
} else {
|
||||
reset($databases);
|
||||
$defaultdb = key($databases);
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'chmod' => isset($distro->directorypermissions) ? sprintf('%04o',$distro->directorypermissions) : '2777', // let distros set dir permissions
|
||||
'lang' => $CFG->lang,
|
||||
'wwwroot' => '',
|
||||
'dataroot' => empty($distro->dataroot) ? str_replace('\\', '/', dirname(dirname(dirname(__DIR__))).'/moodledata'): $distro->dataroot, // initialised later after including libs or by distro
|
||||
'dbtype' => empty($distro->dbtype) ? $defaultdb : $distro->dbtype, // let distro skip dbtype selection
|
||||
'dbhost' => empty($distro->dbhost) ? 'localhost' : $distro->dbhost, // let distros set dbhost
|
||||
'dbname' => 'moodle',
|
||||
'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
|
||||
'dbpass' => '',
|
||||
'dbport' => '',
|
||||
'dbsocket' => '',
|
||||
'prefix' => 'mdl_',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
'summary' => '',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'adminemail' => '',
|
||||
'upgradekey' => '',
|
||||
'non-interactive' => false,
|
||||
'agree-license' => false,
|
||||
'allow-unstable' => false,
|
||||
'skip-database' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
$interactive = empty($options['non-interactive']);
|
||||
|
||||
// set up language
|
||||
$lang = clean_param($options['lang'], PARAM_SAFEDIR);
|
||||
$languages = get_string_manager()->get_list_of_translations();
|
||||
if (array_key_exists($lang, $languages)) {
|
||||
$CFG->lang = $lang;
|
||||
}
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
//Print header
|
||||
cli_logo();
|
||||
echo PHP_EOL;
|
||||
echo get_string('cliinstallheader', 'install', $CFG->target_release)."\n";
|
||||
|
||||
//Fist select language
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
// Do not put the langs into columns because it is not compatible with RTL.
|
||||
$default = $CFG->lang;
|
||||
cli_heading(get_string('chooselanguagehead', 'install'));
|
||||
if (array_key_exists($default, $languages)) {
|
||||
echo $default.' - '.$languages[$default]."\n";
|
||||
}
|
||||
if ($default !== 'en') {
|
||||
echo 'en - English (en)'."\n";
|
||||
}
|
||||
echo '? - '.get_string('availablelangs', 'install')."\n";
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->lang);
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, $default);
|
||||
|
||||
if ($input === '?') {
|
||||
echo implode("\n", $languages)."\n";
|
||||
$error = "\n";
|
||||
|
||||
} else {
|
||||
$input = clean_param($input, PARAM_SAFEDIR);
|
||||
|
||||
if (!array_key_exists($input, $languages)) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
}
|
||||
} while ($error !== '');
|
||||
$CFG->lang = $input;
|
||||
} else {
|
||||
// already selected and verified
|
||||
}
|
||||
|
||||
// Set directorypermissions first
|
||||
$chmod = octdec(clean_param($options['chmod'], PARAM_INT));
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('datarootpermission', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', decoct($chmod));
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, decoct($chmod));
|
||||
$input = octdec(clean_param($input, PARAM_INT));
|
||||
if (empty($input)) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
} while ($error !== '');
|
||||
$chmod = $input;
|
||||
|
||||
} else {
|
||||
if (empty($chmod)) {
|
||||
$a = (object)array('option' => 'chmod', 'value' => decoct($chmod));
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
$CFG->directorypermissions = $chmod;
|
||||
$CFG->filepermissions = ($CFG->directorypermissions & 0666);
|
||||
$CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
|
||||
|
||||
//We need wwwroot before we test dataroot
|
||||
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
|
||||
$wwwroot = trim($wwwroot, '/');
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('wwwroot', 'install'));
|
||||
if (strpos($wwwroot, 'http') === 0) {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $wwwroot);
|
||||
} else {
|
||||
$wwwroot = null;
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, $wwwroot);
|
||||
$input = clean_param($input, PARAM_URL);
|
||||
$input = trim($input, '/');
|
||||
if (strpos($input, 'http') !== 0) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
} while ($error !== '');
|
||||
$wwwroot = $input;
|
||||
|
||||
} else {
|
||||
if (strpos($wwwroot, 'http') !== 0) {
|
||||
$a = (object)array('option'=>'wwwroot', 'value'=>$wwwroot);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
$CFG->wwwroot = $wwwroot;
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
|
||||
|
||||
//We need dataroot before lang download
|
||||
$CFG->dataroot = $options['dataroot'];
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
$i=0;
|
||||
while(is_dataroot_insecure()) {
|
||||
$parrent = dirname($CFG->dataroot);
|
||||
$i++;
|
||||
if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
|
||||
$CFG->dataroot = ''; //can not find secure location for dataroot
|
||||
break;
|
||||
}
|
||||
$CFG->dataroot = dirname($parrent).'/moodledata';
|
||||
}
|
||||
cli_heading(get_string('dataroot', 'install'));
|
||||
$error = '';
|
||||
do {
|
||||
if ($CFG->dataroot !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->dataroot);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
echo $error;
|
||||
$CFG->dataroot = cli_input($prompt, $CFG->dataroot);
|
||||
if ($CFG->dataroot === '') {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else if (is_dataroot_insecure()) {
|
||||
$CFG->dataroot = '';
|
||||
$error = get_string('pathsunsecuredataroot', 'install')."\n";
|
||||
} else {
|
||||
if (install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
|
||||
$error = '';
|
||||
} else {
|
||||
$a = (object)array('dataroot' => $CFG->dataroot);
|
||||
$error = get_string('pathserrcreatedataroot', 'install', $a)."\n";
|
||||
}
|
||||
}
|
||||
|
||||
} while ($error !== '');
|
||||
|
||||
} else {
|
||||
if (is_dataroot_insecure()) {
|
||||
cli_error(get_string('pathsunsecuredataroot', 'install'));
|
||||
}
|
||||
if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
|
||||
$a = (object)array('dataroot' => $CFG->dataroot);
|
||||
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
|
||||
}
|
||||
}
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
$CFG->localcachedir = $CFG->dataroot.'/localcache';
|
||||
|
||||
// download required lang packs
|
||||
if ($CFG->lang !== 'en') {
|
||||
$installer = new lang_installer($CFG->lang);
|
||||
$results = $installer->run();
|
||||
foreach ($results as $langcode => $langstatus) {
|
||||
if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
|
||||
$a = new stdClass();
|
||||
$a->url = $installer->lang_pack_url($langcode);
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string('remotedownloaderror', 'error', $a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// switch the string_manager instance to stop using install/lang/
|
||||
$CFG->early_install_lang = false;
|
||||
$CFG->langotherroot = $CFG->dataroot.'/lang';
|
||||
$CFG->langlocalroot = $CFG->dataroot.'/lang';
|
||||
get_string_manager(true);
|
||||
|
||||
// make sure we are installing stable release or require a confirmation
|
||||
if (isset($maturity)) {
|
||||
if (($maturity < MATURITY_STABLE) and !$options['allow-unstable']) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('notice'));
|
||||
echo get_string('maturitycorewarning', 'admin', $maturitylevel) . PHP_EOL;
|
||||
echo get_string('morehelp') . ': ' . get_docs_url('admin/versions') . PHP_EOL;
|
||||
echo get_string('continue') . PHP_EOL;
|
||||
$prompt = get_string('cliyesnoprompt', 'admin');
|
||||
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
|
||||
if ($input == get_string('clianswerno', 'admin')) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
cli_problem(get_string('maturitycorewarning', 'admin', $maturitylevel));
|
||||
cli_error(get_string('maturityallowunstable', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ask for db type - show only drivers available
|
||||
if ($interactive) {
|
||||
$options['dbtype'] = strtolower($options['dbtype']);
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasetypehead', 'install'));
|
||||
foreach ($databases as $type=>$database) {
|
||||
echo " $type \n";
|
||||
}
|
||||
if (!empty($databases[$options['dbtype']])) {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbtype']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbtype = cli_input($prompt, $options['dbtype'], array_keys($databases));
|
||||
|
||||
} else {
|
||||
if (empty($databases[$options['dbtype']])) {
|
||||
$a = (object)array('option'=>'dbtype', 'value'=>$options['dbtype']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
$CFG->dbtype = $options['dbtype'];
|
||||
}
|
||||
$database = $databases[$CFG->dbtype];
|
||||
|
||||
|
||||
// ask for db host
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasehost', 'install'));
|
||||
if ($options['dbhost'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbhost']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbhost = cli_input($prompt, $options['dbhost']);
|
||||
|
||||
} else {
|
||||
$CFG->dbhost = $options['dbhost'];
|
||||
}
|
||||
|
||||
// ask for db name
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasename', 'install'));
|
||||
if ($options['dbname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbname = cli_input($prompt, $options['dbname']);
|
||||
|
||||
} else {
|
||||
$CFG->dbname = $options['dbname'];
|
||||
}
|
||||
|
||||
// ask for db prefix
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('dbprefix', 'install'));
|
||||
//TODO: solve somehow the prefix trouble for oci
|
||||
if ($options['prefix'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['prefix']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->prefix = cli_input($prompt, $options['prefix']);
|
||||
|
||||
} else {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
}
|
||||
|
||||
// ask for db port
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseport', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbport']);
|
||||
$CFG->dboptions['dbport'] = (int)cli_input($prompt, $options['dbport']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbport'] = (int)$options['dbport'];
|
||||
}
|
||||
if ($CFG->dboptions['dbport'] <= 0) {
|
||||
$CFG->dboptions['dbport'] = '';
|
||||
}
|
||||
|
||||
// ask for db socket
|
||||
if ($CFG->ostype === 'WINDOWS') {
|
||||
$CFG->dboptions['dbsocket'] = '';
|
||||
|
||||
} else if ($interactive and empty($CFG->dboptions['dbport'])) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbsocket']);
|
||||
$CFG->dboptions['dbsocket'] = cli_input($prompt, $options['dbsocket']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
|
||||
// ask for db user
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseuser', 'install'));
|
||||
if ($options['dbuser'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbuser']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbuser = cli_input($prompt, $options['dbuser']);
|
||||
|
||||
} else {
|
||||
$CFG->dbuser = $options['dbuser'];
|
||||
}
|
||||
|
||||
// ask for db password
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasepass', 'install'));
|
||||
do {
|
||||
if ($options['dbpass'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbpass']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
|
||||
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
|
||||
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']), $distro);
|
||||
}
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
} while ($hint_database !== '');
|
||||
|
||||
} else {
|
||||
$CFG->dbpass = $options['dbpass'];
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
if ($hint_database !== '') {
|
||||
cli_error(get_string('dbconnectionerror', 'install'));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for fullname
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('fullsitename', 'moodle'));
|
||||
|
||||
if ($options['fullname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['fullname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
|
||||
do {
|
||||
$options['fullname'] = cli_input($prompt, $options['fullname']);
|
||||
} while (empty($options['fullname']));
|
||||
} else {
|
||||
if (empty($options['fullname'])) {
|
||||
$a = (object)array('option'=>'fullname', 'value'=>$options['fullname']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for shortname
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('shortsitename', 'moodle'));
|
||||
|
||||
if ($options['shortname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['shortname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
|
||||
do {
|
||||
$options['shortname'] = cli_input($prompt, $options['shortname']);
|
||||
} while (empty($options['shortname']));
|
||||
} else {
|
||||
if (empty($options['shortname'])) {
|
||||
$a = (object)array('option'=>'shortname', 'value'=>$options['shortname']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for admin user name
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminusername', 'install'));
|
||||
if (!empty($options['adminuser'])) {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['adminuser']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
do {
|
||||
$options['adminuser'] = cli_input($prompt, $options['adminuser']);
|
||||
} while (empty($options['adminuser']) or $options['adminuser'] === 'guest');
|
||||
} else {
|
||||
if (empty($options['adminuser']) or $options['adminuser'] === 'guest') {
|
||||
$a = (object)array('option'=>'adminuser', 'value'=>$options['adminuser']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for admin user password
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminpassword', 'install'));
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
do {
|
||||
$options['adminpass'] = cli_input($prompt);
|
||||
} while (empty($options['adminpass']) or $options['adminpass'] === 'admin');
|
||||
} else {
|
||||
if (empty($options['adminpass']) or $options['adminpass'] === 'admin') {
|
||||
$a = (object)array('option'=>'adminpass', 'value'=>$options['adminpass']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// Ask for the admin email address.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminemail', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['adminemail']);
|
||||
$options['adminemail'] = cli_input($prompt);
|
||||
}
|
||||
|
||||
// Validate that the address provided was an e-mail address.
|
||||
if (!empty($options['adminemail']) && !validate_email($options['adminemail'])) {
|
||||
$a = (object) array('option' => 'adminemail', 'value' => $options['adminemail']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
|
||||
// Ask for the upgrade key.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('upgradekeyset', 'admin'));
|
||||
if ($options['upgradekey'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['upgradekey']);
|
||||
$options['upgradekey'] = cli_input($prompt, $options['upgradekey']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
$options['upgradekey'] = cli_input($prompt);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the upgrade key if it was provided.
|
||||
if ($options['upgradekey'] !== '') {
|
||||
$CFG->upgradekey = $options['upgradekey'];
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
if (!$options['agree-license']) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('copyrightnotice'));
|
||||
echo "Moodle - Modular Object-Oriented Dynamic Learning Environment\n";
|
||||
echo get_string('gpl3')."\n\n";
|
||||
echo get_string('doyouagree')."\n";
|
||||
$prompt = get_string('cliyesnoprompt', 'admin');
|
||||
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
|
||||
if ($input == get_string('clianswerno', 'admin')) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!$options['agree-license']) {
|
||||
cli_error(get_string('climustagreelicense', 'install'));
|
||||
}
|
||||
}
|
||||
|
||||
// Finally we have all info needed for config.php
|
||||
$configphp = install_generate_configphp($database, $CFG);
|
||||
umask(0137);
|
||||
if (($fh = fopen($configfile, 'w')) !== false) {
|
||||
fwrite($fh, $configphp);
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
if (!file_exists($configfile)) {
|
||||
cli_error('Can not create config file.');
|
||||
}
|
||||
|
||||
// remember selected language
|
||||
$installlang = $CFG->lang;
|
||||
// return back to original dir before executing setup.php which changes the dir again
|
||||
chdir($olddir);
|
||||
// We have config.php, it is a real php script from now on :-)
|
||||
require($configfile);
|
||||
|
||||
// use selected language
|
||||
$CFG->lang = $installlang;
|
||||
$SESSION->lang = $CFG->lang;
|
||||
|
||||
require("$CFG->dirroot/version.php");
|
||||
|
||||
// Test environment first.
|
||||
require_once($CFG->libdir . '/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
if (!$options['skip-database']) {
|
||||
install_cli_database($options, $interactive);
|
||||
// This needs to happen at the end to ensure it occurs after all caches
|
||||
// have been purged for the last time.
|
||||
// This will build a cached version of the current theme for the user
|
||||
// to immediately start browsing the site.
|
||||
require_once($CFG->libdir.'/upgradelib.php');
|
||||
upgrade_themes();
|
||||
} else {
|
||||
echo get_string('cliskipdatabase', 'install')."\n";
|
||||
}
|
||||
|
||||
echo get_string('cliinstallfinished', 'install')."\n";
|
||||
exit(0); // 0 means success
|
||||
@@ -1,189 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This installs Moodle into empty database, config.php must already exist.
|
||||
*
|
||||
* This script is intended for advanced usage such as in Debian packages.
|
||||
* - sudo to www-data (apache account) before
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2010 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when preparing test environment.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
$help =
|
||||
"Advanced command line Moodle database installer.
|
||||
Please note you must execute this script with the same uid as apache.
|
||||
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--lang=CODE Installation and default site language. Default is en.
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
|
||||
--adminpass=PASSWORD Password for the moodle admin account.
|
||||
--adminemail=STRING Email address for the moodle admin account.
|
||||
--agree-license Indicates agreement with software license.
|
||||
--fullname=STRING Name of the site
|
||||
--shortname=STRING Name of the site
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/install_database.php --lang=cs --adminpass=soMePass123 --agree-license
|
||||
";
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible.
|
||||
require_once(__DIR__.'/../../lib/phpminimumversionlib.php');
|
||||
moodle_require_minimum_php_version();
|
||||
|
||||
// Nothing to do if config.php does not exist
|
||||
$configfile = __DIR__.'/../../config.php';
|
||||
if (!file_exists($configfile)) {
|
||||
fwrite(STDERR, 'config.php does not exist, can not continue'); // do not localize
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Include necessary libs
|
||||
require($configfile);
|
||||
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
// make sure no tables are installed yet
|
||||
if ($DB->get_tables() ) {
|
||||
cli_error(get_string('clitablesexist', 'install'));
|
||||
}
|
||||
|
||||
$CFG->early_install_lang = true;
|
||||
get_string_manager(true);
|
||||
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'lang' => 'en',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'adminemail' => '',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
'agree-license' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if (!$options['agree-license']) {
|
||||
cli_error('You have to agree to the license. --help prints out the help'); // TODO: localize
|
||||
}
|
||||
|
||||
if ($options['adminpass'] === true or $options['adminpass'] === '') {
|
||||
cli_error('You have to specify admin password. --help prints out the help'); // TODO: localize
|
||||
}
|
||||
|
||||
// Validate that the address provided was an e-mail address.
|
||||
if (!empty($options['adminemail']) && !validate_email($options['adminemail'])) {
|
||||
$a = (object) array('option' => 'adminemail', 'value' => $options['adminemail']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
|
||||
$options['lang'] = clean_param($options['lang'], PARAM_SAFEDIR);
|
||||
if (!file_exists($CFG->dirroot.'/install/lang/'.$options['lang'])) {
|
||||
$options['lang'] = 'en';
|
||||
}
|
||||
$CFG->lang = $options['lang'];
|
||||
|
||||
// download required lang packs
|
||||
if ($CFG->lang !== 'en') {
|
||||
make_upload_directory('lang');
|
||||
$installer = new lang_installer($CFG->lang);
|
||||
$results = $installer->run();
|
||||
foreach ($results as $langcode => $langstatus) {
|
||||
if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
|
||||
$a = new stdClass();
|
||||
$a->url = $installer->lang_pack_url($langcode);
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string('remotedownloaderror', 'error', $a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// switch the string_manager instance to stop using install/lang/
|
||||
$CFG->early_install_lang = false;
|
||||
get_string_manager(true);
|
||||
|
||||
require("$CFG->dirroot/version.php");
|
||||
|
||||
// Test environment first.
|
||||
require_once($CFG->libdir . '/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
install_cli_database($options, true);
|
||||
|
||||
// This needs to happen at the end to ensure it occurs after all caches
|
||||
// have been purged for the last time.
|
||||
// This will build a cached version of the current theme for the user
|
||||
// to immediately start browsing the site.
|
||||
require_once($CFG->libdir.'/upgradelib.php');
|
||||
upgrade_themes();
|
||||
|
||||
echo get_string('cliinstallfinished', 'install')."\n";
|
||||
exit(0); // 0 means success
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI script to kill all user sessions without asking for confirmation.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2017 Alexander Bias <alexander.bias@uni-ulm.de>
|
||||
* @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');
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Kill all Moodle sessions
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/kill_all_sessions.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
\core\session\manager::kill_all_sessions();
|
||||
|
||||
exit(0);
|
||||
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Enable or disable maintenance mode.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/adminlib.php");
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'enablelater'=>0, 'enableold'=>false, 'disable'=>false, 'help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Maintenance mode settings.
|
||||
Current status displayed if not option specified.
|
||||
|
||||
Options:
|
||||
--enable Enable CLI maintenance mode
|
||||
--enablelater=MINUTES Number of minutes before entering CLI maintenance mode
|
||||
--enableold Enable legacy half-maintenance mode
|
||||
--disable Disable maintenance mode
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
|
||||
|
||||
if ($options['enablelater']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// Already enabled, sorry.
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
$time = time() + ($options['enablelater']*60);
|
||||
set_config('maintenance_later', $time);
|
||||
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($time))."\n";
|
||||
return 0;
|
||||
|
||||
} else if ($options['enable']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// The maintenance is already enabled, nothing to do.
|
||||
} else {
|
||||
enable_cli_maintenance_mode();
|
||||
}
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceoncli', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['enableold']) {
|
||||
set_config('maintenance_enabled', 1);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceon', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['disable']) {
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
unlink("$CFG->dataroot/climaintenance.html");
|
||||
}
|
||||
echo get_string('sitemaintenanceoff', 'admin')."\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!empty($CFG->maintenance_enabled) or file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
|
||||
} else if (isset($CFG->maintenance_later)) {
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($CFG->maintenance_later))."\n";
|
||||
|
||||
} else {
|
||||
echo get_string('clistatusdisabled', 'admin')."\n";
|
||||
}
|
||||
@@ -1,328 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL collation conversion tool.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2012 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This function is designed for MySQL databases only!');
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'collation'=>false, 'available'=>false),
|
||||
array('h'=>'help', 'l'=>'list', 'a'=>'available'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"MySQL collation conversions script.
|
||||
|
||||
It is strongly recommended to stop the web server before the conversion.
|
||||
This script may be executed before the main upgrade - 1.9.x data for example.
|
||||
|
||||
Options:
|
||||
--collation=COLLATION Convert MySQL tables to different collation
|
||||
-l, --list Show table and column information
|
||||
-a, --available Show list of available collations
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci
|
||||
";
|
||||
|
||||
if (!empty($options['collation'])) {
|
||||
$collations = mysql_get_collations();
|
||||
$collation = clean_param($options['collation'], PARAM_ALPHANUMEXT);
|
||||
$collation = strtolower($collation);
|
||||
if (!isset($collations[$collation])) {
|
||||
cli_error("Error: collation '$collation' is not available on this server!");
|
||||
}
|
||||
|
||||
$collationinfo = explode('_', $collation);
|
||||
$charset = reset($collationinfo);
|
||||
|
||||
$engine = strtolower($DB->get_dbengine());
|
||||
|
||||
// Do checks for utf8mb4.
|
||||
if (strpos($collation, 'utf8mb4') === 0) {
|
||||
// Do we have the right engine?
|
||||
if ($engine !== 'innodb' && $engine !== 'xtradb') {
|
||||
cli_error("Error: '$collation' requires InnoDB or XtraDB set as the engine.");
|
||||
}
|
||||
// Are we using Barracuda?
|
||||
if ($DB->get_row_format() != 'Barracuda') {
|
||||
// Try setting it here.
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_format=Barracuda");
|
||||
} catch (dml_exception $e) {
|
||||
cli_error("Error: '$collation' requires the file format to be set to Barracuda.
|
||||
An attempt was made to change the format, but it failed. Please try doing this manually.");
|
||||
}
|
||||
echo "GLOBAL SETTING: innodb_file_format changed to Barracuda\n";
|
||||
}
|
||||
// Is one file per table being used?
|
||||
if (!$DB->is_file_per_table_enabled()) {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_per_table=1");
|
||||
} catch (dml_exception $e) {
|
||||
cli_error("Error: '$collation' requires the setting 'innodb_file_per_table' be set to 'ON'.
|
||||
An attempt was made to change the format, but it failed. Please try doing this manually.");
|
||||
}
|
||||
echo "GLOBAL SETTING: innodb_file_per_table changed to 1\n";
|
||||
}
|
||||
// Is large prefix set?
|
||||
if (!$DB->is_large_prefix_enabled()) {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_large_prefix=1");
|
||||
} catch (dml_exception $e) {
|
||||
cli_error("Error: '$collation' requires the setting 'innodb_large_prefix' be set to 'ON'.
|
||||
An attempt was made to change the format, but it failed. Please try doing this manually.");
|
||||
}
|
||||
echo "GLOBAL SETTING: innodb_large_prefix changed to 1\n";
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SHOW VARIABLES LIKE 'collation_database'";
|
||||
if (!$dbcollation = $DB->get_record_sql($sql)) {
|
||||
cli_error("Error: Could not access collation information on the database.");
|
||||
}
|
||||
$sql = "SHOW VARIABLES LIKE 'character_set_database'";
|
||||
if (!$dbcharset = $DB->get_record_sql($sql)) {
|
||||
cli_error("Error: Could not access character set information on the database.");
|
||||
}
|
||||
if ($dbcollation->value !== $collation || $dbcharset->value !== $charset) {
|
||||
// Try to convert the DB.
|
||||
echo "Converting database to '$collation' for $CFG->wwwroot:\n";
|
||||
$sql = "ALTER DATABASE $CFG->dbname DEFAULT CHARACTER SET $charset DEFAULT COLLATE = $collation";
|
||||
try {
|
||||
$DB->change_database_structure($sql);
|
||||
} catch (exception $e) {
|
||||
cli_error("Error: Tried to alter the database with no success. Please try manually changing the database
|
||||
to the new collation and character set and then run this script again.");
|
||||
}
|
||||
echo "DATABASE CONVERTED\n";
|
||||
}
|
||||
|
||||
echo "Converting tables and columns to '$collation' for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$converted = 0;
|
||||
$skipped = 0;
|
||||
$errors = 0;
|
||||
foreach ($rs as $table) {
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
if ($table->collation === $collation) {
|
||||
echo "NO CHANGE\n";
|
||||
$skipped++;
|
||||
|
||||
} else {
|
||||
try {
|
||||
$DB->change_database_structure("ALTER TABLE $table->name CONVERT TO CHARACTER SET $charset COLLATE $collation");
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
} catch (ddl_exception $e) {
|
||||
$result = mysql_set_row_format($table->name, $charset, $collation, $engine);
|
||||
if ($result) {
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
} else {
|
||||
// We don't know what the problem is. Stop the conversion.
|
||||
cli_error("Error: Tried to convert $table->name, but there was a problem. Please check the details of this
|
||||
table and try again.");
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $table->name WHERE collation IS NOT NULL";
|
||||
$rs2 = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs2 as $column) {
|
||||
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
|
||||
echo ' '.str_pad($column->field, 36). " - ";
|
||||
if ($column->collation === $collation) {
|
||||
echo "NO CHANGE\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for utf8mb4 collation.
|
||||
$rowformat = $DB->get_row_format_sql($engine, $collation);
|
||||
|
||||
if ($column->type === 'tinytext' or $column->type === 'mediumtext' or $column->type === 'text' or $column->type === 'longtext') {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||
// primary, unique and inc are not supported for texts
|
||||
$sql = "ALTER TABLE $table->name
|
||||
MODIFY COLUMN $column->field $column->type
|
||||
CHARACTER SET $charset
|
||||
COLLATE $collation $notnull $default";
|
||||
$DB->change_database_structure($sql);
|
||||
|
||||
} else if (strpos($column->type, 'varchar') === 0) {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = !is_null($column->default) ? "DEFAULT '$column->default'" : '';
|
||||
|
||||
if ($rowformat != '') {
|
||||
$sql = "ALTER TABLE $table->name $rowformat";
|
||||
$DB->change_database_structure($sql);
|
||||
}
|
||||
|
||||
$sql = "ALTER TABLE $table->name
|
||||
MODIFY COLUMN $column->field $column->type
|
||||
CHARACTER SET $charset
|
||||
COLLATE $collation $notnull $default";
|
||||
$DB->change_database_structure($sql);
|
||||
} else {
|
||||
echo "ERROR (unknown column type: $column->type)\n";
|
||||
$errors++;
|
||||
continue;
|
||||
}
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
}
|
||||
$rs2->close();
|
||||
}
|
||||
$rs->close();
|
||||
echo "Converted: $converted, skipped: $skipped, errors: $errors\n";
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
echo "List of tables for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$counts = array();
|
||||
foreach ($rs as $table) {
|
||||
if (isset($counts[$table->collation])) {
|
||||
$counts[$table->collation]++;
|
||||
} else {
|
||||
$counts[$table->collation] = 1;
|
||||
}
|
||||
echo str_pad($table->name, 40);
|
||||
echo $table->collation. "\n";
|
||||
$collations = mysql_get_column_collations($table->name);
|
||||
foreach ($collations as $columname=>$collation) {
|
||||
if (isset($counts[$collation])) {
|
||||
$counts[$collation]++;
|
||||
} else {
|
||||
$counts[$collation] = 1;
|
||||
}
|
||||
echo ' ';
|
||||
echo str_pad($columname, 36);
|
||||
echo $collation. "\n";
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo "\n";
|
||||
echo "Table collations summary for $CFG->wwwroot:\n";
|
||||
foreach ($counts as $collation => $count) {
|
||||
echo "$collation: $count\n";
|
||||
}
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['available'])) {
|
||||
echo "List of available MySQL collations for $CFG->wwwroot:\n";
|
||||
$collations = mysql_get_collations();
|
||||
foreach ($collations as $collation) {
|
||||
echo " $collation\n";
|
||||
}
|
||||
die;
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========== Some functions ==============
|
||||
|
||||
function mysql_get_collations() {
|
||||
global $DB;
|
||||
|
||||
$collations = array();
|
||||
$sql = "SHOW COLLATION
|
||||
WHERE Collation LIKE 'utf8\_%' AND Charset = 'utf8'
|
||||
OR Collation LIKE 'utf8mb4\_%' AND Charset = 'utf8mb4'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $collation) {
|
||||
$collations[$collation->collation] = $collation->collation;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
$collation = $DB->get_dbcollation();
|
||||
if (isset($collations[$collation])) {
|
||||
$collations[$collation] .= ' (default)';
|
||||
}
|
||||
|
||||
return $collations;
|
||||
}
|
||||
|
||||
function mysql_get_column_collations($tablename) {
|
||||
global $DB;
|
||||
|
||||
$collations = array();
|
||||
$sql = "SELECT column_name, collation_name
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_schema = DATABASE() AND table_name = ? AND collation_name IS NOT NULL";
|
||||
$rs = $DB->get_recordset_sql($sql, array($tablename));
|
||||
foreach($rs as $record) {
|
||||
$collations[$record->column_name] = $record->collation_name;
|
||||
}
|
||||
$rs->close();
|
||||
return $collations;
|
||||
}
|
||||
|
||||
function mysql_set_row_format($tablename, $charset, $collation, $engine) {
|
||||
global $DB;
|
||||
|
||||
$sql = "SELECT row_format
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_schema = DATABASE() AND table_name = ?";
|
||||
$rs = $DB->get_record_sql($sql, array($tablename));
|
||||
if ($rs) {
|
||||
if ($rs->row_format == 'Compact' || $rs->row_format == 'Redundant') {
|
||||
$rowformat = $DB->get_row_format_sql($engine, $collation);
|
||||
// Try to convert to compressed format and then try updating the collation again.
|
||||
$DB->change_database_structure("ALTER TABLE $tablename $rowformat");
|
||||
$DB->change_database_structure("ALTER TABLE $tablename CONVERT TO CHARACTER SET $charset COLLATE $collation");
|
||||
} else {
|
||||
// Row format may not be the problem. Can not diagnose problem. Send fail reply.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL table row compression tool tool.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Petr Skoda <petr.skoda@totaralms.com>
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This script is used for MySQL databases only.');
|
||||
}
|
||||
|
||||
$engine = strtolower($DB->get_dbengine());
|
||||
if ($engine !== 'innodb' and $engine !== 'xtradb') {
|
||||
cli_error('This script is for MySQL servers using InnoDB or XtraDB engines only.');
|
||||
}
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array('help' => false, 'info' => false, 'list' => false, 'fix' => false, 'showsql' => false),
|
||||
array('h' => 'help', 'i' => 'info', 'l' => 'list', 'f' => 'fix', 's' => 'showsql')
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"Script for detection of row size problems in MySQL InnoDB tables.
|
||||
|
||||
By default InnoDB storage table is using legacy Antelope file format
|
||||
which has major restriction on database row size.
|
||||
Use this script to detect and fix database tables with potential data
|
||||
overflow problems.
|
||||
|
||||
Options:
|
||||
-i, --info Show database information
|
||||
-l, --list List problematic tables
|
||||
-f, --fix Attempt to fix all tables (requires SUPER privilege)
|
||||
-s, --showsql Print SQL statements for fixing of tables
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/mysql_compressed_rows.php -l
|
||||
";
|
||||
|
||||
/** @var mysql_sql_generator $generator */
|
||||
$generator = $DB->get_manager()->generator;
|
||||
|
||||
$info = $DB->get_server_info();
|
||||
$filepertable = $DB->get_record_sql("SHOW VARIABLES LIKE 'innodb_file_per_table'");
|
||||
$filepertable = $filepertable ? $filepertable->value : '';
|
||||
$fileformat = $DB->get_record_sql("SHOW VARIABLES LIKE 'innodb_file_format'");
|
||||
$fileformat = $fileformat ? $fileformat->value : '';
|
||||
$prefix = $DB->get_prefix();
|
||||
$database = $CFG->dbname;
|
||||
|
||||
if (!empty($options['info'])) {
|
||||
echo "Database version: " . $info['description'] . "\n";
|
||||
echo "Database name: $database\n";
|
||||
echo "Database engine: " . $DB->get_dbengine() . "\n";
|
||||
echo "innodb_file_per_table: $filepertable\n";
|
||||
echo "innodb_file_format: $fileformat\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
$problem = false;
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antelope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT);
|
||||
echo str_pad($format, 11, ' ', STR_PAD_RIGHT);
|
||||
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$problem = true;
|
||||
echo " (needs fixing)\n";
|
||||
|
||||
} else if ($format !== 'Compressed' and $format !== 'Dynamic') {
|
||||
echo " (unknown)\n";
|
||||
|
||||
} else {
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($problem) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['fix'])) {
|
||||
$fixtables = array();
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antelope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$fixtables[$table] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fixtables) {
|
||||
echo "No changes necessary\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($filepertable !== 'ON') {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_per_table=1");
|
||||
} catch (dml_exception $e) {
|
||||
echo "Cannot enable GLOBAL innodb_file_per_table setting, use --showsql option and execute the statements manually.";
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
if ($fileformat !== 'Barracuda') {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_format=Barracuda");
|
||||
} catch (dml_exception $e) {
|
||||
echo "Cannot change GLOBAL innodb_file_format setting, use --showsql option and execute the statements manually.";
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$DB->is_compressed_row_format_supported(false)) {
|
||||
echo "MySQL server is not compatible with compressed row format.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($fixtables as $table) {
|
||||
$DB->change_database_structure("ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed");
|
||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT) . " ... Compressed\n";
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['showsql'])) {
|
||||
$fixtables = array();
|
||||
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antelope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$fixtables[$table] = $table;
|
||||
}
|
||||
}
|
||||
if (!$fixtables) {
|
||||
echo "No changes necessary\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
echo "Copy the following SQL statements and execute them using account with SUPER privilege:\n\n";
|
||||
echo "USE $database;\n";
|
||||
echo "SET SESSION sql_mode=STRICT_ALL_TABLES;\n";
|
||||
echo "SET GLOBAL innodb_file_per_table=1;\n";
|
||||
echo "SET GLOBAL innodb_file_format=Barracuda;\n";
|
||||
foreach ($fixtables as $table) {
|
||||
echo "ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed;\n";
|
||||
}
|
||||
echo "\n";
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL engine conversion tool.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This function is designed for MySQL databases only!');
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'engine'=>false, 'available'=>false),
|
||||
array('h'=>'help', 'l'=>'list', 'a'=>'available'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"MySQL engine conversions script.
|
||||
|
||||
It is recommended to stop the web server before the conversion.
|
||||
Do not use MyISAM if possible, because it is not ACID compliant
|
||||
and does not support transactions.
|
||||
|
||||
Options:
|
||||
--engine=ENGINE Convert MySQL tables to different engine
|
||||
-l, --list Show table information
|
||||
-a, --available Show list of available engines
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB
|
||||
";
|
||||
|
||||
if (!empty($options['engine'])) {
|
||||
$engines = mysql_get_engines();
|
||||
$engine = clean_param($options['engine'], PARAM_ALPHA);
|
||||
if (!isset($engines[strtoupper($engine)])) {
|
||||
cli_error("Error: engine '$engine' is not available on this server!");
|
||||
}
|
||||
|
||||
echo "Converting tables to '$engine' for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$converted = 0;
|
||||
$skipped = 0;
|
||||
$errors = 0;
|
||||
foreach ($rs as $table) {
|
||||
if (strtoupper($table->engine) === strtoupper($engine)) {
|
||||
$newengine = mysql_get_table_engine($table->name);
|
||||
echo str_pad($table->name, 40). " - NO CONVERSION NEEDED ($newengine)\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
try {
|
||||
$DB->change_database_structure("ALTER TABLE {$table->name} ENGINE = $engine");
|
||||
$newengine = mysql_get_table_engine($table->name);
|
||||
if (strtoupper($newengine) !== strtoupper($engine)) {
|
||||
echo "ERROR ($newengine)\n";
|
||||
$errors++;
|
||||
continue;
|
||||
}
|
||||
echo "DONE ($newengine)\n";
|
||||
$converted++;
|
||||
} catch (moodle_exception $e) {
|
||||
echo $e->getMessage()."\n";
|
||||
$errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
echo "Converted: $converted, skipped: $skipped, errors: $errors\n";
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
echo "List of tables for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$counts = array();
|
||||
foreach ($rs as $table) {
|
||||
if (isset($counts[$table->engine])) {
|
||||
$counts[$table->engine]++;
|
||||
} else {
|
||||
$counts[$table->engine] = 1;
|
||||
}
|
||||
echo str_pad($table->engine, 10);
|
||||
echo $table->name . "\n";
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo "\n";
|
||||
echo "Table engines summary for $CFG->wwwroot:\n";
|
||||
foreach ($counts as $engine => $count) {
|
||||
echo "$engine: $count\n";
|
||||
}
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['available'])) {
|
||||
echo "List of available MySQL engines for $CFG->wwwroot:\n";
|
||||
$engines = mysql_get_engines();
|
||||
foreach ($engines as $engine) {
|
||||
echo " $engine\n";
|
||||
}
|
||||
die;
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========== Some functions ==============
|
||||
|
||||
function mysql_get_engines() {
|
||||
global $DB;
|
||||
|
||||
$sql = "SHOW Engines";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$engines = array();
|
||||
foreach ($rs as $engine) {
|
||||
if (strtoupper($engine->support) !== 'YES' and strtoupper($engine->support) !== 'DEFAULT') {
|
||||
continue;
|
||||
}
|
||||
$engines[strtoupper($engine->engine)] = $engine->engine;
|
||||
if (strtoupper($engine->support) === 'DEFAULT') {
|
||||
$engines[strtoupper($engine->engine)] .= ' (default)';
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
return $engines;
|
||||
}
|
||||
|
||||
function mysql_get_table_engine($tablename) {
|
||||
global $DB;
|
||||
|
||||
$engine = null;
|
||||
$sql = "SHOW TABLE STATUS WHERE Name = '$tablename'"; // no special chars expected here
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
if ($rs->valid()) {
|
||||
$record = $rs->current();
|
||||
$engine = $record->engine;
|
||||
}
|
||||
$rs->close();
|
||||
return $engine;
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI script to purge caches without asking for confirmation.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
* @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');
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Invalidates all Moodle internal caches
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/purge_caches.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
purge_all_caches();
|
||||
|
||||
exit(0);
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script allows you to reset any local user password.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
// Define the input options.
|
||||
$longparams = array(
|
||||
'help' => false,
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'ignore-password-policy' => false
|
||||
);
|
||||
|
||||
$shortparams = array(
|
||||
'h' => 'help',
|
||||
'u' => 'username',
|
||||
'p' => 'password',
|
||||
'i' => 'ignore-password-policy'
|
||||
);
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params($longparams, $shortparams);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Reset local user passwords, useful especially for admin acounts.
|
||||
|
||||
There are no security checks here because anybody who is able to
|
||||
execute this file may execute any PHP too.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-u, --username=username Specify username to change
|
||||
-p, --password=newpassword Specify new password
|
||||
--ignore-password-policy Ignore password policy when setting password
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/reset_password.php
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/reset_password.php --username=rosaura --password=jiu3jiu --ignore-password-policy
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
if ($options['username'] == '' ) {
|
||||
cli_heading('Password reset');
|
||||
$prompt = "Enter username (manual authentication only)";
|
||||
$username = cli_input($prompt);
|
||||
} else {
|
||||
$username = $options['username'];
|
||||
}
|
||||
|
||||
if (!$user = $DB->get_record('user', array('auth'=>'manual', 'username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
|
||||
cli_error("Can not find user '$username'");
|
||||
}
|
||||
|
||||
if ($options['password'] == '' ) {
|
||||
$prompt = "Enter new password";
|
||||
$password = cli_input($prompt);
|
||||
} else {
|
||||
$password = $options['password'];
|
||||
}
|
||||
|
||||
$errmsg = '';//prevent eclipse warning
|
||||
if (!$options['ignore-password-policy'] ) {
|
||||
if (!check_password_policy($password, $errmsg)) {
|
||||
cli_error(html_to_text($errmsg, 0));
|
||||
}
|
||||
}
|
||||
|
||||
$hashedpassword = hash_internal_user_password($password);
|
||||
|
||||
$DB->set_field('user', 'password', $hashedpassword, array('id'=>$user->id));
|
||||
|
||||
echo "Password changed\n";
|
||||
|
||||
exit(0); // 0 means success.
|
||||
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script implements some useful svg manipulation tricks.
|
||||
*
|
||||
* @package core_admin
|
||||
* @subpackage cli
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'ie9fix'=>false, 'noaspectratio'=>false, 'path'=>$CFG->dirroot),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
// If necessary add files that should be ignored - such as in 3rd party plugins.
|
||||
$blacklist = 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);
|
||||
|
||||
} else if ($options['noaspectratio']) {
|
||||
core_admin_recurse_svgs($path, '', 'core_admin_svgtool_noaspectratio', $blacklist);
|
||||
|
||||
} else {
|
||||
$help =
|
||||
"Some svg image tweaks for icon designers.
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help Print out this help
|
||||
--ie9fix Adds preserveAspectRatio=\"xMinYMid meet\" to every svg image
|
||||
--noaspectratio Removes preserveAspectRatio from svg files
|
||||
--path=PATH Path to directory or file to be converted, by default \$CFG->dirroot
|
||||
|
||||
Examples:
|
||||
\$ php svgtool.php --ie9fix
|
||||
\$ php svgtool.php --ie9fix --path=../../../pix
|
||||
\$ php svgtool.php --noaspectratio
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
/**
|
||||
* Fixes SVG images for IE9.
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
function core_admin_svgtool_ie9fix($file) {
|
||||
global $CFG;
|
||||
|
||||
if (strpos($file, $CFG->dirroot.DIRECTORY_SEPARATOR) === 0) {
|
||||
$relfile = substr($file, strlen($CFG->dirroot));
|
||||
} else {
|
||||
$relfile = $file;
|
||||
}
|
||||
|
||||
$content = file_get_contents($file);
|
||||
|
||||
if (!preg_match('/<svg\s[^>]*>/', $content, $matches)) {
|
||||
echo " skipping $relfile (invalid format)\n";
|
||||
return;
|
||||
}
|
||||
$svg = $matches[0];
|
||||
if (strpos($svg, 'preserveAspectRatio') !== false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_writable($file)) {
|
||||
echo " skipping $relfile (can not modify file)\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$newsvg = rtrim($svg, '>').' preserveAspectRatio="xMinYMid meet">';
|
||||
|
||||
$content = str_replace($svg, $newsvg, $content);
|
||||
echo "converting $relfile\n";
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes preserveAspectRatio attributes from SVG images.
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
function core_admin_svgtool_noaspectratio($file) {
|
||||
global $CFG;
|
||||
|
||||
if (strpos($file, $CFG->dirroot.DIRECTORY_SEPARATOR) === 0) {
|
||||
$relfile = substr($file, strlen($CFG->dirroot));
|
||||
} else {
|
||||
$relfile = $file;
|
||||
}
|
||||
|
||||
$content = file_get_contents($file);
|
||||
|
||||
if (!preg_match('/<svg\s[^>]*>/', $content, $matches)) {
|
||||
echo " skipping $relfile (invalid format)\n";
|
||||
return;
|
||||
}
|
||||
$svg = $matches[0];
|
||||
if (strpos($svg, 'preserveAspectRatio="xMinYMid meet"') === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_writable($file)) {
|
||||
echo " skipping $relfile (can not modify file)\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$newsvg = preg_replace('/ ?preserveAspectRatio="xMinYMid meet"/', '', $svg);
|
||||
|
||||
$content = str_replace($svg, $newsvg, $content);
|
||||
echo "resetting $relfile\n";
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively works through directories of this theme, finding and fixing SVG images.
|
||||
*
|
||||
* @param string $base
|
||||
* @param string $sub
|
||||
* @param string $filecallback
|
||||
* @param array $blacklist
|
||||
*/
|
||||
function core_admin_recurse_svgs($base, $sub, $filecallback, $blacklist) {
|
||||
if (is_dir("$base/$sub")) {
|
||||
$items = new DirectoryIterator("$base/$sub");
|
||||
foreach ($items as $item) {
|
||||
if ($item->isDot()) {
|
||||
continue;
|
||||
}
|
||||
$file = $item->getFilename();
|
||||
core_admin_recurse_svgs("$base/$sub", $file, $filecallback, $blacklist);
|
||||
}
|
||||
unset($item);
|
||||
unset($items);
|
||||
return;
|
||||
|
||||
} else if (is_file("$base/$sub")) {
|
||||
if (substr($sub, -4) !== '.svg') {
|
||||
return;
|
||||
}
|
||||
$file = realpath("$base/$sub");
|
||||
if (in_array($file, $blacklist)) {
|
||||
return;
|
||||
}
|
||||
$filecallback($file);
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script creates config.php file and prepares database.
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - su to apache account or sudo before execution
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when detecting if upgrade necessary or when running upgrade.
|
||||
if (function_exists('opcache_reset') and !isset($_SERVER['REMOTE_ADDR'])) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
|
||||
// now get cli options
|
||||
$lang = isset($SESSION->lang) ? $SESSION->lang : $CFG->lang;
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'non-interactive' => false,
|
||||
'allow-unstable' => false,
|
||||
'help' => false,
|
||||
'lang' => $lang
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['lang']) {
|
||||
$SESSION->lang = $options['lang'];
|
||||
}
|
||||
|
||||
$interactive = empty($options['non-interactive']);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Command line Moodle upgrade.
|
||||
Please note you must execute this script with the same uid as apache!
|
||||
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--non-interactive No interactive questions or confirmations
|
||||
--allow-unstable Upgrade even if the version is not marked as stable yet,
|
||||
required in non-interactive mode.
|
||||
--lang=CODE Set preferred language for CLI output. Defaults to the
|
||||
site language if not set. Defaults to 'en' if the lang
|
||||
parameter is invalid or if the language pack is not
|
||||
installed.
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/upgrade.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
cli_error(get_string('missingconfigversion', 'debug'));
|
||||
}
|
||||
|
||||
require("$CFG->dirroot/version.php"); // defines $version, $release, $branch and $maturity
|
||||
$CFG->target_release = $release; // used during installation and upgrades
|
||||
|
||||
if ($version < $CFG->version) {
|
||||
cli_error(get_string('downgradedcore', 'error'));
|
||||
}
|
||||
|
||||
$oldversion = "$CFG->release ($CFG->version)";
|
||||
$newversion = "$release ($version)";
|
||||
|
||||
if (!moodle_needs_upgrading()) {
|
||||
cli_error(get_string('cliupgradenoneed', 'core_admin', $newversion), 0);
|
||||
}
|
||||
|
||||
// Test environment first.
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = $oldversion;
|
||||
$a->newversion = $newversion;
|
||||
echo cli_heading(get_string('databasechecking', '', $a)) . PHP_EOL;
|
||||
}
|
||||
|
||||
// make sure we are upgrading to a stable release or display a warning
|
||||
if (isset($maturity)) {
|
||||
if (($maturity < MATURITY_STABLE) and !$options['allow-unstable']) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('notice'));
|
||||
echo get_string('maturitycorewarning', 'admin', $maturitylevel) . PHP_EOL;
|
||||
echo get_string('morehelp') . ': ' . get_docs_url('admin/versions') . PHP_EOL;
|
||||
cli_separator();
|
||||
} else {
|
||||
cli_problem(get_string('maturitycorewarning', 'admin', $maturitylevel));
|
||||
cli_error(get_string('maturityallowunstable', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
echo html_to_text(get_string('upgradesure', 'admin', $newversion))."\n";
|
||||
$prompt = get_string('cliyesnoprompt', 'admin');
|
||||
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
|
||||
if ($input == get_string('clianswerno', 'admin')) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) {
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
set_config('release', $release);
|
||||
set_config('branch', $branch);
|
||||
|
||||
// unconditionally upgrade
|
||||
upgrade_noncore(true);
|
||||
|
||||
// log in as admin - we need doanything permission when applying defaults
|
||||
\core\session\manager::set_user(get_admin());
|
||||
|
||||
// apply all default settings, just in case do it twice to fill all defaults
|
||||
admin_apply_default_settings(NULL, false);
|
||||
admin_apply_default_settings(NULL, false);
|
||||
|
||||
// This needs to happen at the end to ensure it occurs after all caches
|
||||
// have been purged for the last time.
|
||||
// This will build a cached version of the current theme for the user
|
||||
// to immediately start browsing the site.
|
||||
upgrade_themes();
|
||||
|
||||
echo get_string('cliupgradefinished', 'admin')."\n";
|
||||
exit(0); // 0 means success
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$installing = optional_param('installing', 0, PARAM_BOOL);
|
||||
|
||||
$focus = '';
|
||||
|
||||
if ($site = get_site()) { // If false then this is a new installation
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error('Only the admin can use this page');
|
||||
}
|
||||
}
|
||||
|
||||
/// This is to overcome the "insecure forms paradox"
|
||||
if (isset($secureforms) and $secureforms == 0) {
|
||||
$match = 'nomatch';
|
||||
} else {
|
||||
$match = '';
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted($match)) {
|
||||
|
||||
if (!empty($USER->id)) { // Additional identity check
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
}
|
||||
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
foreach ($config as $name => $value) {
|
||||
if ($name == "sessioncookie") {
|
||||
$value = eregi_replace("[^a-zA-Z0-9_]", "", $value);
|
||||
}
|
||||
if ($name == "defaultallowedmodules") {
|
||||
$value = implode(',',$value);
|
||||
}
|
||||
if ($name == 'hiddenuserfields') {
|
||||
if (in_array('none', $value)) {
|
||||
$value = '';
|
||||
} else {
|
||||
$value = implode(',',$value);
|
||||
}
|
||||
}
|
||||
if ($name == "locale") {
|
||||
$value = trim($value);
|
||||
}
|
||||
$conf = new object();
|
||||
$conf->name = $name;
|
||||
$conf->value = $value;
|
||||
if ($current = get_record('config', 'name', $name)) {
|
||||
$conf->id = $current->id;
|
||||
if (! update_record('config', $conf)) {
|
||||
notify("Could not update $name to $value");
|
||||
}
|
||||
} else {
|
||||
if (! insert_record('config', $conf)) {
|
||||
notify("Error: could not add new variable $name !");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($installing) {
|
||||
print_header();
|
||||
notify(get_string('changessaved'), 'notifysuccess');
|
||||
print_continue('index.php');
|
||||
exit;
|
||||
} else {
|
||||
// the following redirect was randomly breaking upgrades because it did double redirects,
|
||||
// we must not use it during install/upgrade
|
||||
redirect('index.php', get_string('changessaved'), 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
}
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strconfigvariables = get_string('configvariables', 'admin');
|
||||
|
||||
if ($site) {
|
||||
print_header("$site->shortname: $strconfigvariables", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strconfigvariables", $focus);
|
||||
print_heading($strconfigvariables);
|
||||
} else {
|
||||
print_header();
|
||||
print_heading($strconfigvariables);
|
||||
print_simple_box(get_string('configintro', 'admin'), 'center', "50%");
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Get all the configuration fields and helptext
|
||||
require('configvars.php');
|
||||
|
||||
/// Cycle through the sections to get the sectionnames
|
||||
$linktext = '';
|
||||
foreach($configvars as $sectionname=>$section) {
|
||||
if ($linktext !== '') {
|
||||
$linktext .= ' | ';
|
||||
}
|
||||
$linktext .= '<a href="#configsection'.$sectionname.'">'.get_string('configsection'.$sectionname, 'admin').'</a>';
|
||||
}
|
||||
|
||||
echo "<center>$linktext</center>\n";
|
||||
|
||||
|
||||
echo '<form method="post" action="config.php" name="form">';
|
||||
echo '<center><input type="submit" value="'.get_string('savechanges').'" /></center>';
|
||||
|
||||
/// Cycle through each section of the configuration
|
||||
foreach ($configvars as $sectionname=>$section) {
|
||||
|
||||
print_heading('<a name="configsection'.$sectionname.'"></a>'.get_string('configsection'.$sectionname, 'admin'));
|
||||
|
||||
$table = NULL;
|
||||
$table->data = array();
|
||||
foreach ($section as $configvariable=>$configobject) {
|
||||
$table->data[] = array ( $configvariable.': ',
|
||||
$configobject->field
|
||||
);
|
||||
if ($configobject->display_warning()) {
|
||||
$table->data[] = array ( ' ',
|
||||
'<span class="configwarning">'.$configobject->warning.'</span>'
|
||||
);
|
||||
}
|
||||
$table->data[] = array ( ' ',
|
||||
'<span class="confighelp">'.$configobject->help.'</span>'
|
||||
);
|
||||
$table->align = array ('right', 'left');
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
}
|
||||
echo '<center>';
|
||||
echo '<input type="hidden" name="installing" value="'.$installing.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$sesskey.'" />';
|
||||
echo '<input type="submit" value="'.get_string('savechanges').'" />';
|
||||
echo '</center>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Lock some options
|
||||
|
||||
$httpsurl = str_replace('http://', 'https://', $CFG->wwwroot);
|
||||
if ($httpsurl != $CFG->wwwroot) {
|
||||
if (ini_get('allow_url_fopen')) {
|
||||
if ((($fh = @fopen($httpsurl, 'r')) == false) and ($config->loginhttps == 0)) {
|
||||
echo '<script type="text/javascript">'."\n";
|
||||
echo '<!--'."\n";
|
||||
echo "eval('document.form.loginhttps.disabled=true');\n";
|
||||
echo '-->'."\n";
|
||||
echo '</script>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($site) {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
function validate_form(&$form, &$err) {
|
||||
|
||||
// Currently no checks are needed ...
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only admins can access this page');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
|
||||
print_header("$site->shortname: $stradministration: $strconfiguration", "$site->fullname",
|
||||
'<a href="index.php">'. "$stradministration</a> -> $strconfiguration");
|
||||
|
||||
print_heading($strconfiguration);
|
||||
|
||||
$table->align = array ('right', 'left');
|
||||
|
||||
$table->data[] = array("<strong><a href=\"config.php\">". get_string('configvariables', 'admin') .'</a></strong>',
|
||||
get_string('adminhelpconfigvariables'));
|
||||
$table->data[] = array("<strong><a href=\"site.php\">". get_string('sitesettings') .'</a></strong>',
|
||||
get_string('adminhelpsitesettings'));
|
||||
$table->data[] = array("<strong><a href=\"../theme/index.php\">". get_string('themes') .'</a></strong>',
|
||||
get_string('adminhelpthemes'));
|
||||
$table->data[] = array("<strong><a href=\"lang.php\">". get_string('language') .'</a></strong>',
|
||||
get_string('adminhelplanguage'));
|
||||
$table->data[] = array("<strong><a href=\"modules.php\">".get_string('managemodules'). ' </a></strong>',
|
||||
get_string('adminhelpmanagemodules'));
|
||||
$table->data[] = array("<strong><a href=\"blocks.php\">". get_string('manageblocks') .'</a></strong>',
|
||||
get_string('adminhelpmanageblocks'));
|
||||
$table->data[] = array("<strong><a href=\"filters.php\">". get_string('managefilters') .'</a></strong>',
|
||||
get_string('adminhelpmanagefilters'));
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$table->data[] = array("<strong><a href=\"backup.php\">".get_string("backup")."</a></strong>",
|
||||
get_string('adminhelpbackup'));
|
||||
}
|
||||
|
||||
$table->data[]= array("<strong><a href=\"editor.php\">". get_string('editorsettings') ."</a></strong>",
|
||||
get_string('adminhelpeditorsettings'));
|
||||
$table->data[]= array("<strong><a href=\"calendar.php\">". get_string('calendarsettings', 'admin') ."</a></strong>",
|
||||
get_string('helpcalendarsettings', 'admin'));
|
||||
$table->data[]= array("<strong><a href=\"maintenance.php\">". get_string('sitemaintenancemode', 'admin') ."</a></strong>",
|
||||
get_string('helpsitemaintenance', 'admin'));
|
||||
print_table($table);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -0,0 +1,660 @@
|
||||
<?php // $Id$
|
||||
// Shane Elliott
|
||||
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
|
||||
/// Add new sitewide configuration variables to this file.
|
||||
|
||||
|
||||
/// $configvars is parsed by config.php
|
||||
/// It is an array of arrays of objects
|
||||
/// $configvars[sectionname][configvariablename] = configvar object
|
||||
$configvars = array();
|
||||
|
||||
|
||||
/// no, yes strings and menu options are used in a number of places
|
||||
/// so we define them here to save time on repeatedly calling
|
||||
/// get_string()
|
||||
$stryes = get_string('yes');
|
||||
$strno = get_string('no');
|
||||
|
||||
$noyesoptions[0] = $strno;
|
||||
$noyesoptions[1] = $stryes;
|
||||
|
||||
|
||||
|
||||
/// A class to hold the configurable information
|
||||
/// $field - the html code for the form field
|
||||
/// $help - help text for the field
|
||||
/// $warning - optional warning text to be displayed
|
||||
/// method display_warning() - a generic function that can be used in an extended class
|
||||
/// e.g. enablerssfeeds
|
||||
class configvar {
|
||||
|
||||
var $field;
|
||||
var $help;
|
||||
var $warning;
|
||||
|
||||
function configvar($help, $field, $warning='') {
|
||||
$this->help = $help;
|
||||
$this->field = $field;
|
||||
$this->warning = $warning;
|
||||
}
|
||||
|
||||
function display_warning() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// Miscellaneous config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$misc = array();
|
||||
|
||||
|
||||
/// maxeditingtime
|
||||
unset($options);
|
||||
$options[3600] = get_string('numminutes', '', 60);
|
||||
$options[2700] = get_string('numminutes', '', 45);
|
||||
$options[1800] = get_string('numminutes', '', 30);
|
||||
$options[900] = get_string('numminutes', '', 15);
|
||||
$options[300] = get_string('numminutes', '', 5);
|
||||
$options[60] = get_string('numminutes', '', 1);
|
||||
|
||||
$misc['maxeditingtime'] = new configvar (get_string('configmaxeditingtime', 'admin'),
|
||||
choose_from_menu ($options, 'maxeditingtime', $config->maxeditingtime, '', '', '', true) );
|
||||
|
||||
/// debug
|
||||
unset($options);
|
||||
$options[5] = $strno;
|
||||
$options[15] = $stryes;
|
||||
|
||||
$misc['debug'] = new configvar (get_string('configdebug', 'admin'),
|
||||
choose_from_menu ($options, 'debug', $config->debug, '', '', '', true) );
|
||||
|
||||
$misc['perfdebug'] = new configvar (get_string('configperfdebug', 'admin'),
|
||||
choose_from_menu ($options, 'perfdebug', $config->perfdebug, '', '', '', true) );
|
||||
|
||||
/// enablerssfeeds
|
||||
class configvarrss extends configvar {
|
||||
function display_warning() {
|
||||
return (!function_exists('utf8_encode'));
|
||||
}
|
||||
}
|
||||
|
||||
$misc['enablerssfeeds'] = new configvarrss (get_string('configenablerssfeeds', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'enablerssfeeds', $config->enablerssfeeds, '', '', '', true),
|
||||
'<font color="red"> You need to add XML support to your PHP installation.</font>' );
|
||||
|
||||
$misc['mymoodleredirect'] = new configvar (get_string('configmymoodleredirect','admin'),
|
||||
choose_from_menu($noyesoptions,'mymoodleredirect',$config->mymoodleredirect,'','','',true));
|
||||
|
||||
unset($options);
|
||||
$options[5] = get_string('worldblogs','blog');
|
||||
$options[4] = get_string('siteblogs','blog');
|
||||
$options[3] = get_string('courseblogs','blog');
|
||||
$options[2] = get_string('groupblogs','blog');
|
||||
$options[1] = get_string('personalblogs','blog');
|
||||
$options[0] = get_string('disableblogs','blog');
|
||||
|
||||
$misc['bloglevel'] = new configvar (get_string('configbloglevel', 'admin'),
|
||||
choose_from_menu ($options, 'bloglevel', $config->bloglevel,'','','',true));
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// OPERATING SYSTEM config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$operatingsystem = array();
|
||||
|
||||
/// gdversion
|
||||
unset($options);
|
||||
$options[0] = get_string('gdnot');
|
||||
$options[1] = get_string('gd1');
|
||||
$options[2] = get_string('gd2');
|
||||
|
||||
$installed = check_gd_version();
|
||||
|
||||
$operatingsystem['gdversion'] = new configvar (get_string('configgdversion', 'admin'),
|
||||
choose_from_menu ($options, 'gdversion', $installed, '', '', '', true) );
|
||||
|
||||
/// dbsessions
|
||||
$operatingsystem['dbsessions'] = new configvar (get_string('configdbsessions', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'dbsessions', $config->dbsessions, '', '', '', true) );
|
||||
|
||||
/// sessiontimeout
|
||||
unset($options);
|
||||
$options[14400] = get_string('numhours', '', 4);
|
||||
$options[10800] = get_string('numhours', '', 3);
|
||||
$options[7200] = get_string('numhours', '', 2);
|
||||
$options[5400] = get_string('numhours', '', '1.5');
|
||||
$options[3600] = get_string('numminutes', '', 60);
|
||||
$options[2700] = get_string('numminutes', '', 45);
|
||||
$options[1800] = get_string('numminutes', '', 30);
|
||||
$options[900] = get_string('numminutes', '', 15);
|
||||
$options[300] = get_string('numminutes', '', 5);
|
||||
|
||||
$operatingsystem['sessiontimeout'] = new configvar (get_string('configsessiontimeout', 'admin'),
|
||||
choose_from_menu ($options, 'sessiontimeout', $config->sessiontimeout, '', '', '', true) );
|
||||
|
||||
/// sessioncookie
|
||||
$operatingsystem['sessioncookie'] = new configvar (get_string('configsessioncookie', 'admin'),
|
||||
'<input name="sessioncookie" type="text" size="10" value="'.s($config->sessioncookie).'" alt="sessioncookie" />' );
|
||||
$operatingsystem['sessioncookiepath'] = new configvar (get_string('configsessioncookiepath', 'admin'),
|
||||
'<input name="sessioncookiepath" type="text" size="10" value="'.s($config->sessioncookiepath).'" alt="sessioncookiepath" />' );
|
||||
|
||||
/// zip
|
||||
$operatingsystem['zip'] = new configvar (get_string('configzip', 'admin'),
|
||||
'<input name="zip" type="text" size="30" value="'.s($config->zip).'" alt="zip" />' );
|
||||
|
||||
/// unzip
|
||||
$operatingsystem['unzip'] = new configvar (get_string('configunzip', 'admin'),
|
||||
'<input name="unzip" type="text" size="30" value="'.s($config->unzip).'" alt="unzip" />' );
|
||||
|
||||
$operatingsystem['pathtodu'] = new configvar(get_string('configpathtodu', 'admin'),
|
||||
'<input name="pathtodu" type="text" size="30" value="'.s($config->pathtodu).'" alt="pathtodu" />');
|
||||
|
||||
/// slasharguments
|
||||
unset($options);
|
||||
$options[0] = "file.php?file=/1/pic.jpg";
|
||||
$options[1] = "file.php/1/pic.jpg";
|
||||
|
||||
$operatingsystem['slasharguments'] = new configvar (get_string('configslasharguments', 'admin'),
|
||||
choose_from_menu ($options, 'slasharguments', $config->slasharguments, '', '', '', true) );
|
||||
|
||||
/// proxyhost
|
||||
$operatingsystem['proxyhost'] = new configvar (get_string('configproxyhost', 'admin'),
|
||||
'<input name="proxyhost" type="text" size="30" value="'.s($config->proxyhost).'" alt="proxyhost" />' );
|
||||
|
||||
/// proxyport
|
||||
$operatingsystem['proxyport'] = new configvar ('',
|
||||
'<input name="proxyport" type="text" size="5" value="'.s($config->proxyport).'" alt="proxyport" />' );
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// PERMISSIONS config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$permissions = array();
|
||||
|
||||
/// teacherassignteachers
|
||||
$permissions['teacherassignteachers'] = new configvar (get_string('configteacherassignteachers', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'teacherassignteachers', $config->teacherassignteachers, '', '', '', true) );
|
||||
|
||||
/// allowunenroll
|
||||
$permissions['allowunenroll'] = new configvar (get_string('configallowunenroll', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowunenroll', $config->allowunenroll, '', '', '', true) );
|
||||
|
||||
/// allusersaresitestudents
|
||||
$permissions['allusersaresitestudents'] = new configvar (get_string('configallusersaresitestudents', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allusersaresitestudents', $config->allusersaresitestudents, '', '', '', true) );
|
||||
|
||||
/// showsiteparticipantslist
|
||||
unset($options);
|
||||
$options[0] = get_string('siteteachers');
|
||||
$options[1] = get_string('allteachers');
|
||||
$options[2] = get_string('studentsandteachers');
|
||||
|
||||
$permissions['showsiteparticipantslist'] = new configvar (get_string('configshowsiteparticipantslist', 'admin'),
|
||||
choose_from_menu ($options, 'showsiteparticipantslist', $config->showsiteparticipantslist, '', '', '', true) );
|
||||
|
||||
/// forcelogin
|
||||
$permissions['forcelogin'] = new configvar (get_string('configforcelogin', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'forcelogin', $config->forcelogin, '', '', '', true) );
|
||||
|
||||
/// forceloginforprofiles
|
||||
$permissions['forceloginforprofiles'] = new configvar (get_string('configforceloginforprofiles', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'forceloginforprofiles', $config->forceloginforprofiles, '', '', '', true) );
|
||||
|
||||
/// opentogoogle
|
||||
$permissions['opentogoogle'] = new configvar (get_string('configopentogoogle', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'opentogoogle', $config->opentogoogle, '', '', '', true) );
|
||||
|
||||
/// maxbytes
|
||||
$options = get_max_upload_sizes();
|
||||
|
||||
$permissions['maxbytes'] = new configvar (get_string('configmaxbytes', 'admin'),
|
||||
choose_from_menu ($options, 'maxbytes', $config->maxbytes, '', '', 0, true) );
|
||||
|
||||
/// messaging
|
||||
$permissions['messaging'] = new configvar (get_string('configmessaging', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'messaging', $config->messaging, '', '', '', true) );
|
||||
|
||||
/// allowobjectembed
|
||||
$permissions['allowobjectembed'] = new configvar (get_string('configallowobjectembed', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowobjectembed', $config->allowobjectembed, '', '', '', true) );
|
||||
|
||||
|
||||
unset($options);
|
||||
$options['none'] = 'No courses';
|
||||
$options['all'] = 'All courses';
|
||||
$options['requested'] = 'Requested courses';
|
||||
|
||||
$permissions['restrictmodulesfor'] = new configvar (get_string('configrestrictmodulesfor','admin'),
|
||||
' <script language="JavaScript">
|
||||
function togglemodules(index) {
|
||||
if (index == 0) {
|
||||
document.getElementById(\'allowedmodules\').disabled=true;
|
||||
}
|
||||
else {
|
||||
document.getElementById(\'allowedmodules\').disabled=false;
|
||||
}
|
||||
}
|
||||
</script>'.
|
||||
choose_from_menu($options,'restrictmodulesfor',$config->restrictmodulesfor,'','togglemodules(this.selectedIndex);','',true) );
|
||||
|
||||
$permissions['restrictbydefault'] = new configvar (get_string('configrestrictbydefault','admin'),
|
||||
choose_from_menu($noyesoptions, 'restrictbydefault',$config->restrictbydefault,'','','',true) );
|
||||
|
||||
$allowstr = '<select name="defaultallowedmodules[]" id="allowedmodules" multiple="multiple" size="10"'.((empty($config->restrictmodulesfor)) ? "disabled=\"disabled\"" : "").'>';
|
||||
|
||||
$allowedmodules = array();
|
||||
if (!empty($config->defaultallowedmodules)) {
|
||||
$allowedmodules = explode(',',$config->defaultallowedmodules);
|
||||
}
|
||||
|
||||
// On a fresh install of Moodle, this could be empty; prevent a warning on the following loop.
|
||||
if (!$mods = get_records("modules")) {
|
||||
$mods = array();
|
||||
}
|
||||
$s = "selected=\"selected\"";
|
||||
$allowstr .= '<option value="0" '.((empty($allowedmodules)) ? $s : '').'>'.get_string('allownone').'</option>'."\n";
|
||||
foreach ($mods as $mod) {
|
||||
$selected = "";
|
||||
if (in_array($mod->id,$allowedmodules))
|
||||
$selected = $s;
|
||||
$allowstr .= '<option '.$selected.' value="'.$mod->id.'">'.$mod->name.'</option>'."\n";
|
||||
}
|
||||
$allowstr .= '</select>';
|
||||
|
||||
$permissions['defaultallowedmodules'] = new configvar (get_string('configdefaultallowedmodules','admin'),$allowstr);
|
||||
|
||||
|
||||
/// course requests
|
||||
$reqcourse['enablecourserequests'] = new configvar (get_string('configenablecourserequests', 'admin'),
|
||||
choose_from_menu ($noyesoptions,'enablecourserequests',$config->enablecourserequests,'','','',true) );
|
||||
|
||||
/// default category for course requests
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
$reqcourse['defaultrequestedcategory'] = new configvar (get_string('configdefaultrequestedcategory', 'admin'),
|
||||
choose_from_menu (make_categories_options(), 'defaultrequestedcategory',$config->defaultrequestedcategory,'','','',true) );
|
||||
|
||||
$reqcourse['requestedteachername'] = new configvar (get_string('configrequestedteachername','admin'),
|
||||
'<input type="text" name="requestedteachername" size="20" maxlength="100" value="'.s($config->requestedteachername).'" />');
|
||||
|
||||
$reqcourse['requestedteachersname'] = new configvar (get_string('configrequestedteachersname','admin'),
|
||||
'<input type="text" name="requestedteachersname" size="20" maxlength="100" value="'.s($config->requestedteachersname).'" />');
|
||||
|
||||
$reqcourse['requestedstudentname'] = new configvar (get_string('configrequestedstudentname','admin'),
|
||||
'<input type="text" name="requestedstudentname" size="20" maxlength="100" value="'.s($config->requestedstudentname).'" />');
|
||||
|
||||
$reqcourse['requestedstudentsname'] = new configvar (get_string('configrequestedstudentsname','admin'),
|
||||
'<input type="text" name="requestedstudentsname" size="20" maxlength="100" value="'.s($config->requestedstudentsname).'" />');
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// INTERFACE config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$interface = array();
|
||||
|
||||
/// language settings
|
||||
$interface['lang'] = new configvar ( get_string('configlang', 'admin'),
|
||||
choose_from_menu(get_list_of_languages(), 'lang', $config->lang, '', '', '', true) );
|
||||
|
||||
/// language menu
|
||||
$interface['langmenu'] = new configvar ( get_string('configlangmenu', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'langmenu', $config->langmenu, '', '', '', true) );
|
||||
|
||||
/// language list
|
||||
$interface['langlist'] = new configvar ( get_string('configlanglist', 'admin'),
|
||||
'<input name="langlist" type="text" size="60" value="'.s($config->langlist).'" alt="langlist" />' );
|
||||
|
||||
/// language menu
|
||||
$interface['langcache'] = new configvar ( get_string('configlangcache', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'langcache', $config->langcache, '', '', '', true) );
|
||||
|
||||
/// locale
|
||||
$interface['locale'] = new configvar ( get_string('configlocale', 'admin'),
|
||||
'<input name="locale" type="text" size="15" value="'.s($config->locale).'" alt="locale" />' );
|
||||
|
||||
/// docroot
|
||||
$interface['docroot'] = new configvar ( get_string('configdocroot', 'admin'),
|
||||
'<input name="docroot" type="text" size="60" value="'.s($config->docroot).'" alt="docroot" />' );
|
||||
|
||||
/// doctonewwindow
|
||||
$interface['doctonewwindow'] = new configvar ( get_string('configdoctonewwindow', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'doctonewwindow', $config->doctonewwindow, '', '', '', true) );
|
||||
|
||||
/// timezone
|
||||
$interface['timezone'] = new configvar ( get_string('configtimezone', 'admin'),
|
||||
choose_from_menu (get_list_of_timezones(), 'timezone', $config->timezone, get_string('serverlocaltime'), '', '99', true ) );
|
||||
|
||||
/// country
|
||||
$interface['country'] = new configvar ( get_string('configcountry', 'admin'),
|
||||
choose_from_menu (get_list_of_countries(), 'country', $config->country, get_string('selectacountry'), '', 0, true) );
|
||||
|
||||
/// framename
|
||||
if (empty($config->framename)) {
|
||||
$config->framename = "_top";
|
||||
}
|
||||
|
||||
$interface['framename'] = new configvar (get_string('configframename', 'admin'),
|
||||
'<input name="framename" type="text" size="15" value="'.s($config->framename).'" alt="framename" />' );
|
||||
|
||||
/// language list
|
||||
$interface['themelist'] = new configvar ( get_string('configthemelist', 'admin'),
|
||||
'<input name="themelist" type="text" size="60" value="'.s($config->themelist).'" alt="themelist" />' );
|
||||
|
||||
/// user themes
|
||||
$interface['allowuserthemes'] = new configvar (get_string('configallowuserthemes', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowuserthemes', $config->allowuserthemes, '', '', '', true) );
|
||||
|
||||
/// course themes
|
||||
$interface['allowcoursethemes'] = new configvar (get_string('configallowcoursethemes', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowcoursethemes', $config->allowcoursethemes, '', '', '', true) );
|
||||
|
||||
/// allowuserblockhiding
|
||||
$interface['allowuserblockhiding'] = new configvar (get_string('configallowuserblockhiding', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowuserblockhiding', $config->allowuserblockhiding, '', '', '', true) );
|
||||
|
||||
/// showblocksonmodpages
|
||||
$interface['showblocksonmodpages'] = new configvar (get_string('configshowblocksonmodpages', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'showblocksonmodpages', $config->showblocksonmodpages, '', '', '', true) );
|
||||
|
||||
|
||||
/// tabselectedtofront
|
||||
$interface['tabselectedtofront'] = new configvar (get_string('tabselectedtofront', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'tabselectedtofront', $config->tabselectedtofront, '', '', '', true) );
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// USER config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$user = array();
|
||||
|
||||
/// sitepolicy
|
||||
$user['sitepolicy'] = new configvar (get_string('configsitepolicy', 'admin'),
|
||||
'<input type="text" name="sitepolicy" size="60" value="'.$config->sitepolicy.'" alt="sitepolicy" />' );
|
||||
|
||||
|
||||
/// fullnamedisplay
|
||||
unset($options);
|
||||
$options['language'] = get_string('language');
|
||||
$options['firstname lastname'] = get_string('firstname') . ' + ' . get_string('lastname');
|
||||
$options['lastname firstname'] = get_string('lastname') . ' + ' . get_string('firstname');
|
||||
$options['firstname'] = get_string('firstname');
|
||||
|
||||
$user['fullnamedisplay'] = new configvar (get_string('configfullnamedisplay', 'admin'),
|
||||
choose_from_menu ($options, 'fullnamedisplay', $config->fullnamedisplay, '', '', '', true) );
|
||||
|
||||
/// extendedusernamechars
|
||||
$user['extendedusernamechars'] = new configvar (get_string('configextendedusernamechars', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'extendedusernamechars', $config->extendedusernamechars, '', '', '', true) );
|
||||
|
||||
/// autologinguests
|
||||
$user['autologinguests'] = new configvar (get_string('configautologinguests', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'autologinguests', $config->autologinguests, '', '', '', true) );
|
||||
|
||||
/// hiddenuserfields
|
||||
$fields = array('none', 'description', 'city', 'country', 'webpage', 'icqnumber', 'skypeid', 'yahooid', 'aimid', 'msnid', 'lastaccess');
|
||||
if (empty($config->hiddenuserfields)) {
|
||||
$config->hiddenuserfields = 'none';
|
||||
}
|
||||
$configfields = array_flip(explode(',', $config->hiddenuserfields));
|
||||
$fieldoptions = '';
|
||||
foreach ($fields as $value) {
|
||||
$fieldoptions .= '<option value="'.$value.'"';
|
||||
if (isset($configfields[$value])) {
|
||||
$fieldoptions .= ' selected="selected"';
|
||||
}
|
||||
$fieldoptions .= '>'.get_string($value).'</option>';
|
||||
}
|
||||
|
||||
$user['hiddenuserfields'] = new configvar (get_string('confighiddenuserfields', 'admin'),
|
||||
'<select id="menuhiddenuserfields" name="hiddenuserfields[]" size="10" multiple="multiple">'.$fieldoptions.'</select>' );
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// SECURITY config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$security = array();
|
||||
|
||||
/// displayloginfailures
|
||||
unset($options);
|
||||
$options[''] = get_string('nobody');
|
||||
$options['admin'] = get_string('administrators');
|
||||
$options['teacher'] = get_string('administratorsandteachers');
|
||||
$options['everybody'] = get_string('everybody');
|
||||
|
||||
$security['displayloginfailures'] = new configvar (get_string('configdisplayloginfailures', 'admin'),
|
||||
choose_from_menu($options, 'displayloginfailures', $config->displayloginfailures, '', '', '', true) );
|
||||
|
||||
/// notifyloginfailures
|
||||
unset($options);
|
||||
$options[''] = get_string('nobody');
|
||||
$options['mainadmin'] = get_string('administrator');
|
||||
$options['alladmins'] = get_string('administratorsall');
|
||||
|
||||
$security['notifyloginfailures'] = new configvar (get_string('confignotifyloginfailures', 'admin'),
|
||||
choose_from_menu($options, 'notifyloginfailures', $config->notifyloginfailures, '', '', '', true) );
|
||||
|
||||
/// notifyloginthreshold
|
||||
unset($options);
|
||||
for ($i=1; $i<=100; $i++) {
|
||||
$options[$i] = "$i";
|
||||
}
|
||||
|
||||
$security['notifyloginthreshold'] = new configvar (get_string('confignotifyloginthreshold', 'admin'),
|
||||
choose_from_menu($options, 'notifyloginthreshold', $config->notifyloginthreshold, '', '', '', true) );
|
||||
|
||||
$security['protectusernames'] = new configvar (get_string('configprotectusernames', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'protectusernames', $config->protectusernames, '', '', '', true) );
|
||||
|
||||
/// secureforms
|
||||
$security['secureforms'] = new configvar (get_string('configsecureforms', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'secureforms', $config->secureforms, '', '', '', true) );
|
||||
|
||||
/// loginhttps
|
||||
$security['loginhttps'] = new configvar (get_string('configloginhttps', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'loginhttps', $config->loginhttps, '', '', '', true) );
|
||||
|
||||
/// runclamonupload
|
||||
$security['runclamonupload'] = new configvar (get_string('configrunclamonupload', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'runclamonupload', $config->runclamonupload, '', '', '', true) );
|
||||
|
||||
/// pathtoclam
|
||||
$security['pathtoclam'] = new configvar (get_string('configpathtoclam', 'admin'),
|
||||
'<input type="text" name="pathtoclam" size="30" value="'.$config->pathtoclam.'" alt="pathtoclam" />' );
|
||||
|
||||
/// quarantinedir
|
||||
$security['quarantinedir'] = new configvar (get_string('configquarantinedir', 'admin'),
|
||||
'<input type="text" name="quarantinedir" size="30" value="'.$config->quarantinedir.'" alt="quarantinedir" />' );
|
||||
|
||||
/// clamfailureonupload
|
||||
unset($options);
|
||||
$options['donothing'] = get_string('configclamdonothing', 'admin');
|
||||
$options['actlikevirus'] = get_string('configclamactlikevirus', 'admin');
|
||||
|
||||
$security['clamfailureonupload'] = new configvar (get_string('configclamfailureonupload', 'admin'),
|
||||
choose_from_menu($options, 'clamfailureonupload', $config->clamfailureonupload, '', '', '', true) );
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// MAINTENANCE config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$maintenance = array();
|
||||
|
||||
/// longtimenosee
|
||||
unset($options);
|
||||
$options[0] = get_string('never');
|
||||
$options[1000] = get_string('numdays', '', 1000);
|
||||
$options[365] = get_string('numdays', '', 365);
|
||||
$options[180] = get_string('numdays', '', 180);
|
||||
$options[150] = get_string('numdays', '', 150);
|
||||
$options[120] = get_string('numdays', '', 120);
|
||||
$options[90] = get_string('numdays', '', 90);
|
||||
$options[60] = get_string('numdays', '', 60);
|
||||
$options[30] = get_string('numdays', '', 30);
|
||||
$options[21] = get_string('numdays', '', 21);
|
||||
$options[14] = get_string('numdays', '', 14);
|
||||
$options[7] = get_string('numdays', '', 7);
|
||||
|
||||
$maintenance['longtimenosee'] = new configvar (get_string('configlongtimenosee', 'admin'),
|
||||
choose_from_menu ($options, 'longtimenosee', $config->longtimenosee, '', '', '', true) );
|
||||
|
||||
/// deleteunconfirmed
|
||||
unset($options);
|
||||
$options[0] = get_string('never');
|
||||
$options[168] = get_string('numdays', '', 7);
|
||||
$options[144] = get_string('numdays', '', 6);
|
||||
$options[120] = get_string('numdays', '', 5);
|
||||
$options[96] = get_string('numdays', '', 4);
|
||||
$options[72] = get_string('numdays', '', 3);
|
||||
$options[48] = get_string('numdays', '', 2);
|
||||
$options[24] = get_string('numdays', '', 1);
|
||||
$options[12] = get_string('numhours', '', 12);
|
||||
$options[6] = get_string('numhours', '', 6);
|
||||
$options[1] = get_string('numhours', '', 1);
|
||||
|
||||
$maintenance['deleteunconfirmed'] = new configvar (get_string('configdeleteunconfirmed', 'admin'),
|
||||
choose_from_menu ($options, 'deleteunconfirmed', $config->deleteunconfirmed, '', '', '', true) );
|
||||
|
||||
/// loglifetime
|
||||
unset($options);
|
||||
$options[0] = get_string('neverdeletelogs');
|
||||
$options[1000] = get_string('numdays', '', 1000);
|
||||
$options[365] = get_string('numdays', '', 365);
|
||||
$options[180] = get_string('numdays', '', 180);
|
||||
$options[150] = get_string('numdays', '', 150);
|
||||
$options[120] = get_string('numdays', '', 120);
|
||||
$options[90] = get_string('numdays', '', 90);
|
||||
$options[60] = get_string('numdays', '', 60);
|
||||
$options[30] = get_string('numdays', '', 30);
|
||||
|
||||
$maintenance['loglifetime'] = new configvar (get_string('configloglifetime', 'admin'),
|
||||
choose_from_menu ($options, 'loglifetime', $config->loglifetime, '', '', '', true) );
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// MAIL config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$mail = array();
|
||||
|
||||
/// smtphosts
|
||||
$mail['smtphosts'] = new configvar (get_string('configsmtphosts', 'admin'),
|
||||
'<input name="smtphosts" type="text" size="30" value="'.s($config->smtphosts).'" alt="smtphosts" />' );
|
||||
|
||||
/// smtpuser
|
||||
$mail['smtpuser'] = new configvar (get_string('configsmtpuser', 'admin'),
|
||||
'<input name="smtpuser" type="text" size="10" value="'.s($config->smtpuser).'" alt="smtpuser" />' );
|
||||
|
||||
/// smtppass
|
||||
$mail['smtppass'] = new configvar ('',
|
||||
'<input name="smtppass" type="password" size="10" value="'.s($config->smtppass).'" alt="smtppass" />' );
|
||||
|
||||
/// noreplyaddress
|
||||
$mail['noreplyaddress'] = new configvar (get_string('confignoreplyaddress', 'admin'),
|
||||
'<input name="noreplyaddress" type="text" size="30" value="'.s($config->noreplyaddress).'" alt="noreplyaddress" />' );
|
||||
|
||||
/// digestmailtime
|
||||
$hours = array();
|
||||
for ($i=0; $i<=23; $i++) {
|
||||
$hours[$i] = sprintf("%02d",$i);
|
||||
}
|
||||
|
||||
$mail['digestmailtime'] = new configvar (get_string('configdigestmailtime', 'admin'),
|
||||
choose_from_menu($hours, 'digestmailtime', $config->digestmailtime, '', '', 0, true) );
|
||||
|
||||
/// allowemailaddresses
|
||||
$mail['allowemailaddresses'] = new configvar (get_string('configallowemailaddresses', 'admin'),
|
||||
'<input name="allowemailaddresses" type="text" size="60" value="'.s($config->allowemailaddresses).'" alt="allowemailaddresses" />' );
|
||||
|
||||
/// denyemailaddresses
|
||||
$mail['denyemailaddresses'] = new configvar (get_string('configdenyemailaddresses', 'admin'),
|
||||
'<input name="denyemailaddresses" type="text" size="60" value="'.s($config->denyemailaddresses).'" alt="denyemailaddresses" />' );
|
||||
|
||||
if (!empty($CFG->unicodedb)) { ///These options are only available if running under unicodedb
|
||||
/// sitemailcharset
|
||||
unset($options);
|
||||
unset($charsets);
|
||||
$charsets = get_list_of_charsets();
|
||||
$options['0'] = get_string('none');
|
||||
$options = array_merge($options, $charsets);
|
||||
$mail['sitemailcharset'] = new configvar (get_string('configsitemailcharset', 'admin'),
|
||||
choose_from_menu($options, 'sitemailcharset', $config->sitemailcharset, '', '', '', true));
|
||||
|
||||
/// allowusermailcharset
|
||||
$mail['allowusermailcharset'] = new configvar (get_string('configallowusermailcharset', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'allowusermailcharset', $config->allowusermailcharset, '', '', '', true));
|
||||
}
|
||||
|
||||
/// enable stats
|
||||
if (empty($CFG->disablestatsprocessing)) {
|
||||
$stats['enablestats'] = new configvar (get_string('configenablestats','admin'),
|
||||
choose_from_menu($noyesoptions, 'enablestats', $config->enablestats, '', '', '', true) );
|
||||
|
||||
unset($options);
|
||||
$options['none'] = get_string('none');
|
||||
$options[60*60*24*7] = get_string('numweeks','moodle',1);
|
||||
$options[60*60*24*14] = get_string('numweeks','moodle',2);
|
||||
$options[60*60*24*21] = get_string('numweeks','moodle',3);
|
||||
$options[60*60*24*28] = get_string('nummonths','moodle',1);
|
||||
$options[60*60*24*56] = get_string('nummonths','moodle',2);
|
||||
$options[60*60*24*84] = get_string('nummonths','moodle',3);
|
||||
$options[60*60*24*112] = get_string('nummonths','moodle',4);
|
||||
$options[60*60*24*140] = get_string('nummonths','moodle',5);
|
||||
$options[60*60*24*168] = get_string('nummonths','moodle',6);
|
||||
$options['all'] = get_string('all');
|
||||
|
||||
$stats['statsfirstrun'] = new configvar (get_string('configstatsfirstrun','admin'),
|
||||
choose_from_menu($options,'statsfirstrun',$config->statsfirstrun,'','','',true) );
|
||||
|
||||
unset($options);
|
||||
$options[0] = get_string('untilcomplete');
|
||||
$options[60*60] = '1 '.get_string('hour');
|
||||
$options[60*60*2] = '2 '.get_string('hours');
|
||||
$options[60*60*3] = '3 '.get_string('hours');
|
||||
$options[60*60*4] = '4 '.get_string('hours');
|
||||
$options[60*60*5] = '5 '.get_string('hours');
|
||||
$options[60*60*6] = '6 '.get_string('hours');
|
||||
$options[60*60*7] = '7 '.get_string('hours');
|
||||
$options[60*60*8] = '8 '.get_string('hours');
|
||||
|
||||
if (empty($config->statsruntimestarthour)) {
|
||||
$config->statsruntimestarthour = 0;
|
||||
}
|
||||
if (empty($config->statsruntimestartminute)) {
|
||||
$config->statsruntimestartminute = 0;
|
||||
}
|
||||
|
||||
$stats['statsmaxruntime'] = new configvar (get_string('configstatsmaxruntime','admin'),
|
||||
choose_from_menu($options,'statsmaxruntime',$config->statsmaxruntime,'','','',true) );
|
||||
|
||||
$stats['statsruntimestart'] = new configvar (get_string('configstatsruntimestart','admin'),
|
||||
print_time_selector("statsruntimestarthour","statsruntimestartminute",make_timestamp(2000,1,1,$config->statsruntimestarthour,$config->statsruntimestartminute),5,true) );
|
||||
|
||||
$stats['statsuserthreshold'] = new configvar (get_string('configstatsuserthreshold','admin'),
|
||||
'<input type="text" name="statsuserthreshold" size="4" value="'.$config->statsuserthreshold.'" />');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
$configvars['interface'] = $interface;
|
||||
$configvars['security'] = $security;
|
||||
$configvars['operatingsystem'] = $operatingsystem;
|
||||
$configvars['maintenance'] = $maintenance;
|
||||
$configvars['mail'] = $mail;
|
||||
$configvars['user'] = $user;
|
||||
$configvars['permissions'] = $permissions;
|
||||
$configvars['requestedcourse'] = $reqcourse;
|
||||
$configvars['misc'] = $misc;
|
||||
if (empty($CFG->disablestatsprocessing)) {
|
||||
$configvars['stats'] = $stats;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to enable, disable and uninstall course formats
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$formatname = required_param('format', PARAM_PLUGIN);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/courseformats.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
|
||||
|
||||
$formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
|
||||
$sortorder = array_flip(array_keys($formatplugins));
|
||||
|
||||
if (!isset($formatplugins[$formatname])) {
|
||||
print_error('courseformatnotfound', 'error', $return, $formatname);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($formatplugins[$formatname]->is_enabled()) {
|
||||
if (get_config('moodlecourse', 'format') === $formatname) {
|
||||
print_error('cannotdisableformat', 'error', $return);
|
||||
}
|
||||
set_config('disabled', 1, 'format_'. $formatname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$formatplugins[$formatname]->is_enabled()) {
|
||||
unset_config('disabled', 'format_'. $formatname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'up':
|
||||
if ($sortorder[$formatname]) {
|
||||
$currentindex = $sortorder[$formatname];
|
||||
$seq = array_keys($formatplugins);
|
||||
$seq[$currentindex] = $seq[$currentindex-1];
|
||||
$seq[$currentindex-1] = $formatname;
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'down':
|
||||
if ($sortorder[$formatname] < count($sortorder)-1) {
|
||||
$currentindex = $sortorder[$formatname];
|
||||
$seq = array_keys($formatplugins);
|
||||
$seq[$currentindex] = $seq[$currentindex+1];
|
||||
$seq[$currentindex+1] = $formatname;
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
}
|
||||
redirect($return);
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strcourses = get_string("courses");
|
||||
|
||||
print_header("$site->shortname: $stradministration: $strcourses", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strcourses");
|
||||
|
||||
print_heading($strcourses);
|
||||
|
||||
$table->align = array ("right", "left");
|
||||
|
||||
$table->data[] = array('<b><a href="../course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.get_string("managecourses")."</a></b>",
|
||||
get_string("adminhelpcourses"));
|
||||
$table->data[] = array("<b><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolmentplugins")."</a></b>",
|
||||
get_string("adminhelpenrolments"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a></b>",
|
||||
get_string("adminhelpassignstudents"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a></b>",
|
||||
get_string("adminhelpassignteachers")." <img src=\"../pix/t/user.gif\" height=\"11\" width=\"11\" alt=\"\" />");
|
||||
$table->data[] = array("<b><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a></b>",
|
||||
get_string("adminhelpassigncreators"));
|
||||
$table->data[] = array("<b><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a></b>",
|
||||
get_string("adminhelpassignadmins"));
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
<form name="creatorsform" id="creatorsform" method="post" action="creators.php">
|
||||
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = count($creators);
|
||||
$a->items = $strexistingcreators;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = $usercount;
|
||||
$a->items = $strpotentialcreators;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple
|
||||
onFocus="document.creatorsform.add.disabled=true;
|
||||
document.creatorsform.remove.disabled=false;
|
||||
document.creatorsform.addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($creators as $creator) {
|
||||
$fullname = fullname($creator, true);
|
||||
echo "<option value=\"$creator->id\">".$fullname.", ".$creator->email."</option>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple
|
||||
onFocus="document.creatorsform.add.disabled=false;
|
||||
document.creatorsform.remove.disabled=true;
|
||||
document.creatorsform.removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
|
||||
foreach ($searchusers as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext) ?>"
|
||||
onFocus ="document.creatorsform.add.disabled=true;
|
||||
document.creatorsform.remove.disabled=true;
|
||||
document.creatorsform.removeselect.selectedIndex=-1;
|
||||
document.creatorsform.addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
document.creatorsform.previoussearch.value=1;
|
||||
document.creatorsform.submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>"/>
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
<?PHP // $Id$
|
||||
// Admin only script to assign course creator rights to users
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
$stringstoload = array (
|
||||
"assigncreators",
|
||||
"administration",
|
||||
"existingcreators",
|
||||
"potentialcreators",
|
||||
"search",
|
||||
"users",
|
||||
"searchresults",
|
||||
"showall"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
$strstringtoload = "str" . $stringtoload;
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassigncreators",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
|
||||
$strassigncreators", "creatorsform.searchtext");
|
||||
|
||||
|
||||
if (!$frm = data_submitted()) {
|
||||
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
|
||||
$frm = new object();
|
||||
|
||||
/// A form was submitted so process the input
|
||||
|
||||
} else {
|
||||
if (!empty($frm->add) and !empty($frm->addselect)) {
|
||||
foreach ($frm->addselect as $addcreator) {
|
||||
if (! add_creator($addcreator)) {
|
||||
error("Could not add course creator with user id $addcreator!");
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
|
||||
foreach ($frm->removeselect as $removecreator) {
|
||||
if (! remove_creator($removecreator)) {
|
||||
error("Could not remove course creator with user id $removecreator!");
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->showall)) {
|
||||
unset($frm->searchtext);
|
||||
$frm->previoussearch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Is there a current search?
|
||||
$previoussearch = (!empty($frm->search) or (isset($frm->previoussearch) && $frm->previoussearch == 1)) ;
|
||||
|
||||
|
||||
/// Get all existing creators
|
||||
if (! $creators = get_creators()) {
|
||||
$creators = array();
|
||||
}
|
||||
|
||||
$creatorsarray = array();
|
||||
foreach ($creators as $creator) {
|
||||
$creatorsarray[] = $creator->id;
|
||||
}
|
||||
$creatorlist = implode(',', $creatorsarray);
|
||||
|
||||
unset($creatorarray);
|
||||
|
||||
|
||||
/// Get search results excluding any current admins
|
||||
if (!empty($frm->searchtext) and $previoussearch) {
|
||||
$searchusers = get_users(true, $frm->searchtext, true, $creatorlist, 'firstname ASC, lastname ASC',
|
||||
'', '', 0, 99999, 'id, firstname, lastname, email');
|
||||
$usercount = get_users(false, '', true, $creatorlist);
|
||||
}
|
||||
|
||||
/// If no search results then get potential users excluding current creators
|
||||
if (empty($searchusers)) {
|
||||
if (!$users = get_users(true, '', true, $creatorlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email') ) {
|
||||
$users = array();
|
||||
}
|
||||
$usercount = count($users);
|
||||
}
|
||||
|
||||
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
|
||||
$previoussearch = ($previoussearch) ? '1' : '0';
|
||||
|
||||
include('./creators.html');
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+326
-72
@@ -1,81 +1,335 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
|
||||
// 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 looks through all the module directories for cron.php files
|
||||
/// and runs them. These files can contain cleanup functions, email functions
|
||||
/// or anything that needs to be run on a regular basis.
|
||||
///
|
||||
/// This file is best run from cron on the host system (ie outside PHP).
|
||||
/// The script can either be invoked via the web server or via a standalone
|
||||
/// version of PHP compiled for CGI.
|
||||
///
|
||||
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
|
||||
/// or php /web/moodle/admin/cron.php
|
||||
|
||||
/**
|
||||
* Web cron
|
||||
*
|
||||
* This script looks through all the module directories for cron.php files
|
||||
* and runs them. These files can contain cleanup functions, email functions
|
||||
* or anything that needs to be run on a regular basis.
|
||||
*
|
||||
* This file is best run from cron on the host system (ie outside PHP).
|
||||
* It is strongly recommended to add password protection via admin settings.
|
||||
*
|
||||
* eg wget -q -O /dev/null 'http: *moodle.somewhere.edu/admin/cron.php?password=SeCreT666'
|
||||
*
|
||||
* It is also possible to use CLI script admin/cli/cron.php instead,
|
||||
* you can not call this script from command line any more.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
$starttime = microtime();
|
||||
|
||||
/// The following is a hack necessary to allow this script to work well
|
||||
/// from the command line.
|
||||
|
||||
if (defined('STDIN')) {
|
||||
fwrite(STDERR, "ERROR: This script no longer supports CLI, please use admin/cli/cron.php instead\n");
|
||||
exit(1);
|
||||
}
|
||||
define('FULLME', 'cron');
|
||||
|
||||
/// The current directory in PHP version 4.3.0 and above isn't necessarily the
|
||||
/// directory of the script when run from the command line. The require_once()
|
||||
/// would fail, so we'll have to chdir()
|
||||
|
||||
// This is a fake CLI script, it is a really ugly hack which emulates
|
||||
// CLI via web interface, please do not use this hack elsewhere
|
||||
define('CLI_SCRIPT', true);
|
||||
define('WEB_CRON_EMULATED_CLI', 'defined'); // ugly ugly hack, do not use elsewhere please
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// extra safety
|
||||
\core\session\manager::write_close();
|
||||
|
||||
// check if execution allowed
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
// This script can only be run via the cli.
|
||||
print_error('cronerrorclionly', 'admin');
|
||||
exit;
|
||||
}
|
||||
// This script is being called via the web, so check the password if there is one.
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$pass = optional_param('password', '', PARAM_RAW);
|
||||
if ($pass != $CFG->cronremotepassword) {
|
||||
// wrong password.
|
||||
print_error('cronerrorpassword', 'admin');
|
||||
exit;
|
||||
if (!isset($_SERVER['REMOTE_ADDR']) && isset($_SERVER['argv'][0])) {
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
}
|
||||
}
|
||||
|
||||
// send mime type and encoding
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot.'/lib/adminlib.php');
|
||||
|
||||
// we do not want html markup in emulated CLI
|
||||
@ini_set('html_errors', 'off');
|
||||
if (!$alreadyadmin = isadmin()) {
|
||||
unset($_SESSION['USER']);
|
||||
unset($USER);
|
||||
unset($_SESSION['SESSION']);
|
||||
unset($SESSION);
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
// we need to override the admin timezone to the moodle timezone!
|
||||
$USER->timezone = $CFG->timezone;
|
||||
}
|
||||
|
||||
// execute the cron
|
||||
cron_run();
|
||||
//unset test cookie, user must login again anyway
|
||||
setcookie('MoodleSessionTest'.$CFG->sessioncookie, '', time() - 3600, '/');
|
||||
|
||||
/// switch to site language and locale
|
||||
if (!empty($CFG->courselang)) {
|
||||
unset ($CFG->courselang);
|
||||
}
|
||||
if (!empty($SESSION->lang)) {
|
||||
unset ($SESSION->lang);
|
||||
}
|
||||
$USER->lang = '';
|
||||
moodle_setlocale();
|
||||
|
||||
/// send mime type and encoding
|
||||
@header('Content-Type: text/plain; charset='.current_charset());
|
||||
|
||||
/// Start output log
|
||||
|
||||
$timenow = time();
|
||||
|
||||
mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
|
||||
/// Run all cron jobs for each module
|
||||
|
||||
mtrace("Starting activity modules");
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
foreach ($mods as $mod) {
|
||||
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
|
||||
if (file_exists($libfile)) {
|
||||
include_once($libfile);
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
if ($cron_function()) {
|
||||
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
|
||||
mtrace("Error: could not update timestamp for $mod->fullname");
|
||||
}
|
||||
}
|
||||
mtrace("done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mtrace("Finished activity modules");
|
||||
|
||||
mtrace("Starting blocks");
|
||||
if ($blocks = get_records_select("block", "cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
// we will need the base class.
|
||||
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
|
||||
foreach ($blocks as $block) {
|
||||
$blockfile = $CFG->dirroot.'/blocks/'.$block->name.'/block_'.$block->name.'.php';
|
||||
if (file_exists($blockfile)) {
|
||||
require_once($blockfile);
|
||||
$classname = 'block_'.$block->name;
|
||||
$blockobj = new $classname;
|
||||
if (method_exists($blockobj,'cron')) {
|
||||
mtrace("Processing cron function for ".$block->name.'....','');
|
||||
if ($blockobj->cron()) {
|
||||
if (!set_field('block','lastcron',$timenow,'id',$block->id)) {
|
||||
mtrace('Error: could not update timestamp for '.$block->name);
|
||||
}
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mtrace("Finished blocks");
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages();
|
||||
}
|
||||
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
/// to randomly choose the percentage of times we should run these jobs.
|
||||
|
||||
srand ((double) microtime() * 10000000);
|
||||
$random100 = rand(0,100);
|
||||
|
||||
if ($random100 < 20) { // Approximately 20% of the time.
|
||||
mtrace("Running clean-up tasks...");
|
||||
|
||||
/// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
if ($CFG->longtimenosee) { // value in days
|
||||
$longtime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
if ($students = get_users_longtimenosee($longtime)) {
|
||||
foreach ($students as $student) {
|
||||
if (unenrol_student($student->userid, $student->course)) {
|
||||
mtrace("Deleted student enrolment for user $student->userid from course $student->course");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Delete users who haven't confirmed within required period
|
||||
|
||||
if (!empty($CFG->deleteunconfirmed)) {
|
||||
$oneweek = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
if ($users = get_users_unconfirmed($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
/// Delete users who haven't completed profile within required period
|
||||
|
||||
if (!empty($CFG->deleteunconfirmed)) {
|
||||
$oneweek = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
if ($users = get_users_not_fully_set_up($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted not fully setup user $user->username ($user->id)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
/// Delete old logs to save space (this might need a timer to slow it down...)
|
||||
|
||||
if (!empty($CFG->loglifetime)) { // value in days
|
||||
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
|
||||
delete_records_select("log", "time < '$loglifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
/// Delete old cached texts
|
||||
|
||||
if (!empty($CFG->cachetext)) { // Defined in config.php
|
||||
$cachelifetime = time() - $CFG->cachetext - 60; // Add an extra minute to allow for really heavy sites
|
||||
delete_records_select('cache_text', "timemodified < '$cachelifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
if (!empty($CFG->notifyloginfailures)) {
|
||||
notify_login_failures();
|
||||
}
|
||||
flush();
|
||||
|
||||
sync_metacourses();
|
||||
|
||||
//
|
||||
// generate new password emails for users
|
||||
//
|
||||
mtrace('checking for create_password');
|
||||
if (count_records('user_preferences', 'name', 'create_password', 'value', '1')) {
|
||||
mtrace('creating passwords for new users');
|
||||
$newusers = get_records_sql("SELECT u.id as id, u.email, u.firstname,
|
||||
u.lastname, u.username,
|
||||
p.id as prefid
|
||||
FROM {$CFG->prefix}user u
|
||||
JOIN {$CFG->prefix}user_preferences p ON u.id=p.userid
|
||||
WHERE p.name='create_password' AND p.value=1 AND u.email !='' ");
|
||||
|
||||
foreach ($newusers as $newuserid => $newuser) {
|
||||
$newuser->emailstop = 0; // send email regardless
|
||||
// email user
|
||||
if (setnew_password_and_mail($newuser)) {
|
||||
// remove user pref
|
||||
delete_records('user_preferences', 'id', $newuser->prefid);
|
||||
} else {
|
||||
trigger_error("Could not create and mail new user password!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of occasional clean-up tasks
|
||||
|
||||
|
||||
if (!isset($CFG->disablescheduledbackups)) { // Defined in config.php
|
||||
//Execute backup's cron
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("128M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
// if we are running from Apache, give httpd a hint that
|
||||
// it can recycle the process after it's done. Apache's
|
||||
// memory management is truly awful but we can help it.
|
||||
@apache_child_terminate();
|
||||
}
|
||||
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
|
||||
file_exists("$CFG->dirroot/backup/backuplib.php") and
|
||||
file_exists("$CFG->dirroot/backup/lib.php") and
|
||||
file_exists("$CFG->libdir/blocklib.php")) {
|
||||
include_once("$CFG->dirroot/backup/backup_scheduled.php");
|
||||
include_once("$CFG->dirroot/backup/backuplib.php");
|
||||
include_once("$CFG->dirroot/backup/lib.php");
|
||||
require_once ("$CFG->libdir/blocklib.php");
|
||||
mtrace("Running backups if required...");
|
||||
|
||||
if (! schedule_backup_cron()) {
|
||||
mtrace("ERROR: Something went wrong while performing backup tasks!!!");
|
||||
} else {
|
||||
mtrace("Backup tasks finished.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablerssfeeds)) { //Defined in admin/variables page
|
||||
include_once("$CFG->libdir/rsslib.php");
|
||||
mtrace("Running rssfeeds if required...");
|
||||
|
||||
if ( ! cron_rss_feeds()) {
|
||||
mtrace("Something went wrong while generating rssfeeds!!!");
|
||||
} else {
|
||||
mtrace("Rssfeeds finished");
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the enrolment cron, if any
|
||||
if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
|
||||
$plugins = array($CFG->enrol);
|
||||
}
|
||||
require_once($CFG->dirroot .'/enrol/enrol.class.php');
|
||||
foreach ($plugins as $p) {
|
||||
$enrol = enrolment_factory::factory($p);
|
||||
if (method_exists($enrol, 'cron')) {
|
||||
$enrol->cron();
|
||||
}
|
||||
if (!empty($enrol->log)) {
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
unset($enrol);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
|
||||
|
||||
// check we're not before our runtime
|
||||
$timetocheck = strtotime("$CFG->statsruntimestarthour:$CFG->statsruntimestartminute today");
|
||||
|
||||
if (time() > $timetocheck) {
|
||||
$time = 60*60*20; // set it to 20 here for first run... (overridden by $CFG)
|
||||
$clobber = true;
|
||||
if (!empty($CFG->statsmaxruntime)) {
|
||||
$time = $CFG->statsmaxruntime+(60*30); // add on half an hour just to make sure (it could take that long to break out of the loop)
|
||||
}
|
||||
if (!get_field_sql('SELECT id FROM '.$CFG->prefix.'stats_daily LIMIT 1')) {
|
||||
// first run, set another lock. we'll check for this in subsequent runs to set the timeout to later for the normal lock.
|
||||
set_cron_lock('statsfirstrunlock',true,$time,true);
|
||||
$firsttime = true;
|
||||
}
|
||||
$time = 60*60*2; // this time set to 2.. (overridden by $CFG)
|
||||
if (!empty($CFG->statsmaxruntime)) {
|
||||
$time = $CFG->statsmaxruntime+(60*30); // add on half an hour to make sure (it could take that long to break out of the loop)
|
||||
}
|
||||
if ($config = get_record('config','name','statsfirstrunlock')) {
|
||||
if (!empty($config->value)) {
|
||||
$clobber = false; // if we're on the first run, just don't clobber it.
|
||||
}
|
||||
}
|
||||
if (set_cron_lock('statsrunning',true,$time, $clobber)) {
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
$return = stats_cron_daily();
|
||||
if (stats_check_runtime() && $return == STATS_RUN_COMPLETE) {
|
||||
stats_cron_weekly();
|
||||
}
|
||||
if (stats_check_runtime() && $return == STATS_RUN_COMPLETE) {
|
||||
$return = $return && stats_cron_monthly();
|
||||
}
|
||||
if (stats_check_runtime() && $return == STATS_RUN_COMPLETE) {
|
||||
stats_clean_old();
|
||||
}
|
||||
set_cron_lock('statsrunning',false);
|
||||
if (!empty($firsttime)) {
|
||||
set_cron_lock('statsfirstrunlock',false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Unset session variables and destroy it
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
|
||||
mtrace("Cron script completed correctly");
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Lets users manage data formats
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @copyright 2016 Brendan Heywood (brendan@catalyst-au.net)
|
||||
* @package core
|
||||
* @subpackage dataformat
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$name = required_param('name', PARAM_PLUGIN);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/dataformats.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'managedataformats'));
|
||||
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
|
||||
$sortorder = array_flip(array_keys($plugins));
|
||||
|
||||
if (!isset($plugins[$name])) {
|
||||
print_error('courseformatnotfound', 'error', $return, $name);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($plugins[$name]->is_enabled()) {
|
||||
set_config('disabled', 1, 'dataformat_'. $name);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$plugins[$name]->is_enabled()) {
|
||||
unset_config('disabled', 'dataformat_'. $name);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'up':
|
||||
if ($sortorder[$name]) {
|
||||
$currentindex = $sortorder[$name];
|
||||
$seq = array_keys($plugins);
|
||||
$seq[$currentindex] = $seq[$currentindex - 1];
|
||||
$seq[$currentindex - 1] = $name;
|
||||
set_config('dataformat_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'down':
|
||||
if ($sortorder[$name] < count($sortorder) - 1) {
|
||||
$currentindex = $sortorder[$name];
|
||||
$seq = array_keys($plugins);
|
||||
$seq[$currentindex] = $seq[$currentindex + 1];
|
||||
$seq[$currentindex + 1] = $name;
|
||||
set_config('dataformat_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
}
|
||||
redirect($return);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?PHP // $Id$
|
||||
// dbperformance.php - shows latest ADOdb stats for the current server
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$topframe = optional_param('topframe', 0, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', 0, PARAM_BOOL);
|
||||
$do = optional_param('do', '', PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$strdatabaseperformance = get_string("databaseperformance");
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
if (!empty($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> Database performance");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($bottomframe) or !empty($do)) {
|
||||
$perf =&NewPerfMonitor($db);
|
||||
$perf->UI($pollsecs=5);
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<head>
|
||||
<title><?php echo "$site->shortname: $strdatabaseperformance" ?></title>
|
||||
</head>
|
||||
|
||||
<frameset rows="80,*">
|
||||
<frame src="dbperformance.php?topframe=true">
|
||||
<frame src="dbperformance.php?bottomframe=true">
|
||||
</frameset>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// Deletes the moodledata directory, COMPLETELY!!
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
$sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
$reallysure = optional_param('reallysure', 0, PARAM_BOOL);
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be admin to use this script!');
|
||||
}
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
if (empty($sure)) {
|
||||
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 'delete.php?sure=yes&sesskey='.sesskey(), 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($reallysure)) {
|
||||
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?', 'delete.php?sure=yes&reallysure=yes&sesskey='.sesskey(), 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error('This script was called wrongly');
|
||||
}
|
||||
|
||||
/// OK, here goes ...
|
||||
|
||||
delete_subdirectories($deletedir);
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
print_continue($CFG->wwwroot);
|
||||
exit;
|
||||
|
||||
|
||||
function delete_subdirectories($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
if (filetype($fullfile) == 'dir') {
|
||||
delete_subdirectories($fullfile);
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (rmdir($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
}
|
||||
} else {
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (unlink($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,331 @@
|
||||
<form method="post" action="editor.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="tab" value="<?php p($currentpage) ?>" />
|
||||
<table border="0" cellpadding="4" cellspacing="2">
|
||||
<tr>
|
||||
<td align="right" valign="top">htmleditor:</td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("allownot");
|
||||
$options[1] = get_string("allow");
|
||||
choose_from_menu ($options, "htmleditor", $CFG->htmleditor, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('confightmleditor', 'admin') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $currenttab == 'htmlarea' ) { ?>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorbackgroundcolor:</td>
|
||||
<td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>" /></td>
|
||||
<td valign="top"><?php print_string("edhelpbgcolor");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorfontfamily:</td>
|
||||
<td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>" /></td>
|
||||
<td valign="top"><?php print_string("edhelpfontfamily");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorfontsize:</td>
|
||||
<td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>" /></td>
|
||||
<td valign="top"><?php print_string("edhelpfontsize");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorkillword:</td>
|
||||
<td valign="top"><select name="killword">
|
||||
<option value="1"<?php print(!$CFG->editorkillword)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
|
||||
<option value="0"<?php print(!$CFG->editorkillword)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
|
||||
</select></td>
|
||||
<td valign="top"><?php print_string("edhelpcleanword");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">aspellpath:</td>
|
||||
<td valign="top"><input onchange="change_state()" id="aspellpath" type="text" name="aspellpath" size="25" value="<?php print($CFG->aspellpath);?>" /></td>
|
||||
<td valign="top"><?php print_string("edhelpaspellpath");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorspelling:</td>
|
||||
<td valign="top"><select onchange="change_state()" id="spelling" name="spelling"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editorspelling = false;
|
||||
}
|
||||
?>>
|
||||
<option value="1"<?php print(!$CFG->editorspelling)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
|
||||
<option value="0"<?php print(!$CFG->editorspelling)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
|
||||
</select>
|
||||
<select id="dictionary" name="dictionary"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editordictionary = false;
|
||||
}
|
||||
?>>
|
||||
<?php
|
||||
if (is_array($dicts)) {
|
||||
foreach ($dicts as $dict) {
|
||||
echo "<option value=\"$dict\"";
|
||||
if (!empty($CFG->editordictionary)) {
|
||||
print ($CFG->editordictionary != $dict) ? "" : " selected=\"selected\"";
|
||||
}
|
||||
echo ">$dict</option>\n";
|
||||
}
|
||||
} else if (is_string($dicts)) {
|
||||
echo '<option value="">'. $dicts .'</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td valign="top"><?php print_string("edhelpenablespelling");?></td>
|
||||
</tr>
|
||||
<tr><td colspan="3"><br /><?php print_string("edhelpfontlist");?></td></tr>
|
||||
<?php
|
||||
if(is_array($fontlist)) {
|
||||
foreach($fontlist as $fontkey => $fontvalue) {
|
||||
?>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>">
|
||||
<input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="" />
|
||||
<input type="text" name="fontnamevalue[]" size="30" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right">editorhidebuttons:</td>
|
||||
<td colspan="2">
|
||||
<?php
|
||||
$buttons = array();
|
||||
if (!empty($CFG->editorhidebuttons)) {
|
||||
$buttons = explode(chr(32), $CFG->editorhidebuttons);
|
||||
}
|
||||
?>
|
||||
<table border="0" cellpadding="2" cellspacing="1">
|
||||
<tr>
|
||||
<td colspan="12"><input type="checkbox" name="buttons[fontname]"<?php print(in_array("fontname", $buttons)) ? " checked=\"checked\"": "";?> /> <?php print_string("fontname","editor");?>
|
||||
<input type="checkbox" name="buttons[fontsize]"<?php print(in_array("fontsize", $buttons)) ? " checked=\"checked\"": "";?> /> <?php print_string("fontsize","editor");?>
|
||||
<input type="checkbox" name="buttons[formatblock]"<?php print(in_array("formatblock", $buttons)) ? " checked=\"checked\"": "";?> /> <?php print_string("formatblock","editor");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_bold.gif" width="18" height="18" alt="<?php print_string("bold","editor");?>" title="<?php print_string("bold","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_italic.gif" width="18" height="18" alt="<?php print_string("italic","editor");?>" title="<?php print_string("italic","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_underline.gif" width="18" height="18" alt="<?php print_string("underline","editor");?>" title="<?php print_string("underline","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_strike.gif" width="18" height="18" alt="<?php print_string("strikethrough","editor");?>" title="<?php print_string("strikethrough","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_sub.gif" width="18" height="18" alt="<?php print_string("subscript","editor");?>" title="<?php print_string("subscript","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_sup.gif" width="18" height="18" alt="<?php print_string("superscript","editor");?>" title="<?php print_string("superscript","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_copy.gif" width="18" height="18" alt="<?php print_string("copy","editor");?>" title="<?php print_string("copy","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_cut.gif" width="18" height="18" alt="<?php print_string("cut","editor");?>" title="<?php print_string("cut","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_paste.gif" width="18" height="18" alt="<?php print_string("paste","editor");?>" title="<?php print_string("paste","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_wordclean.gif" width="18" height="18" alt="<?php print_string("wordclean","editor");?>" title="<?php print_string("wordclean","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_undo.gif" width="18" height="18" alt="<?php print_string("undo","editor");?>" title="<?php print_string("undo","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_redo.gif" width="18" height="18" alt="<?php print_string("redo","editor");?>" title="<?php print_string("redo","editor");?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[bold]"<?php print(in_array("bold", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[italic]"<?php print(in_array("italic", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[underline]"<?php print(in_array("underline", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[strikethrough]"<?php print(in_array("strikethrough", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[subscript]"<?php print(in_array("subscript", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[superscript]"<?php print(in_array("superscript", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[copy]"<?php print(in_array("copy", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[cut]"<?php print(in_array("cut", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[paste]"<?php print(in_array("paste", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[clean]"<?php print(in_array("clean", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[undo]"<?php print(in_array("undo", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[redo]"<?php print(in_array("redo", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_left.gif" width="18" height="18" alt="<?php print_string("justifyleft","editor");?>" title="<?php print_string("justifyleft","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_center.gif" width="18" height="18" alt="<?php print_string("justifycenter","editor");?>" title="<?php print_string("justifycenter","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_right.gif" width="18" height="18" alt="<?php print_string("justifyright","editor");?>" title="<?php print_string("justifyright","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_justify.gif" width="18" height="18" alt="<?php print_string("justifyfull","editor");?>" title="<?php print_string("justifyfull","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_left_to_right.gif" width="18" height="18" alt="<?php print_string("lefttoright","editor");?>" title="<?php print_string("lefttoright","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_right_to_left.gif" width="18" height="18" alt="<?php print_string("righttoleft","editor");?>" title="<?php print_string("righttoleft","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_list_num.gif" width="18" height="18" alt="<?php print_string("orderedlist","editor");?>" title="<?php print_string("orderedlist","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_list_bullet.gif" width="18" height="18" alt="<?php print_string("unorderedlist","editor");?>" title="<?php print_string("unorderedlist","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_indent_less.gif" width="18" height="18" alt="<?php print_string("outdent","editor");?>" title="<?php print_string("outdent","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_indent_more.gif" width="18" height="18" alt="<?php print_string("indent","editor");?>" title="<?php print_string("indent","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_color_fg.gif" width="18" height="18" alt="<?php print_string("forecolor","editor");?>" title="<?php print_string("forecolor","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_color_bg.gif" width="18" height="18" alt="<?php print_string("hilitecolor","editor");?>" title="<?php print_string("hilitecolor","editor");?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[justifyleft]"<?php print(in_array("justifyleft", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[justifycenter]"<?php print(in_array("justifycenter", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[justifyright]"<?php print(in_array("justifyright", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[justifyfull]"<?php print(in_array("justifyfull", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[lefttoright]"<?php print(in_array("lefttoright", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[righttoleft]"<?php print(in_array("righttoleft", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertorderedlist]"<?php print(in_array("insertorderedlist", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertunorderedlist]"<?php print(in_array("insertunorderedlist", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[outdent]"<?php print(in_array("outdent", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[indent]"<?php print(in_array("indent", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[forecolor]"<?php print(in_array("forecolor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[hilitecolor]"<?php print(in_array("hilitecolor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_hr.gif" width="18" height="18" alt="<?php print_string("horizontalrule","editor");?>" title="<?php print_string("horizontalrule","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_anchor.gif" width="18" height="18" alt="<?php print_string("createanchor","editor");?>" title="<?php print_string("createanchor","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_link.gif" width="18" height="18" alt="<?php print_string("insertlink","editor");?>" title="<?php print_string("insertlink","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_unlink.gif" width="18" height="18" alt="<?php print_string("removelink","editor");?>" title="<?php print_string("removelink","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_image.gif" width="18" height="18" alt="<?php print_string("insertimage","editor");?>" title="<?php print_string("insertimage","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/insert_table.gif" width="18" height="18" alt="<?php print_string("inserttable","editor");?>" title="<?php print_string("inserttable","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/em.icon.smile.gif" width="18" height="18" alt="<?php print_string("insertsmile","editor");?>" title="<?php print_string("insertsmile","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/icon_ins_char.gif" width="18" height="18" alt="<?php print_string("insertchar","editor");?>" title="<?php print_string("insertchar","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/spell-check.gif" width="18" height="18" alt="<?php print_string("spellcheck","editor");?>" title="<?php print_string("spellcheck","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_html.gif" width="18" height="18" alt="<?php print_string("htmlmode","editor");?>" title="<?php print_string("htmlmode","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/fullscreen_maximize.gif" width="18" height="18" alt="<?php print_string("popupeditor","editor");?>" title="<?php print_string("popupeditor","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_replace.gif" width="18" height="18" alt="<?php print_string("popupeditor","editor");?>" title="<?php print_string("searchandreplace","editor");?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[inserthorizontalrule]"<?php print(in_array("inserthorizontalrule", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[createanchor]"<?php print(in_array("createanchor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[createlink]"<?php print(in_array("createlink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[unlink]"<?php print(in_array("unlink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertimage]"<?php print(in_array("insertimage", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[inserttable]"<?php print(in_array("inserttable", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertsmile]"<?php print(in_array("insertsmile", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertchar]"<?php print(in_array("insertchar", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[spellcheck]"<?php print(in_array("spellcheck", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[htmlmode]"<?php print(in_array("htmlmode", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[popupeditor]"<?php print(in_array("popupeditor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[search_replace]"<?php print(in_array("search_replace", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_nolink.gif" width="18" height="18" alt="<?php print_string("horizontalrule","editor");?>" title="<?php print_string("nolink","editor");?>" /></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[nolink]"<?php print(in_array("nolink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
else if ( $currenttab == 'tinymce' ) {
|
||||
?>
|
||||
<tr>
|
||||
<td>tinymcetheme:</td>
|
||||
<td><?php
|
||||
$options = array('advanced' => 'Advanced','simple' => 'Simple');
|
||||
choose_from_menu ($options, "tinymcetheme", $CFG->tinymcetheme, "", "", "");
|
||||
?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">tinymceplugins:</td>
|
||||
<td nowrap="nowrap"><?php
|
||||
$pluginsdir = $CFG->libdir .'/editor/tinymce/jscripts/tiny_mce/plugins';
|
||||
$plugins = editor_get_tiny_plugins();
|
||||
$pluginsinuse = explode(",", $CFG->tinymceplugins);
|
||||
|
||||
sort($plugins);
|
||||
$cnt = 0;
|
||||
echo '<table border="0" cellpadding="2">';
|
||||
foreach ( $plugins as $plugin ) {
|
||||
$num = ($cnt % 2);
|
||||
if ( $num < 1 ) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td><input type="checkbox" name="tinymceplugins[]" value="'. s($plugin) .'"';
|
||||
if ( in_array($plugin, $pluginsinuse) ) {
|
||||
echo ' checked="checked"';
|
||||
}
|
||||
echo ' /> '. $plugin .'</td>'."\n";
|
||||
|
||||
if ( $num > 0 ) {
|
||||
echo '</tr>';
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
echo '</table>';
|
||||
?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tinymcecontentcss:</td>
|
||||
<td><input type="text" name="tinymcecontentcss" value="<?php
|
||||
!empty($CFG->tinymcecontentcss) ? p($CFG->tinymcecontentcss) : ''; ?>" size="40" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tinymcepopupcss:</td>
|
||||
<td><input type="text" name="tinymcepopupcss" value="<?php
|
||||
!empty($CFG->tinymcepopupcss) ? p($CFG->tinymcepopupcss) : ''; ?>" size="40" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tinymceeditorcss:</td>
|
||||
<td><input type="text" name="tinymceeditorcss" value="<?php
|
||||
!empty($CFG->tinymceeditorcss) ? p($CFG->tinymceeditorcss) : ''; ?>" size="40" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<form method="post" action="<?php print($GLOBALS['ME']);?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="tab" value="<?php p($currentpage) ?>" />
|
||||
<center>
|
||||
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
|
||||
</center>
|
||||
</form>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
|
||||
function change_state () {
|
||||
|
||||
var choice = document.forms[0].spelling;
|
||||
var speller = choice.options[choice.selectedIndex].value;
|
||||
var spellpath = document.forms[0].aspellpath.value;
|
||||
|
||||
if (spellpath == '') {
|
||||
document.forms[0].spelling.disabled = true;
|
||||
} else {
|
||||
document.forms[0].spelling.disabled = false;
|
||||
}
|
||||
|
||||
if (speller != 1) {
|
||||
document.forms[0].dictionary.disabled = true;
|
||||
} else {
|
||||
document.forms[0].dictionary.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
document.onload = change_state();
|
||||
-->
|
||||
</script>
|
||||
@@ -0,0 +1,306 @@
|
||||
<?php // $Id$
|
||||
/// configuration routines for HTMLArea editor
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$currentpage = optional_param('tab', 1, PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (($data = data_submitted()) && confirm_sesskey()) {
|
||||
|
||||
// do we want default values?
|
||||
if (isset($data->resettodefaults)) {
|
||||
if (!(reset_to_defaults($currentpage))) {
|
||||
error("Editor settings could not be restored!");
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!(editor_update_config($data, $currentpage))) {
|
||||
error("Editor settings could not be updated!");
|
||||
}
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/editor.php?tab=$currentpage", get_string("changessaved"), 1);
|
||||
|
||||
} else {
|
||||
// Generate edit form
|
||||
|
||||
$inactive = array();
|
||||
switch ( $currentpage ) {
|
||||
case 1:
|
||||
$currenttab = 'htmlarea';
|
||||
break;
|
||||
case 2:
|
||||
$currenttab = 'tinymce';
|
||||
break;
|
||||
default:
|
||||
error("Unknown currentpage: $currentpage");
|
||||
}
|
||||
|
||||
//$url = 'editor.php?tab=';
|
||||
//$tabrow = array();
|
||||
//$tabrow[] = new tabobject('htmlarea',$url . '1', 'HTMLArea');
|
||||
//$tabrow[] = new tabobject('tinymce',$url . '2', 'TinyMCE');
|
||||
//$tabs = array($tabrow);
|
||||
|
||||
$fontlist = editor_convert_to_array($CFG->editorfontlist);
|
||||
$dicts = editor_get_dictionaries();
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$streditorsettings = get_string("editorsettings");
|
||||
$streditorsettingshelp = get_string("adminhelpeditorsettings");
|
||||
print_header("Editor settings","Editor settings",
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $streditorsettings");
|
||||
print_heading($streditorsettings);
|
||||
|
||||
print_simple_box("<center>$streditorsettingshelp</center>","center","50%");
|
||||
print("<br />\n");
|
||||
//print_tabs($tabs, $currenttab, $inactive);
|
||||
|
||||
print_simple_box_start("center");
|
||||
include("editor.html");
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
}
|
||||
|
||||
|
||||
/// FUNCTIONS
|
||||
|
||||
function editor_convert_to_array ($string) {
|
||||
/// Converts $CFG->editorfontlist to array
|
||||
|
||||
if (empty($string) || !is_string($string)) {
|
||||
return false;
|
||||
}
|
||||
$fonts = array();
|
||||
|
||||
$lines = explode(";", $string);
|
||||
foreach ($lines as $line) {
|
||||
if (!empty($line)) {
|
||||
list($fontkey, $fontvalue) = explode(":", $line);
|
||||
$fonts[$fontkey] = $fontvalue;
|
||||
}
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
function editor_update_config ($data, $editor) {
|
||||
|
||||
/// Updates the editor config values.
|
||||
|
||||
if (!is_object($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch($editor) {
|
||||
case 1: // HTMLArea.
|
||||
// Make array for unwanted characters.
|
||||
$nochars = array(chr(33),chr(34),chr(35),chr(36),chr(37),
|
||||
chr(38),chr(39),chr(40),chr(41),chr(42),
|
||||
chr(43),chr(46),chr(47),chr(58),chr(59),
|
||||
chr(60),chr(61),chr(62),chr(63),chr(64),
|
||||
chr(91),chr(92),chr(93),chr(94),chr(95),
|
||||
chr(96),chr(123),chr(124),chr(125),chr(126));
|
||||
|
||||
$fontlist = '';
|
||||
|
||||
// make font string
|
||||
$cnt = count($data->fontname);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if (!empty($data->fontname[$i])) {
|
||||
$fontlist .= str_replace($nochars, "", $data->fontname[$i]) .":";
|
||||
$fontlist .= str_replace($nochars, "", $data->fontnamevalue[$i]) .";";
|
||||
}
|
||||
}
|
||||
// strip last semicolon
|
||||
$fontlist = substr($fontlist, 0, strlen($fontlist) - 1);
|
||||
|
||||
// make array of values to update
|
||||
$updatedata = array();
|
||||
$updatedata['htmleditor'] = !empty($data->htmleditor) ? $data->htmleditor : 0;
|
||||
$updatedata['editorbackgroundcolor'] = !empty($data->backgroundcolor) ? $data->backgroundcolor : "#ffffff";
|
||||
$updatedata['editorfontfamily'] = !empty($data->fontfamily) ? str_replace($nochars,"",$data->fontfamily) : "Times New Roman, Times";
|
||||
$updatedata['editorfontsize'] = !empty($data->fontsize) ? $data->fontsize : "";
|
||||
$updatedata['editorkillword'] = !empty($data->killword) ? $data->killword : 0;
|
||||
$updatedata['editorspelling'] = !empty($data->spelling) ? $data->spelling : 0;
|
||||
$updatedata['editorfontlist'] = $fontlist;
|
||||
$updatedata['editordictionary'] = !empty($data->dictionary) ? $data->dictionary : '';
|
||||
$updatedata['aspellpath'] = !empty($data->aspellpath) ? $data->aspellpath : '';
|
||||
|
||||
$hidebuttons = '';
|
||||
if (!empty($data->buttons) && is_array($data->buttons)) {
|
||||
foreach ($data->buttons as $key => $value) {
|
||||
$hidebuttons .= $key . " ";
|
||||
}
|
||||
}
|
||||
$updatedata['editorhidebuttons'] = trim($hidebuttons);
|
||||
break;
|
||||
|
||||
case 2: // TinyMCE.
|
||||
$updatedata = array();
|
||||
$updatedata['htmleditor'] = !empty($data->htmleditor) ? $data->htmleditor : 0;
|
||||
|
||||
// Process plugins
|
||||
if ( !empty($data->tinymceplugins) ) {
|
||||
foreach ( $data->tinymceplugins as $key => $value ) {
|
||||
$value = stripslashes(clean_param($value, PARAM_ALPHA));
|
||||
$data->tinymceplugins[$key] = addslashes($value);
|
||||
}
|
||||
}
|
||||
$updatedata['tinymceplugins'] = !empty($data->tinymceplugins) ? implode(",", $data->tinymceplugins) : '';
|
||||
$updatedata['tinymcetheme'] = !empty($data->tinymcetheme) ?
|
||||
clean_param($data->tinymcetheme, PARAM_ALPHA) : '';
|
||||
$updatedata['tinymcecontentcss'] = !empty($data->tinymcecontentcss) ?
|
||||
clean_param($data->tinymcecontentcss, PARAM_URL) : '';
|
||||
$updatedata['tinymcepopupcss'] = !empty($data->tinymcepopupcss) ?
|
||||
clean_param($data->tinymcepopupcss, PARAM_URL) : '';
|
||||
$updatedata['tinymceeditorcss'] = !empty($data->tinymceeditorcss) ?
|
||||
clean_param($data->tinymceeditorcss, PARAM_URL) : '';
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($updatedata as $name => $value) {
|
||||
if (!(set_config($name, $value))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset_to_defaults ($editor) {
|
||||
/// Reset the values to default
|
||||
|
||||
global $CFG;
|
||||
include_once($CFG->dirroot .'/lib/defaults.php');
|
||||
|
||||
$updatedata = array();
|
||||
|
||||
switch ( $editor ) {
|
||||
case 1: // HTMLArea.
|
||||
$updatedata['editorbackgroundcolor'] = $defaults['editorbackgroundcolor'];
|
||||
$updatedata['editorfontfamily'] = $defaults['editorfontfamily'];
|
||||
$updatedata['editorfontsize'] = $defaults['editorfontsize'];
|
||||
$updatedata['editorkillword'] = $defaults['editorkillword'];
|
||||
$updatedata['editorspelling'] = $defaults['editorspelling'];
|
||||
$updatedata['editorfontlist'] = $defaults['editorfontlist'];
|
||||
$updatedata['editorhidebuttons'] = $defaults['editorhidebuttons'];
|
||||
$updatedata['editordictionary'] = '';
|
||||
break;
|
||||
|
||||
case 2: // TinyMCE.
|
||||
$updatedata['tinymceplugins'] = $defaults['tinymceplugins'];
|
||||
$updatedata['tinymcetheme'] = $defaults['tinymcetheme'];
|
||||
$updatedata['tinymcecontentcss'] = $defaults['tinymcecontentcss'];
|
||||
$updatedata['tinymcepopupcss'] = $defaults['tinymcepopupcss'];
|
||||
$updatedata['tinymceeditorcss'] = $defaults['tinymceeditorcss'];
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($updatedata as $name => $value) {
|
||||
if (!(set_config($name, $value))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function editor_get_dictionaries () {
|
||||
/// Get all installed dictionaries in the system
|
||||
|
||||
global $CFG;
|
||||
|
||||
error_reporting(E_ALL); // for debug, final version shouldn't have this...
|
||||
clearstatcache();
|
||||
|
||||
$strerror = '';
|
||||
|
||||
// If aspellpath isn't set don't even bother ;-)
|
||||
if (empty($CFG->aspellpath)) {
|
||||
return $strerror = 'Empty aspell path!';
|
||||
}
|
||||
|
||||
// Do we have access to popen function?
|
||||
if (!function_exists('popen')) {
|
||||
return $strerror = "Popen function disabled!";
|
||||
exit;
|
||||
}
|
||||
|
||||
global $CFG;
|
||||
|
||||
$cmd = $CFG->aspellpath;
|
||||
$output = '';
|
||||
$dictionaries = array();
|
||||
$dicts = array();
|
||||
|
||||
if(!($handle = @popen(escapeshellarg($cmd) .' dump dicts', 'r'))) {
|
||||
return $strerror = "Couldn't create handle!";
|
||||
exit;
|
||||
}
|
||||
|
||||
while(!feof($handle)) {
|
||||
$output .= fread($handle, 1024);
|
||||
}
|
||||
@pclose($handle);
|
||||
|
||||
$dictionaries = explode(chr(10), $output);
|
||||
|
||||
// Get rid of possible empty values
|
||||
if (is_array($dictionaries)) {
|
||||
|
||||
$cnt = count($dictionaries);
|
||||
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if (!empty($dictionaries[$i])) {
|
||||
$dicts[] = $dictionaries[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($dicts) >= 1) {
|
||||
return $dicts;
|
||||
}
|
||||
|
||||
$strerror = "Error! Check your aspell installation!";
|
||||
return $strerror;
|
||||
|
||||
}
|
||||
|
||||
function editor_get_tiny_plugins() {
|
||||
global $CFG;
|
||||
|
||||
$plugins = array();
|
||||
$plugindir = $CFG->libdir .'/editor/tinymce/jscripts/tiny_mce/plugins';
|
||||
|
||||
if ( !$fp = opendir($plugindir) ) {
|
||||
return $plugins;
|
||||
exit;
|
||||
}
|
||||
|
||||
while ( ($file = readdir($fp)) !== false ) {
|
||||
|
||||
if ( preg_match("/^\.+/", $file) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_dir($plugindir .'/'. $file) ) {
|
||||
array_push($plugins, $file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $fp ) {
|
||||
closedir($fp);
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Allows admin to configure editors.
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$editor = required_param('editor', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$available_editors = editors_get_available();
|
||||
if (!empty($editor) and empty($available_editors[$editor])) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
|
||||
$active_editors = explode(',', $CFG->texteditors);
|
||||
foreach ($active_editors as $key=>$active) {
|
||||
if (empty($available_editors[$active])) {
|
||||
unset($active_editors[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
|
||||
$return = true;
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
// remove from enabled list
|
||||
$key = array_search($editor, $active_editors);
|
||||
unset($active_editors[$key]);
|
||||
add_to_config_log('editor_visibility', '1', '0', $editor);
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
// add to enabled list
|
||||
if (!in_array($editor, $active_editors)) {
|
||||
$active_editors[] = $editor;
|
||||
$active_editors = array_unique($active_editors);
|
||||
add_to_config_log('editor_visibility', '0', '1', $editor);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($editor, $active_editors);
|
||||
// check auth plugin is valid
|
||||
if ($key !== false) {
|
||||
// move down the list
|
||||
if ($key < (count($active_editors) - 1)) {
|
||||
$fsave = $active_editors[$key];
|
||||
$active_editors[$key] = $active_editors[$key + 1];
|
||||
$active_editors[$key + 1] = $fsave;
|
||||
add_to_config_log('editor_position', $key, $key + 1, $editor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key = array_search($editor, $active_editors);
|
||||
// check auth is valid
|
||||
if ($key !== false) {
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
$fsave = $active_editors[$key];
|
||||
$active_editors[$key] = $active_editors[$key - 1];
|
||||
$active_editors[$key - 1] = $fsave;
|
||||
add_to_config_log('editor_position', $key, $key - 1, $editor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// at least one editor must be active
|
||||
if (empty($active_editors)) {
|
||||
$active_editors = array('textarea');
|
||||
}
|
||||
|
||||
set_config('texteditors', implode(',', $active_editors));
|
||||
core_plugin_manager::reset_caches();
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
+93
-115
@@ -1,133 +1,111 @@
|
||||
<?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 // $Id$
|
||||
// enrol.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
/**
|
||||
* Enrol config manipulation script.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage enrol
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once('../config.php');
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
|
||||
$CFG->pagepath = 'enrol';
|
||||
|
||||
require_login();
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$enrol = required_param('enrol', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$PAGE->set_url('/admin/enrol.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_sesskey();
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enabled = enrol_get_plugins(true);
|
||||
$all = enrol_get_plugins(false);
|
||||
/// Save settings
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols'));
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
core_plugin_manager::reset_caches();
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
if (!isset($all[$enrol])) {
|
||||
break;
|
||||
if ($frm = data_submitted()) {
|
||||
if (empty($frm->enable)) {
|
||||
$frm->enable = array();
|
||||
}
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled[] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
core_plugin_manager::reset_caches();
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
if (empty($frm->default)) {
|
||||
$frm->default = '';
|
||||
}
|
||||
if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) {
|
||||
$frm->enable[] = $frm->default;
|
||||
}
|
||||
asort($frm->enable);
|
||||
$frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first
|
||||
set_config('enrol_plugins_enabled', implode(',', $frm->enable));
|
||||
set_config('enrol', $frm->default);
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
|
||||
case 'up':
|
||||
if (!isset($enabled[$enrol])) {
|
||||
break;
|
||||
}
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled = array_flip($enabled);
|
||||
$current = $enabled[$enrol];
|
||||
if ($current == 0) {
|
||||
break; //already at the top
|
||||
}
|
||||
$enabled = array_flip($enabled);
|
||||
$enabled[$current] = $enabled[$current - 1];
|
||||
$enabled[$current - 1] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
/// Print the form
|
||||
|
||||
case 'down':
|
||||
if (!isset($enabled[$enrol])) {
|
||||
break;
|
||||
}
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled = array_flip($enabled);
|
||||
$current = $enabled[$enrol];
|
||||
if ($current == count($enabled) - 1) {
|
||||
break; //already at the end
|
||||
}
|
||||
$enabled = array_flip($enabled);
|
||||
$enabled[$current] = $enabled[$current + 1];
|
||||
$enabled[$current + 1] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
|
||||
|
||||
case 'migrate':
|
||||
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
|
||||
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
|
||||
print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
|
||||
"<a href=\"index.php\">$str->administration</a> ->
|
||||
<a href=\"users.php\">$str->users</a> -> $str->enrolmentplugins");
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$options = array();
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
|
||||
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
|
||||
$table = new stdClass();
|
||||
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
|
||||
$table->align = array('left', 'center', 'center', 'center');
|
||||
$table->size = array('60%', '', '', '15%');
|
||||
$table->width = '700';
|
||||
$table->data = array();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
|
||||
// skip if directory is empty
|
||||
if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = get_string("enrolname", "enrol_$module");
|
||||
$plugin = enrolment_factory::factory($module);
|
||||
$enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
|
||||
if (stristr($CFG->enrol_plugins_enabled, $module) !== false) {
|
||||
$enable .= ' checked="checked"';
|
||||
}
|
||||
if ($module == 'manual') {
|
||||
$enable .= ' disabled="disabled"';
|
||||
}
|
||||
$enable .= ' />';
|
||||
if (method_exists($plugin, 'print_entry')) {
|
||||
$default = '<input type="radio" name="default" value="'.$module.'"';
|
||||
if ($CFG->enrol == $module) {
|
||||
$default .= ' checked="checked"';
|
||||
}
|
||||
$default .= ' />';
|
||||
} else {
|
||||
$strplugin = $enrol;
|
||||
$default = '';
|
||||
}
|
||||
$table->data[$name] = array($name, $enable, $default,
|
||||
'<a href="enrol_config.php?sesskey='.$USER->sesskey.'&enrol='.$module.'">'.$str->edit.'</a>');
|
||||
}
|
||||
asort($table->data);
|
||||
|
||||
$PAGE->set_title($strplugin);
|
||||
echo $OUTPUT->header();
|
||||
print_table($table);
|
||||
|
||||
// This may take a long time.
|
||||
core_php_time_limit::raise();
|
||||
echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
// Disable plugin to prevent concurrent cron execution.
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
print_footer();
|
||||
|
||||
echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol));
|
||||
|
||||
require_once("$CFG->dirroot/enrol/manual/locallib.php");
|
||||
enrol_manual_migrate_plugin_enrolments($enrol);
|
||||
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
|
||||
if (!$return = core_plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol, 'manage')) {
|
||||
$return = new moodle_url('/admin/plugins.php');
|
||||
}
|
||||
echo $OUTPUT->continue_button($return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
redirect($return);
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
$enrol = required_param('enrol', PARAM_ALPHA);
|
||||
$CFG->pagepath = 'enrol/' . $enrol;
|
||||
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory($enrol);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($enrolment->process_config($frm)) {
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
} else {
|
||||
$frm = $CFG;
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
|
||||
"<a href=\"index.php\">$str->administration</a> ->
|
||||
<a href=\"users.php\">$str->users</a> ->
|
||||
<a href=\"enrol.php?sesskey=$USER->sesskey\">$str->enrolmentplugins</a> ->
|
||||
$str->configuration");
|
||||
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
echo "<div align=\"center\"><p><b>";
|
||||
|
||||
|
||||
/// Choose an enrolment method
|
||||
echo get_string('chooseenrolmethod').': ';
|
||||
choose_from_menu ($options, "enrol", $enrol, "",
|
||||
"document.location='enrol_config.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
|
||||
|
||||
echo "</b></p></div>";
|
||||
|
||||
/// Print current enrolment type description
|
||||
print_simple_box_start("center", "80%");
|
||||
print_heading($options[$enrol]);
|
||||
|
||||
print_simple_box_start("center", "60%", '', 5, 'informationbox');
|
||||
print_string("description", "enrol_$enrol");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
+138
-96
@@ -1,109 +1,151 @@
|
||||
<?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 //$Id$
|
||||
|
||||
/**
|
||||
* This file is the admin frontend to execute all the checks available
|
||||
* in the environment.xml file. It includes database, php and
|
||||
* php_extensions. Also, it's possible to update the xml file
|
||||
* from moodle.org be able to check more and more versions.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2006 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
|
||||
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is the admin frontend to execute all the checks available
|
||||
// in the environment.xml file. It includes database, php and
|
||||
// php_extensions. Also, it's possible to update the xml file
|
||||
// from moodle.org be able to check more and more versions.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
/// Parameters
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
|
||||
// Parameters
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
/// Security checks
|
||||
require_login();
|
||||
|
||||
$extraurlparams = array();
|
||||
if ($version) {
|
||||
$extraurlparams['version'] = $version;
|
||||
}
|
||||
admin_externalpage_setup('environment', '', $extraurlparams);
|
||||
|
||||
// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
// Create component installer and execute it
|
||||
if ($cd = new component_installer('https://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'https://download.moodle.org/environment/environment.zip';
|
||||
$a->dest = $CFG->dataroot . '/';
|
||||
print_error($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
die();
|
||||
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', $PAGE->url);
|
||||
die();
|
||||
}
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
redirect($PAGE->url, get_string($cd->get_error(), 'error'));
|
||||
die;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
redirect($PAGE->url, get_string('componentinstalled', 'admin'));
|
||||
die;
|
||||
}
|
||||
if (!isadmin()) {
|
||||
error('You need to be admin to use this page');
|
||||
}
|
||||
}
|
||||
|
||||
// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
// Calculate list of versions
|
||||
$versions = array();
|
||||
if ($contents = load_environment_xml()) {
|
||||
if ($env_versions = get_list_of_environment_versions($contents)) {
|
||||
// Set the current version at the beginning
|
||||
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
||||
$versions[$env_version] = $current_version;
|
||||
// If no version has been previously selected, default to $current_version
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
//Iterate over each version, adding bigger than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
/// Get some strings
|
||||
$stradmin = get_string('administration');
|
||||
$stradminhelpenvironment = get_string("adminhelpenvironment");
|
||||
$strenvironment = get_string('environment', 'admin');
|
||||
$strerror = get_string('error');
|
||||
$strmoodleversion = get_string('moodleversion');
|
||||
$strupdate = get_string('updatecomponent', 'admin');
|
||||
$strupwards = get_string('upwards', 'admin');
|
||||
$strmisc = get_string('miscellaneous');
|
||||
|
||||
/// Print the header stuff
|
||||
print_header("$SITE->shortname: $strenvironment", $SITE->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> <a href=\"misc.php\">$strmisc</a> -> "
|
||||
.$strenvironment);
|
||||
|
||||
/// Print the component download link
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.$USER->sesskey.'">'.$strupdate.'</a></div>';
|
||||
|
||||
print_heading($strenvironment);
|
||||
|
||||
/// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
/// Create component installer and execute it
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest= $CFG->dataroot.'/';
|
||||
print_simple_box(get_string($cd->get_error(), 'error', $a), 'center', '', '', 5, 'errorbox');
|
||||
} else {
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center', '', '', 5, 'errorbox');
|
||||
}
|
||||
break;
|
||||
case UPTODATE:
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center');
|
||||
break;
|
||||
case INSTALLED:
|
||||
print_simple_box(get_string('componentinstalled', 'admin'), 'center');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.get_string('upwards', 'admin');
|
||||
} else {
|
||||
$versions = array('error' => get_string('error'));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the results of the environment check.
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version, ENV_SELECT_NEWER);
|
||||
/// Start of main box
|
||||
print_simple_box_start('center');
|
||||
|
||||
// Display the page.
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
|
||||
echo "<center>".$stradminhelpenvironment."</center><br />";
|
||||
|
||||
/// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
|
||||
/// Calculate list of versions
|
||||
$versions = array();
|
||||
if ($contents = load_environment_xml()) {
|
||||
if ($env_versions = get_list_of_environment_versions($contents)) {
|
||||
/// Set the current version at the beginning
|
||||
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
||||
$versions[$env_version] = $current_version;
|
||||
/// If no version has been previously selected, default to $current_version
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
///Iterate over each version, adding bigged than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
}
|
||||
}
|
||||
/// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.$strupwards;
|
||||
} else {
|
||||
$versions = array('error' => $strerror);
|
||||
}
|
||||
}
|
||||
|
||||
/// Print form and popup menu
|
||||
echo '<center><form method="post" action="environment.php">';
|
||||
echo $strmoodleversion.' ';
|
||||
choose_from_menu ($versions, 'version', $version, null, 'this.form.submit();' );
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '</form></center>';
|
||||
/// End of main box
|
||||
print_simple_box_end();
|
||||
|
||||
/// Gather and show results
|
||||
$status = check_moodle_environment($version, $environment_results);
|
||||
|
||||
/// Other links
|
||||
echo '<div align="center">';
|
||||
print_single_button('phpinfo.php', NULL, get_string('phpinfo'));
|
||||
echo '</div>';
|
||||
|
||||
/// Print footer
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
+1
-2374
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
<?php // $Id$
|
||||
// filter.php
|
||||
// Edit text filter settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// check for allowed access
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error( 'Only administrators can use the filters administration page' );
|
||||
}
|
||||
if (!$site = get_site()) {
|
||||
error( 'Site is not defined in filters administration page' );
|
||||
}
|
||||
|
||||
// get parameters
|
||||
$param = new Object;
|
||||
|
||||
$param->filter = required_param('filter', PARAM_PATH);
|
||||
$param->submit = optional_param('submit', 0, PARAM_BOOL);
|
||||
$param->reset = optional_param('reset', 0, PARAM_BOOL);
|
||||
|
||||
$filtername = substr($param->filter, strpos( $param->filter, '/' )+1 ) ;
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'filter/' . $filtername . '/config';
|
||||
|
||||
// get translated strings for use on page
|
||||
$txt = new Object;
|
||||
$txt->managefilters = get_string( 'managefilters' );
|
||||
$txt->administration = get_string( 'administration' );
|
||||
$txt->configuration = get_string( 'configuration' );
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
// if reset pressed let filter config page handle it
|
||||
$forcereset = false;
|
||||
if (!empty($param->reset)) {
|
||||
$forcereset = true;
|
||||
}
|
||||
else
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
// check session key
|
||||
if (!confirm_sesskey()) {
|
||||
error( get_string('confirmsesskeybad', 'error' ) );
|
||||
}
|
||||
|
||||
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
|
||||
if (file_exists($configpath)) {
|
||||
require_once($configpath);
|
||||
$functionname = $filtername.'_process_config';
|
||||
if (function_exists($functionname)) {
|
||||
$functionname($config);
|
||||
$saved = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($saved)) {
|
||||
// run through submitted data
|
||||
// reject if does not start with filter_
|
||||
foreach ($config as $name => $value) {
|
||||
set_config( $name,$value );
|
||||
}
|
||||
}
|
||||
redirect( "$CFG->wwwroot/$CFG->admin/filters.php", get_string('changessaved'), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
$filtername = ucfirst($filtername);
|
||||
print_header( "$site->shortname: $txt->managefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
|
||||
"-> <a href=\"filters.php\">$txt->managefilters</a> -> $filtername" );
|
||||
|
||||
print_heading( $txt->managefilters );
|
||||
|
||||
print_simple_box("<center>".get_string("configwarning", "admin")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center",'');
|
||||
|
||||
?>
|
||||
<form action="filter.php?filter=<?php echo urlencode($param->filter); ?>" method="post">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
|
||||
<?php include "$CFG->dirroot/$param->filter/filterconfig.html"; ?>
|
||||
|
||||
<center>
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
<input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
+308
-227
@@ -1,253 +1,334 @@
|
||||
<?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 // $Id$
|
||||
// filters.php
|
||||
// Edit list of available text filters
|
||||
|
||||
/**
|
||||
* Filter management page.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
// defines
|
||||
define('FILTER_TABLE','filter_administration_table');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PLUGIN);
|
||||
// check for allowed access
|
||||
require_login();
|
||||
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('managefilters');
|
||||
|
||||
// Clean up bogus filter states first.
|
||||
$plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
|
||||
$filters = array();
|
||||
$states = filter_get_global_states();
|
||||
foreach ($states as $state) {
|
||||
if (!isset($plugininfos[$state->filter]) and !get_config('filter_'.$state->filter, 'version')) {
|
||||
// Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
|
||||
$DB->delete_records('filter_active', array('filter' => $state->filter));
|
||||
$DB->delete_records('filter_config', array('filter' => $state->filter));
|
||||
error_log('Deleted bogus "filter_'.$state->filter.'" states and config data.');
|
||||
} else {
|
||||
$filters[$state->filter] = $state;
|
||||
if (!isadmin()) {
|
||||
error('Only administrators can use the filters administration page');
|
||||
}
|
||||
}
|
||||
|
||||
// Add properly installed and upgraded filters to the global states table.
|
||||
foreach ($plugininfos as $filter => $info) {
|
||||
if (isset($filters[$filter])) {
|
||||
continue;
|
||||
if (!$site = get_site()) {
|
||||
error('Site is not defined in filters administration page');
|
||||
}
|
||||
/** @var \core\plugininfo\base $info */
|
||||
if ($info->is_installed_and_upgraded()) {
|
||||
filter_set_global_state($filter, TEXTFILTER_DISABLED);
|
||||
$states = filter_get_global_states();
|
||||
foreach ($states as $state) {
|
||||
if ($state->filter === $filter) {
|
||||
$filters[$filter] = $state;
|
||||
break;
|
||||
|
||||
// get values from page
|
||||
$params = new object();
|
||||
$params->action = optional_param('action', '', PARAM_ACTION);
|
||||
$params->filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
$params->cachetext = optional_param('cachetext', 0, PARAM_INT);
|
||||
$params->filterall = optional_param('filterall', 0, PARAM_BOOL);
|
||||
$params->filteruploadedfiles = optional_param('filteruploadedfiles', 0, PARAM_INT);
|
||||
$params->filtermatchoneperpage = optional_param('filtermatchoneperpage', 0, PARAM_BOOL);
|
||||
$params->filtermatchonepertext = optional_param('filtermatchonepertext', 0, PARAM_BOOL);
|
||||
|
||||
// some basic information
|
||||
$url = 'filters.php';
|
||||
$myurl = "$url?sesskey=" . sesskey();
|
||||
$img = "$CFG->pixpath/t";
|
||||
|
||||
// get translated strings for use on page
|
||||
$txt = new object();
|
||||
$txt->managefilters = get_string('managefilters');
|
||||
$txt->administration = get_string('administration');
|
||||
$txt->configuration = get_string('configuration');
|
||||
$txt->name = get_string('name');
|
||||
$txt->hide = get_string('hide');
|
||||
$txt->show = get_string('show');
|
||||
$txt->hideshow = "$txt->hide/$txt->show";
|
||||
$txt->settings = get_string('settings');
|
||||
$txt->up = get_string('up');
|
||||
$txt->down = get_string('down');
|
||||
$txt->updown = "$txt->up/$txt->down";
|
||||
$txt->cachetext = get_string('cachetext', 'admin');
|
||||
$txt->configcachetext = get_string('configcachetext', 'admin');
|
||||
$txt->filteruploadedfiles = get_string('filteruploadedfiles','admin');
|
||||
$txt->configfilteruploadedfiles = get_string('configfilteruploadedfiles','admin');
|
||||
$txt->filterall = get_string('filterall','admin');
|
||||
$txt->filtermatchoneperpage = get_string('filtermatchoneperpage','admin');
|
||||
$txt->filtermatchonepertext = get_string('filtermatchonepertext','admin');
|
||||
$txt->configfilterall = get_string('configfilterall','admin');
|
||||
$txt->configfiltermatchoneperpage = get_string('configfiltermatchoneperpage','admin');
|
||||
$txt->configfiltermatchonepertext = get_string('configfiltermatchonepertext','admin');
|
||||
$txt->cachecontrols = get_string('cachecontrols');
|
||||
$txt->yes = get_string('yes');
|
||||
$txt->no = get_string('no');
|
||||
$txt->none = get_string('none');
|
||||
$txt->allfiles = get_string('allfiles');
|
||||
$txt->htmlfilesonly = get_string('htmlfilesonly');
|
||||
|
||||
// get a list of possible filters (and translate name if possible)
|
||||
// note filters can be in the dedicated filters area OR in their
|
||||
// associated modules
|
||||
$installedfilters = array();
|
||||
$filtersettings = array();
|
||||
$filterlocations = array('mod','filter');
|
||||
foreach ($filterlocations as $filterlocation) {
|
||||
$plugins = get_list_of_plugins($filterlocation);
|
||||
foreach ($plugins as $plugin) {
|
||||
$pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php";
|
||||
$settingspath = "$CFG->dirroot/$filterlocation/$plugin/filterconfig.html";
|
||||
if (is_readable($pluginpath)) {
|
||||
$name = trim(get_string("filtername", $plugin));
|
||||
if (empty($name) or ($name == '[[filtername]]')) {
|
||||
$name = ucfirst($plugin);
|
||||
}
|
||||
$installedfilters["$filterlocation/$plugin"] = $name;
|
||||
if (is_readable($settingspath)) {
|
||||
$filtersettings[] = "$filterlocation/$plugin";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
require_sesskey();
|
||||
}
|
||||
// get all the currently selected filters
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$oldactivefilters = explode(',', $CFG->textfilters);
|
||||
$oldactivefilters = array_unique($oldactivefilters);
|
||||
} else {
|
||||
$oldactivefilters = array();
|
||||
}
|
||||
|
||||
// Process actions.
|
||||
switch ($action) {
|
||||
// take this opportunity to clean up filters
|
||||
$activefilters = array();
|
||||
foreach ($oldactivefilters as $oldactivefilter) {
|
||||
if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) {
|
||||
$activefilters[] = $oldactivefilter;
|
||||
}
|
||||
}
|
||||
|
||||
case 'setstate':
|
||||
if (isset($filters[$filterpath]) and $newstate = optional_param('newstate', '', PARAM_INT)) {
|
||||
filter_set_global_state($filterpath, $newstate);
|
||||
if ($newstate == TEXTFILTER_DISABLED) {
|
||||
filter_set_applies_to_strings($filterpath, false);
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
if ($params->action=="") {
|
||||
// store cleaned active filers in db
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
} elseif (($params->action=="hide") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
// ignore it - doubleclick??
|
||||
} else {
|
||||
// just delete it
|
||||
unset($activefilters[$key]);
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="show") and confirm_sesskey()) {
|
||||
// check filterpath is valid
|
||||
if (!array_key_exists($params->filterpath, $installedfilters)) {
|
||||
error("Filter $params->filterpath is not currently installed", $url);
|
||||
} elseif (array_search($params->filterpath,$activefilters)) {
|
||||
// filterpath is already active - doubleclick??
|
||||
} else {
|
||||
// add it to installed filters
|
||||
$activefilters[] = $params->filterpath;
|
||||
$activefilters = array_unique($activefilters);
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="down") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $params->filterpath is not currently active", $url);
|
||||
} elseif ($key>=(count($activefilters)-1)) {
|
||||
// cannot be moved any further down - doubleclick??
|
||||
} else {
|
||||
// swap with $key+1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key+1];
|
||||
$activefilters[$key+1] = $fsave;
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="up") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $params->filterpath is not currently active", $url);
|
||||
} elseif ($key<1) {
|
||||
//cannot be moved any further up - doubleclick??
|
||||
} else {
|
||||
// swap with $key-1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key-1];
|
||||
$activefilters[$key-1] = $fsave;
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="config") and confirm_sesskey()) {
|
||||
set_config('cachetext', $params->cachetext);
|
||||
set_config('filteruploadedfiles', $params->filteruploadedfiles);
|
||||
set_config('filterall', $params->filterall);
|
||||
set_config('filtermatchoneperpage', $params->filtermatchoneperpage);
|
||||
set_config('filtermatchonepertext', $params->filtermatchonepertext);
|
||||
}
|
||||
|
||||
//======================
|
||||
// Build Display Objects
|
||||
//======================
|
||||
|
||||
// construct the display array with installed filters
|
||||
// at the top in the right order
|
||||
$displayfilters = array();
|
||||
foreach ($activefilters as $activefilter) {
|
||||
$name = $installedfilters[$activefilter];
|
||||
$displayfilters[$activefilter] = $name;
|
||||
}
|
||||
foreach ($installedfilters as $key => $filter) {
|
||||
if (!array_key_exists($key, $displayfilters)) {
|
||||
$displayfilters[$key] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(FILTER_TABLE);
|
||||
$table->define_columns(array('name', 'hideshow', 'order', 'settings'));
|
||||
$table->column_style('hideshow', 'text-align', 'center');
|
||||
$table->column_style('order', 'text-align', 'center');
|
||||
$table->column_style('settings', 'text-align', 'center');
|
||||
$table->define_headers(array($txt->name, $txt->hideshow, $txt->updown, $txt->settings));
|
||||
$table->define_baseurl("$CFG->wwwroot/$CFG->admin/filters.php");
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'flexible generaltable generalbox');
|
||||
$table->set_attribute('style', 'margin:auto;');
|
||||
$table->set_attribute('cellpadding', '5');
|
||||
$table->setup();
|
||||
|
||||
// iterate through filters adding to display table
|
||||
$updowncount = 1;
|
||||
$activefilterscount = count($activefilters);
|
||||
foreach ($displayfilters as $path => $name) {
|
||||
$upath = urlencode($path);
|
||||
// get hide/show link
|
||||
if (in_array($path, $activefilters)) {
|
||||
$hideshow = "<a href=\"$myurl&action=hide&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" height=\"16\" width=\"16\" alt=\"hide\" /></a>";
|
||||
$hidden = false;
|
||||
$displayname = "<span>$name</span>";
|
||||
}
|
||||
else {
|
||||
$hideshow = "<a href=\"$myurl&action=show&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" height=\"16\" width=\"16\" alt=\"show\" /></a>";
|
||||
$hidden = true;
|
||||
$displayname = "<span class=\"dimmed_text\">$name</span>";
|
||||
}
|
||||
|
||||
// get up/down link (only if not hidden)
|
||||
$updown = '';
|
||||
if (!$hidden) {
|
||||
if ($updowncount>1) {
|
||||
$updown .= "<a href=\"$myurl&action=up&filterpath=$upath\">";
|
||||
$updown .= "<img src=\"$img/up.gif\" alt=\"up\" /></a> ";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" height=\"16\" width=\"16\" alt=\"\" /> ";
|
||||
}
|
||||
if ($updowncount<$activefilterscount) {
|
||||
$updown .= "<a href=\"$myurl&action=down&filterpath=$upath\">";
|
||||
$updown .= "<img src=\"$img/down.gif\" alt=\"down\" /></a>";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" height=\"16\" width=\"16\" alt=\"\" />";
|
||||
}
|
||||
++$updowncount;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'setapplyto':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
|
||||
filter_set_applies_to_strings($filterpath, $applytostrings);
|
||||
// settings link (if defined)
|
||||
$settings = '';
|
||||
if (in_array($path, $filtersettings)) {
|
||||
$settings = "<a href=\"filter.php?filter=" . urlencode($path) . "\">";
|
||||
$settings .= "{$txt->settings}</a>";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
if (isset($filters[$filterpath])) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, 1);
|
||||
// write data into the table object
|
||||
$table->add_data(array($displayname, $hideshow, $updown, $settings));
|
||||
}
|
||||
|
||||
// build options list for cache lifetime
|
||||
$seconds = array(604800,86400,43200,10800,7200,3600,2700,1800,900,600,540,480,420,360,300,240,180,120,60,30,0);
|
||||
unset($lifetimeoptions);
|
||||
foreach ($seconds as $second) {
|
||||
if ($second>=86400) {
|
||||
$options[$second] = get_string('numdays','',$second/86400);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
|
||||
elseif ($second>=3600) {
|
||||
$options[$second] = get_string('numhours','',$second/3600);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Reset caches and return.
|
||||
if ($action) {
|
||||
reset_text_filters_cache();
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect(new moodle_url('/admin/filters.php'));
|
||||
}
|
||||
|
||||
// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
|
||||
|
||||
$states = filter_get_global_states();
|
||||
$stringfilters = filter_get_string_filters();
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
|
||||
$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->id = 'filterssetting';
|
||||
$table->data = array();
|
||||
|
||||
$lastactive = null;
|
||||
foreach ($states as $state) {
|
||||
if ($state->active != TEXTFILTER_DISABLED) {
|
||||
$lastactive = $state->filter;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through filters adding to display table.
|
||||
$firstrow = true;
|
||||
foreach ($states as $state) {
|
||||
$filter = $state->filter;
|
||||
if (!isset($plugininfos[$filter])) {
|
||||
continue;
|
||||
}
|
||||
$plugininfo = $plugininfos[$filter];
|
||||
$applytostrings = isset($stringfilters[$filter]) && $state->active != TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($plugininfo, $state, $firstrow, $filter == $lastactive, $applytostrings);
|
||||
$table->data[] = $row;
|
||||
if ($state->active == TEXTFILTER_DISABLED) {
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
} else {
|
||||
$table->rowclasses[] = '';
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
|
||||
echo html_writer::table($table);
|
||||
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
|
||||
/**
|
||||
* Return action URL.
|
||||
*
|
||||
* @param string $filterpath
|
||||
* @param string $action
|
||||
* @return moodle_url
|
||||
*/
|
||||
function filters_action_url($filterpath, $action) {
|
||||
if ($action === 'delete') {
|
||||
return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
|
||||
}
|
||||
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct table record.
|
||||
*
|
||||
* @param \core\plugininfo\filter $plugininfo
|
||||
* @param stdClass $state
|
||||
* @param bool $isfirstrow
|
||||
* @param bool $islastactive
|
||||
* @param bool $applytostrings
|
||||
* @return array data
|
||||
*/
|
||||
function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow, $islastactive, $applytostrings) {
|
||||
global $OUTPUT;
|
||||
$row = array();
|
||||
$filter = $state->filter;
|
||||
$active = $plugininfo->is_installed_and_upgraded();
|
||||
|
||||
static $activechoices;
|
||||
static $applytochoices;
|
||||
if (!isset($activechoices)) {
|
||||
$activechoices = array(
|
||||
TEXTFILTER_DISABLED => get_string('disabled', 'core_filters'),
|
||||
TEXTFILTER_OFF => get_string('offbutavailable', 'core_filters'),
|
||||
TEXTFILTER_ON => get_string('on', 'core_filters'),
|
||||
);
|
||||
$applytochoices = array(
|
||||
0 => get_string('content', 'core_filters'),
|
||||
1 => get_string('contentandheadings', 'core_filters'),
|
||||
);
|
||||
}
|
||||
|
||||
// Filter name.
|
||||
$displayname = $plugininfo->displayname;
|
||||
if (!$plugininfo->rootdir) {
|
||||
$displayname = '<span class="error">' . $displayname . ' - ' . get_string('status_missing', 'core_plugin') . '</span>';
|
||||
} else if (!$active) {
|
||||
$displayname = '<span class="error">' . $displayname . ' - ' . get_string('error') . '</span>';
|
||||
}
|
||||
$row[] = $displayname;
|
||||
|
||||
// Disable/off/on.
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $state->active, null, 'active' . $filter);
|
||||
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Re-order.
|
||||
$updown = '';
|
||||
$spacer = $OUTPUT->spacer();
|
||||
if ($state->active != TEXTFILTER_DISABLED) {
|
||||
if (!$isfirstrow) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
elseif ($second>=60) {
|
||||
$options[$second] = get_string('numminutes','',$second/60);
|
||||
}
|
||||
if (!$islastactive) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down'), '', array('class' => 'iconsmall')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
elseif ($second>=1) {
|
||||
$options[$second] = get_string('numseconds','',$second);
|
||||
}
|
||||
else {
|
||||
$options[$second] = get_string('no');
|
||||
}
|
||||
}
|
||||
$row[] = $updown;
|
||||
|
||||
// Apply to strings.
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter);
|
||||
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
|
||||
$select->disabled = ($state->active == TEXTFILTER_DISABLED);
|
||||
$row[] = $OUTPUT->render($select);
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
// Settings link, if required.
|
||||
if ($active and filter_has_global_settings($filter)) {
|
||||
$row[] = html_writer::link(new moodle_url('/admin/settings.php', array('section'=>'filtersetting'.$filter)), get_string('settings'));
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
print_header("$site->shortname: $txt->managefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
|
||||
"-> $txt->managefilters");
|
||||
|
||||
// Uninstall.
|
||||
$row[] = html_writer::link(filters_action_url($filter, 'delete'), get_string('uninstallplugin', 'core_admin'));
|
||||
print_heading_with_help($txt->managefilters, 'filters');
|
||||
|
||||
return $row;
|
||||
}
|
||||
// print the table of all the filters
|
||||
$table->print_html();
|
||||
|
||||
// print the table for the cache controls
|
||||
print_heading($txt->cachecontrols);
|
||||
print_simple_box_start('center');
|
||||
?>
|
||||
|
||||
<form name="options" id="options" method="post" action="<?php echo $url; ?>" >
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<input type="hidden" name="action" value="config" />
|
||||
<table cellpadding="20">
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->cachetext; ?></td>
|
||||
<td><?php choose_from_menu($options, "cachetext", $CFG->cachetext, "", "", ""); ?></td>
|
||||
<td><?php echo $txt->configcachetext; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filteruploadedfiles; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->none,$txt->allfiles,$txt->htmlfilesonly),
|
||||
"filteruploadedfiles", $CFG->filteruploadedfiles,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfilteruploadedfiles; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filtermatchoneperpage; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->no,$txt->yes), "filtermatchoneperpage", $CFG->filtermatchoneperpage,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfiltermatchoneperpage; ?></td>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filtermatchonepertext; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->no,$txt->yes), "filtermatchonepertext", $CFG->filtermatchonepertext,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfiltermatchonepertext; ?></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filterall; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->no,$txt->yes), "filterall", $CFG->filterall,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfilterall; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td> </td>
|
||||
<td><input type="submit" value="<?php print_string('savechanges'); ?>" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php // $Id$
|
||||
/** This expects the output from a command like
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
|
||||
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
|
||||
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
|
||||
*/
|
||||
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$FULLME='cron';
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
|
||||
|
||||
$site = get_site();
|
||||
|
||||
while(!feof($fd)) {
|
||||
$entry = fgets($fd);
|
||||
if (strlen(trim($entry)) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!$file = validate_line($entry)) {
|
||||
continue;
|
||||
}
|
||||
$bits = explode('/',$file);
|
||||
$a->filename = $bits[count($bits)-1];
|
||||
|
||||
if (!$log = get_record("log","module","upload","info",$file,"action","upload")) {
|
||||
$a->action = clam_handle_infected_file($file,0,false);
|
||||
clam_replace_infected_file($file);
|
||||
notify_admins_unknown($file,$a);
|
||||
continue;
|
||||
}
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
$user = get_record("user","id",$log->userid);
|
||||
$course = get_record("course","id",$log->course);
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
$a->course = $course->fullname;
|
||||
$a->user = fullname($user);
|
||||
|
||||
notify_user($user,$subject,$a);
|
||||
notify_admins($user,$subject,$a);
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
|
||||
function notify_user($user,$subject,$a) {
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
$body = get_string('virusfoundlater','moodle',$a);
|
||||
email_to_user($user,get_admin(),$subject,$body);
|
||||
}
|
||||
|
||||
|
||||
function notify_admins($user,$subject,$a) {
|
||||
|
||||
$admins = get_admins();
|
||||
|
||||
$body = get_string('virusfoundlateradmin','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function notify_admins_unknown($file,$a) {
|
||||
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_line($line) {
|
||||
global $CFG;
|
||||
if (strpos($line,"FOUND") === false) {
|
||||
return false;
|
||||
}
|
||||
$index = strpos($line,":");
|
||||
$file = substr($line,0,$index);
|
||||
if (!(strpos($file,$CFG->dataroot) === false)) {
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($file{0} == "/") {
|
||||
$file = $CFG->dataroot.$file;
|
||||
}
|
||||
else {
|
||||
$file = $CFG->dataroot."/".$file;
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// clean up
|
||||
$file = preg_replace('/\.\//','/',$file);
|
||||
$file = preg_replace('/\/\//','/',$file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,565 @@
|
||||
<?php // $Id$
|
||||
|
||||
ob_start(); //for whitespace test
|
||||
require_once('../config.php');
|
||||
|
||||
// extra whitespace test - intentionally breaks cookieless mode
|
||||
$extraws = '';
|
||||
while (true) {
|
||||
$extraws .= ob_get_contents();
|
||||
if (!@ob_end_clean()) { //
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
define('SEVERITY_NOTICE', 'notice');
|
||||
define('SEVERITY_ANNOYANCE', 'annoyance');
|
||||
define('SEVERITY_SIGNIFICANT', 'significant');
|
||||
define('SEVERITY_CRITICAL', 'critical');
|
||||
|
||||
$solution = optional_param('solution', 0, PARAM_SAFEDIR); //in fact it is class name alhanumeric and _
|
||||
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error('Only the admin can use this page');
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$stradmin = get_string('administration');
|
||||
$strhealthcenter = get_string('healthcenter');
|
||||
$strmisc = get_string('miscellaneous');
|
||||
|
||||
print_header($site->shortname.': '.$strhealthcenter, $site->fullname,
|
||||
'<a href="index.php">'.$stradmin.'</a> -> <a href="misc.php">'.$strmisc.'</a> ->'.
|
||||
$strhealthcenter);
|
||||
|
||||
echo <<<STYLES
|
||||
<style type="text/css">
|
||||
div#healthnoproblemsfound {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
padding: 1em;
|
||||
border: 1px black solid;
|
||||
-moz-border-radius: 6px;
|
||||
}
|
||||
dl.healthissues {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
}
|
||||
dl.critical dt, dl.critical dd {
|
||||
background-color: #a71501;
|
||||
}
|
||||
dl.significant dt, dl.significant dd {
|
||||
background-color: #d36707;
|
||||
}
|
||||
dl.annoyance dt, dl.annoyance dd {
|
||||
background-color: #dba707;
|
||||
}
|
||||
dl.notice dt, dl.notice dd {
|
||||
background-color: #e5db36;
|
||||
}
|
||||
dt.solution, dd.solution, div#healthnoproblemsfound {
|
||||
background-color: #5BB83E !important;
|
||||
}
|
||||
dl.healthissues dt, dl.healthissues dd {
|
||||
margin: 0px;
|
||||
padding: 1em;
|
||||
border: 1px black solid;
|
||||
}
|
||||
dl.healthissues dt {
|
||||
font-weight: bold;
|
||||
border-bottom: none;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
dl.healthissues dd {
|
||||
border-top: none;
|
||||
padding-top: 0.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
dl.healthissues dd form {
|
||||
margin-top: 0.5em;
|
||||
text-align: right;
|
||||
}
|
||||
form#healthformreturn {
|
||||
text-align: center;
|
||||
margin: 2em;
|
||||
}
|
||||
dd.solution p {
|
||||
padding: 0px;
|
||||
margin: 1em 0px;
|
||||
}
|
||||
dd.solution li {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
STYLES;
|
||||
|
||||
if(strpos($solution, 'problem_') === 0 && class_exists($solution)) {
|
||||
health_print_solution($solution);
|
||||
}
|
||||
else {
|
||||
health_find_problems();
|
||||
}
|
||||
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
function health_find_problems() {
|
||||
|
||||
print_heading(get_string('healthcenter'));
|
||||
|
||||
$issues = array(
|
||||
SEVERITY_CRITICAL => array(),
|
||||
SEVERITY_SIGNIFICANT => array(),
|
||||
SEVERITY_ANNOYANCE => array(),
|
||||
SEVERITY_NOTICE => array(),
|
||||
);
|
||||
$problems = 0;
|
||||
|
||||
for($i = 1; $i < 1000000; ++$i) {
|
||||
$classname = sprintf('problem_%06d', $i);
|
||||
if(!class_exists($classname)) {
|
||||
break;
|
||||
}
|
||||
$problem = new $classname;
|
||||
if($problem->exists()) {
|
||||
$severity = $problem->severity();
|
||||
$issues[$severity][$classname] = array(
|
||||
'severity' => $severity,
|
||||
'description' => $problem->description(),
|
||||
'title' => $problem->title()
|
||||
);
|
||||
++$problems;
|
||||
}
|
||||
unset($problem);
|
||||
}
|
||||
|
||||
if($problems == 0) {
|
||||
echo '<div id="healthnoproblemsfound">';
|
||||
echo get_string('healthnoproblemsfound');
|
||||
echo '</div>';
|
||||
}
|
||||
else {
|
||||
print_heading(get_string('healthproblemsdetected'));
|
||||
$severities = array(SEVERITY_CRITICAL, SEVERITY_SIGNIFICANT, SEVERITY_ANNOYANCE, SEVERITY_NOTICE);
|
||||
foreach($severities as $severity) {
|
||||
if(!empty($issues[$severity])) {
|
||||
echo '<dl class="healthissues '.$severity.'">';
|
||||
foreach($issues[$severity] as $classname => $data) {
|
||||
echo '<dt id="'.$classname.'">'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'];
|
||||
echo '<form action="health.php#solution" method="get">';
|
||||
echo '<input type="hidden" name="solution" value="'.$classname.'" /><input type="submit" value="'.get_string('viewsolution').'" />';
|
||||
echo '</form></dd>';
|
||||
}
|
||||
echo '</dl>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function health_print_solution($classname) {
|
||||
$problem = new $classname;
|
||||
$data = array(
|
||||
'title' => $problem->title(),
|
||||
'severity' => $problem->severity(),
|
||||
'description' => $problem->description(),
|
||||
'solution' => $problem->solution()
|
||||
);
|
||||
|
||||
print_heading(get_string('healthcenter'));
|
||||
print_heading(get_string('healthproblemsolution'));
|
||||
echo '<dl class="healthissues '.$data['severity'].'">';
|
||||
echo '<dt>'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'].'</dd>';
|
||||
echo '<dt id="solution" class="solution">'.get_string('healthsolution').'</dt>';
|
||||
echo '<dd class="solution">'.$data['solution'].'</dd></dl>';
|
||||
echo '<form id="healthformreturn" action="health.php#'.$classname.'" method="get">';
|
||||
echo '<input type="submit" value="'.get_string('healthreturntomain').'" />';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
class problem_base {
|
||||
function exists() {
|
||||
return false;
|
||||
}
|
||||
function title() {
|
||||
return '???';
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_NOTICE;
|
||||
}
|
||||
function description() {
|
||||
return '';
|
||||
}
|
||||
function solution() {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000001 extends problem_base {
|
||||
function title() {
|
||||
return 'Invalid value for $CFG->dirroot';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
if (!empty($dirroot) && $dirroot != $CFG->dirroot) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> file contains the setting <strong>$CFG->dirroot = "'.$CFG->dirroot.'"</strong>, which is incorrect. Unless you correct this problem, Moodle will not function correctly, if at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
return 'You need to edit your <strong>config.php</strong> file. Find the line which reads <pre>$CFG->dirroot = \''.$CFG->dirroot.'\';</pre> and change it to read <pre>$CFG->dirroot = \''.$dirroot.'\'</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000002 extends problem_base {
|
||||
function title() {
|
||||
return 'Extra characters at the end of config.php or other library function';
|
||||
}
|
||||
function exists() {
|
||||
global $extraws;
|
||||
|
||||
if($extraws === '') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your Moodle configuration file config.php or another library file, contains some characters after the closing PHP tag (?>). This causes Moodle to exhibit several kinds of problems (such as broken downloaded files) and must be fixed.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'You need to edit <strong>'.$CFG->dirroot.'/config.php</strong> and remove all characters (including spaces and returns) after the ending ?> tag. These two characters should be the very last in that file. The extra trailing whitespace may be also present in other PHP files that are included from lib/setup.php.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000003 extends problem_base {
|
||||
function title() {
|
||||
return '$CFG->dataroot does not exist or does not have write permissions';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
if(!is_dir($CFG->dataroot) || !is_writable($CFG->dataroot)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> says that your "data root" directory is <strong>'.$CFG->dataroot.'</strong>. However, this directory either does not exist or cannot be written to by Moodle. This means that a variety of problems will be present, such as users not being able to log in and not being able to upload any files. It is imperative that you address this problem for Moodle to work correctly.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'First of all, make sure that the directory <strong>'.$CFG->dataroot.'</strong> exists. If the directory does exist, then you must make sure that Moodle is able to write to it. Contact your web server administrator and request that he gives write permissions for that directory to the user that the web server process is running as.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000004 extends problem_base {
|
||||
function title() {
|
||||
return 'cron.php is not set up to run automatically';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM '.$CFG->prefix.'modules');
|
||||
return (time() - $lastcron > 3600 * 24);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'The cron.php mainenance script has not been run in the past 24 hours. This probably means that your server is not configured to automatically run this script in regular time intervals. If this is the case, then Moodle will mostly work as it should but some operations (notably sending email to users) will not be carried out at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'For detailed instructions on how to enable cron, see <a href="'.$CFG->wwwroot.'/doc/?file=install.html#cron">this section</a> of the installation manual.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000005 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: session.auto_start is enabled';
|
||||
}
|
||||
function exists() {
|
||||
return ini_get_bool('session.auto_start');
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes an enabled setting, session.auto_start, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include fatal errors and/or blank pages when trying to log in.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>session.auto_start = 1</pre> and change it to <pre>session.auto_start = 0</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value session.auto_start "0"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000006 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: magic_quotes_runtime is enabled';
|
||||
}
|
||||
function exists() {
|
||||
return (ini_get_bool('magic_quotes_runtime'));
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes an enabled setting, magic_quotes_runtime, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include strange display errors whenever a text field that includes single or double quotes is processed.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>magic_quotes_runtime = On</pre> and change it to <pre>magic_quotes_runtime = Off</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value magic_quotes_runtime "Off"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000007 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: file_uploads is disabled';
|
||||
}
|
||||
function exists() {
|
||||
return !ini_get_bool('file_uploads');
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes a disabled setting, file_uploads, that <strong>must be enabled</strong> to let Moodle offer its full functionality. Until this setting is enabled, it will not be possible to upload any files into Moodle. This includes, for example, course content and user pictures.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>file_uploads = Off</pre> and change it to <pre>file_uploads = On</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value file_uploads "On"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000008 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: memory_limit cannot be controlled by Moodle';
|
||||
}
|
||||
function exists() {
|
||||
$oldmemlimit = @ini_get('memory_limit');
|
||||
if(empty($oldmemlimit)) {
|
||||
// PHP not compiled with memory limits, this means that it's
|
||||
// probably limited to 8M or in case of Windows not at all.
|
||||
// We can ignore it for now - there is not much to test anyway
|
||||
// TODO: add manual test that fills memory??
|
||||
return false;
|
||||
}
|
||||
$oldmemlimit = get_real_size($oldmemlimit);
|
||||
//now lets change the memory limit to something unique below 128M==134217728
|
||||
@ini_set('memory_limit', 134217720);
|
||||
$testmemlimit = get_real_size(@ini_get('memory_limit'));
|
||||
//verify the change had any effect at all
|
||||
if ($oldmemlimit == $testmemlimit) {
|
||||
//memory limit can not be changed - is it big enough then?
|
||||
if ($oldmemlimit < get_real_size('128M')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ini_set('memory_limit', $oldmemlimit);
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_NOTICE;
|
||||
}
|
||||
function description() {
|
||||
return 'The settings for PHP on your server do not allow a script to request more memory during its execution. '.
|
||||
'This means that there is a hard limit of '.@ini_get('memory_limit').' for each script. '.
|
||||
'It is possible that certain operations within Moodle will require more than this amount in order '.
|
||||
'to complete successfully, especially if there are lots of data to be processed.';
|
||||
}
|
||||
function solution() {
|
||||
return 'It is recommended that you contact your web server administrator to address this issue.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000009 extends problem_base {
|
||||
function title() {
|
||||
return 'SQL: using account without password';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return empty($CFG->dbpass);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'The user account your are connecting to the database server with is set up without a password. This is a very big security risk and is only somewhat lessened if your database is configured to not accept connections from any hosts other than the server Moodle is running on. Unless you use a strong password to connect to the database, you risk unauthorized access to and manipulation of your data.'.($CFG->dbuser != 'root'?'':' <strong>This is especially alarming because such access to the database would be as the superuser (root)!</strong>');
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'You should change the password of the user <strong>'.$CFG->dbuser.'</strong> both in your database and in your Moodle <strong>config.php</strong> immediately!'.($CFG->dbuser != 'root'?'':' It would also be a good idea to change the user account from root to something else, because this would lessen the impact in the event that your database is compromised anyway.');
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000010 extends problem_base {
|
||||
function title() {
|
||||
return 'Uploaded files: slasharguments disabled or not working';
|
||||
}
|
||||
function exists() {
|
||||
if (!$this->is_enabled()) {
|
||||
return true;
|
||||
}
|
||||
if ($this->status() < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
if ($this->is_enabled() and $this->status() == 0) {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
} else {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
$desc = 'Slasharguments are needed for relative linking in uploaded resources:<ul>';
|
||||
if (!$this->is_enabled()) {
|
||||
$desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
|
||||
}
|
||||
if ($this->status() == -1) {
|
||||
$desc .= '<li>can not run automatic test, you can verify it <a href="'.$CFG->wwwroot.'/file.php/testslasharguments" target="_blank">here</a> manually</li>';
|
||||
} else if ($this->status() == 0) {
|
||||
$desc .= '<li>slashargument test <strong>failed</strong>, please check server configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slashargument test passed</li>';
|
||||
}
|
||||
$desc .= '</ul>';
|
||||
return $desc;
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$enabled = $this->is_enabled();
|
||||
$status = $this->status();
|
||||
$solution = '';
|
||||
if ($enabled and ($status == 0)) {
|
||||
$solution .= 'Slasharguments are enabled, but the test failed. Please disable slasharguments in Moodle configuration or fix the server configuration.<hr />';
|
||||
} else if ((!$enabled) and ($status == 0)) {
|
||||
$solution .= 'Slasharguments are disabled and the test failed. You may try to fix the server configuration.<hr />';
|
||||
} else if ($enabled and ($status == -1)) {
|
||||
$solution .= 'Slasharguments are enabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
|
||||
} else if ((!$enabled) and ($status == -1)) {
|
||||
$solution .= 'Slasharguments are disabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
|
||||
} else if ((!$enabled) and ($status > 0)) {
|
||||
$solution .= 'Slasharguments are disabled though the iternal test is OK. You should enable slasharguments in Moodle configuration.';
|
||||
} else if ($enabled and ($status > 0)) {
|
||||
$solution .= 'Congratulations - everything seems OK now :-D';
|
||||
}
|
||||
if ($status < 1) {
|
||||
$solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>';
|
||||
$solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
|
||||
$solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
|
||||
}
|
||||
return $solution;
|
||||
}
|
||||
function is_enabled() {
|
||||
global $CFG;
|
||||
return !empty($CFG->slasharguments);
|
||||
}
|
||||
function status() {
|
||||
global $CFG;
|
||||
$handle = @fopen($CFG->wwwroot.'/file.php?file=/testslasharguments', "r");
|
||||
$contents = @trim(fread($handle, 10));
|
||||
@fclose($handle);
|
||||
if ($contents != 'test -1') {
|
||||
return -1;
|
||||
}
|
||||
$handle = @fopen($CFG->wwwroot.'/file.php/testslasharguments', "r");
|
||||
$contents = trim(@fread($handle, 10));
|
||||
@fclose($handle);
|
||||
switch ($contents) {
|
||||
case 'test 1': return 1;
|
||||
case 'test 2': return 2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000011 extends problem_base {
|
||||
function title() {
|
||||
return 'Session errors detected';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return isset($CFG->session_error_counter);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
if (isset($CFG->session_error_counter)) {
|
||||
return 'Session problems were detected. Total count: '.$CFG->session_error_counter;
|
||||
} else {
|
||||
return 'No session errors detected.';
|
||||
}
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
if (optional_param('resetsesserrorcounter', 0, PARAM_BOOL)) {
|
||||
if (get_field('config', 'name', 'name', 'session_error_counter')) {
|
||||
delete_records('config', 'name', 'session_error_counter');
|
||||
}
|
||||
return 'Error counter was cleared.';
|
||||
} else {
|
||||
return '<p>Session errors can be caused by:<ul><li>unresolved problem in server software (aka random switching of users),</li><li>blocked or modified cookies,</li><li>deleting of active session files.</li></ul></p><p><a href="'.me().'&resetsesserrorcounter=1">Reset counter.</a></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class problem_00000x extends problem_base {
|
||||
function title() {
|
||||
return '';
|
||||
}
|
||||
function exists() {
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return '';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
||||
session.save_path -- it doesn't really matter because we are already IN a session, right?
|
||||
detect unsupported characters in $CFG->wwwroot - see bug Bug #6091 - relative vs absolute path during backup/restore process
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
+437
-834
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Admin only');
|
||||
}
|
||||
|
||||
print_header("Convert all tables from MYISAM to InnoDB", "Convert all tables from MYISAM to InnoDB",
|
||||
"Convert all tables from MYISAM to InnoDB");
|
||||
|
||||
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
|
||||
print_heading("Please be patient and wait for this to complete...");
|
||||
|
||||
if ($tables = $db->MetaTables()) {
|
||||
$db->debug = true;
|
||||
foreach ($tables as $table) {
|
||||
execute_sql("ALTER TABLE $table TYPE=INNODB; ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notice_yesno("Are you sure you want convert all your tables to the InnoDB format?",
|
||||
"innodb.php?confirm=1&sesskey=".sesskey(), "index.php");
|
||||
}
|
||||
|
||||
?>
|
||||
+626
@@ -0,0 +1,626 @@
|
||||
<?PHP // $Id$
|
||||
/**
|
||||
* Display the admin/language menu and process strings translation.
|
||||
*
|
||||
* CHANGES
|
||||
*
|
||||
* 2006/06/08 mudrd8mz
|
||||
* 1) Fixed bug 5745 reported by Harry Smith so now can edit en_utf8_local pack
|
||||
* 2) More notification messages included
|
||||
*
|
||||
* 2006/05/30 mudrd8mz
|
||||
* Merged with version by Mitsuhiro Yoshida - display icon links instead of text links
|
||||
* (I have changed the position of arrow icons to not to be so close each other)
|
||||
*
|
||||
* 2006/05/19 mudrd8mz
|
||||
* A lot of changes to support translation of *_utf8_local langugage packs. Needs testing
|
||||
*
|
||||
* 2006/05/16 mudrd8mz
|
||||
* 1) LANG_DEFAULT_FILE can be now set. moodle.php used to be opened automatically.
|
||||
* As it was (and still is) one of the biggest files it usually took a long time to load the page
|
||||
* even if you just want to choose the file to translate.
|
||||
* 2) added links from "missing" to "compare" mode page
|
||||
* 3) english strings are now key-sorted in "missing" mode
|
||||
* 4) list of files with missing strings is now displayed at the top of "missing" page
|
||||
*
|
||||
* 2006/05/14 mudrd8mz Improvements of lang.php,v 1.65 2006/04/10 22:15:57 stronk7 Exp
|
||||
* 1) "go to first missing string" link can be displayed (see LANG_DISPLAY_MISSING_LINKS)
|
||||
* 2) "go to next missing" link can be displayed (see LANG_DISPLAY_MISSING_LINKS)
|
||||
* 3) submit button may be repeated (see LANG_SUBMIT_REPEAT*)
|
||||
* 4) added (empty) "summary" attribute for the <table>'s
|
||||
* 5) added error_reporting(E_ALL ^ E_NOTICE); in "compare" mode (even in debug environment
|
||||
* we know that missing keys are missing strings here, not bugs ;-)
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
define('LANG_SUBMIT_REPEAT', 1); // repeat displaying submit button?
|
||||
define('LANG_SUBMIT_REPEAT_EVERY', 20); // if so, after how many lines?
|
||||
define('LANG_DISPLAY_MISSING_LINKS', 1); // display "go to first/next missing string" links?
|
||||
define('LANG_DEFAULT_FILE', ''); // default file to translate. Empty allowed
|
||||
define('LANG_LINK_MISSING_STRINGS', 1); // create links from "missing" page to "compare" page?
|
||||
define('LANG_DEFAULT_USELOCAL', 0); // should *_utf8_local be used by default?
|
||||
|
||||
$mode = optional_param('mode', '', PARAM_ALPHA);
|
||||
$currentfile = optional_param('currentfile', LANG_DEFAULT_FILE, PARAM_FILE);
|
||||
$uselocal = optional_param('uselocal', -1, PARAM_INT);
|
||||
|
||||
if ($uselocal == -1) {
|
||||
if (isset($SESSION->langtranslateintolocal)) {
|
||||
$uselocal = $SESSION->langtranslateintolocal;
|
||||
} else {
|
||||
$uselocal = LANG_DEFAULT_USELOCAL;
|
||||
}
|
||||
} else {
|
||||
$SESSION->langtranslateintolocal = $uselocal;
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You need to be admin to edit this page");
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Site not defined!");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strlanguage = get_string("language");
|
||||
$strcurrentlanguage = get_string("currentlanguage");
|
||||
$strmissingstrings = get_string("missingstrings");
|
||||
$streditstrings = get_string("editstrings", 'admin');
|
||||
$stredithelpdocs = get_string("edithelpdocs", 'admin');
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$strgotofirst = get_string('gotofirstmissing','admin');
|
||||
$strfilestoredin = get_string('langstorein', 'admin');
|
||||
$strfilestoredinhelp = get_string('langstoreinhelp', 'admin');
|
||||
$strswitchlangdirbtn = get_string('langstoreswitch', 'admin');
|
||||
$strchoosefiletoedit = get_string('langchoosefile', 'admin');
|
||||
$streditennotallowed = get_string('langnoeditenglish', 'admin');
|
||||
$strfilecreated = get_string('langfilecreated', 'admin');
|
||||
|
||||
// FIXME / TODO
|
||||
// remove following lines after adding string into proper english lang pack
|
||||
$strgotofirst = 'go to first missing string';
|
||||
$strfilestoredin = 'Save file into folder :';
|
||||
$strfilestoredinhelp = 'Where the file will be stored';
|
||||
$strswitchlangdirbtn = 'switch';
|
||||
$strchoosefiletoedit = 'Choose file to edit from the box above';
|
||||
$streditennotallowed = 'Language en_utf8 cannot be edited with this page - switch to local';
|
||||
$strfilecreated = 'New file created';
|
||||
|
||||
$currentlang = current_language();
|
||||
|
||||
switch ($mode) {
|
||||
case "missing":
|
||||
// Missing array keys are not bugs here but missing strings
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $strmissingstrings";
|
||||
$title = $strmissingstrings;
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="submit" value="'.$streditstrings.'" /></form>';
|
||||
break;
|
||||
case "compare":
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $streditstrings";
|
||||
$title = $streditstrings;
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="missing" />'.
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></form>';
|
||||
break;
|
||||
default:
|
||||
$title = $strlanguage;
|
||||
$navigation = $strlanguage;
|
||||
$button = '';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
print_header("$site->shortname: $title", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $navigation",
|
||||
'', '', true, $button);
|
||||
|
||||
if (!$mode) {
|
||||
print_simple_box_start('center','80%');
|
||||
echo '<table summary="" align="center" width="100%"><tr><td width="50%" align="center">';
|
||||
print_string('managelang','admin');
|
||||
echo '</td><td align="center" width="50%">';
|
||||
print_string('editlang','admin');
|
||||
echo '</td></tr><tr><td>';
|
||||
print_string('lang16notify','admin');
|
||||
echo '<p /><a href="langimport.php">'.get_string('langimport','admin').'</a>';
|
||||
echo '</td><td>';
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
echo "<table summary=\"\" align=\"center\"><tr><td align=\"right\">";
|
||||
echo "<b>$strcurrentlanguage:</b>";
|
||||
echo "</td><td>";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
echo '</td></tr><tr><td colspan="2">';
|
||||
$options["lang"] = $currentlang;
|
||||
//print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||
echo "</td></tr></table>";
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare\">$streditstrings</a>");
|
||||
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
|
||||
echo '</td></tr></table>';
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get a list of all the root files in the English directory
|
||||
|
||||
$enlangdir = "$CFG->dirroot/lang/en_utf8";
|
||||
if ($currentlang == 'en_utf8') {
|
||||
$langdir = $enlangdir;
|
||||
} else {
|
||||
$langdir = "$CFG->dataroot/lang/$currentlang";
|
||||
}
|
||||
$locallangdir = "$CFG->dataroot/lang/{$currentlang}_local";
|
||||
|
||||
if (! $stringfiles = get_directory_list($enlangdir, "", false)) {
|
||||
error("Could not find English language pack!");
|
||||
}
|
||||
|
||||
foreach ($stringfiles as $key => $file) {
|
||||
if (substr($file, -4) != ".php") { //Avoid non php files to be showed
|
||||
unset($stringfiles[$key]);
|
||||
}
|
||||
if ($file == "langconfig.php") { //Avoid langconfig.php to be showed
|
||||
unset($stringfiles[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "missing") {
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
|
||||
// Following variables store the HTML output to be echo-ed
|
||||
$m = '';
|
||||
$o = '';
|
||||
|
||||
// For each file, check that a counterpart exists, then check all the strings
|
||||
foreach ($stringfiles as $file) {
|
||||
unset($string);
|
||||
include("$enlangdir/$file");
|
||||
$enstring = $string;
|
||||
|
||||
ksort($enstring);
|
||||
|
||||
unset($string);
|
||||
|
||||
if (file_exists("$langdir/$file")) {
|
||||
include("$langdir/$file");
|
||||
$fileismissing = 0;
|
||||
} else {
|
||||
$fileismissing = 1;
|
||||
// notify(get_string("filemissing", "", "$langdir/$file"));
|
||||
$o .= '<div class="notifyproblem" align="center">'.get_string("filemissing", "", "$langdir/$file").'</div><br />';
|
||||
$string = array();
|
||||
}
|
||||
|
||||
$missingcounter = 0;
|
||||
|
||||
$first = true;
|
||||
foreach ($enstring as $key => $value) {
|
||||
if (empty($string[$key]) and $string[$key] != "0") { //bug fix 4735 mits
|
||||
$value = htmlspecialchars($value);
|
||||
$value = str_replace("$"."a", "\\$"."a", $value);
|
||||
$value = str_replace("%%","%",$value);
|
||||
if ($first) {
|
||||
$m .= "<a href=\"lang.php?mode=missing#$file\">$file";
|
||||
$m .= $fileismissing ? '*' : '';
|
||||
$m .= '</a> ';
|
||||
$o .= "<p><a name=\"$file\"></a><b>".get_string("stringsnotset","","$langdir/$file")."</b></p><pre>";
|
||||
$first = false;
|
||||
$somethingfound = true;
|
||||
}
|
||||
$missingcounter++;
|
||||
if (LANG_LINK_MISSING_STRINGS) {
|
||||
$missinglinkstart = "<a href=\"lang.php?mode=compare&currentfile=$file#missing$missingcounter\">";
|
||||
$missinglinkend = '</a>';
|
||||
} else {
|
||||
$missinglinkstart = '';
|
||||
$missinglinkend = '';
|
||||
}
|
||||
$o .= "$"."string['".$missinglinkstart.$key.$missinglinkend."'] = \"$value\";<br />";
|
||||
}
|
||||
}
|
||||
if (!$first) {
|
||||
$o .= '</pre><hr />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($m <> '') {
|
||||
echo '<br />';
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center><font size="2">';
|
||||
echo $m;
|
||||
echo '</font></center>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
echo $o;
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
if (!file_exists("$langdir/help/$file")) {
|
||||
echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/help/$file")."</font></p>";
|
||||
$somethingfound = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
foreach ($files as $filekey => $file) { // check all the docs files.
|
||||
if (!file_exists("$langdir/docs/$file")) {
|
||||
echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/docs/$file")."</font></p>";
|
||||
$somethingfound = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($somethingfound)) {
|
||||
print_continue("lang.php");
|
||||
} else {
|
||||
notice(get_string("languagegood"), "lang.php");
|
||||
}
|
||||
|
||||
} else if ($mode == "compare") {
|
||||
|
||||
if (!$uselocal && !file_exists($langdir)) {
|
||||
if (!lang_make_directory($langdir)) {
|
||||
error('ERROR: Could not create directory '.$langdir);
|
||||
} else {
|
||||
echo '<div class="notifysuccess" align="center">Created directory '.
|
||||
$langdir .'</div>'."<br />\n";
|
||||
}
|
||||
}
|
||||
if ($uselocal && !file_exists($locallangdir)) {
|
||||
if (!lang_make_directory($locallangdir)) {
|
||||
echo '<div class="notifyproblem" align="center">ERROR: Could not create directory '.
|
||||
$locallangdir .'</div>'."<br />\n";
|
||||
$uselocal = 0;
|
||||
} else {
|
||||
echo '<div class="notifysuccess" align="center">Created directory '.
|
||||
$locallangdir .'</div>'."<br />\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['currentfile'])){ // Save a file
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$newstrings = array();
|
||||
|
||||
foreach ($_POST as $postkey => $postval) {
|
||||
$stringkey = lang_file_string_key($postkey);
|
||||
$newstrings[$stringkey] = $postval;
|
||||
}
|
||||
|
||||
unset($newstrings['currentfile']);
|
||||
|
||||
if ($uselocal) {
|
||||
include("$langdir/$currentfile");
|
||||
if (isset($string)) {
|
||||
$packstring = $string;
|
||||
} else {
|
||||
$packstring = array();
|
||||
}
|
||||
unset($string);
|
||||
$saveinto = $locallangdir;
|
||||
} else {
|
||||
$packstring = array();
|
||||
$saveinto = $langdir;
|
||||
}
|
||||
|
||||
if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) {
|
||||
notify(get_string("changessaved")." ($saveinto/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare&currentfile=$currentfile");
|
||||
}
|
||||
unset($packstring);
|
||||
}
|
||||
|
||||
print_heading_with_help($streditstrings, "langedit");
|
||||
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center><font size="2">';
|
||||
foreach ($stringfiles as $file) {
|
||||
if ($file == $currentfile) {
|
||||
echo "<b>$file</b> ";
|
||||
} else {
|
||||
echo "<a href=\"lang.php?mode=compare&currentfile=$file\">$file</a> ";
|
||||
}
|
||||
}
|
||||
echo '</font></center>';
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center>'.$strfilestoredin.' <strong>';
|
||||
echo $uselocal ? "{$currentlang}_local" : $currentlang;
|
||||
echo '</strong> ';
|
||||
helpbutton('langswitchstorage', $strfilestoredinhelp, 'moodle');
|
||||
|
||||
echo '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="hidden" name="currentfile" value="'.$currentfile.'" />'.
|
||||
'<input type="hidden" name="uselocal" value="'.(1 - $uselocal % 2).'" />'.
|
||||
'<input type="submit" value="'.$strswitchlangdirbtn.'" />'.
|
||||
'</form></center>';
|
||||
print_simple_box_end();
|
||||
|
||||
if ($currentfile <> '') {
|
||||
$saveto = $uselocal ? $locallangdir : $langdir;
|
||||
error_reporting(0);
|
||||
if (!file_exists("$saveto/$currentfile")) {
|
||||
if (!@touch("$saveto/$currentfile")) {
|
||||
print_heading(get_string("filemissing", "", "$saveto/$currentfile"), "center", 4, "error");
|
||||
} else {
|
||||
print_heading($strfilecreated, "center", 4, "notifysuccess");
|
||||
}
|
||||
}
|
||||
if ($currentlang == "en_utf8" && !$uselocal) {
|
||||
$editable = false;
|
||||
print_heading($streditennotallowed, 'center', 4);
|
||||
} elseif ($f = fopen("$saveto/$currentfile","r+")) {
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
} else {
|
||||
$editable = false;
|
||||
echo "<p><font size=\"1\">".get_string("makeeditable", "", "$saveto/$currentfile")."</font></p>";
|
||||
}
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
print_heading("$currentfile", "center", 4);
|
||||
if (LANG_DISPLAY_MISSING_LINKS && $editable) {
|
||||
print_heading('<a href="#missing1">'.$strgotofirst.'</a>', "center", 4);
|
||||
}
|
||||
|
||||
unset($string);
|
||||
include("$enlangdir/$currentfile");
|
||||
$enstring = $string;
|
||||
if ($currentlang != 'en' and $currentfile == 'moodle.php') {
|
||||
$enstring['thislanguage'] = "<< TRANSLATORS: Specify the name of your language here. If possible use Unicode Numeric Character References >>";
|
||||
$enstring['thischarset'] = "<< TRANSLATORS: Specify the character set of your language here. Note that all text created while this language is active will be stored using this character set, so don't change it once you have set it. Example: iso-8859-1 >>";
|
||||
$enstring['thisdirection'] = "<< TRANSLATORS: This string specifies the direction of your text, either left-to-right or right-to-left. Insert either 'ltr' or 'rtl' here. >>";
|
||||
$enstring['parentlanguage'] = "<< TRANSLATORS: If your language has a Parent Language that Moodle should use when strings are missing from your language pack, then specify the code for it here. If you leave this blank then English will be used. Example: nl >>";
|
||||
}
|
||||
ksort($enstring);
|
||||
|
||||
unset($string);
|
||||
|
||||
@include("$locallangdir/$currentfile");
|
||||
$localstring = isset($string) ? $string : array();
|
||||
unset($string);
|
||||
|
||||
@include("$langdir/$currentfile");
|
||||
|
||||
if ($editable) {
|
||||
echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
|
||||
}
|
||||
echo "<table summary=\"\" width=\"100%\" cellpadding=\"2\" cellspacing=\"3\" border=\"0\" class=\"generalbox\">";
|
||||
$linescounter = 0;
|
||||
$missingcounter = 0;
|
||||
foreach ($enstring as $key => $envalue) {
|
||||
$linescounter++ ;
|
||||
if (LANG_SUBMIT_REPEAT && $editable && $linescounter % LANG_SUBMIT_REPEAT_EVERY == 0) {
|
||||
echo '<tr><td colspan="2"> <td><br />';
|
||||
echo ' <input type="submit" name="update" value="'.get_string('savechanges').': '.$currentfile.'" />';
|
||||
echo '<br /> </td></tr>';
|
||||
}
|
||||
$envalue = nl2br(htmlspecialchars($envalue));
|
||||
$envalue = preg_replace('/(\$a\-\>[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
|
||||
$envalue = str_replace("%%","%",$envalue);
|
||||
$envalue = str_replace("\\","",$envalue); // Delete all slashes
|
||||
|
||||
echo "\n\n".'<tr>';
|
||||
echo '<td dir="ltr" lang="en" width="20%" nowrap="nowrap" valign="top">'.$key.'</td>'."\n";
|
||||
echo '<td dir="ltr" lang="en" width="40%" valign="top">'.$envalue.'</td>'."\n";
|
||||
|
||||
// Missing array keys are not bugs here but missing strings
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
if ($uselocal) {
|
||||
$value = lang_fix_value_from_file($localstring[$key]);
|
||||
$value2 = lang_fix_value_from_file($string[$key]);
|
||||
if ($value == '') {
|
||||
$value = $value2;
|
||||
}
|
||||
} else {
|
||||
$value = lang_fix_value_from_file($string[$key]);
|
||||
$value2 = lang_fix_value_from_file($localstring[$key]);
|
||||
}
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
// Color highlighting:
|
||||
// red #ef6868 - translation missing in both system and local pack
|
||||
// yellow #feff7f - translation missing in system pack but is translated in local
|
||||
// green #AAFFAA - translation present in both system and local but is different
|
||||
if (!$value) {
|
||||
if (!$value2) {
|
||||
$cellcolour = 'style="background-color: #ef6868"'; // TODO: replace by CSS class
|
||||
} else {
|
||||
$cellcolour = 'style="background-color: #feff7f"'; // TODO: replace by CSS class
|
||||
}
|
||||
$missingcounter++;
|
||||
if (LANG_DISPLAY_MISSING_LINKS) {
|
||||
$missingtarget = '<a name="missing'.$missingcounter.'"></a>';
|
||||
$missingnext = '<a href="#missing'.($missingcounter+1).'">'.
|
||||
'<img src="' . $CFG->pixpath . '/t/down.gif" height="11" width="11" border="0" alt="" /></a>';
|
||||
$missingprev = '<a href="#missing'.($missingcounter-1).'">'.
|
||||
'<img src="' . $CFG->pixpath . '/t/up.gif" height="11" width="11" border="0" alt="" /></a>';
|
||||
} else {
|
||||
$missingtarget = '';
|
||||
$missingnext = '';
|
||||
$missingprev = '';
|
||||
}
|
||||
} else {
|
||||
if ($value <> $value2 && $value2 <> '') {
|
||||
$cellcolour = 'style="background-color: #AAFFAA"'; // TODO: replace by CSS class
|
||||
} else {
|
||||
$cellcolour = '';
|
||||
}
|
||||
$missingtarget = '';
|
||||
$missingnext = '';
|
||||
$missingprev = '';
|
||||
}
|
||||
|
||||
if ($editable) {
|
||||
echo '<td width="40%" '.$cellcolour.' valign="top">'. $missingprev . $missingtarget."\n";
|
||||
if (isset($string[$key])) {
|
||||
$valuelen = strlen($value);
|
||||
} else {
|
||||
$valuelen = strlen($envalue);
|
||||
}
|
||||
$cols=50;
|
||||
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
|
||||
$rows = ceil($valuelen / $cols);
|
||||
echo '<textarea name="stringXXX'.lang_form_string_key($key).'" cols="'.$cols.'" rows="'.$rows.'">'.$value.'</textarea>'."\n";
|
||||
} else {
|
||||
if ($valuelen) {
|
||||
$cols = $valuelen + 5;
|
||||
}
|
||||
echo '<input type="text" name="stringXXX'.lang_form_string_key($key).'" value="'.$value.'" size="'.$cols.'" />';
|
||||
}
|
||||
if ($value2 <> '' && $value <> $value2) {
|
||||
echo '<br /><span style="font-size:small">'.$value2.'</span>';
|
||||
}
|
||||
echo $missingnext . '</td>';
|
||||
|
||||
} else {
|
||||
echo '<td width="40%" bgcolor="'.$cellcolour.'" valign="top">'.$value.'</td>';
|
||||
}
|
||||
}
|
||||
if ($editable) {
|
||||
echo '<tr><td colspan="2"> <td><br />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo ' <input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
echo ' <input type="hidden" name="mode" value="compare" />';
|
||||
echo ' <input type="submit" name="update" value="'.get_string('savechanges').': '.$currentfile.'" />';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
echo '</form>';
|
||||
|
||||
} else {
|
||||
// no $currentfile specified
|
||||
print_heading($strchoosefiletoedit, "center", 4);
|
||||
}
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Save language translation file.
|
||||
*
|
||||
* Thanks to Petri Asikainen for the original version of code
|
||||
* used to save language files.
|
||||
*
|
||||
* @uses $CFG
|
||||
* @uses $USER
|
||||
* @param string $path Full pathname to the directory to use
|
||||
* @param string $file File to overwrite
|
||||
* @param array $strings Array of strings to write
|
||||
* @param bool $local Should *_local version be saved?
|
||||
* @param array $packstrings Array of default langpack strings (needed if $local)
|
||||
* @return bool Created successfully?
|
||||
*/
|
||||
function lang_save_file($path, $file, $strings, $local, $packstrings) {
|
||||
global $CFG, $USER;
|
||||
if (!$f = @fopen("$path/$file","w")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fwrite($f, "<?PHP // \$Id\$ \n");
|
||||
fwrite($f, " // $file - created with Moodle $CFG->release ($CFG->version)\n");
|
||||
if ($local) {
|
||||
fwrite($f, " // local modifications from $CFG->wwwroot\n");
|
||||
}
|
||||
fwrite($f, "\n\n");
|
||||
ksort($strings);
|
||||
foreach ($strings as $key => $value) {
|
||||
@list($id, $stringname) = explode('XXX',$key);
|
||||
if ($CFG->lang != "zh_hk" and $CFG->lang != "zh_tw") { // Some MB languages include backslash bytes
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
}
|
||||
$value = str_replace("'", "\\'", $value); // Add slashes for '
|
||||
$value = str_replace('"', "\\\"", $value); // Add slashes for "
|
||||
$value = str_replace("%","%%",$value); // Escape % characters
|
||||
$value = str_replace("\r", "",$value); // Remove linefeed characters
|
||||
$value = trim($value); // Delete leading/trailing white space
|
||||
if ($id == "string" and $value != ""){
|
||||
if ((!$local) || (lang_fix_value_from_file($packstrings[$stringname]) <> lang_fix_value_from_file($value))) {
|
||||
fwrite($f,"\$string['$stringname'] = '$value';\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
fwrite($f,"\n?>\n");
|
||||
fclose($f);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix value of string to translate.
|
||||
*
|
||||
* @param string $value Original string from the file
|
||||
* @return string Fixed value
|
||||
*/
|
||||
function lang_fix_value_from_file($value='') {
|
||||
$value = str_replace("\r","",$value); // Bad character caused by Windows
|
||||
$value = preg_replace("/\n{3,}/", "\n\n", $value); // Collapse runs of blank lines
|
||||
$value = trim($value); // Delete leading/trailing white space
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
$value = str_replace("%%","%",$value);
|
||||
$value = str_replace("<","<",$value);
|
||||
$value = str_replace(">",">",$value);
|
||||
$value = str_replace('"',""",$value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try and create a new language directory.
|
||||
*
|
||||
* @uses $CFG
|
||||
* @param string $directory directory name under $CFG->dataroot/lang eg cs_utf8_local
|
||||
* @return string|false Returns full path to directory if successful, false if not
|
||||
*/
|
||||
function lang_make_directory($dir, $shownotices=true) {
|
||||
global $CFG;
|
||||
umask(0000);
|
||||
if (! file_exists($dir)) {
|
||||
if (! @mkdir($dir, $CFG->directorypermissions)) {
|
||||
return false;
|
||||
}
|
||||
//@chmod($dir, $CFG->directorypermissions); // Just in case mkdir didn't do it
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Following functions are required because '.' in form input names
|
||||
/// get replaced by '_' by PHP.
|
||||
|
||||
function lang_form_string_key($keyfromfile) {
|
||||
return str_replace('.', '##46#', $keyfromfile); /// Derived from ., the ascii value for a period.
|
||||
}
|
||||
|
||||
function lang_file_string_key($keyfromform) {
|
||||
return str_replace('##46#', '.', $keyfromform);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Executable
+257
@@ -0,0 +1,257 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
This script enables Moodle translators to edit /docs and /help language
|
||||
files directly via WWW interface.
|
||||
|
||||
Author: mudrd8mz@uxit.pedf.cuni.cz (http://moodle.cz)
|
||||
Based on: lang.php in 1.4.3+ release
|
||||
Thanks: Jaime Villate for important bug fixing, koen roggemans for his job and all moodlers
|
||||
for intensive testing of this my first contribution
|
||||
*/
|
||||
require_once('../config.php');
|
||||
|
||||
//
|
||||
// Some local configuration
|
||||
//
|
||||
$fileeditorrows = 12; // number of textareas' rows
|
||||
$fileeditorcols = 100; // dtto cols
|
||||
$fileeditorinline = 1; // shall be textareas put in one row?
|
||||
$filemissingmark = ' (***)'; // mark to add to non-existing filenames in selection form
|
||||
$fileoldmark = ' (old?)'; // mark to add to filenames in selection form id english version is newer
|
||||
// or to filenames with filesize() == 0
|
||||
$filetemplate = ''; // template for new files, i.e. '$Id$';
|
||||
|
||||
$currentfile = optional_param('currentfile', 'docs/README.txt', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You need to be admin to edit this page");
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Site not defined!");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strlanguage = get_string("language");
|
||||
$strcurrentlanguage = get_string("currentlanguage");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$stredithelpdocs = get_string('edithelpdocs', 'admin');
|
||||
|
||||
print_header("$site->shortname: $stredithelpdocs: $currentfile", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> ->
|
||||
<a href=\"lang.php\">$strlanguage</a> -> $stredithelpdocs",
|
||||
'choosefile.popup', '', true);
|
||||
|
||||
$currentlang = current_language();
|
||||
$langdir = "$CFG->dataroot/lang/$currentlang";
|
||||
$enlangdir = "$CFG->dirroot/lang/en_utf8";
|
||||
|
||||
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
// Shall I save POSTed data?
|
||||
|
||||
if (isset($_POST['currentfile'])) {
|
||||
if (confirm_sesskey()) {
|
||||
if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_reporting(0); // Error reporting turned off due to non-existing files
|
||||
|
||||
// Generate selection for all help and documentation files
|
||||
|
||||
// Get all files from /docs directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the docs files.
|
||||
$options["docs/$file"] = "docs/$file";
|
||||
// add mark if file doesn't exist or is empty
|
||||
if (( !file_exists("$langdir/docs/$file")) || (filesize("$langdir/docs/$file") == 0)) {
|
||||
$options["docs/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/docs/$file") < filemtime("$CFG->dirroot/lang/en_utf8/docs/$file")) {
|
||||
$options["docs/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all files from /help directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
$options["help/$file"] = "help/$file";
|
||||
if (( !file_exists("$langdir/help/$file")) || (filesize("$CFG->dirroot/lang/en_utf8/help/$file") == 0)) {
|
||||
$options["help/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/help/$file") < filemtime("$langdir/help/$file")) {
|
||||
$options["help/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr><td align=\"center\">";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=", $options, "choosefile", $currentfile, "", "", "", true);
|
||||
echo "</td></tr></table>";
|
||||
|
||||
// Generate textareas
|
||||
|
||||
if (!empty($currentfile)) {
|
||||
|
||||
if (!file_exists("$langdir/$currentfile")) {
|
||||
//check if directory exist
|
||||
$pathparts = explode('/',$currentfile);
|
||||
$checkpath = $langdir;
|
||||
for ($a=0; $a < count($pathparts)-1 ; $a++) {
|
||||
$checkpath .= "/".$pathparts[$a];
|
||||
if(!file_exists($checkpath)){
|
||||
if(!mkdir($checkpath)){
|
||||
echo ("Cannot create directory: $checkpath");
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// file doesn't exist - let's check webserver's permission to create it
|
||||
//
|
||||
if (!touch("$langdir/$currentfile")) {
|
||||
//
|
||||
// webserver is unable to create new file
|
||||
//
|
||||
echo "<p align=\"center\"><font color=red>".get_string("filemissing", "", "
|
||||
$langdir/$currentfile")."</font></p>";
|
||||
$editable = false;
|
||||
} else {
|
||||
//
|
||||
// webserver can create new file - we can delete it now and let
|
||||
// the langdoc_save_file() create it again if its filesize() > 0
|
||||
//
|
||||
$editable = true;
|
||||
unlink("$langdir/$currentfile");
|
||||
}
|
||||
} elseif ($f = fopen("$langdir/$currentfile","r+")) {
|
||||
//
|
||||
// file exists and is writeable - good for you, translator ;-)
|
||||
//
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
} else {
|
||||
//
|
||||
// file exists but it is not writeable by web server process :-(
|
||||
//
|
||||
$editable = false;
|
||||
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")
|
||||
."</font></p>";
|
||||
}
|
||||
|
||||
//en_utf8 in dataroot is not editable
|
||||
if ($currentlang == 'en_utf8') {
|
||||
$editable = false;
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr valign=\"center\"><td align=\"center\">\n";
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"\">\n";
|
||||
echo htmlspecialchars(file_get_contents("$enlangdir/$currentfile"));
|
||||
echo "</textarea>\n";
|
||||
//link_to_popup_window("/lang/en_utf8/$currentfile", "popup", get_string("preview"));
|
||||
link_to_popup_window(help_preview_url($currentfile).'&forcelang=en_utf8', 'popup', get_string('preview'));
|
||||
echo "</td>\n";
|
||||
if ($fileeditorinline == 1) {
|
||||
echo "</tr>\n<tr valign=\"center\">\n";
|
||||
}
|
||||
echo "<td align=\"center\">\n";
|
||||
|
||||
if ($editable) {
|
||||
echo "<form name=\"$currentfile\" action=\"langdoc.php\" method=\"post\">";
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
}
|
||||
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"filedata\">\n";
|
||||
if (file_exists("$langdir/$currentfile")) {
|
||||
echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
|
||||
} else {
|
||||
echo ($filetemplate);
|
||||
}
|
||||
echo "</textarea>\n";
|
||||
link_to_popup_window(help_preview_url($currentfile), 'popup', get_string('preview'));
|
||||
echo "</td>\n</tr>\n</table>";
|
||||
|
||||
if ($editable) {
|
||||
echo '<div align="center"><input type="submit" value="'.get_string('savechanges').': lang/'.$currentlang.'/'.$currentfile.'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
function langdoc_save_file($path, $file, $content) {
|
||||
|
||||
// $path is a full pathname to the file
|
||||
// $file is the file to overwrite.
|
||||
// $content are data to write
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
if (!$f = fopen("$path/$file","w")) {
|
||||
error_reporting($CFG->debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
$content = str_replace("\r", "",$content); // Remove linefeed characters
|
||||
$content = preg_replace("/\n{3,}/", "\n\n", $content); // Collapse runs of blank lines
|
||||
$content = trim($content); // Delete leading/trailing whitespace
|
||||
|
||||
fwrite($f, stripslashes($content));
|
||||
|
||||
fclose($f);
|
||||
|
||||
// Remove file if its empty
|
||||
|
||||
if (filesize("$path/$file") == 0) {
|
||||
unlink("$path/$file");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function help_preview_url($currentfile) {
|
||||
if (substr($currentfile, 0, 5) == 'help/') {
|
||||
$currentfile = substr($currentfile, 5);
|
||||
}
|
||||
$currentpathexp = explode('/', $currentfile);
|
||||
if (count($currentpathexp) > 1) {
|
||||
$url = '/help.php?module='.$currentpathexp[0].'&file='.$currentpathexp[1];
|
||||
} else {
|
||||
$url = '/help.php?module=moodle&file='.$currentfile;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
Executable
+424
@@ -0,0 +1,424 @@
|
||||
<?php //$Id$
|
||||
///This file only manages the installation of 1.6 lang packs.
|
||||
///in downloads.moodle.org, they are store in separate directory /lang16
|
||||
///in local server, they are stored in $CFG->dataroot/lang
|
||||
///This helps to avoid confusion.
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$mode = optional_param('mode', 0, PARAM_INT); //phase
|
||||
$pack = optional_param('pack', '', PARAM_FILE); //pack to install
|
||||
$displaylang = $pack;
|
||||
$uninstalllang = optional_param('uninstalllang', '', PARAM_FILE);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$sitelang = optional_param('sitelangconfig', '', PARAM_FILE);
|
||||
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('CHANGE_SITE_LANG', 3);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be an admin');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site not defined!");
|
||||
}
|
||||
|
||||
$strlang = get_string('langimport','admin');
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strlanguage = get_string("language");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$title = $strlang;
|
||||
|
||||
print_header("$site->shortname: $title", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"lang.php\">$strlanguage</a> -> $strlang",
|
||||
'', '', true, '');
|
||||
|
||||
print_heading('');
|
||||
|
||||
switch ($mode){
|
||||
|
||||
case INSTALLATION_OF_SELECTED_LANG: ///installation of selected language pack
|
||||
|
||||
if (confirm_sesskey()) {
|
||||
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
error(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
break;
|
||||
|
||||
case INSTALLED:
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack));
|
||||
break;
|
||||
|
||||
case UPTODATE:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
notify('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CHANGE_SITE_LANG: //change site language
|
||||
|
||||
if (confirm_sesskey()) {
|
||||
$langconfig = get_record('config','name','lang');
|
||||
$langconfig->value = $sitelang;
|
||||
if (!empty($sitelang) && update_record('config',$langconfig)){
|
||||
redirect('langimport.php', get_string('sitelangchanged','admin'));
|
||||
} else {
|
||||
error('Could not update the default site language!');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
|
||||
|
||||
if (!$confirm && confirm_sesskey()) {
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode=4&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
'langimport.php');
|
||||
} else if (confirm_sesskey()) {
|
||||
if ($uninstalllang == 'en_utf8') {
|
||||
error ('en_utf8 can not be uninstalled!');
|
||||
}
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$uninstalllang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$uninstalllang;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)){
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
//delete the direcotries
|
||||
if ($rm1 or $rm2) {
|
||||
redirect('langimport.php', get_string('langpackremoved','admin'));
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
error('An error has occurred, language pack is not completely uninstalled, please check file permissions');
|
||||
}
|
||||
}
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
break;
|
||||
|
||||
case UPDATE_ALL_LANG: //1 click update for all updatable language packs
|
||||
|
||||
//0th pull a list from download.moodle.org,
|
||||
//key = langname, value = md5
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$md5array = array();
|
||||
$updated = 0; //any packs updated?
|
||||
unset($CFG->langlist); // ignore admin's langlist
|
||||
$alllangs = array_keys(get_list_of_languages());
|
||||
$lang16 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
|
||||
$packs = array(); //all the packs that needs updating
|
||||
|
||||
|
||||
if (!$availablelangs = proxy_url($source)) {
|
||||
error ('can not read from course');
|
||||
}
|
||||
|
||||
//and build an associative array
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
//filtering out non-16 packs
|
||||
foreach ($alllangs as $clang) {
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||
|
||||
if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
|
||||
$lang16[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
//then filter out packs that have the same md5 key
|
||||
foreach ($lang16 as $clang) {
|
||||
if (!is_installed_lang($clang, $md5array[$clang])){
|
||||
$packs[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
@mkdir ($CFG->dataroot.'/temp/');
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
foreach ($packs as $pack){ //for each of the remaining in the list, we
|
||||
if ($pack == 'en_utf8') { // no update for en_utf8
|
||||
continue;
|
||||
}
|
||||
//1. delete old director(ies)
|
||||
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$pack;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)) {
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)) {
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
if (!($rm1 || $rm2)) {
|
||||
error ('could not delete old directory, update failed');
|
||||
}
|
||||
|
||||
//2. copy & unzip into new
|
||||
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
error(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
break;
|
||||
case UPTODATE:
|
||||
//Print error string or whatever you want to do
|
||||
break;
|
||||
case INSTALLED:
|
||||
notify(get_string('langpackupdated','admin',$pack), 'notifysuccess');
|
||||
$updated = true;
|
||||
//Print/do whatever you want
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php');
|
||||
} else {
|
||||
notice(get_string('nolangupdateneeded','admin'), 'langimport.php');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default: //display choice mode
|
||||
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$remote = 0; //flag for reading from remote or local
|
||||
|
||||
if ($availablelangs = proxy_url($source)) {
|
||||
$remote = 1;
|
||||
} else {
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
/*
|
||||
if ($fp = fopen($source, 'r')){ /// attempt to get the list from Moodle.org.
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
$remote = 1; //can read from download.moodle.org
|
||||
} else { /// fopen failed, we find local copy of list.
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
*/
|
||||
if (!$remote) {
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<div align="center">';
|
||||
print_string('remotelangnotavailable','admin',$CFG->dataroot.'/lang/');
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<table width="100%"><tr><td align="center">';
|
||||
echo get_string('installedlangs','admin');
|
||||
echo '</td><td align="center">';
|
||||
echo get_string('availablelangs','admin');
|
||||
echo '</td></tr>';
|
||||
echo '<tr><td align="center" valign="top">';
|
||||
echo '<form name="uninstallform" action="langimport.php?mode=4" method="POST">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
unset($CFG->langlist); // ignore admin's langlist
|
||||
$installedlangs = get_list_of_languages();
|
||||
|
||||
/// display installed langs here
|
||||
|
||||
echo '<select name="uninstalllang" size="15">';
|
||||
foreach ($installedlangs as $clang =>$ilang){
|
||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.get_string('uninstall','admin').'" />';
|
||||
echo '</form>';
|
||||
echo '<form name="updateform" action="langimport.php?mode=5" method="POST">';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</form>';
|
||||
echo '<p />';
|
||||
|
||||
/// Display option to change site language
|
||||
|
||||
print_string('changesitelang','admin');
|
||||
$sitelanguage = get_record('config','name','lang');
|
||||
echo '<form name="changelangform" action="langimport.php?mode=3" method="POST">';
|
||||
echo '<select name="sitelangconfig">';
|
||||
|
||||
foreach ($installedlangs as $clang =>$ilang) {
|
||||
if ($clang == $sitelanguage->value){
|
||||
echo '<option value="'.$clang.'" selected="selected">'.$ilang.'</option>';
|
||||
} else {
|
||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||
}
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="submit" value="'.get_string('change','admin').'" />';
|
||||
echo '</form>';
|
||||
|
||||
/// display to be installed langs here
|
||||
|
||||
echo '</td><td align="center" valign="top">';
|
||||
echo '<table><tr><td valign="top" align="center">'; //availabe langs table
|
||||
$empty = 1; //something to pring
|
||||
|
||||
/// if this language pack is not already installed, then we allow installation
|
||||
|
||||
echo '<form name="installform" method="POST" action="langimport.php?mode=2">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
if ($remote) {
|
||||
echo '<select name="pack" size="15">';
|
||||
}
|
||||
|
||||
foreach ($availablelangs as $alang) {
|
||||
if (trim($alang[0]) != "en_utf8") {
|
||||
if ($remote){
|
||||
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
|
||||
$shortlang = substr($alang[0], 0, -5);
|
||||
} else {
|
||||
$shortlang = $alang[0];
|
||||
}
|
||||
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
||||
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$shortlang.')</option>';
|
||||
}
|
||||
} else { //print list in local format, and instruction to install
|
||||
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang16/'.$alang[0].'.zip">'.get_string('download','admin').'</a>';
|
||||
}
|
||||
$empty = 0;
|
||||
}
|
||||
}
|
||||
if ($remote) {
|
||||
echo '</select>';
|
||||
echo '<br/ ><input type="submit" value="<-- '.get_string('install','admin').'">';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
if ($empty) {
|
||||
echo '<tr><td align="center">';
|
||||
print_string('nolanguagetodownload','admin');
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
echo '</td><tr></table>'; //close available langs table
|
||||
echo '<form>';
|
||||
echo '</td></tr></table>';
|
||||
print_simple_box_end();
|
||||
|
||||
break;
|
||||
|
||||
} //close of main switch
|
||||
|
||||
print_footer();
|
||||
|
||||
/* returns a list of available language packs from a
|
||||
* local copy shipped with standard moodle distro
|
||||
* this is for site that can't perform fopen
|
||||
* @return array
|
||||
*/
|
||||
function get_local_list_of_languages() {
|
||||
global $CFG;
|
||||
$source = $CFG->wwwroot.'/lib/languages.md5';
|
||||
$availablelangs = array();
|
||||
if ($fp = fopen($source, 'r')){
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
}
|
||||
|
||||
/* checks the md5 of the zip file, grabbed from download.moodle.org,
|
||||
* against the md5 of the local language file from last update
|
||||
* @param string $lang
|
||||
* @param string $md5check
|
||||
* @return bool
|
||||
*/
|
||||
function is_installed_lang($lang, $md5check) {
|
||||
global $CFG;
|
||||
$md5file = $CFG->dataroot.'/lang/'.$lang.'/'.$lang.'.md5';
|
||||
if (file_exists($md5file)){
|
||||
return (file_get_contents($md5file) == $md5check);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//returns an array of languages, or false if can not read from source
|
||||
//uses a socket if proxy is set as a config variable
|
||||
function proxy_url($url) {
|
||||
global $CFG;
|
||||
|
||||
if ($CFG->proxyhost && $CFG->proxyport) {
|
||||
|
||||
$proxy_fp = fsockopen($CFG->proxyhost, $CFG->proxyport);
|
||||
if (!$proxy_fp) {
|
||||
return false; //failed
|
||||
}
|
||||
fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
|
||||
$i = 0;
|
||||
while(!feof($proxy_fp)) {
|
||||
$string = fgets($proxy_fp, 1024);
|
||||
if ($i > 11) { //12 lines of info skipped
|
||||
$availablelangs[] = split(',', $string);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
fclose($proxy_fp);
|
||||
|
||||
} else { //proxy not in use
|
||||
if ($fp = fopen($url, 'r')){ /// attempt to get the list from Moodle.org.
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
} else { /// fopen failed, return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
}
|
||||
?>
|
||||
-124
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains functions used by the admin pages
|
||||
*
|
||||
* @since Moodle 2.1
|
||||
* @package admin
|
||||
* @copyright 2011 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Return a list of page types
|
||||
* @param string $pagetype current page type
|
||||
* @param stdClass $parentcontext Block's parent context
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
*/
|
||||
function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$array = array(
|
||||
'admin-*' => get_string('page-admin-x', 'pagetype'),
|
||||
$pagetype => get_string('page-admin-current', 'pagetype')
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* File serving.
|
||||
*
|
||||
* @param stdClass $course The course object.
|
||||
* @param stdClass $cm The cm object.
|
||||
* @param context $context The context object.
|
||||
* @param string $filearea The file area.
|
||||
* @param array $args List of arguments.
|
||||
* @param bool $forcedownload Whether or not to force the download of the file.
|
||||
* @param array $options Array of options.
|
||||
* @return void|false
|
||||
*/
|
||||
function core_admin_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
if (in_array($filearea, ['logo', 'logocompact'])) {
|
||||
$size = array_shift($args); // The path hides the size.
|
||||
$itemid = clean_param(array_shift($args), PARAM_INT);
|
||||
$filename = clean_param(array_shift($args), PARAM_FILE);
|
||||
$themerev = theme_get_revision();
|
||||
if ($themerev <= 0) {
|
||||
// Normalise to 0 as -1 doesn't place well with paths.
|
||||
$themerev = 0;
|
||||
}
|
||||
|
||||
// Extract the requested width and height.
|
||||
$maxwidth = 0;
|
||||
$maxheight = 0;
|
||||
if (preg_match('/^\d+x\d+$/', $size)) {
|
||||
list($maxwidth, $maxheight) = explode('x', $size);
|
||||
$maxwidth = clean_param($maxwidth, PARAM_INT);
|
||||
$maxheight = clean_param($maxheight, PARAM_INT);
|
||||
}
|
||||
|
||||
$lifetime = 0;
|
||||
if ($itemid > 0 && $themerev == $itemid) {
|
||||
// The itemid is $CFG->themerev, when 0 or less no caching. Also no caching when they don't match.
|
||||
$lifetime = DAYSECS * 60;
|
||||
}
|
||||
|
||||
// Anyone, including guests and non-logged in users, can view the logos.
|
||||
$options = ['cacheability' => 'public'];
|
||||
|
||||
// Check if we've got a cached file to return. When lifetime is 0 then we don't want to cached one.
|
||||
$candidate = $CFG->localcachedir . "/core_admin/$themerev/$filearea/{$maxwidth}x{$maxheight}/$filename";
|
||||
if (file_exists($candidate) && $lifetime > 0) {
|
||||
send_file($candidate, $filename, $lifetime, 0, false, false, '', false, $options);
|
||||
}
|
||||
|
||||
// Find the original file.
|
||||
$fs = get_file_storage();
|
||||
$filepath = "/{$context->id}/core_admin/{$filearea}/0/{$filename}";
|
||||
if (!$file = $fs->get_file_by_hash(sha1($filepath))) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
// No need for resizing, but if the file should be cached we save it so we can serve it fast next time.
|
||||
if (empty($maxwidth) && empty($maxheight)) {
|
||||
if ($lifetime) {
|
||||
file_safe_save_content($file->get_content(), $candidate);
|
||||
}
|
||||
send_stored_file($file, $lifetime, 0, false, $options);
|
||||
}
|
||||
|
||||
// Proceed with the resizing.
|
||||
$filedata = $file->resize_image($maxwidth, $maxheight);
|
||||
if (!$filedata) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
// If we don't want to cached the file, serve now and quit.
|
||||
if (!$lifetime) {
|
||||
send_content_uncached($filedata, $filename);
|
||||
}
|
||||
|
||||
// Save, serve and quit.
|
||||
file_safe_save_content($filedata, $candidate);
|
||||
send_file($candidate, $filename, $lifetime, 0, false, false, '', false, $options);
|
||||
}
|
||||
|
||||
send_file_not_found();
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows admin to configure licenses.
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/licenselib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$license = optional_param('license', '', PARAM_SAFEDIR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
$return = true;
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
license_manager::disable($license);
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
license_manager::enable($license);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides an overview of installed local plugins
|
||||
*
|
||||
* Displays the list of found local plugins, their version (if found) and
|
||||
* a link to delete the local plugin.
|
||||
*
|
||||
* @see http://docs.moodle.org/dev/Local_customisation
|
||||
* @package admin
|
||||
* @copyright 2010 David Mudrak <david.mudrak@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managelocalplugins');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
/// Print the table of all installed local plugins
|
||||
|
||||
$table = new flexible_table('localplugins_administration_table');
|
||||
$table->define_columns(array('name', 'version', 'uninstall'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('uninstallplugin', 'core_admin')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'localplugins');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $plugin);
|
||||
} else {
|
||||
$strpluginname = $plugin;
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
core_collator::asort($plugins);
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('local_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
|
||||
}
|
||||
|
||||
$version = get_config('local_' . $plugin);
|
||||
if (!empty($version->version)) {
|
||||
$version = $version->version;
|
||||
} else {
|
||||
$version = '?';
|
||||
}
|
||||
|
||||
$table->add_data(array($name, $version, $uninstall));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/*
|
||||
* Utility to debug mailouts - will save the content of emails to a
|
||||
* logfile instead of sending them out. Use it as a sendmail
|
||||
* "stand-in" when testing mailouts.
|
||||
*
|
||||
* It is not Moodle specific - use it anywhere by setting the php
|
||||
* "sendmail_path" setting to this file with a logfile parameter.
|
||||
*
|
||||
* - Set in php.ini (not settable in config.php):
|
||||
* sendmail_path=/path-to-moodle/admin/mailout-debugger.php');
|
||||
* Or from the commandline
|
||||
* php -d sendmail_path='/path-to-moodle/admin/mailout-debugger.php' /path/to/cron.php
|
||||
*
|
||||
* - Create a file in admin called mailout-debugger.enable
|
||||
* (this is a security check to prevent execution in prod environments)
|
||||
* touch /path/to/moodle/admin/mailout-debugger.enable
|
||||
*
|
||||
* - Mark as executable: chmod ugo+rx mailout-debugger.php
|
||||
*
|
||||
* - Run your admin/cron.php
|
||||
*
|
||||
* - Read /tmp/moodle-mailout.log
|
||||
*
|
||||
*
|
||||
* This script will create logfiles in /tmp/ or in $TMPDIR if set.
|
||||
* On windows, use php -r 'print sys_get_temp_dir()' to see where the file is saved.
|
||||
*/
|
||||
|
||||
// Security check.
|
||||
if (!file_exists(__DIR__.'/mailout-debugger.enable')) {
|
||||
mdie("Disabled.");
|
||||
}
|
||||
$tmpdir=sys_get_temp_dir(); // default
|
||||
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
mdie("should not be called from web server!");
|
||||
}
|
||||
|
||||
if (isset($_ENV['TMPDIR']) && is_dir($_ENV['TMPDIR'])) {
|
||||
$tmpdir = $_ENV['TMPDIR'];
|
||||
}
|
||||
|
||||
$tmpfile = $tmpdir . '/moodle-mailout.log';
|
||||
$fh = fopen($tmpfile, 'a+', false)
|
||||
or mdie("Error openning $tmpfile on append\n");
|
||||
fwrite($fh, "==== ".strftime("%a %b %e %H:%M:%S %Y", time())." ====\n");
|
||||
fwrite($fh, "==== Commandline: " . implode(' ',$argv) . "\n");
|
||||
|
||||
$stdin = fopen('php://stdin', 'r');
|
||||
|
||||
while ($line = fgets($stdin)) {
|
||||
fwrite($fh, $line);
|
||||
}
|
||||
fwrite($fh, "\n");
|
||||
fclose($fh);
|
||||
fclose($stdin);
|
||||
|
||||
/**
|
||||
* Print an error to STDOUT and exit with a non-zero code. For commandline scripts.
|
||||
* Default errorcode is 1.
|
||||
*
|
||||
* Very useful for perl-like error-handling:
|
||||
*
|
||||
* do_something() or mdie("Something went wrong");
|
||||
*
|
||||
* @param string $msg Error message
|
||||
* @param integer $errorcode Error code to emit
|
||||
*
|
||||
*/
|
||||
function mdie($msg='', $errorcode=1) {
|
||||
trigger_error($msg);
|
||||
exit($errorcode);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php // $Id$
|
||||
// Enables/disables maintenance mode
|
||||
|
||||
require('../config.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You need to be admin to use this page');
|
||||
}
|
||||
|
||||
//Check folder exists
|
||||
if (! make_upload_directory(SITEID)) { // Site folder
|
||||
error("Could not create site folder. The site administrator needs to fix the file permissions");
|
||||
}
|
||||
|
||||
$filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($form->action == "disable") {
|
||||
unlink($filename);
|
||||
redirect('index.php', get_string('sitemaintenanceoff','admin'));
|
||||
} else {
|
||||
$file = fopen($filename, 'w');
|
||||
fwrite($file, stripslashes($form->text));
|
||||
fclose($file);
|
||||
redirect('index.php', get_string('sitemaintenanceon', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the header stuff
|
||||
|
||||
$strmaintenance = get_string('sitemaintenancemode', 'admin');
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
|
||||
print_header("$SITE->shortname: $strmaintenance", $SITE->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmaintenance");
|
||||
|
||||
print_heading($strmaintenance);
|
||||
|
||||
/// Print the appropriate form
|
||||
|
||||
if (file_exists($filename)) { // We are in maintenance mode
|
||||
echo '<center>';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<input type="hidden" name="action" value="disable">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
|
||||
echo '<p><input type="submit" value="'.get_string('disable').'"></p>';
|
||||
echo '</form>';
|
||||
echo '</center>';
|
||||
} else { // We are not in maintenance mode
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
echo '<center>';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<input type="hidden" name="action" value="enable">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
|
||||
echo '<p><input type="submit" value="'.get_string('enable').'"></p>';
|
||||
echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
|
||||
echo '<table><tr><td>';
|
||||
print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
|
||||
echo '</td></tr></table>';
|
||||
echo '</form>';
|
||||
echo '</center>';
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
}
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Enrol config manipulation script.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage media
|
||||
* @copyright 2016 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$media = required_param('media', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/media.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_sesskey();
|
||||
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('media');
|
||||
$sortorder = array_values(\core\plugininfo\media::get_enabled_plugins());
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'managemediaplayers'));
|
||||
|
||||
if (!array_key_exists($media, $plugins)) {
|
||||
redirect($return);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
$plugins[$media]->set_enabled(false);
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
$plugins[$media]->set_enabled(true);
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (($pos = array_search($media, $sortorder)) > 0) {
|
||||
$tmp = $sortorder[$pos - 1];
|
||||
$sortorder[$pos - 1] = $sortorder[$pos];
|
||||
$sortorder[$pos] = $tmp;
|
||||
\core\plugininfo\media::set_enabled_plugins($sortorder);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
if ((($pos = array_search($media, $sortorder)) !== false) && ($pos < count($sortorder) - 1)) {
|
||||
$tmp = $sortorder[$pos + 1];
|
||||
$sortorder[$pos + 1] = $sortorder[$pos];
|
||||
$sortorder[$pos] = $tmp;
|
||||
\core\plugininfo\media::set_enabled_plugins($sortorder);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
redirect($return);
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Message outputs configuration page
|
||||
*
|
||||
* @package message
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// This is an admin page
|
||||
admin_externalpage_setup('managemessageoutputs');
|
||||
|
||||
// Require site configuration capability
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
|
||||
$headingtitle = get_string('managemessageoutputs', 'message');
|
||||
|
||||
if (!empty($disable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
\core_message\api::update_processor_status($processor, 0); // Disable output.
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if (!empty($enable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
\core_message\api::update_processor_status($processor, 1); // Enable output.
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if ($disable || $enable) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
// Page settings
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
|
||||
// Display the manage message outputs interface
|
||||
$processors = get_message_processors();
|
||||
$messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
|
||||
// Display the page
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strmisc = get_string("miscellaneous");
|
||||
|
||||
print_header("$site->shortname: $stradministration: $strmisc", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strmisc");
|
||||
|
||||
print_heading($strmisc);
|
||||
|
||||
$table->align = array ("right", "left");
|
||||
|
||||
$table->data[] = array('<b><a href="../files/index.php?id='.$site->id.'">'.get_string('sitefiles').'</a></b>',
|
||||
get_string("adminhelpsitefiles"));
|
||||
$table->data[] = array('<b><a href="stickyblocks.php">'.get_string('stickyblocks','admin')."</a></b>",
|
||||
get_string('adminhelpstickyblocks'));
|
||||
$table->data[] = array('<b><a href="report.php">'.get_string('reports')."</a></b>",
|
||||
get_string('adminhelpreports'));
|
||||
// to be enabled later
|
||||
/* $table->data[] = array('<b><a href="health.php">'.get_string('healthcenter')."</a></b>",
|
||||
get_string('adminhelphealthcenter'));*/
|
||||
$table->data[] = array('<b><a href="environment.php">'.get_string('environment', 'admin')."</a></b>",
|
||||
get_string('adminhelpenvironment'));
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
|
||||
$table->data[] = array('<b><a href="'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase')."</a></b>",
|
||||
get_string('adminhelpmanagedatabase'));
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Allows the admin to control user logins from remote moodles.
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
$sort = optional_param('sort', 'username', PARAM_ALPHA);
|
||||
$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$perpage = optional_param('perpage', 30, PARAM_INT);
|
||||
$action = trim(strtolower(optional_param('action', '', PARAM_ALPHA)));
|
||||
|
||||
require_login();
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
$sesskey = sesskey();
|
||||
$formerror = array();
|
||||
|
||||
// grab the mnet hosts and remove the localhost
|
||||
$mnethosts = $DB->get_records_menu('mnet_host', array(), 'name', 'id, name');
|
||||
if (array_key_exists($CFG->mnet_localhost_id, $mnethosts)) {
|
||||
unset($mnethosts[$CFG->mnet_localhost_id]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process actions
|
||||
if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
// boot if insufficient permission
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet');
|
||||
}
|
||||
|
||||
// fetch the record in question
|
||||
$id = required_param('id', PARAM_INT);
|
||||
if (!$idrec = $DB->get_record('mnet_sso_access_control', array('id'=>$id))) {
|
||||
print_error('recordnoexists','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case "delete":
|
||||
$DB->delete_records('mnet_sso_access_control', array('id'=>$id));
|
||||
redirect('access_control.php', get_string('deleteuserrecord', 'mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
break;
|
||||
|
||||
case "acl":
|
||||
|
||||
// require the access parameter, and it must be 'allow' or 'deny'
|
||||
$accessctrl = trim(strtolower(required_param('accessctrl', PARAM_ALPHA)));
|
||||
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
|
||||
print_error('invalidaccessparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
if ($accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
} else if ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
print_error('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process the form results
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
// check permissions and verify form input
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
if (empty($form->username)) {
|
||||
$formerror['username'] = get_string('enterausername','mnet');
|
||||
}
|
||||
if (empty($form->mnet_host_id)) {
|
||||
$formerror['mnet_host_id'] = get_string('selectahost','mnet');
|
||||
}
|
||||
if (empty($form->accessctrl)) {
|
||||
$formerror['accessctrl'] = get_string('selectaccesslevel','mnet'); ;
|
||||
}
|
||||
|
||||
// process if there are no errors
|
||||
if (count($formerror) == 0) {
|
||||
|
||||
// username can be a comma separated list
|
||||
$usernames = explode(',', $form->username);
|
||||
|
||||
foreach ($usernames as $username) {
|
||||
$username = trim(core_text::strtolower($username));
|
||||
if (!empty($username)) {
|
||||
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
|
||||
if ($form->accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user'=>$username, 'host'=>$mnethosts[$form->mnet_host_id])));
|
||||
} elseif ($form->accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$username, 'host'=>$mnethosts[$form->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Explain
|
||||
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
|
||||
// Are the needed bits enabled?
|
||||
$warn = '';
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
$warn = '<p>' . get_string('mnetdisabled','mnet') .'</p>';
|
||||
}
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
$warn .= '<p>' . get_string('authmnetdisabled','mnet').'</p>';
|
||||
}
|
||||
|
||||
if (!empty($warn)) {
|
||||
$warn = '<p>' . get_string('ssoaclneeds','mnet').'</p>' . $warn;
|
||||
echo $OUTPUT->box($warn);
|
||||
}
|
||||
// output the ACL table
|
||||
$columns = array("username", "mnet_host_id", "access", "delete");
|
||||
$headings = array();
|
||||
$string = array('username' => get_string('username'),
|
||||
'mnet_host_id' => get_string('remotehost', 'mnet'),
|
||||
'access' => get_string('accesslevel', 'mnet'),
|
||||
'delete' => get_string('delete'));
|
||||
foreach ($columns as $column) {
|
||||
if ($sort != $column) {
|
||||
$columnicon = "";
|
||||
$columndir = "ASC";
|
||||
} else {
|
||||
$columndir = $dir == "ASC" ? "DESC" : "ASC";
|
||||
$columnicon = $dir == "ASC" ? "down" : "up";
|
||||
$columnicon = " " . $OUTPUT->pix_icon('t/' . $columnicon, get_string('sort'));
|
||||
}
|
||||
$headings[$column] = "<a href=\"?sort=$column&dir=$columndir&\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
$headings['delete'] = '';
|
||||
$acl = $DB->get_records('mnet_sso_access_control', null, "$sort $dir", '*'); //, $page * $perpage, $perpage);
|
||||
$aclcount = $DB->count_records('mnet_sso_access_control');
|
||||
|
||||
if (!$acl) {
|
||||
echo $OUTPUT->heading(get_string('noaclentries','mnet'));
|
||||
$table = NULL;
|
||||
} else {
|
||||
$table = new html_table();
|
||||
$table->head = $headings;
|
||||
$table->align = array('left', 'left', 'center');
|
||||
$table->width = "95%";
|
||||
foreach ($acl as $aclrecord) {
|
||||
if ($aclrecord->accessctrl == 'allow') {
|
||||
$accesscolumn = get_string('allow', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=deny&sesskey=".sesskey()."\">"
|
||||
. get_string('deny', 'mnet') . "</a>)";
|
||||
} else {
|
||||
$accesscolumn = get_string('deny', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=allow&sesskey=".sesskey()."\">"
|
||||
. get_string('allow', 'mnet') . "</a>)";
|
||||
}
|
||||
$deletecolumn = "<a href=\"?id={$aclrecord->id}&action=delete&sesskey=".sesskey()."\">"
|
||||
. get_string('delete') . "</a>";
|
||||
$table->data[] = array (s($aclrecord->username), $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($table)) {
|
||||
echo html_writer::table($table);
|
||||
echo '<p> </p>';
|
||||
$baseurl = new moodle_url('/admin/mnet/access_control.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
|
||||
echo $OUTPUT->paging_bar($aclcount, $page, $perpage, $baseurl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// output the add form
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
?>
|
||||
<div class="mnetaddtoaclform">
|
||||
<form id="mnetaddtoacl" method="post">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $sesskey; ?>" />
|
||||
<?php
|
||||
|
||||
// enter a username
|
||||
echo get_string('username') . ":\n";
|
||||
if (!empty($formerror['username'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo html_writer::label(get_string('username'), 'menuusername', false, array('class' => 'accesshide'));
|
||||
echo '<input id="menuusername" type="text" name="username" size="20" maxlength="100" />';
|
||||
|
||||
// choose a remote host
|
||||
echo " " . html_writer::label(get_string('remotehost', 'mnet'), 'menumnet_host_id') . ":\n";
|
||||
if (!empty($formerror['mnet_host_id'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo html_writer::select($mnethosts, 'mnet_host_id');
|
||||
|
||||
// choose an access level
|
||||
echo " " . html_writer::label(get_string('accesslevel', 'mnet'), 'menuaccessctrl') . ":\n";
|
||||
if (!empty($formerror['accessctrl'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
$accessmenu['allow'] = get_string('allow', 'mnet');
|
||||
$accessmenu['deny'] = get_string('deny', 'mnet');
|
||||
echo html_writer::select($accessmenu, 'accessctrl');
|
||||
|
||||
// submit button
|
||||
echo '<input type="submit" value="' . get_string('addtoacl', 'mnet') . '" />';
|
||||
echo "</form></div>\n";
|
||||
|
||||
// print errors
|
||||
foreach ($formerror as $error) {
|
||||
echo "<br><span class=\"error\">$error<span>";
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Page to allow the administrator to delete networked hosts, with a confirm message
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2007 Donal McMullan
|
||||
* @copyright 2007 Martin Langhoff
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$step = optional_param('step', 'verify', PARAM_ALPHA);
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
|
||||
require_login();
|
||||
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
$PAGE->set_url('/admin/mnet/delete.php');
|
||||
admin_externalpage_setup('mnetpeer' . $hostid);
|
||||
|
||||
require_sesskey();
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
if ('verify' == $step) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
|
||||
if ($live_users = $mnet_peer->count_live_sessions() > 0) {
|
||||
echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
|
||||
}
|
||||
$yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
|
||||
$nourl = new moodle_url('/admin/mnet/peers.php');
|
||||
echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet') . ': ' . $mnet_peer->name, $yesurl, $nourl);
|
||||
echo $OUTPUT->footer();
|
||||
} elseif ('delete' == $step) {
|
||||
$mnet_peer->delete();
|
||||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Allows the admin to configure mnet stuff
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('net');
|
||||
|
||||
$context = context_system::instance();
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$site = get_site();
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo $OUTPUT->header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
echo $OUTPUT->header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nocurl', 'mnet');
|
||||
}
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
}
|
||||
|
||||
/// If data submitted, process and store
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
if (!empty($form->submit) && $form->submit == get_string('savechanges')) {
|
||||
if (in_array($form->mode, array("off", "strict", "dangerous"))) {
|
||||
if (set_config('mnet_dispatcher_mode', $form->mode)) {
|
||||
redirect('index.php', get_string('changessaved'));
|
||||
} else {
|
||||
print_error('invalidaction', '', 'index.php');
|
||||
}
|
||||
}
|
||||
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
|
||||
$mnet->get_private_key();
|
||||
$SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])).':'.time();
|
||||
|
||||
$formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url('index.php', array()), get_string('no'));
|
||||
echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel);
|
||||
exit;
|
||||
} else {
|
||||
// We're deleting
|
||||
|
||||
|
||||
if (!isset($SESSION->mnet_confirm_delete_key)) {
|
||||
// fail - you're being attacked?
|
||||
}
|
||||
|
||||
$key = '';
|
||||
$time = '';
|
||||
@list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
|
||||
$mnet->get_private_key();
|
||||
|
||||
if($time < time() - 60) {
|
||||
// fail - you're out of time.
|
||||
print_error ('deleteoutoftime', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) {
|
||||
// fail - you're being attacked?
|
||||
print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$mnet->replace_keys();
|
||||
redirect('index.php', get_string('keydeleted','mnet'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('publickey', 'mnet'); ?>:</td>
|
||||
<td><pre><?php echo $mnet->public_key; ?></pre></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('expires', 'mnet'); ?>:</td>
|
||||
<td><?php echo userdate($mnet->public_key_expires); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
<td align="left"><input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<input type="hidden" name="deleteKey" value="" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,191 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains two forms for adding/editing mnet hosts, used by peers.php
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
/**
|
||||
* The very basic first step add new host form - just wwwroot & application
|
||||
* The second form is loaded up with the information from this one.
|
||||
*/
|
||||
class mnet_simple_host_form extends moodleform {
|
||||
function definition() {
|
||||
global $DB;
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
$mform->addRule('wwwroot', null, 'required', null, 'client');
|
||||
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'),
|
||||
$DB->get_records_menu('mnet_application', array(), 'id,display_name'));
|
||||
$mform->addRule('applicationid', null, 'required', null, 'client');
|
||||
|
||||
$this->add_action_buttons(false, get_string('addhost', 'mnet'));
|
||||
}
|
||||
|
||||
function validation($data, $files) {
|
||||
global $DB;
|
||||
|
||||
$wwwroot = $data['wwwroot'];
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($wwwroot, 0, 4)) != 'http') {
|
||||
$wwwroot = 'http://'.$wwwroot;
|
||||
}
|
||||
if ($host = $DB->get_record('mnet_host', array('wwwroot' => $wwwroot))) {
|
||||
global $CFG;
|
||||
return array('wwwroot' => get_string('hostexists', 'mnet',
|
||||
new moodle_url('/admin/mnet/peers.php', array('hostid' => $host->id))));
|
||||
}
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The second step of the form - reviewing the host details
|
||||
* This is also the same form that is used for editing an existing host
|
||||
*/
|
||||
class mnet_review_host_form extends moodleform {
|
||||
function definition() {
|
||||
global $OUTPUT;
|
||||
|
||||
$mform = $this->_form;
|
||||
$mnet_peer = $this->_customdata['peer'];
|
||||
|
||||
$mform->addElement('hidden', 'last_connect_time');
|
||||
$mform->setType('last_connect_time', PARAM_INT);
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('hidden', 'applicationid');
|
||||
$mform->setType('applicationid', PARAM_INT);
|
||||
$mform->addElement('hidden', 'oldpublickey');
|
||||
$mform->setType('oldpublickey', PARAM_PEM);
|
||||
|
||||
$mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
|
||||
$mform->setType('name', PARAM_NOTAGS);
|
||||
$mform->addRule('name', get_string('maximumchars', '', 80), 'maxlength', 80, 'client');
|
||||
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$options = array(
|
||||
mnet_peer::SSL_NONE => get_string('none'),
|
||||
mnet_peer::SSL_HOST => get_string('verifyhostonly', 'core_mnet'),
|
||||
mnet_peer::SSL_HOST_AND_PEER => get_string('verifyhostandpeer', 'core_mnet')
|
||||
);
|
||||
$mform->addElement('select', 'sslverification', get_string('sslverification', 'core_mnet'), $options);
|
||||
$mform->setDefault('sslverification', mnet_peer::SSL_HOST_AND_PEER);
|
||||
$mform->addHelpButton('sslverification', 'sslverification', 'core_mnet');
|
||||
|
||||
$themes = array('' => get_string('forceno'));
|
||||
foreach (array_keys(core_component::get_plugin_list('theme')) as $themename) {
|
||||
$themes[$themename] = get_string('pluginname', 'theme_'.$themename);
|
||||
}
|
||||
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
|
||||
|
||||
$mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
|
||||
$mform->setType('public_key', PARAM_PEM);
|
||||
$mform->addRule('public_key', get_string('required'), 'required');
|
||||
|
||||
// finished with form controls, now the static informational stuff
|
||||
if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
|
||||
$expires = '';
|
||||
if ($mnet_peer->public_key_expires < time()) {
|
||||
$expires = get_string('expired', 'mnet') . ' ';
|
||||
}
|
||||
$expires .= userdate($mnet_peer->public_key_expires);
|
||||
$mform->addElement('static', 'validuntil', get_string('expires', 'mnet'), $expires);
|
||||
|
||||
$lastconnect = '';
|
||||
if ($mnet_peer->last_connect_time == 0) {
|
||||
$lastconnect = get_string('never', 'mnet');
|
||||
} else {
|
||||
$lastconnect = date('H:i:s d/m/Y',$mnet_peer->last_connect_time);
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'lastconnect', get_string('last_connect_time', 'mnet'), $lastconnect);
|
||||
$mform->addElement('static', 'ipaddress', get_string('ipaddress', 'mnet'), $mnet_peer->ip_address);
|
||||
|
||||
if (isset($mnet_peer->currentkey)) { // key being published is not the same as our records
|
||||
$currentkeystr = '<b>' . get_string('keymismatch', 'mnet') . '</b><br /><br /> ' . $OUTPUT->box('<pre>' . $mnet_peer->currentkey . '</pre>');
|
||||
$mform->addElement('static', 'keymismatch', get_string('currentkey', 'mnet'), $currentkeystr);
|
||||
}
|
||||
|
||||
$credstr = '';
|
||||
if ($credentials = $mnet_peer->check_credentials($mnet_peer->public_key)) {
|
||||
foreach($credentials['subject'] as $key => $credential) {
|
||||
if (is_scalar($credential)) {
|
||||
$credstr .= str_pad($key, 16, " ", STR_PAD_LEFT).': '.$credential."\n";
|
||||
} else {
|
||||
$credstr .= str_pad($key, 16, " ", STR_PAD_LEFT).': '.var_export($credential,1)."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'),
|
||||
$OUTPUT->box('<pre>' . $credstr . '</pre>', 'generalbox certdetails'));
|
||||
}
|
||||
|
||||
if ($mnet_peer && !empty($mnet_peer->deleted)) {
|
||||
$radioarray = array();
|
||||
$radioarray[] = $mform->createElement('static', 'deletedinfo', '',
|
||||
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
|
||||
$radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('yes'), 1);
|
||||
$radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('no'), 0);
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
$mform->setType('deleted', PARAM_BOOL);
|
||||
}
|
||||
|
||||
// finished with static stuff, print save button
|
||||
$this->add_action_buttons(false);
|
||||
}
|
||||
|
||||
function validation($data, $files) {
|
||||
$errors = array();
|
||||
if ($data['oldpublickey'] == $data['public_key']) {
|
||||
return;
|
||||
}
|
||||
$mnet_peer = new mnet_peer(); // idiotic api
|
||||
$mnet_peer->wwwroot = $data['wwwroot']; // just hard-set this rather than bootstrap the object
|
||||
if (empty($data['public_key'])) {
|
||||
$errors['public_key'] = get_string('publickeyrequired', 'mnet');
|
||||
} else if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
|
||||
$errmsg = '';
|
||||
foreach ($mnet_peer->error as $err) {
|
||||
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
|
||||
}
|
||||
$errors['public_key'] = get_string('invalidpubkey', 'mnet', $errmsg);
|
||||
}
|
||||
unset($mnet_peer);
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Page to allow the administrator to configure networked hosts, and add new ones
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2007 Donal McMullan
|
||||
* @copyright 2007 Martin Langhoff
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/mnet/lib.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/mnet/peer_forms.php');
|
||||
|
||||
require_login();
|
||||
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
|
||||
/// Initialize variables.
|
||||
$hostid = optional_param('hostid', 0, PARAM_INT);
|
||||
$updra = optional_param('updateregisterall', 0, PARAM_INT);
|
||||
|
||||
// first process the register all hosts setting if required
|
||||
if (!empty($updra)) {
|
||||
set_config('mnet_register_allhosts', optional_param('registerallhosts', 0, PARAM_INT));
|
||||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
|
||||
}
|
||||
|
||||
$adminsection = 'mnetpeers';
|
||||
if ($hostid && $DB->get_field('mnet_host', 'deleted', array('id' => $hostid)) != 1) {
|
||||
$adminsection = 'mnetpeer' . $hostid;
|
||||
}
|
||||
|
||||
$PAGE->set_url('/admin/mnet/peers.php');
|
||||
admin_externalpage_setup($adminsection);
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
print_error('nocurl', 'mnet');
|
||||
}
|
||||
|
||||
if (!function_exists('xmlrpc_encode_request')) {
|
||||
print_error('xmlrpc-missing', 'mnet');
|
||||
}
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
}
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
$simpleform = new mnet_simple_host_form(); // the one that goes on the bottom of the main page
|
||||
$reviewform = null; // set up later in different code branches, so mnet_peer can be passed to the constructor
|
||||
|
||||
// if the first form has been submitted, bootstrap the peer and load up the review form
|
||||
if ($formdata = $simpleform->get_data()) {
|
||||
// ensure we remove trailing slashes
|
||||
$formdata->wwwroot = trim($formdata->wwwroot);
|
||||
$formdata->wwwroot = rtrim($formdata->wwwroot, '/');
|
||||
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($formdata->wwwroot, 0, 4)) != 'http') {
|
||||
$formdata->wwwroot = 'http://'.$formdata->wwwroot;
|
||||
}
|
||||
|
||||
$mnet_peer->set_applicationid($formdata->applicationid);
|
||||
$application = $DB->get_field('mnet_application', 'name', array('id'=>$formdata->applicationid));
|
||||
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
|
||||
// bootstrap the second form straight with the data from the first form
|
||||
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
|
||||
$formdata->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
|
||||
$reviewform->set_data($mnet_peer);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box_start();
|
||||
$reviewform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
} else if ($simpleform->is_submitted()) { // validation failed
|
||||
$noreviewform = true;
|
||||
}
|
||||
|
||||
// editing a host - load up the review form
|
||||
if (!empty($hostid)) {
|
||||
// TODO print a nice little heading
|
||||
$mnet_peer->set_id($hostid);
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'mnetdetails';
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/mnet/tabs.php');
|
||||
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
$mnet_peer->currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
|
||||
if ($mnet_peer->currentkey == $mnet_peer->public_key) {
|
||||
unset($mnet_peer->currentkey);
|
||||
} else {
|
||||
error_log($mnet_peer->currentkey);
|
||||
error_log($mnet_peer->public_key);
|
||||
error_log(md5($mnet_peer->currentkey));
|
||||
error_log(md5($mnet_peer->public_key));
|
||||
}
|
||||
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
|
||||
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
|
||||
$mnet_peer->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
|
||||
$reviewform->set_data((object)$mnet_peer);
|
||||
echo $OUTPUT->box_start();
|
||||
$reviewform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
} else {
|
||||
// no options for allhosts host - just let the tabs display and print a notification
|
||||
echo $OUTPUT->notification(get_string('allhosts_no_options', 'mnet'));
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// either we're in the second step of setting up a new host
|
||||
// or editing an existing host
|
||||
// try our best to set up the mnet_peer object to pass to the form definition
|
||||
// unless validation on simpleform failed, in which case fall through.
|
||||
if (empty($noreviewform) && $id = optional_param('id', 0, PARAM_INT)) {
|
||||
// we're editing an existing one, so set up the tabs
|
||||
$currenttab = 'mnetdetails';
|
||||
$mnet_peer->set_id($id);
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/mnet/tabs.php');
|
||||
} else if (empty($noreviewform) && ($wwwroot = optional_param('wwwroot', '', PARAM_URL)) && ($applicationid = optional_param('applicationid', 0, PARAM_INT))) {
|
||||
$application = $DB->get_field('mnet_application', 'name', array('id'=>$applicationid));
|
||||
$mnet_peer->bootstrap($wwwroot, null, $application);
|
||||
}
|
||||
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer));
|
||||
if ($formdata = $reviewform->get_data()) {
|
||||
|
||||
$mnet_peer->set_applicationid($formdata->applicationid);
|
||||
$application = $DB->get_field('mnet_application', 'name', array('id'=>$formdata->applicationid));
|
||||
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
|
||||
|
||||
if (!empty($formdata->name) && $formdata->name != $mnet_peer->name) {
|
||||
$mnet_peer->set_name($formdata->name);
|
||||
}
|
||||
|
||||
if (empty($formdata->theme)) {
|
||||
$mnet_peer->force_theme = 0;
|
||||
$mnet_peer->theme = null;
|
||||
} else {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = $formdata->theme;
|
||||
}
|
||||
|
||||
$mnet_peer->deleted = $formdata->deleted;
|
||||
$mnet_peer->public_key = $formdata->public_key;
|
||||
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
|
||||
$mnet_peer->public_key_expires = $credentials['validTo_time_t'];
|
||||
$mnet_peer->sslverification = $formdata->sslverification;
|
||||
|
||||
if ($mnet_peer->commit()) {
|
||||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $mnet_peer->id)), get_string('changessaved'));
|
||||
} else {
|
||||
print_error('invalidaction', 'error', 'index.php');
|
||||
}
|
||||
} else if ($reviewform->is_submitted()) { // submitted, but errors
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box_start();
|
||||
$reviewform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// normal flow - just display all hosts with links
|
||||
echo $OUTPUT->header();
|
||||
$hosts = mnet_get_hosts(true);
|
||||
|
||||
// print the table to display the register all hosts setting
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('registerallhosts', 'mnet'));
|
||||
|
||||
$registerrow = '';
|
||||
$registerstr = '';
|
||||
$registerurl = new moodle_url('/admin/mnet/peers.php', array('updateregisterall' => 1));
|
||||
if (!empty($CFG->mnet_register_allhosts)) {
|
||||
$registerrow = get_string('registerhostson', 'mnet');
|
||||
$registerurl->param('registerallhosts', 0);
|
||||
$registerstr = get_string('turnitoff', 'mnet');
|
||||
} else {
|
||||
$registerrow = get_string('registerhostsoff', 'mnet');
|
||||
$registerurl->param('registerallhosts', 1);
|
||||
$registerstr = get_string('turniton', 'mnet');
|
||||
}
|
||||
$registerrow .= $OUTPUT->single_button($registerurl, $registerstr);
|
||||
|
||||
// simple table with two rows of a single cell
|
||||
$table->data = array(
|
||||
array(
|
||||
get_string('registerallhostsexplain', 'mnet'),
|
||||
),
|
||||
array(
|
||||
$registerrow
|
||||
),
|
||||
);
|
||||
echo html_writer::table($table);
|
||||
|
||||
// print the list of all hosts, with little action links and buttons
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('site'),
|
||||
get_string('system', 'mnet'),
|
||||
get_string('last_connect_time', 'mnet'),
|
||||
'',
|
||||
);
|
||||
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
|
||||
$baseurl = new moodle_url('/admin/mnet/peers.php');
|
||||
$deleted = array();
|
||||
foreach($hosts as $host) {
|
||||
$hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
|
||||
if (trim($host->name) === '') {
|
||||
// should not happen but...
|
||||
$host->name = '???';
|
||||
}
|
||||
// process all hosts first since it's the easiest
|
||||
if ($host->id == $CFG->mnet_all_hosts_id) {
|
||||
$table->data[] = array(html_writer::link($hosturl, get_string('allhosts', 'core_mnet')), '*', '', '');
|
||||
continue;
|
||||
}
|
||||
|
||||
// populate the list of deleted hosts
|
||||
if ($host->deleted) {
|
||||
$deleted[] = html_writer::link($hosturl, $host->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($host->last_connect_time == 0) {
|
||||
$last_connect = get_string('never');
|
||||
} else {
|
||||
$last_connect = userdate($host->last_connect_time, get_string('strftimedatetime', 'core_langconfig'));
|
||||
}
|
||||
$table->data[] = array(
|
||||
html_writer::link($hosturl, $host->name),
|
||||
html_writer::link($host->wwwroot, $host->wwwroot),
|
||||
$last_connect,
|
||||
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
|
||||
);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
if ($deleted) {
|
||||
echo $OUTPUT->box(get_string('deletedhosts', 'core_mnet', join(', ', $deleted)), 'deletedhosts');
|
||||
}
|
||||
|
||||
// finally, print the initial form to add a new host
|
||||
echo $OUTPUT->box_start();
|
||||
echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
|
||||
$simpleform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// done
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to configure a list of profile fields that are sent/recieved
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 onwards Penny Leach <penny@liip.ch>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin .'/mnet/profilefields_form.php');
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
require_login();
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
$context = context_system::instance();
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
$form = new mnet_profile_form(null, array('hostid' => $hostid));
|
||||
|
||||
if ($data = $form->get_data()) {
|
||||
if (!isset($data->importdefault)) {
|
||||
$data->importdefault = 0;
|
||||
}
|
||||
if (!isset($data->exportdefault)) {
|
||||
$data->exportdefault = 0;
|
||||
}
|
||||
if (!isset($data->importfields)) {
|
||||
$data->importfields = array();
|
||||
}
|
||||
if (!isset($data->exportfields)) {
|
||||
$data->exportfields = array();
|
||||
}
|
||||
set_config('host' . $hostid . 'importdefault', $data->importdefault, 'mnet');
|
||||
set_config('host' . $hostid . 'importfields', implode(',', $data->importfields), 'mnet');
|
||||
set_config('host' . $hostid . 'exportdefault', $data->exportdefault, 'mnet');
|
||||
set_config('host' . $hostid . 'exportfields', implode(',', $data->exportfields), 'mnet');
|
||||
|
||||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
|
||||
} elseif ($form->is_cancelled()) {
|
||||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $hostid)));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'mnetprofilefields';
|
||||
require_once('tabs.php');
|
||||
|
||||
echo $OUTPUT->heading(get_string('peerprofilefielddesc', 'mnet'), 4);
|
||||
|
||||
$data = new Stdclass;
|
||||
$data->importdefault = get_config('mnet', 'host' . $hostid . 'importdefault');
|
||||
$data->exportdefault = get_config('mnet', 'host' . $hostid . 'exportdefault');
|
||||
$data->importfields = get_config('mnet', 'host' . $hostid . 'importfields');
|
||||
$data->exportfields = get_config('mnet', 'host' . $hostid . 'exportfields');
|
||||
|
||||
if ($data->importfields === false) {
|
||||
$data->importdefault = true;
|
||||
} else {
|
||||
$data->importfields = explode(',', $data->importfields);
|
||||
}
|
||||
if ($data->exportfields === false) {
|
||||
$data->exportdefault = true;
|
||||
} else {
|
||||
$data->exportfields = explode(',', $data->exportfields);
|
||||
}
|
||||
|
||||
$form->set_data($data);
|
||||
$form->display();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to configure a list of profile fields that are sent/recieved
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 onwards Penny Leach <penny@liip.ch>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
/**
|
||||
* small form to allow the administrator to configure (override) which profile fields are sent/imported over mnet
|
||||
*/
|
||||
class mnet_profile_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mnetprofileimportfields = '';
|
||||
if (isset($CFG->mnetprofileimportfields)) {
|
||||
$mnetprofileimportfields = str_replace(',', ', ', $CFG->mnetprofileimportfields);
|
||||
}
|
||||
|
||||
$mnetprofileexportfields = '';
|
||||
if (isset($CFG->mnetprofileexportfields)) {
|
||||
$mnetprofileexportfields = str_replace(',', ', ', $CFG->mnetprofileexportfields);
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$fields = mnet_profile_field_options();
|
||||
|
||||
// Fields to import ----------------------------------------------------
|
||||
$mform->addElement('header', 'import', get_string('importfields', 'mnet'));
|
||||
|
||||
$select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), $mnetprofileimportfields);
|
||||
|
||||
// Fields to export ----------------------------------------------------
|
||||
$mform->addElement('header', 'export', get_string('exportfields', 'mnet'));
|
||||
|
||||
$select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), $mnetprofileexportfields);
|
||||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* This page is for configuring which services are published/subscribed on a host
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/mnet/services_form.php');
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
$mform = new mnet_services_form(null, array('peer' => $mnet_peer));
|
||||
if ($formdata = $mform->get_data()) {
|
||||
if (!isset($formdata->publish)) {
|
||||
$formdata->publish = array();
|
||||
}
|
||||
if (!isset($formdata->subscribe)) {
|
||||
$formdata->subscribe = array();
|
||||
}
|
||||
foreach($formdata->exists as $key => $value) {
|
||||
$host2service = $DB->get_record('mnet_host2service', array('hostid'=>$hostid, 'serviceid'=>$key));
|
||||
$publish = (array_key_exists($key, $formdata->publish)) ? $formdata->publish[$key] : 0;
|
||||
$subscribe = (array_key_exists($key, $formdata->subscribe)) ? $formdata->subscribe[$key] : 0;
|
||||
|
||||
if ($publish != 1 && $subscribe != 1) {
|
||||
if (false == $host2service) {
|
||||
// We don't have or need a record - do nothing!
|
||||
} else {
|
||||
// We don't need the record - delete it
|
||||
$DB->delete_records('mnet_host2service', array('hostid' => $hostid, 'serviceid'=>$key));
|
||||
}
|
||||
} elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) {
|
||||
$host2service = new stdClass();
|
||||
$host2service->hostid = $hostid;
|
||||
$host2service->serviceid = $key;
|
||||
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
|
||||
$host2service->id = $DB->insert_record('mnet_host2service', $host2service);
|
||||
} elseif ($host2service->publish != $publish || $host2service->subscribe != $subscribe) {
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
$DB->update_record('mnet_host2service', $host2service);
|
||||
}
|
||||
}
|
||||
$redirecturl = new moodle_url('/admin/mnet/services.php?hostid=' . $hostid);
|
||||
redirect($redirecturl, get_string('changessaved'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'mnetservices';
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/mnet/tabs.php');
|
||||
echo $OUTPUT->box_start();
|
||||
$s = mnet_get_service_info($mnet_peer, false); // basic data only
|
||||
$mform->set_data($s);
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* The form for configuring which services are subscribed and published on a host
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
class mnet_services_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$mnet_peer =& $this->_customdata['peer'];
|
||||
$myservices = mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$count = 0;
|
||||
foreach ($myservices as $name => $versions) {
|
||||
$version = current($versions);
|
||||
$langmodule =
|
||||
($version['plugintype'] == 'mod'
|
||||
? ''
|
||||
: ($version['plugintype'] . '_'))
|
||||
. $version['pluginname']; // TODO there should be a moodle-wide way to do this
|
||||
|
||||
if ($count > 0) {
|
||||
$mform->addElement('html', '<hr />');
|
||||
}
|
||||
$mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
|
||||
|
||||
$mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
|
||||
// Temporary fix until MDL-38885 gets integrated.
|
||||
$mform->setType('exists', PARAM_BOOL);
|
||||
|
||||
$pubstr = get_string('publish','mnet');
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
$pubstr .= ' <a class="notifysuccess" title="'.s(get_string('issubscribed','mnet', $mnet_peer->name)).'">√</a> ';
|
||||
}
|
||||
$mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
|
||||
|
||||
$substr = get_string('subscribe','mnet');
|
||||
if (!empty($version['hostpublishes'])) {
|
||||
$substr .= ' <a class="notifysuccess" title="'.s(get_string('ispublished','mnet', $mnet_peer->name)).'">√</a> ';
|
||||
}
|
||||
$mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid']. ']', $substr);
|
||||
$count++;
|
||||
}
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Tabs to be included on the pages for configuring a single host
|
||||
* $mnet_peer object must be set and bootstrapped
|
||||
* $currenttab string must be set
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2007 Donal McMullan
|
||||
* @copyright 2007 Martin Langhoff
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
|
||||
$tabs = array();
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'services.php?hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetprofilefields', 'profilefields.php?hostid=' . $mnet_peer->id, get_string('profilefields', 'mnet'), get_string('profilefields', 'mnet'), false);
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
}
|
||||
print_tabs(array($tabs), $currenttab);
|
||||
@@ -1,231 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A service browser for remote Moodles
|
||||
*
|
||||
* This script 'remotely' executes the reflection methods on a remote Moodle,
|
||||
* and publishes the details of the available services
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @author Donal McMullan donal@catalyst.net.nz
|
||||
* @version 0.0.1
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package mnet
|
||||
*/
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
if ($CFG->mnet_dispatcher_mode === 'off') {
|
||||
print_error('mnetdisabled', 'mnet');
|
||||
}
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnettestclient');
|
||||
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
error_reporting(DEBUG_ALL);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
// optional drilling down parameters
|
||||
$hostid = optional_param('hostid', 0, PARAM_INT);
|
||||
$servicename = optional_param('servicename', '', PARAM_SAFEDIR);
|
||||
$methodid = optional_param('method', 0, PARAM_INT);
|
||||
|
||||
$hosts = $DB->get_records('mnet_host');
|
||||
$moodleapplicationid = $DB->get_field('mnet_application', 'id', array('name' => 'moodle'));
|
||||
|
||||
$url = new moodle_url('/admin/mnet/testclient.php');
|
||||
$PAGE->set_url($url);
|
||||
|
||||
echo $OUTPUT->heading(get_string('hostlist', 'mnet'));
|
||||
foreach ($hosts as $id => $host) {
|
||||
if (empty($host->wwwroot) || $host->wwwroot == $CFG->wwwroot) {
|
||||
continue;
|
||||
}
|
||||
$newurl = new moodle_url($url, array('hostid' => $host->id));
|
||||
echo '<p>' . html_writer::link($newurl, $host->wwwroot) . '</p>';
|
||||
}
|
||||
|
||||
if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
|
||||
$host = $hosts[$hostid];
|
||||
if ($host->applicationid != $moodleapplicationid) {
|
||||
echo $OUTPUT->notification(get_string('notmoodleapplication', 'mnet'));
|
||||
}
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_wwwroot($host->wwwroot);
|
||||
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
$mnet_request->set_method('system/listServices');
|
||||
$mnet_request->send($mnet_peer);
|
||||
|
||||
$services = $mnet_request->response;
|
||||
$yesno = array('No', 'Yes');
|
||||
$servicenames = array();
|
||||
|
||||
echo $OUTPUT->heading(get_string('servicesavailableonhost', 'mnet', $host->wwwroot));
|
||||
|
||||
if (!empty($mnet_request->error)) {
|
||||
echo $OUTPUT->heading(get_string('error'), 3);
|
||||
echo html_writer::alist($mnet_request->error);
|
||||
$services = array();
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('serviceid', 'mnet'),
|
||||
get_string('service', 'mnet'),
|
||||
get_string('version', 'mnet'),
|
||||
get_string('theypublish', 'mnet'),
|
||||
get_string('theysubscribe', 'mnet'),
|
||||
get_string('options', 'mnet'),
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
$yesno = array(get_string('no'), get_string('yes'));
|
||||
|
||||
// this query is horrible and has to be remapped afterwards, because of the non-uniqueness
|
||||
// of the remoterep service (it has two plugins so far that use it)
|
||||
// it's possible to get a unique list back using a subquery with LIMIT but that would break oracle
|
||||
// so it's best to just do this small query and then remap the results afterwards
|
||||
$sql = '
|
||||
SELECT DISTINCT
|
||||
' . $DB->sql_concat('r.plugintype', "'_'", 'r.pluginname', "'_'", 's.name') . ' AS uniqueid,
|
||||
s.name,
|
||||
r.plugintype,
|
||||
r.pluginname
|
||||
FROM
|
||||
{mnet_service} s
|
||||
JOIN {mnet_remote_service2rpc} s2r ON s2r.serviceid = s.id
|
||||
JOIN {mnet_remote_rpc} r ON r.id = s2r.rpcid';
|
||||
|
||||
$serviceinfo = array();
|
||||
|
||||
foreach ($DB->get_records_sql($sql) as $result) {
|
||||
$serviceinfo[$result->name] = $result->plugintype . '_' . $result->pluginname;
|
||||
}
|
||||
|
||||
foreach ($services as $id => $servicedata) {
|
||||
if (array_key_exists($servicedata['name'], $serviceinfo)) {
|
||||
$service = $serviceinfo[$servicedata['name']];
|
||||
$servicedata['humanname'] = get_string($servicedata['name'].'_name', $service);
|
||||
} else {
|
||||
$servicedata['humanname'] = get_string('unknown', 'mnet');
|
||||
}
|
||||
$newurl = new moodle_url($url, array('hostid' => $host->id, 'servicename' => $servicedata['name']));
|
||||
$table->data[] = array(
|
||||
$servicedata['name'],
|
||||
$servicedata['humanname'],
|
||||
$servicedata['apiversion'],
|
||||
$yesno[$servicedata['publish']],
|
||||
$yesno[$servicedata['subscribe']],
|
||||
html_writer::link($newurl, get_string('listservices', 'mnet'))
|
||||
);
|
||||
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
$mnet_request->set_method('system/listMethods');
|
||||
if (isset($servicename) && array_key_exists($servicename, $serviceinfo)) {
|
||||
echo $OUTPUT->heading(get_string('methodsavailableonhostinservice', 'mnet', (object)array('host' => $host->wwwroot, 'service' => $servicename)));
|
||||
$service = $serviceinfo[$servicename];
|
||||
$mnet_request->add_param($servicename, 'string');
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('methodsavailableonhost', 'mnet', $host->wwwroot));
|
||||
}
|
||||
|
||||
$mnet_request->send($mnet_peer);
|
||||
$methods = $mnet_request->response;
|
||||
|
||||
if (!empty($mnet_request->error)) {
|
||||
echo $OUTPUT->heading(get_string('error'), 3);
|
||||
echo html_writer::alist($mnet_request->error);
|
||||
$methods = array();
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('method', 'mnet'),
|
||||
get_string('options', 'mnet'),
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
foreach ($methods as $id => $method) {
|
||||
$params = array('hostid' => $host->id, 'method' => $id+1);
|
||||
if (isset($servicename)) {
|
||||
$params['servicename'] = $servicename;
|
||||
}
|
||||
$newurl = new moodle_url($url, $params);
|
||||
$table->data[] = array(
|
||||
$method,
|
||||
html_writer::link($newurl, get_string('inspect', 'mnet'))
|
||||
);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
if (isset($methodid) && array_key_exists($methodid-1, $methods)) {
|
||||
$method = $methods[$methodid-1];
|
||||
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
$mnet_request->set_method('system/methodSignature');
|
||||
$mnet_request->add_param($method, 'string');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$signature = $mnet_request->response;
|
||||
|
||||
echo $OUTPUT->heading(get_string('methodsignature', 'mnet', $method));
|
||||
|
||||
if (!empty($mnet_request->error)) {
|
||||
echo $OUTPUT->heading(get_string('error'), 3);
|
||||
echo html_writer::alist($mnet_request->error);
|
||||
$signature = array();
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('position', 'mnet'),
|
||||
get_string('name', 'mnet'),
|
||||
get_string('type', 'mnet'),
|
||||
get_string('description', 'mnet'),
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
$params = $signature['parameters'];
|
||||
foreach ($params as $pos => $details) {
|
||||
$table->data[] = array(
|
||||
$pos,
|
||||
$details['name'],
|
||||
$details['type'],
|
||||
$details['description'],
|
||||
);
|
||||
}
|
||||
$table->data[] = array(
|
||||
get_string('returnvalue', 'mnet'),
|
||||
'',
|
||||
$signature['return']['type'],
|
||||
$signature['return']['description']
|
||||
);
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
$mnet_request->set_method('system/methodHelp');
|
||||
$mnet_request->add_param($method, 'string');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$help = $mnet_request->response;
|
||||
|
||||
echo $OUTPUT->heading(get_string('methodhelp', 'mnet', $method));
|
||||
echo(str_replace('\n', '<br />',$help));
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('trustedhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('trustedhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<form method="post" action="trustedhosts.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<textarea name="hostlist" cols="40" rows="20"><?php echo $trusted_hosts; ?></textarea><br />
|
||||
<input type="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('testtrustedhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
if (!empty($test_ip_address)){
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<?php
|
||||
if ($in_range) {
|
||||
print_string('is_in_range', 'mnet', $test_ip_address);
|
||||
echo '<br />';
|
||||
print_string('validated_by', 'mnet', $validated_by);
|
||||
} else {
|
||||
print_string('not_in_range', 'mnet', $test_ip_address);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('testtrustedhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<form method="get" action="trustedhosts.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<input type="text" name="testipaddress" value="<?php echo $test_ip_address; ?>" />
|
||||
<input type="submit" value="<?php print_string('go'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('trustedhosts');
|
||||
|
||||
$context = context_system::instance();
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo $OUTPUT->header();
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
|
||||
$trusted_hosts = '';//array();
|
||||
$old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts');
|
||||
if (!empty($old_trusted_hosts)) {
|
||||
$old_trusted_hosts = explode(',', $old_trusted_hosts);
|
||||
} else {
|
||||
$old_trusted_hosts = array();
|
||||
}
|
||||
|
||||
$test_ip_address = optional_param('testipaddress', NULL, PARAM_HOST);
|
||||
$in_range = false;
|
||||
if (!empty($test_ip_address)) {
|
||||
foreach($old_trusted_hosts as $host) {
|
||||
if (address_in_subnet($test_ip_address, $host)) {
|
||||
$in_range = true;
|
||||
$validated_by = $host;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If data submitted, process and store
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$hostlist = preg_split("/[\s,]+/", $form->hostlist);
|
||||
foreach($hostlist as $host) {
|
||||
list($address, $mask) = explode('/', $host.'/');
|
||||
if (empty($address)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
$trusted_hosts .= trim($address).'/'.trim($mask)."\n";
|
||||
unset($address, $mask);
|
||||
}
|
||||
set_config('mnet_trusted_hosts', str_replace("\n", ',', $trusted_hosts), 'mnet');
|
||||
} elseif (!empty($old_trusted_hosts)) {
|
||||
foreach($old_trusted_hosts as $host) {
|
||||
list($address, $mask) = explode('/', $host.'/');
|
||||
if (empty($address)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
$trusted_hosts .= trim($address).'/'.trim($mask)."\n";
|
||||
unset($address, $mask);
|
||||
}
|
||||
}
|
||||
|
||||
include('./trustedhosts.html');
|
||||
@@ -0,0 +1,80 @@
|
||||
<?PHP // $Id$
|
||||
// module.php - allows admin to edit all local configuration variables for a module
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only an admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
$module = optional_param('module', '', PARAM_SAFEDIR);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
// if the config.html contains a hidden form field giving
|
||||
// the module name then the form does not have to prefix all
|
||||
// its variable names, we will do it here.
|
||||
$moduleprefix = $module.'_';
|
||||
// let the module process the form data if it has to,
|
||||
// $config is passed to this function by reference
|
||||
$moduleconfig = $module.'_process_options';
|
||||
if (function_exists($moduleconfig)) {
|
||||
$moduleconfig($config);
|
||||
}
|
||||
} else {
|
||||
$moduleprefix = '';
|
||||
}
|
||||
|
||||
unset($config->sesskey);
|
||||
unset($config->module);
|
||||
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($moduleprefix.$name, $value);
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
$module = required_param('module', PARAM_SAFEDIR);
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagemodules = get_string("managemodules");
|
||||
$strmodulename = get_string("modulename", $module);
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'mod/' . $module . '/config';
|
||||
|
||||
print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"modules.php\">$strmanagemodules</a> -> $strmodulename");
|
||||
|
||||
print_heading($strmodulename);
|
||||
|
||||
print_simple_box("<center>".get_string("configwarning", 'admin')."</center>", "center", "60%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
include("$CFG->dirroot/mod/$module/config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user