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
-1
@@ -1,4 +1,4 @@
|
||||
README $Id$
|
||||
README $Id$
|
||||
------
|
||||
|
||||
QUICK INSTALL
|
||||
|
||||
@@ -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();
|
||||
|
||||
?>
|
||||
+324
-92
@@ -1,102 +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', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_login();
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$authsavailable = get_list_of_plugins('auth');
|
||||
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', $url, $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', '');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
// add to enabled list
|
||||
if (!in_array($auth, $authsenabled)) {
|
||||
$authsenabled[] = $auth;
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $url, $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', $url, $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,181 +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_SAFEDIR);
|
||||
|
||||
$CFG->pagepath = 'auth/' . $auth;
|
||||
|
||||
admin_externalpage_setup('authsetting'.$auth);
|
||||
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
$err = array();
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
|
||||
// save configuration changes
|
||||
if ($frm = data_submitted() and confirm_sesskey()) {
|
||||
$frm = stripslashes_recursive($frm);
|
||||
|
||||
$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];
|
||||
if (!set_config($name, $value, $plugin)) {
|
||||
error("Problem saving config $name as $value for plugin $plugin");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect($returnurl);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$frm = get_config("auth/$auth");
|
||||
}
|
||||
|
||||
$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
|
||||
admin_externalpage_print_header();
|
||||
|
||||
// choose an authentication method
|
||||
echo "<form $CFG->frametarget id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
|
||||
echo "<div>\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"auth\" value=\"".$auth."\" />\n";
|
||||
|
||||
// auth plugin description
|
||||
print_simple_box_start('center', '80%');
|
||||
print_heading($authtitle);
|
||||
print_simple_box_start('center', '80%', '', 5, 'informationbox');
|
||||
echo $authdescription;
|
||||
print_simple_box_end();
|
||||
echo "<hr />\n";
|
||||
$authplugin->config_form($frm, $err, $user_fields);
|
||||
print_simple_box_end();
|
||||
echo '<p style="text-align: center"><input type="submit" value="' . get_string("savechanges") . "\" /></p>\n";
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
// 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.
|
||||
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 (!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 (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
|
||||
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
|
||||
} 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> ';
|
||||
choose_from_menu($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, "");
|
||||
echo '<br />';
|
||||
if ($updateopts) {
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
choose_from_menu($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, "");
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
}
|
||||
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();
|
||||
|
||||
?>
|
||||
+24
-9
@@ -3,16 +3,22 @@
|
||||
// block.php - allows admin to edit all local configuration variables for a block
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
require_login();
|
||||
|
||||
if(!$blockrecord = blocks_get_record($blockid)) {
|
||||
error('This block does not exist');
|
||||
if (!isadmin()) {
|
||||
error('Only an admin can use this page');
|
||||
}
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
admin_externalpage_setup('blocksetting'.$blockrecord->name);
|
||||
$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) {
|
||||
@@ -31,7 +37,7 @@
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
error('This block does not support global configuration');
|
||||
@@ -47,14 +53,23 @@
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
// $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(get_string('configwarning', 'admin'), 'center', '50%');
|
||||
print_simple_box('<center>'.get_string('configwarning', 'admin').'</center>', 'center', '50%');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
|
||||
+55
-70
@@ -3,12 +3,8 @@
|
||||
// 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');
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
|
||||
admin_externalpage_setup('manageblocks');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
@@ -16,8 +12,21 @@
|
||||
$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');
|
||||
$strdelete = get_string('delete');
|
||||
$strversion = get_string('version');
|
||||
@@ -27,7 +36,12 @@
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
|
||||
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.
|
||||
|
||||
@@ -36,7 +50,6 @@
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('block', 'visible', '0', 'id', $block->id); // Hide block
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($show) && confirm_sesskey() ) {
|
||||
@@ -44,7 +57,6 @@
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('block', 'visible', '1', 'id', $block->id); // Show block
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($multiple) && confirm_sesskey()) {
|
||||
@@ -53,12 +65,9 @@
|
||||
}
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
error("Block doesn't exist!");
|
||||
@@ -76,38 +85,34 @@
|
||||
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php');
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// Inform block it's about to be deleted
|
||||
$blockobject = block_instance($block->name);
|
||||
if ($blockobject) {
|
||||
$blockobject->before_delete(); //only if we can create instance, block might have been already removed
|
||||
}
|
||||
|
||||
// First delete instances and then block
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
blocks_delete_instance($instance, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete block
|
||||
if (!delete_records('block', 'id', $block->id)) {
|
||||
notify("Error occurred while deleting the $strblockname record from blocks table");
|
||||
}
|
||||
|
||||
drop_plugin_tables($block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false); // old obsoleted table names
|
||||
drop_plugin_tables('block_'.$block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false);
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the capabilities that were defined by this block
|
||||
capabilities_cleanup('block/'.$block->name);
|
||||
// Then the tables themselves
|
||||
|
||||
// remove entent handlers and dequeue pending events
|
||||
events_uninstall('block/'.$block->name);
|
||||
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;
|
||||
@@ -115,9 +120,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
/// Main display starts here
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
@@ -130,7 +132,7 @@
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
notify('Block '. $block->name .' is not compatible with the current version of Moodle and needs to be updated by a programmer.');
|
||||
notify('Block '. $block->name .' is not compatible with the current version of Mooodle and needs to be updated by a programmer.');
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
@@ -155,51 +157,33 @@
|
||||
$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('cellspacing', '0');
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->setup();
|
||||
|
||||
foreach ($blockbyname as $blockname => $blockid) {
|
||||
|
||||
$blockobject = $blockobjects[$blockid];
|
||||
$block = $blocks[$blockid];
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if ($blockobject->has_config()) {
|
||||
if (file_exists($CFG->dirroot.'/blocks/'.$block->name.'/settings.php')) {
|
||||
$settings = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=blocksetting'.$block->name.'">'.$strsettings.'</a>';
|
||||
} else {
|
||||
$settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
|
||||
}
|
||||
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 = count_records('block_instance', 'blockid', $blockid);
|
||||
|
||||
$count = count_records_sql('SELECT COUNT(*)
|
||||
FROM '.$CFG->prefix.'block_instance
|
||||
WHERE blockid = '.$blockid.' AND
|
||||
pagetype = \'course-view\'');
|
||||
|
||||
if ($count>0) {
|
||||
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&sesskey={$USER->sesskey}\" ";
|
||||
$blocklist .= "title=\"$strshowblockcourse\" >$totalcount</a>";
|
||||
}
|
||||
else {
|
||||
$blocklist = "$totalcount";
|
||||
}
|
||||
$count = count_records('block_instance', 'blockid', $blockid);
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon" alt="'.$strhide.'" /></a>';
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" alt="" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon" alt="'.$strshow.'" /></a>';
|
||||
'<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()) {
|
||||
@@ -216,8 +200,8 @@
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$blockobject->get_title().'</span>',
|
||||
$blocklist,
|
||||
'<span'.$class.'>'.$blockobject->get_version().'</span>',
|
||||
$count,
|
||||
$blockobject->get_version(),
|
||||
$visible,
|
||||
$multiple,
|
||||
$delete,
|
||||
@@ -231,14 +215,15 @@
|
||||
print_heading(get_string('incompatibleblocks', 'admin'));
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
|
||||
$table->define_columns(array('block', 'delete'));
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'incompatible');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
@@ -250,6 +235,6 @@
|
||||
$table->print_html();
|
||||
}
|
||||
|
||||
admin_externalpage_print_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();
|
||||
|
||||
?>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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();
|
||||
|
||||
?>
|
||||
+86
-294
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
/// This script looks through all the module directories for cron.php files
|
||||
/// and runs them. These files can contain cleanup functions, email functions
|
||||
@@ -10,18 +10,14 @@
|
||||
///
|
||||
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
|
||||
/// or php /web/moodle/admin/cron.php
|
||||
set_time_limit(0);
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
/// The following is a hack necessary to allow this script to work well
|
||||
/// from the command line.
|
||||
|
||||
define('FULLME', 'cron');
|
||||
|
||||
|
||||
/// Do not set moodle cookie because we do not need it here, it is better to emulate session
|
||||
$nomoodlecookie = true;
|
||||
|
||||
|
||||
/// 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()
|
||||
@@ -31,65 +27,33 @@
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
require_once($CFG->dirroot.'/lib/adminlib.php');
|
||||
|
||||
/// Extra debugging (set in config.php)
|
||||
if (!empty($CFG->showcronsql)) {
|
||||
$db->debug = true;
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
$CFG->displaydebug = true;
|
||||
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;
|
||||
}
|
||||
|
||||
/// extra safety
|
||||
@session_write_close();
|
||||
//unset test cookie, user must login again anyway
|
||||
setcookie('MoodleSessionTest'.$CFG->sessioncookie, '', time() - 3600, '/');
|
||||
|
||||
/// check if execution allowed
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) { // if the script is accessed via the web.
|
||||
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;
|
||||
}
|
||||
}
|
||||
/// switch to site language and locale
|
||||
if (!empty($CFG->courselang)) {
|
||||
unset ($CFG->courselang);
|
||||
}
|
||||
if (!empty($SESSION->lang)) {
|
||||
unset ($SESSION->lang);
|
||||
}
|
||||
|
||||
|
||||
/// emulate normal session
|
||||
$SESSION = new object();
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
|
||||
/// ignore admins timezone, language and locale - use site deafult instead!
|
||||
$USER->timezone = $CFG->timezone;
|
||||
$USER->lang = '';
|
||||
$USER->theme = '';
|
||||
course_setup(SITEID);
|
||||
moodle_setlocale();
|
||||
|
||||
/// send mime type and encoding
|
||||
if (check_browser_version('MSIE')) {
|
||||
//ugly IE hack to work around downloading instead of viewing
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
/// no more headers and buffers
|
||||
while(@ob_end_flush());
|
||||
|
||||
/// increase memory limit (PHP 5.2 does different calculation, we need more memory now)
|
||||
@raise_memory_limit('128M');
|
||||
@header('Content-Type: text/plain; charset='.current_charset());
|
||||
|
||||
/// Start output log
|
||||
|
||||
@@ -100,8 +64,7 @@
|
||||
/// Run all cron jobs for each module
|
||||
|
||||
mtrace("Starting activity modules");
|
||||
get_mailer('buffer');
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron) AND visible = 1 ")) {
|
||||
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)) {
|
||||
@@ -109,32 +72,20 @@
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(1);
|
||||
}
|
||||
if ($cron_function()) {
|
||||
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
|
||||
mtrace("Error: could not update timestamp for $mod->fullname");
|
||||
}
|
||||
}
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
|
||||
}
|
||||
/// Reset possible changes by modules to time_limit. MDL-11597
|
||||
@set_time_limit(0);
|
||||
mtrace("done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get_mailer('close');
|
||||
mtrace("Finished activity modules");
|
||||
|
||||
mtrace("Starting blocks");
|
||||
if ($blocks = get_records_select("block", "cron > 0 AND (($timenow - lastcron) > cron) AND visible = 1")) {
|
||||
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) {
|
||||
@@ -150,79 +101,19 @@
|
||||
mtrace('Error: could not update timestamp for '.$block->name);
|
||||
}
|
||||
}
|
||||
/// Reset possible changes by blocks to time_limit. MDL-11597
|
||||
@set_time_limit(0);
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mtrace('Finished blocks');
|
||||
|
||||
mtrace('Starting admin reports');
|
||||
// Admin reports do not have a database table that lists them. Instead a
|
||||
// report includes cron.php with function report_reportname_cron() if it wishes
|
||||
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
|
||||
// actually do anything occasionally.
|
||||
$reports = get_list_of_plugins($CFG->admin.'/report');
|
||||
foreach($reports as $report) {
|
||||
$cronfile = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$report.'/cron.php';
|
||||
if (file_exists($cronfile)) {
|
||||
require_once($cronfile);
|
||||
$cronfunction = 'report_'.$report.'_cron';
|
||||
mtrace('Processing cron function for '.$report.'...', '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(true);
|
||||
}
|
||||
$cronfunction();
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
mtrace('Finished admin reports');
|
||||
mtrace("Finished blocks");
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages(true);
|
||||
get_list_of_languages();
|
||||
}
|
||||
|
||||
mtrace('Removing expired enrolments ...', ''); // See MDL-8785
|
||||
$timenow = time();
|
||||
$somefound = false;
|
||||
// The preferred way saves memory, dmllib.php
|
||||
// find courses where limited enrolment is enabled
|
||||
global $CFG;
|
||||
$rs_enrol = get_recordset_sql("SELECT ra.roleid, ra.userid, ra.contextid
|
||||
FROM {$CFG->prefix}course c
|
||||
INNER JOIN {$CFG->prefix}context cx ON cx.instanceid = c.id
|
||||
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.contextid = cx.id
|
||||
WHERE cx.contextlevel = '".CONTEXT_COURSE."'
|
||||
AND ra.timeend > 0
|
||||
AND ra.timeend < '$timenow'
|
||||
AND c.enrolperiod > 0
|
||||
");
|
||||
while ($oldenrolment = rs_fetch_next_record($rs_enrol)) {
|
||||
role_unassign($oldenrolment->roleid, $oldenrolment->userid, 0, $oldenrolment->contextid);
|
||||
$somefound = true;
|
||||
}
|
||||
rs_close($rs_enrol);
|
||||
if($somefound) {
|
||||
mtrace('Done');
|
||||
} else {
|
||||
mtrace('none found');
|
||||
}
|
||||
|
||||
|
||||
mtrace('Starting main gradebook job ...');
|
||||
grade_cron();
|
||||
mtrace('done.');
|
||||
|
||||
|
||||
/// 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
|
||||
@@ -237,107 +128,71 @@
|
||||
/// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
if ($CFG->longtimenosee) { // value in days
|
||||
$cuttime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
||||
FROM {$CFG->prefix}user_lastaccess
|
||||
WHERE courseid != ".SITEID."
|
||||
AND timeaccess < $cuttime ");
|
||||
while ($assign = rs_fetch_next_record($rs)) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (role_unassign(0, $assign->userid, 0, $context->id)) {
|
||||
mtrace("Deleted assignment for user $assign->userid from course $assign->courseid");
|
||||
$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");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
/// Execute the same query again, looking for remaining records and deleting them
|
||||
/// if the user hasn't moodle/course:view in the CONTEXT_COURSE context (orphan records)
|
||||
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
||||
FROM {$CFG->prefix}user_lastaccess
|
||||
WHERE courseid != ".SITEID."
|
||||
AND timeaccess < $cuttime ");
|
||||
while ($assign = rs_fetch_next_record($rs)) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (!has_capability('moodle/course:view', $context, $assign->userid)) {
|
||||
delete_records('user_lastaccess', 'userid', $assign->userid, 'courseid', $assign->courseid);
|
||||
mtrace("Deleted orphan user_lastaccess for user $assign->userid from course $assign->courseid");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
|
||||
/// Delete users who haven't confirmed within required period
|
||||
|
||||
if (!empty($CFG->deleteunconfirmed)) {
|
||||
$cuttime = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
$rs = get_recordset_sql ("SELECT id, firstname, lastname
|
||||
FROM {$CFG->prefix}user
|
||||
WHERE confirmed = 0
|
||||
AND firstaccess > 0
|
||||
AND firstaccess < $cuttime");
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
|
||||
$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)");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
/// Delete users who haven't completed profile within required period
|
||||
|
||||
if (!empty($CFG->deleteincompleteusers)) {
|
||||
$cuttime = $timenow - ($CFG->deleteincompleteusers * 3600);
|
||||
$rs = get_recordset_sql ("SELECT id, username
|
||||
FROM {$CFG->prefix}user
|
||||
WHERE confirmed = 1
|
||||
AND lastaccess > 0
|
||||
AND lastaccess < $cuttime
|
||||
AND deleted = 0
|
||||
AND (lastname = '' OR firstname = '' OR email = '')");
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (delete_user($user)) {
|
||||
mtrace("Deleted not fully setup user $user->username ($user->id)");
|
||||
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)");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
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);
|
||||
if (delete_records_select("log", "time < '$loglifetime'")) {
|
||||
mtrace("Deleted old log records");
|
||||
}
|
||||
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
|
||||
if (delete_records_select('cache_text', "timemodified < '$cachelifetime'")) {
|
||||
mtrace("Deleted old cache_text records");
|
||||
}
|
||||
delete_records_select('cache_text', "timemodified < '$cachelifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
if (!empty($CFG->notifyloginfailures)) {
|
||||
notify_login_failures();
|
||||
mtrace('Notified login failured');
|
||||
}
|
||||
flush();
|
||||
|
||||
sync_metacourses();
|
||||
mtrace('Synchronised metacourses');
|
||||
|
||||
//
|
||||
// generate new password emails for users
|
||||
@@ -363,33 +218,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->usetags)) {
|
||||
require_once($CFG->dirroot.'/tag/lib.php');
|
||||
tag_cron();
|
||||
mtrace ('Executed tag cron');
|
||||
}
|
||||
|
||||
// Accesslib stuff
|
||||
cleanup_contexts();
|
||||
mtrace ('Cleaned up contexts');
|
||||
gc_cache_flags();
|
||||
mtrace ('Cleaned cache flags');
|
||||
// If you suspect that the context paths are somehow corrupt
|
||||
// replace the line below with: build_context_path(true);
|
||||
build_context_path();
|
||||
mtrace ('Built context paths');
|
||||
|
||||
mtrace("Finished clean-up tasks...");
|
||||
|
||||
} // End of occasional clean-up tasks
|
||||
|
||||
|
||||
if (empty($CFG->disablescheduledbackups)) { // Defined in config.php
|
||||
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("192M");
|
||||
@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
|
||||
@@ -441,91 +278,51 @@
|
||||
unset($enrol);
|
||||
}
|
||||
|
||||
/// Run the auth cron, if any
|
||||
$auths = get_enabled_auth_plugins();
|
||||
|
||||
mtrace("Running auth crons if required...");
|
||||
foreach ($auths as $auth) {
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
if (method_exists($authplugin, 'cron')) {
|
||||
mtrace("Running cron for auth/$auth...");
|
||||
$authplugin->cron();
|
||||
if (!empty($authplugin->log)) {
|
||||
mtrace($authplugin->log);
|
||||
}
|
||||
}
|
||||
unset($authplugin);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
// check we're not before our runtime
|
||||
$timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour*60*60 + $CFG->statsruntimestartminute*60;
|
||||
$timetocheck = strtotime("$CFG->statsruntimestarthour:$CFG->statsruntimestartminute today");
|
||||
|
||||
if (time() > $timetocheck) {
|
||||
// process max 31 days per cron execution
|
||||
if (stats_cron_daily(31)) {
|
||||
if (stats_cron_weekly()) {
|
||||
if (stats_cron_monthly()) {
|
||||
stats_clean_old();
|
||||
}
|
||||
$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.
|
||||
}
|
||||
}
|
||||
@set_time_limit(0);
|
||||
} else {
|
||||
mtrace('Next stats run after:'. userdate($timetocheck));
|
||||
}
|
||||
}
|
||||
|
||||
// run gradebook import/export/report cron
|
||||
if ($gradeimports = get_list_of_plugins('grade/import')) {
|
||||
foreach ($gradeimports as $gradeimport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php');
|
||||
$cron_function = 'grade_import_'.$gradeimport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook import function $cron_function ...", '');
|
||||
$cron_function;
|
||||
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 ($gradeexports = get_list_of_plugins('grade/export')) {
|
||||
foreach ($gradeexports as $gradeexport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php');
|
||||
$cron_function = 'grade_export_'.$gradeexport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook export function $cron_function ...", '');
|
||||
$cron_function;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradereports = get_list_of_plugins('grade/report')) {
|
||||
foreach ($gradereports as $gradereport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php');
|
||||
$cron_function = 'grade_report_'.$gradereport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook report function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// run any customized cronjobs, if any
|
||||
// looking for functions in lib/local/cron.php
|
||||
if (file_exists($CFG->dirroot.'/local/cron.php')) {
|
||||
mtrace('Processing customized cron script ...', '');
|
||||
include_once($CFG->dirroot.'/local/cron.php');
|
||||
mtrace('done.');
|
||||
}
|
||||
|
||||
|
||||
//Unset session variables and destroy it
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
@@ -535,9 +332,4 @@
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
|
||||
/// finish the IE hack
|
||||
if (check_browser_version('MSIE')) {
|
||||
echo "</xmp>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -3,26 +3,23 @@
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
// disable moodle specific debug messages that would be breaking the frames
|
||||
disable_debugging();
|
||||
|
||||
$topframe = optional_param('topframe', 0, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', 0, PARAM_BOOL);
|
||||
$do = optional_param('do', '', PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$strdatabaseperformance = get_string("databaseperformance");
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
$navigation = build_navigation(array(
|
||||
array('name'=>$stradministration, 'link'=>'index.php', 'type'=>'misc'),
|
||||
array('name'=>$strdatabaseperformance, 'link'=>null, 'type'=>'misc')));
|
||||
if (!empty($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname", $navigation);
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> Database performance");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
+8
-19
@@ -4,35 +4,25 @@
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('purgemoodledata');
|
||||
|
||||
require_login();
|
||||
|
||||
$sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
$reallysure = optional_param('reallysure', 0, PARAM_BOOL);
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error('You must be admin to use this script!');
|
||||
}
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading('Purge moodledata');
|
||||
|
||||
if (empty($sure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
|
||||
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?',
|
||||
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
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 (!data_submitted() or empty($reallysure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
|
||||
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', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -46,7 +36,6 @@
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
print_continue($CFG->wwwroot);
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
|
||||
@@ -54,7 +43,7 @@ function delete_subdirectories($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
if (filetype($fullfile) == 'dir') {
|
||||
@@ -77,5 +66,5 @@ function delete_subdirectories($rootdir) {
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
?>
|
||||
+22
-17
@@ -3,23 +3,29 @@
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
|
||||
$CFG->pagepath = 'enrol';
|
||||
|
||||
require_login();
|
||||
|
||||
admin_externalpage_setup('enrolment');
|
||||
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
|
||||
|
||||
/// Save settings
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if (empty($frm->enable)) {
|
||||
$frm->enable = array();
|
||||
}
|
||||
@@ -33,14 +39,16 @@
|
||||
$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", get_string("changessaved"), 1);
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
|
||||
/// Print the form
|
||||
|
||||
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
|
||||
|
||||
admin_externalpage_print_header();
|
||||
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();
|
||||
@@ -51,9 +59,8 @@
|
||||
|
||||
print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
|
||||
|
||||
echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
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);
|
||||
@@ -63,7 +70,6 @@
|
||||
$table->data = array();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
|
||||
foreach ($modules as $module) {
|
||||
|
||||
// skip if directory is empty
|
||||
@@ -74,7 +80,7 @@
|
||||
$name = get_string("enrolname", "enrol_$module");
|
||||
$plugin = enrolment_factory::factory($module);
|
||||
$enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
|
||||
if (in_array($module, $enabledplugins)) {
|
||||
if (stristr($CFG->enrol_plugins_enabled, $module) !== false) {
|
||||
$enable .= ' checked="checked"';
|
||||
}
|
||||
if ($module == 'manual') {
|
||||
@@ -91,16 +97,15 @@
|
||||
$default = '';
|
||||
}
|
||||
$table->data[$name] = array($name, $enable, $default,
|
||||
'<a href="enrol_config.php?enrol='.$module.'">'.$str->edit.'</a>');
|
||||
'<a href="enrol_config.php?sesskey='.$USER->sesskey.'&enrol='.$module.'">'.$str->edit.'</a>');
|
||||
}
|
||||
asort($table->data);
|
||||
|
||||
print_table($table);
|
||||
|
||||
echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n";
|
||||
echo "</div>";
|
||||
echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
?>
|
||||
+35
-18
@@ -3,13 +3,23 @@
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once("../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('enrolment');
|
||||
|
||||
$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
|
||||
|
||||
@@ -18,9 +28,6 @@
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if ($enrolment->process_config($frm)) {
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
@@ -33,7 +40,6 @@
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
|
||||
unset($options);
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
@@ -41,14 +47,25 @@
|
||||
}
|
||||
asort($options);
|
||||
|
||||
admin_externalpage_print_header();
|
||||
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 $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
echo "<input type=\"hidden\" name=\"enrol\" value=\"".$enrol."\" />";
|
||||
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>";
|
||||
|
||||
/// Print current enrolment type description
|
||||
|
||||
/// 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]);
|
||||
|
||||
@@ -57,15 +74,15 @@
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<p class=\"centerpara\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></p>\n";
|
||||
print_simple_box_end();
|
||||
echo "</div>";
|
||||
echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
|
||||
+31
-16
@@ -7,7 +7,7 @@
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.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 //
|
||||
@@ -30,16 +30,24 @@
|
||||
// from moodle.org be able to check more and more versions.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
admin_externalpage_setup('environment');
|
||||
|
||||
/// Parameters
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
|
||||
/// Security checks
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You need to be admin to use this page');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
/// Get some strings
|
||||
$stradmin = get_string('administration');
|
||||
@@ -52,7 +60,9 @@
|
||||
$strmisc = get_string('miscellaneous');
|
||||
|
||||
/// Print the header stuff
|
||||
admin_externalpage_print_header();
|
||||
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>';
|
||||
@@ -65,10 +75,10 @@
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest= $CFG->dataroot.'/';
|
||||
@@ -77,10 +87,10 @@
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center', '', '', 5, 'errorbox');
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
case UPTODATE:
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center');
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
case INSTALLED:
|
||||
print_simple_box(get_string('componentinstalled', 'admin'), 'center');
|
||||
break;
|
||||
}
|
||||
@@ -90,7 +100,7 @@
|
||||
/// Start of main box
|
||||
print_simple_box_start('center');
|
||||
|
||||
echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";
|
||||
echo "<center>".$stradminhelpenvironment."</center><br />";
|
||||
|
||||
/// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
@@ -120,17 +130,22 @@
|
||||
}
|
||||
|
||||
/// Print form and popup menu
|
||||
echo '<div style="text-align:center">'.$strmoodleversion.' ';
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/environment.php?version=",
|
||||
$versions, 'selectversion', $version, '');
|
||||
echo '</div>';
|
||||
|
||||
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
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
+1
-218
@@ -35,11 +35,6 @@
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.7">
|
||||
<UNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unicoderecommended" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
@@ -49,12 +44,10 @@
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required">
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
@@ -69,214 +62,4 @@
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.8">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required">
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ctyperecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.0" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required">
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ctyperecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_check_no_rqp_questions" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="qtyperqpwillberemovedanyway" />
|
||||
<ON_OK message="qtyperqpwillberemoved" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_random_check" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_OK message="questioncwqpfsok" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.0" requires="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.0" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.2.0" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_check_no_rqp_questions" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="qtyperqpwillberemovedanyway" />
|
||||
<ON_OK message="qtyperqpwillberemoved" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+40
-22
@@ -3,19 +3,30 @@
|
||||
// Edit text filter settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$filterfull = required_param('filter', PARAM_PATH);
|
||||
$forcereset = optional_param('reset', 0, PARAM_BOOL);
|
||||
// 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' );
|
||||
}
|
||||
|
||||
$filtername = substr($filterfull, strpos( $filterfull, '/' )+1 ) ;
|
||||
// get parameters
|
||||
$param = new Object;
|
||||
|
||||
admin_externalpage_setup('filtersetting'.str_replace('/', '', $filterfull));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters";
|
||||
$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' );
|
||||
@@ -27,7 +38,12 @@
|
||||
//======================
|
||||
|
||||
// if reset pressed let filter config page handle it
|
||||
if ($config = data_submitted() and !$forcereset) {
|
||||
$forcereset = false;
|
||||
if (!empty($param->reset)) {
|
||||
$forcereset = true;
|
||||
}
|
||||
else
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
// check session key
|
||||
if (!confirm_sesskey()) {
|
||||
@@ -48,43 +64,45 @@
|
||||
// run through submitted data
|
||||
// reject if does not start with filter_
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, stripslashes($value));
|
||||
set_config( $name,$value );
|
||||
}
|
||||
}
|
||||
|
||||
reset_text_filters_cache();
|
||||
|
||||
redirect($returnurl);
|
||||
redirect( "$CFG->wwwroot/$CFG->admin/filters.php", get_string('changessaved'), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
|
||||
$filtername = ucfirst($filtername);
|
||||
admin_externalpage_print_header();
|
||||
print_heading( $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_simple_box(get_string("configwarning", "admin"), "center", "50%");
|
||||
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($filterfull); ?>" method="post">
|
||||
<div style="text-align: 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/$filterfull/filterconfig.html"; ?>
|
||||
<?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'); ?>" />
|
||||
</div>
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
+272
-40
@@ -1,73 +1,142 @@
|
||||
<?php // $Id$
|
||||
// filters.php
|
||||
// Edit list of available text filters
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
// defines
|
||||
define('FILTER_TABLE','filter_administration_table');
|
||||
|
||||
// check for allowed access
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters";
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
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 a list of installed filters
|
||||
// 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)) {
|
||||
$installedfilters["$filterlocation/$plugin"] = "$filterlocation/$plugin";
|
||||
$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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all the currently selected filters
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$activefilters = explode(',', $CFG->textfilters);
|
||||
$oldactivefilters = explode(',', $CFG->textfilters);
|
||||
$oldactivefilters = array_unique($oldactivefilters);
|
||||
} else {
|
||||
$activefilters = array();
|
||||
$oldactivefilters = array();
|
||||
}
|
||||
|
||||
// take this opportunity to clean up filters
|
||||
$activefilters = array();
|
||||
foreach ($oldactivefilters as $oldactivefilter) {
|
||||
if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) {
|
||||
$activefilters[] = $oldactivefilter;
|
||||
}
|
||||
}
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case 'hide':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
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) {
|
||||
break;
|
||||
// ignore it - doubleclick??
|
||||
} else {
|
||||
// just delete it
|
||||
unset($activefilters[$key]);
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
// just delete it
|
||||
unset($activefilters[$key]);
|
||||
break;
|
||||
|
||||
case 'show':
|
||||
} elseif (($params->action=="show") and confirm_sesskey()) {
|
||||
// check filterpath is valid
|
||||
if (!array_key_exists($filterpath, $installedfilters)) {
|
||||
error("Filter $filterpath is not currently installed", $url);
|
||||
} elseif (array_search($filterpath,$activefilters)) {
|
||||
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[] = $filterpath;
|
||||
$activefilters[] = $params->filterpath;
|
||||
$activefilters = array_unique($activefilters);
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
} elseif (($params->action=="down") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $filterpath is not currently active", $url);
|
||||
error("Filter $params->filterpath is not currently active", $url);
|
||||
} elseif ($key>=(count($activefilters)-1)) {
|
||||
// cannot be moved any further down - doubleclick??
|
||||
} else {
|
||||
@@ -75,14 +144,13 @@
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key+1];
|
||||
$activefilters[$key+1] = $fsave;
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
} elseif (($params->action=="up") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $filterpath is not currently active", $url);
|
||||
error("Filter $params->filterpath is not currently active", $url);
|
||||
} elseif ($key<1) {
|
||||
//cannot be moved any further up - doubleclick??
|
||||
} else {
|
||||
@@ -90,13 +158,177 @@
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key-1];
|
||||
$activefilters[$key-1] = $fsave;
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
break;
|
||||
} 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);
|
||||
}
|
||||
|
||||
// save, reset cache and return
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
reset_text_filters_cache();
|
||||
redirect($returnurl);
|
||||
//======================
|
||||
// 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;
|
||||
}
|
||||
|
||||
// settings link (if defined)
|
||||
$settings = '';
|
||||
if (in_array($path, $filtersettings)) {
|
||||
$settings = "<a href=\"filter.php?filter=" . urlencode($path) . "\">";
|
||||
$settings .= "{$txt->settings}</a>";
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
elseif ($second>=3600) {
|
||||
$options[$second] = get_string('numhours','',$second/3600);
|
||||
}
|
||||
elseif ($second>=60) {
|
||||
$options[$second] = get_string('numminutes','',$second/60);
|
||||
}
|
||||
elseif ($second>=1) {
|
||||
$options[$second] = get_string('numseconds','',$second);
|
||||
}
|
||||
else {
|
||||
$options[$second] = get_string('no');
|
||||
}
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
print_header("$site->shortname: $txt->managefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
|
||||
"-> $txt->managefilters");
|
||||
|
||||
print_heading_with_help($txt->managefilters, 'filters');
|
||||
|
||||
// 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();
|
||||
|
||||
?>
|
||||
|
||||
@@ -40,7 +40,7 @@ while(!feof($fd)) {
|
||||
|
||||
$user = get_record("user","id",$log->userid);
|
||||
$course = get_record("course","id",$log->course);
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
@@ -78,7 +78,7 @@ function notify_admins_unknown($file,$a) {
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
|
||||
+20
-17
@@ -3,19 +3,15 @@
|
||||
ob_start(); //for whitespace test
|
||||
require_once('../config.php');
|
||||
|
||||
// extra whitespace test - intentionally breaks cookieless mode
|
||||
$extraws = '';
|
||||
// extra whitespace test - intentionally breaks cookieless mode
|
||||
$extraws = '';
|
||||
while (true) {
|
||||
$extraws .= ob_get_contents();
|
||||
if (!@ob_end_clean()) {
|
||||
if (!@ob_end_clean()) { //
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('healthcenter');
|
||||
|
||||
define('SEVERITY_NOTICE', 'notice');
|
||||
define('SEVERITY_ANNOYANCE', 'annoyance');
|
||||
define('SEVERITY_SIGNIFICANT', 'significant');
|
||||
@@ -24,11 +20,18 @@
|
||||
$solution = optional_param('solution', 0, PARAM_SAFEDIR); //in fact it is class name alhanumeric and _
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
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');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
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">
|
||||
@@ -100,7 +103,7 @@ STYLES;
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
|
||||
function health_find_problems() {
|
||||
@@ -418,7 +421,7 @@ class problem_000010 extends problem_base {
|
||||
}
|
||||
function exists() {
|
||||
if (!$this->is_enabled()) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
if ($this->status() < 1) {
|
||||
return true;
|
||||
@@ -428,7 +431,7 @@ class problem_000010 extends problem_base {
|
||||
function severity() {
|
||||
if ($this->is_enabled() and $this->status() == 0) {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
} else {
|
||||
} else {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
}
|
||||
@@ -436,9 +439,9 @@ class problem_000010 extends problem_base {
|
||||
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>';
|
||||
$desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
|
||||
$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>';
|
||||
@@ -469,9 +472,9 @@ class problem_000010 extends problem_base {
|
||||
$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>';
|
||||
$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;
|
||||
}
|
||||
|
||||
+255
-436
@@ -22,32 +22,16 @@
|
||||
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
|
||||
require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
|
||||
require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
|
||||
include_once($CFG->dirroot.'/lib/adminlib.php'); // Contains various admin-only functions
|
||||
|
||||
$id = optional_param('id', '', PARAM_TEXT);
|
||||
$id = optional_param('id', '', PARAM_ALPHANUM);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$autopilot = optional_param('autopilot', 0, PARAM_BOOL);
|
||||
$ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
|
||||
$confirmplugincheck = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
||||
$agreelicence = optional_param('agreelicence',0, PARAM_BOOL);
|
||||
|
||||
/// check upgrade status first
|
||||
if ($ignoreupgradewarning and !empty($_SESSION['upgraderunning'])) {
|
||||
$_SESSION['upgraderunning'] = 0;
|
||||
}
|
||||
upgrade_check_running("Upgrade already running in this session, please wait!<br />Click on the exclamation marks to ignore this warning (<a href=\"index.php?ignoreupgradewarning=1\">!!!</a>).", 10);
|
||||
|
||||
/// set install/upgrade autocontinue session flag
|
||||
if ($autopilot) {
|
||||
$_SESSION['installautopilot'] = $autopilot;
|
||||
}
|
||||
|
||||
/// Check some PHP server settings
|
||||
|
||||
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
||||
$documentationlink = "please read the <a href=\"../doc/?frame=install.html&sub=webserver\">install documentation</a>";
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
|
||||
@@ -61,13 +45,6 @@
|
||||
error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
|
||||
}
|
||||
|
||||
if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql
|
||||
error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
|
||||
}
|
||||
|
||||
if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
|
||||
error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
|
||||
}
|
||||
|
||||
/// Check that config.php has been edited
|
||||
|
||||
@@ -99,14 +76,6 @@
|
||||
$CFG->version = "";
|
||||
}
|
||||
|
||||
if (is_readable("$CFG->dirroot/version.php")) {
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
}
|
||||
|
||||
if (!$version or !$release) {
|
||||
error('Main version.php was not readable or specified');# without version, stop
|
||||
}
|
||||
|
||||
/// Check if the main tables have been installed yet or not.
|
||||
|
||||
if (! $tables = $db->Metatables() ) { // No tables yet at all.
|
||||
@@ -116,7 +85,7 @@
|
||||
$maintables = true;
|
||||
$mtables = array("config", "course", "course_categories", "course_modules",
|
||||
"course_sections", "log", "log_display", "modules",
|
||||
"user");
|
||||
"user", "user_admins", "user_students", "user_teachers");
|
||||
foreach ($mtables as $mtable) {
|
||||
if (!in_array($CFG->prefix.$mtable, $tables)) {
|
||||
$maintables = false;
|
||||
@@ -124,110 +93,38 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $maintables) {
|
||||
/// hide errors from headers in case debug enabled in config.php
|
||||
$origdebug = $CFG->debug;
|
||||
$CFG->debug = DEBUG_MINIMAL;
|
||||
error_reporting($CFG->debug);
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
$navigation = build_navigation(array(array('name'=>$strlicense, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strlicense, $strlicense, $navigation, "", "", false, " ", " ");
|
||||
if (empty($agreelicence)) {
|
||||
$strlicense = get_string("license");
|
||||
print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " ");
|
||||
print_heading("<a href=\"http://moodle.org\">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_heading(get_string('copyrightnotice'));
|
||||
print_box(text_to_html(get_string('gpl')), 'copyrightnotice');
|
||||
print_heading(get_string("copyrightnotice"));
|
||||
print_simple_box_start('center');
|
||||
echo text_to_html(get_string("gpl"));
|
||||
print_simple_box_end();
|
||||
echo "<br />";
|
||||
notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1",
|
||||
notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
|
||||
"http://docs.moodle.org/en/License");
|
||||
print_footer('none');
|
||||
exit;
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
$navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'generalbox boxaligncenter boxwidthwide');
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="agreelicense" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
print_footer('none');
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
$strdatabasesetup = get_string("databasesetup");
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
$navigation = build_navigation(array(array('name'=>$strdatabasesetup, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $navigation,
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
error_reporting($CFG->debug);
|
||||
upgrade_log_start();
|
||||
$db->debug = true;
|
||||
|
||||
/// Both old .sql files and new install.xml are supported
|
||||
/// But we prioritise install.xml (XMLDB) if present
|
||||
|
||||
change_db_encoding(); // first try to change db encoding to utf8
|
||||
if (!setup_is_unicodedb()) {
|
||||
// If could not convert successfully, throw error, and prevent installation
|
||||
print_error('unicoderequired', 'admin');
|
||||
}
|
||||
|
||||
$status = false;
|
||||
if (file_exists("$CFG->libdir/db/install.xml")) {
|
||||
$status = install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
|
||||
} else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", "", false, " ", " ");
|
||||
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = true;
|
||||
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
notify($strdatabasesuccess, "green");
|
||||
} else {
|
||||
$db->debug = false;
|
||||
error("Error: Main databases NOT set up successfully");
|
||||
}
|
||||
} else {
|
||||
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.");
|
||||
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle. See the lib/db directory.");
|
||||
}
|
||||
|
||||
// all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
|
||||
set_config('unicodedb', 1);
|
||||
|
||||
/// Continue with the instalation
|
||||
$db->debug = false;
|
||||
if ($status) {
|
||||
|
||||
/// Groups install is now in core above.
|
||||
|
||||
// Install the roles system.
|
||||
moodle_install_roles();
|
||||
set_config('statsrolesupgraded',time());
|
||||
|
||||
// install core event handlers
|
||||
events_update_definition();
|
||||
|
||||
/// This is used to handle any settings that must exist in $CFG but which do not exist in
|
||||
/// admin_get_root()/$ADMIN as admin_setting objects (there are some exceptions).
|
||||
apply_default_exception_settings(array('auth' => 'email',
|
||||
'auth_pop3mailbox' => 'INBOX',
|
||||
'enrol' => 'manual',
|
||||
'enrol_plugins_enabled' => 'manual',
|
||||
'style' => 'default',
|
||||
'template' => 'default',
|
||||
'theme' => 'standardwhite',
|
||||
'filter_multilang_converted' => 1));
|
||||
|
||||
// Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
|
||||
// (this should only have any effect during initial install).
|
||||
admin_apply_default_settings(NULL, true);
|
||||
|
||||
notify($strdatabasesuccess, "green");
|
||||
require_once $CFG->dirroot.'/mnet/lib.php';
|
||||
} else {
|
||||
error("Error: Main databases NOT set up successfully");
|
||||
}
|
||||
print_continue('index.php');
|
||||
print_footer('none');
|
||||
print_continue("index.php");
|
||||
die;
|
||||
}
|
||||
|
||||
@@ -235,343 +132,163 @@
|
||||
/// Check version of Moodle code on disk compared with database
|
||||
/// and upgrade if possible.
|
||||
|
||||
if (file_exists("$CFG->dirroot/lib/db/$CFG->dbtype.php")) {
|
||||
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines old upgrades
|
||||
}
|
||||
if (file_exists("$CFG->dirroot/lib/db/upgrade.php")) {
|
||||
include_once("$CFG->dirroot/lib/db/upgrade.php"); # defines new upgrades
|
||||
}
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
if ($CFG->version) {
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
|
||||
/// If the database is not already Unicode then we do not allow upgrading!
|
||||
/// Instead, we print an error telling them to upgrade to 1.7 first. MDL-6857
|
||||
if (empty($CFG->unicodedb)) {
|
||||
print_error('unicodeupgradeerror', 'error', '', $version);
|
||||
}
|
||||
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string("databasechecking", "", $a);
|
||||
|
||||
// hide errors from headers in case debug is enabled
|
||||
$origdebug = $CFG->debug;
|
||||
$CFG->debug = DEBUG_MINIMAL;
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
// logo ut in case we are upgrading from pre 1.9 version in order to prevent
|
||||
// weird session/role problems caused by incorrect data in USER and SESSION
|
||||
if ($CFG->version < 2007101500) {
|
||||
require_logout();
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strdatabasechecking, $stradministration, $navigation,
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
|
||||
print_footer('none');
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
|
||||
exit;
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
$navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
print_heading(get_string('environment', 'admin'));
|
||||
if (!check_moodle_environment($release, $environment_results, true)) {
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
print_box_end();
|
||||
notice_yesno(get_string('environmenterrorupgrade', 'admin'),
|
||||
'index.php?confirmupgrade=1&confirmrelease=1', 'index.php');
|
||||
} else {
|
||||
notify(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
print_box_end();
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="confirmupgrade" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton">';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
print_footer('none');
|
||||
die;
|
||||
} elseif (empty($confirmplugincheck)) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
$navigation = build_navigation(array(array('name'=>$strplugincheck, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strplugincheck, $strplugincheck, $navigation, "", "", false, " ", " ");
|
||||
print_heading($strplugincheck);
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('pluginchecknotice');
|
||||
print_box_end();
|
||||
print_plugin_tables();
|
||||
echo "<br />";
|
||||
echo '<div class="continuebutton">';
|
||||
print_single_button('index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1), get_string('reload'), 'get');
|
||||
echo '</div><br />';
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="confirmupgrade" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '<input type="hidden" name="confirmplugincheck" value="1" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
print_footer('none');
|
||||
die();
|
||||
|
||||
} else {
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
$navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strdatabasechecking, $stradministration, $navigation,
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
error_reporting($CFG->debug);
|
||||
upgrade_log_start();
|
||||
|
||||
/// Upgrade current language pack if we can
|
||||
upgrade_language_pack();
|
||||
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
/// Launch the old main upgrade (if exists)
|
||||
$status = true;
|
||||
if (function_exists('main_upgrade')) {
|
||||
$status = main_upgrade($CFG->version);
|
||||
}
|
||||
/// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
|
||||
if ($status && function_exists('xmldb_main_upgrade')) {
|
||||
$status = xmldb_main_upgrade($CFG->version);
|
||||
}
|
||||
$db->debug=false;
|
||||
/// If successful, continue upgrading roles and setting everything properly
|
||||
if ($status) {
|
||||
if (empty($CFG->rolesactive)) {
|
||||
|
||||
/// Groups upgrade is now in core above.
|
||||
|
||||
// Upgrade to the roles system.
|
||||
moodle_install_roles();
|
||||
set_config('rolesactive', 1);
|
||||
} else if (!update_capabilities()) {
|
||||
error('Had trouble upgrading the core capabilities for the Roles System');
|
||||
}
|
||||
// update core events
|
||||
events_update_definition();
|
||||
|
||||
require_once($CFG->libdir.'/statslib.php');
|
||||
if (!stats_upgrade_for_roles_wrapper()) {
|
||||
notify('Couldn\'t upgrade the stats tables to use the new roles system');
|
||||
}
|
||||
if (main_upgrade($CFG->version)) {
|
||||
$db->debug=false;
|
||||
if (set_config("version", $version)) {
|
||||
remove_dir($CFG->dataroot . '/cache', true); // flush cache
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("upgradesettings.php");
|
||||
print_footer('none');
|
||||
print_continue("index.php");
|
||||
exit;
|
||||
} else {
|
||||
error('Upgrade failed! (Could not update version in config table)');
|
||||
notify("Upgrade failed! (Could not update version in config table)");
|
||||
}
|
||||
/// Main upgrade not success
|
||||
} else {
|
||||
notify('Main Upgrade failed! See lib/db/upgrade.php');
|
||||
print_continue('index.php?confirmupgrade=1&confirmrelease=1&confirmplugincheck=1');
|
||||
print_footer('none');
|
||||
die;
|
||||
$db->debug=false;
|
||||
notify("Upgrade failed! See /version.php");
|
||||
}
|
||||
upgrade_log_finish();
|
||||
}
|
||||
} else if ($version < $CFG->version) {
|
||||
upgrade_log_start();
|
||||
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
|
||||
upgrade_log_finish();
|
||||
}
|
||||
|
||||
} else {
|
||||
$strcurrentversion = get_string("currentversion");
|
||||
print_header($strcurrentversion, $stradministration, $strcurrentversion,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
if (!set_config("version", $version)) {
|
||||
error("A problem occurred inserting current version into databases");
|
||||
$db->debug=true;
|
||||
if (main_upgrade(0)) {
|
||||
print_continue("index.php");
|
||||
} else {
|
||||
error("A problem occurred inserting current version into databases");
|
||||
}
|
||||
$db->debug=false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updated human-readable release version if necessary
|
||||
|
||||
if ($release <> $CFG->release) { // Update the release version
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
if (!set_config("release", $release)) {
|
||||
error("ERROR: Could not update release version in database!!");
|
||||
notify("ERROR: Could not update release version in database!!");
|
||||
}
|
||||
notice(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Insert default values for any important configuration variables
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Groups install/upgrade is now in core above.
|
||||
/// Send $CFG->unicodedb to DB to have it available for next requests
|
||||
set_config('unicodedb', $CFG->unicodedb);
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php?installing=1");
|
||||
}
|
||||
|
||||
/// Find and check all main modules and load them up or upgrade them if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all questiontype plugins and upgrade if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
/// It is important that this is done AFTER the quiz module has been upgraded
|
||||
// It is important that this is done AFTER the quiz module has been upgraded
|
||||
upgrade_plugins('qtype', 'question/type', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Upgrade backup/restore system if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/backup/lib.php");
|
||||
upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Upgrade blocks system if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/lib/blocklib.php");
|
||||
upgrade_blocks_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all blocks and load (or upgrade them if necessary)
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all enrolment plugins and upgrade if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
upgrade_plugins('enrol', 'enrol', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all auth plugins and upgrade if necessary
|
||||
upgrade_plugins('auth','auth',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all course formats and upgrade if necessary
|
||||
upgrade_plugins('format','course/format',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check for local database customisations
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/lib/locallib.php");
|
||||
upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check for changes to RPC functions
|
||||
require_once("$CFG->dirroot/$CFG->admin/mnet/adminlib.php");
|
||||
upgrade_RPC_functions("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Upgrade all plugins for gradebook
|
||||
upgrade_plugins('gradeexport', 'grade/export', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
upgrade_plugins('gradeimport', 'grade/import', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
upgrade_plugins('gradereport', 'grade/report', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all message output plugins and upgrade if necessary
|
||||
upgrade_plugins('message','message/output',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all admin report plugins and upgrade if necessary
|
||||
upgrade_plugins('report', $CFG->admin.'/report', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
|
||||
/// just make sure upgrade logging is properly terminated
|
||||
upgrade_log_finish();
|
||||
|
||||
unset($_SESSION['installautopilot']);
|
||||
|
||||
/// Set up the blank site - to be customized later at the end of install.
|
||||
/// Set up the overall site name etc.
|
||||
if (! $site = get_site()) {
|
||||
// We are about to create the site "course"
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
$newsite = new object();
|
||||
$newsite->fullname = "";
|
||||
$newsite->shortname = "";
|
||||
$newsite->summary = NULL;
|
||||
$newsite->newsitems = 3;
|
||||
$newsite->numsections = 0;
|
||||
$newsite->category = 0;
|
||||
$newsite->format = 'site'; // Only for this course
|
||||
$newsite->teacher = get_string("defaultcourseteacher");
|
||||
$newsite->teachers = get_string("defaultcourseteachers");
|
||||
$newsite->student = get_string("defaultcoursestudent");
|
||||
$newsite->students = get_string("defaultcoursestudents");
|
||||
$newsite->timemodified = time();
|
||||
|
||||
if (!$newid = insert_record('course', $newsite)) {
|
||||
error("Serious Error! Could not set up the site!");
|
||||
}
|
||||
// make sure course context exists
|
||||
get_context_instance(CONTEXT_COURSE, $newid);
|
||||
|
||||
// Site created, add blocks for it
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $newid);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
|
||||
$cat = new object();
|
||||
$cat->name = get_string('miscellaneous');
|
||||
$cat->depth = 1;
|
||||
if (!$catid = insert_record('course_categories', $cat)) {
|
||||
error("Serious Error! Could not set up a default course category!");
|
||||
}
|
||||
// make sure category context exists
|
||||
get_context_instance(CONTEXT_COURSECAT, $catid);
|
||||
mark_context_dirty('/'.SYSCONTEXTID);
|
||||
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
// initialise default blocks on admin and site page if needed
|
||||
if (empty($CFG->adminblocks_initialised)) {
|
||||
require_once("$CFG->dirroot/$CFG->admin/pagelib.php");
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
$page = page_create_object(PAGE_ADMIN, 0); // there must be some id number
|
||||
blocks_repopulate_page($page);
|
||||
|
||||
//add admin_tree block to site if not already present
|
||||
if ($admintree = get_record('block', 'name', 'admin_tree')) {
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, SITEID);
|
||||
$pageblocks=blocks_get_by_page($page);
|
||||
blocks_execute_action($page, $pageblocks, 'add', (int)$admintree->id, false, false);
|
||||
if ($admintreeinstance = get_record('block_instance', 'pagetype', $page->type, 'pageid', SITEID, 'blockid', $admintree->id)) {
|
||||
$pageblocks=blocks_get_by_page($page); // Needs to be re-got, since has just changed
|
||||
blocks_execute_action($page, $pageblocks, 'moveleft', $admintreeinstance, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
set_config('adminblocks_initialised', 1);
|
||||
redirect("site.php");
|
||||
}
|
||||
|
||||
/// Define the unique site ID code if it isn't already
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
|
||||
set_config('siteidentifier', random_string(32));
|
||||
}
|
||||
|
||||
/// Check if the guest user exists. If not, create one.
|
||||
if (! record_exists("user", "username", "guest")) {
|
||||
if (! $guest = create_guest_record()) {
|
||||
$guest->auth = "manual";
|
||||
$guest->username = "guest";
|
||||
$guest->password = md5("guest");
|
||||
$guest->firstname = addslashes(get_string("guestuser"));
|
||||
$guest->lastname = " ";
|
||||
$guest->email = "root@localhost";
|
||||
$guest->description = addslashes(get_string("guestuserinfo"));
|
||||
$guest->confirmed = 1;
|
||||
$guest->lang = $CFG->lang;
|
||||
$guest->timemodified= time();
|
||||
|
||||
if (! $guest->id = insert_record("user", $guest)) {
|
||||
notify("Could not create guest user record !!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Set up the admin user
|
||||
if (empty($CFG->rolesactive)) {
|
||||
build_context_path(); // just in case - should not be needed
|
||||
create_admin_user();
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
redirect("user.php");
|
||||
}
|
||||
|
||||
/// Check for valid admin user - no guest autologin
|
||||
require_login(0, false);
|
||||
/// Check for valid admin user
|
||||
require_login();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
/// check that site is properly customized
|
||||
if (empty($site->shortname)) {
|
||||
// probably new installation - lets return to frontpage after this step
|
||||
// remove settings that we want uninitialised
|
||||
unset_config('registerauth');
|
||||
redirect('upgradesettings.php?return=site');
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
/// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
|
||||
@@ -582,47 +299,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
$adminroot =& admin_get_root();
|
||||
/// At this point everything is set up and the user is an admin, so print menu
|
||||
|
||||
/// Check if there are any new admin settings which have still yet to be set
|
||||
if (any_new_admin_settings($adminroot)){
|
||||
redirect('upgradesettings.php');
|
||||
}
|
||||
|
||||
/// Everything should now be set up, and the user is an admin
|
||||
|
||||
/// Print default admin page with notifications.
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
admin_externalpage_print_header();
|
||||
$stradministration = get_string("administration");
|
||||
print_header("$site->shortname: $stradministration","$site->fullname", "$stradministration");
|
||||
print_simple_box_start('center', '100%', '', 20);
|
||||
print_heading($stradministration);
|
||||
|
||||
/// Deprecated database! Warning!!
|
||||
if (!empty($CFG->migrated_to_new_db)) {
|
||||
print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
|
||||
print_simple_box_start('center','60%');
|
||||
print_string('dbmigrationdeprecateddb','admin');
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
/// Check for any special upgrades that might need to be run
|
||||
if (!empty($CFG->upgrade)) {
|
||||
print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"));
|
||||
if (!empty($CFG->upgrade)) { // Print notice about extra upgrading that needs to be done
|
||||
print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
|
||||
"$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center", '60%');
|
||||
print_spacer(10,10);
|
||||
}
|
||||
|
||||
if (ini_get_bool('register_globals')) {
|
||||
print_box(get_string('globalswarning', 'admin'), 'generalbox adminwarning');
|
||||
if (ini_get_bool('register_globals') && !ini_get_bool('magic_quotes_gpc')) {
|
||||
print_simple_box(get_string('globalsquoteswarning', 'admin'), 'center', '60%');
|
||||
}
|
||||
|
||||
if (is_dataroot_insecure()) {
|
||||
print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
|
||||
print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
if (substr($CFG->wwwroot, -1) == '/') {
|
||||
print_box(get_string('cfgwwwrootslashwarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
if (strpos($ME, $CFG->httpswwwroot.'/') === false) {
|
||||
print_box(get_string('cfgwwwrootwarning', 'admin'), 'generalbox adminwarning');
|
||||
print_simple_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'center', '60%');
|
||||
}
|
||||
|
||||
/// If no recently cron run
|
||||
@@ -630,44 +332,161 @@
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
$strinstallation = get_string('installation', 'install');
|
||||
$helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
|
||||
print_box(get_string('cronwarning', 'admin')." ".$helpbutton, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Print multilang upgrade notice if needed
|
||||
if (empty($CFG->filter_multilang_converted)) {
|
||||
print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
|
||||
print_simple_box(get_string('cronwarning', 'admin')." ".$helpbutton, 'center', '60%');
|
||||
}
|
||||
|
||||
/// Alert if we are currently in maintenance mode
|
||||
if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
|
||||
print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning');
|
||||
print_simple_box(get_string('sitemaintenancewarning', 'admin') , 'center', '60%');
|
||||
}
|
||||
|
||||
/// Alert if we are currently in maintenance mode
|
||||
if (empty($CFG->unicodedb)) {
|
||||
print_simple_box(get_string('unicodeupgradenotice', 'admin') , 'center', '60%');
|
||||
}
|
||||
|
||||
/// Print slightly annoying registration button every six months ;-)
|
||||
/// You can set the "registered" variable to something far in the future
|
||||
/// if you really want to prevent this. eg 9999999999
|
||||
if (!isset($CFG->registered) || $CFG->registered < (time() - 3600*24*30*6)) {
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<div align="center">';
|
||||
print_string('pleaseregister', 'admin');
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
$table->tablealign = "center";
|
||||
$table->align = array ("right", "left");
|
||||
$table->wrap = array ("nowrap", "nowrap");
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '40%';
|
||||
|
||||
$configdata = '<div class="adminlink"><a href="config.php">'.get_string('configvariables', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpconfigvariables').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="site.php">'.get_string('sitesettings').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpsitesettings').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="../theme/index.php">'.get_string('themes').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpthemes').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="lang.php">'.get_string('language').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelplanguage').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="modules.php">'.get_string('managemodules').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagemodules').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="blocks.php">'.get_string('manageblocks').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanageblocks').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="filters.php">'.get_string('managefilters').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagefilters').'</span></div>';
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$configdata .= '<div class="adminlink"><a href="backup.php">'.get_string('backup').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpbackup').'</span></div>';
|
||||
}
|
||||
$configdata .= '<div class="adminlink"><a href="editor.php">'.get_string('editorsettings').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpeditorsettings').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="calendar.php">'.get_string('calendarsettings', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('helpcalendarsettings', 'admin').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="maintenance.php">'.get_string('sitemaintenancemode', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('helpsitemaintenance', 'admin').'</span></div>';
|
||||
|
||||
$table->data[] = array('<strong><a href="configure.php">'.get_string('configuration').'</a></strong>', $configdata);
|
||||
|
||||
|
||||
$userdata = '<div class="adminlink"><a href="auth.php?sesskey='.$USER->sesskey.'">'.get_string("authentication").
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpauthentication').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="user.php">'.get_string('edituser').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpedituser').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/user.php?newuser=true&sesskey='.$USER->sesskey.'">'.
|
||||
get_string('addnewuser').'</a> - <span class="explanation">'.get_string('adminhelpaddnewuser').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/uploaduser.php?sesskey='.$USER->sesskey.'">'.
|
||||
get_string('uploadusers').'</a> - <span class="explanation">'.get_string('adminhelpuploadusers').'</span></div>';
|
||||
|
||||
$table->data[] = array('<strong><a href="users.php">'.get_string('users').'</a></strong>', $userdata);
|
||||
|
||||
$coursedata = '<div class="adminlink"><a href="../course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.get_string('managecourses').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpcourses').'</span></div>';
|
||||
$coursedata .= '<div class="adminlink"><a href="enrol.php?sesskey='.$USER->sesskey.'">'.get_string('enrolmentplugins').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpenrolments').'</span></div>';
|
||||
$coursedata .= '<div class="adminlink"><a href="../course/index.php?edit=off&sesskey='.$USER->sesskey.'">'.
|
||||
get_string('assignstudents').'</a> - <span class="explanation">'.get_string('adminhelpassignstudents').'</span></div>';
|
||||
$coursedata .= '<div class="adminlink"><a href="../course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.
|
||||
get_string('assignteachers').'</a> - <span class="explanation">'.get_string('adminhelpassignteachers').
|
||||
' <img src="../pix/t/user.gif" height="11" width="11" alt="" /></span></div>';
|
||||
$coursedata .= '<div class="adminlink"><a href="creators.php?sesskey='.$USER->sesskey.'">'.get_string('assigncreators').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpassigncreators').'</span></div>';
|
||||
$coursedata .= '<div class="adminlink"><a href="admin.php?sesskey='.$USER->sesskey.'">'.get_string('assignadmins').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpassignadmins').'</span></div>';
|
||||
|
||||
$table->data[] = array('<strong><a href="courses.php">'.get_string('courses').'</a></strong>', $coursedata);
|
||||
|
||||
$miscdata = '<div class="adminlink"><a href="../files/index.php?id='.$site->id.'">'.get_string('sitefiles').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpsitefiles').'</span></div>';
|
||||
$miscdata .= '<div class="adminlink"><a href="stickyblocks.php">'.get_string('stickyblocks','admin').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpstickyblocks').'</span></div>';
|
||||
$miscdata .= '<div class="adminlink"><a href="report.php">'.get_string('reports').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpreports').'</span></div>';
|
||||
//to be enabled later
|
||||
/* $miscdata .= '<div class="adminlink"><a href="health.php">'.get_string('healthcenter').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelphealthcenter').'</span></div>';*/
|
||||
$miscdata .= '<div class="adminlink"><a href="environment.php">'.get_string('environment', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpenvironment').'</span></div>';
|
||||
/// Optional stuff
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
|
||||
$miscdata .= '<div class="adminlink"><a href="'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagedatabase').'</span></div>';
|
||||
}
|
||||
|
||||
$table->data[] = array('<strong><a href="misc.php">'.get_string('miscellaneous').'</a></strong>', $miscdata);
|
||||
|
||||
|
||||
/// Hooks for Matt Oquists contrib code for repositories and portfolio.
|
||||
/// The eventual official versions may not look like this
|
||||
if (isset($CFG->portfolio) && file_exists("$CFG->dirroot/$CFG->portfolio")) {
|
||||
$table->data[] = array("<strong><a href=\"../portfolio/\">".get_string('portfolio','portfolio').'</a></
|
||||
trong>',
|
||||
'<div class="explanation">'.get_string('adminhelpportfolio','portfolio').'</div>');
|
||||
}
|
||||
|
||||
if (isset($CFG->repo) && file_exists("$CFG->dirroot/$CFG->repo")) {
|
||||
$table->data[] = array("<strong><a href=\"../repository/?repoid=1&action=list\">".get_string('repository','
|
||||
epository').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelprepository','repository').'</div>');
|
||||
}
|
||||
|
||||
|
||||
/// Print slightly annoying registration button
|
||||
|
||||
print_table($table);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO REMOVE OR MODIFY THE COPYRIGHT NOTICE BELOW ////
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/en/Release">'.$CFG->release.'</a> ('.$CFG->version.')<br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
|
||||
echo '<p class="copyright">'.$copyrighttext.'</p>';
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
echo '<div align="center">';
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_box_start('generalbox adminwarning');
|
||||
if(!isset($CFG->registered)) {
|
||||
print_string('pleaseregister', 'admin');
|
||||
}
|
||||
else { /* if (isset($CFG->registered) && $CFG->registered < (time() - 3600*24*30*6)) { */
|
||||
print_string('pleaserefreshregistration', 'admin', userdate($CFG->registered));
|
||||
}
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
print_box_end();
|
||||
echo '</div>';
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/en/Release" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />'.
|
||||
'<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
|
||||
print_box($copyrighttext, 'copyright');
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
if (optional_param('dbmigrate')) { // ??? Is this actually used?
|
||||
print_simple_box_start('center','60%');
|
||||
require_once($CFG->dirroot.'/admin/utfdbmigrate.php');
|
||||
db_migrate2utf8();
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
+10
-21
@@ -1,43 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toinodb');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading('Convert all MySQL tables from MYISAM to InnoDB');
|
||||
|
||||
if ($CFG->dbfamily != 'mysql') {
|
||||
notice('This function is for MySQL databases only!', 'index.php');
|
||||
if (!isadmin()) {
|
||||
error('Admin only');
|
||||
}
|
||||
|
||||
if (data_submitted() and $confirm and confirm_sesskey()) {
|
||||
print_header("Convert all tables from MYISAM to InnoDB", "Convert all tables from MYISAM to InnoDB",
|
||||
"Convert all tables from MYISAM to InnoDB");
|
||||
|
||||
notify('Please be patient and wait for this to complete...', 'notifysuccess');
|
||||
|
||||
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; ");
|
||||
}
|
||||
$db->debug = false;
|
||||
}
|
||||
notify('... done.', 'notifysuccess');
|
||||
print_continue('index.php');
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
} else {
|
||||
$optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
|
||||
notice_yesno('Are you sure you want convert all your tables to the InnoDB format?',
|
||||
'innodb.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
notice_yesno("Are you sure you want convert all your tables to the InnoDB format?",
|
||||
"innodb.php?confirm=1&sesskey=".sesskey(), "index.php");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+289
-1036
File diff suppressed because it is too large
Load Diff
+48
-50
@@ -1,17 +1,15 @@
|
||||
<?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
|
||||
*/
|
||||
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');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('langedit');
|
||||
|
||||
//
|
||||
// Some local configuration
|
||||
@@ -26,15 +24,28 @@
|
||||
|
||||
$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');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
notify('NOTICE: This interface is obsolete now and will be removed. You should use
|
||||
improved <a href="lang.php?mode=helpfiles">lang.php</a> interface.');
|
||||
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";
|
||||
@@ -160,10 +171,7 @@ $langdir/$currentfile")."</font></p>";
|
||||
echo htmlspecialchars(file_get_contents("$enlangdir/$currentfile"));
|
||||
echo "</textarea>\n";
|
||||
//link_to_popup_window("/lang/en_utf8/$currentfile", "popup", get_string("preview"));
|
||||
$preview_url = langdoc_preview_url($currentfile);
|
||||
if ($preview_url) {
|
||||
link_to_popup_window($preview_url.'&forcelang=en_utf8', '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";
|
||||
@@ -171,32 +179,30 @@ $langdir/$currentfile")."</font></p>";
|
||||
echo "<td align=\"center\">\n";
|
||||
|
||||
if ($editable) {
|
||||
echo "<form id=\"$currentfile\" action=\"langdoc.php\" method=\"post\">";
|
||||
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";
|
||||
$preview_url = langdoc_preview_url($currentfile);
|
||||
if ($preview_url) {
|
||||
link_to_popup_window($preview_url, 'popup', get_string('preview'));
|
||||
}
|
||||
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>';
|
||||
}
|
||||
|
||||
echo "</td>\n</tr>\n</table>";
|
||||
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -234,26 +240,18 @@ function langdoc_save_file($path, $file, $content) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a preview URL for the file, if available.
|
||||
*
|
||||
* Documentation will be moved into moodle.org wiki and current version 1.6 does not
|
||||
* seem to be able to display local documentation. Thus, return empty URL for doc files.
|
||||
* See lib/moodlelib.php document_file() - it still relies on old pre-UTF8 lang/ location.
|
||||
*/
|
||||
function langdoc_preview_url($currentfile) {
|
||||
|
||||
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='.implode('/',array_slice($currentpathexp,0,count($currentpathexp)-1)).'&file='.end($currentpathexp);
|
||||
} else {
|
||||
$url = '/help.php?module=moodle&file='.$currentfile;
|
||||
}
|
||||
}
|
||||
$currentpathexp = explode('/', $currentfile);
|
||||
if (count($currentpathexp) > 1) {
|
||||
$url = '/help.php?module='.$currentpathexp[0].'&file='.$currentpathexp[1];
|
||||
} else {
|
||||
$url = '';
|
||||
$url = '/help.php?module=moodle&file='.$currentfile;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
+258
-273
@@ -5,99 +5,108 @@
|
||||
///This helps to avoid confusion.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
admin_externalpage_setup('langimport');
|
||||
|
||||
$mode = optional_param('mode', 0, PARAM_INT); //phase
|
||||
$pack = optional_param('pack', array(), PARAM_FILE); //pack to install
|
||||
$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);
|
||||
|
||||
$strlang = get_string('langimport','admin');
|
||||
$strlanguage = get_string('language');
|
||||
$strthislanguage = get_string('thislanguage');
|
||||
$title = $strlang;
|
||||
require_login();
|
||||
|
||||
//reset and diagnose lang cache permissions
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
if (file_exists($CFG->dataroot.'/cache/languages')) {
|
||||
error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
|
||||
if (!isadmin()) {
|
||||
error('You must be an admin');
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
|
||||
$notice_ok = array();
|
||||
$notice_error = array();
|
||||
|
||||
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() and !empty($pack)) {
|
||||
set_time_limit(0);
|
||||
|
||||
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) {
|
||||
|
||||
if (is_array($pack)) {
|
||||
$packs = $pack;
|
||||
} else {
|
||||
$packs = array($pack);
|
||||
}
|
||||
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;
|
||||
|
||||
foreach ($packs as $pack) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
case INSTALLED:
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack));
|
||||
break;
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new object();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
print_error($cd->get_error(), 'error', 'langimport.php', $a);
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', 'langimport.php');
|
||||
}
|
||||
break;
|
||||
case UPTODATE:
|
||||
break;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackinstalled','admin',$pack);
|
||||
break;
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
notify('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
} 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 ($uninstalllang == 'en_utf8') {
|
||||
$notice_error[] = 'en_utf8 can not be uninstalled!';
|
||||
|
||||
} else if (!$confirm && confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode='.DELETION_OF_SELECTED_LANG.'&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
if (!$confirm && confirm_sesskey()) {
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode=4&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
'langimport.php');
|
||||
print_footer();
|
||||
die;
|
||||
|
||||
} 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;
|
||||
@@ -108,30 +117,31 @@
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
//delete the direcotries
|
||||
if ($rm1 or $rm2) {
|
||||
$notice_ok[] = get_string('langpackremoved','admin');
|
||||
redirect('langimport.php', get_string('langpackremoved','admin'));
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
$notice_error[] = 'An error has occurred, language pack is not completely uninstalled, please check file permissions';
|
||||
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
|
||||
set_time_limit(0);
|
||||
|
||||
//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?
|
||||
$alllangs = array_keys(get_list_of_languages(false, true)); //get all available langs
|
||||
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 = get_remote_list_of_languages()) {
|
||||
print_error('cannotdownloadlanguageupdatelist');
|
||||
if (!$availablelangs = proxy_url($source)) {
|
||||
error ('can not read from course');
|
||||
}
|
||||
|
||||
//and build an associative array
|
||||
@@ -139,12 +149,8 @@
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
//filtering out non-16 and unofficial packs
|
||||
//filtering out non-16 packs
|
||||
foreach ($alllangs as $clang) {
|
||||
if (!array_key_exists($clang, $md5array)) {
|
||||
$notice_ok[] = get_string('langpackupdateskipped', 'admin', $clang);
|
||||
continue;
|
||||
}
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||
|
||||
@@ -166,7 +172,6 @@
|
||||
if ($pack == 'en_utf8') { // no update for en_utf8
|
||||
continue;
|
||||
}
|
||||
|
||||
//1. delete old director(ies)
|
||||
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||
@@ -174,40 +179,38 @@
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)) {
|
||||
if (!remove_dir($dest1)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest1.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)) {
|
||||
if (!remove_dir($dest2)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest2.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
$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 COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
print_error($cd->get_error(), 'error', "", $a); // not probable
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error'); // not probable
|
||||
error(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
case UPTODATE:
|
||||
//Print error string or whatever you want to do
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackupdated', 'admin', $pack);
|
||||
case INSTALLED:
|
||||
notify(get_string('langpackupdated','admin',$pack), 'notifysuccess');
|
||||
$updated = true;
|
||||
//Print/do whatever you want
|
||||
break;
|
||||
@@ -219,187 +222,158 @@
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
$notice_ok[] = get_string('langupdatecomplete','admin');
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php');
|
||||
} else {
|
||||
$notice_ok[] = get_string('nolangupdateneeded','admin');
|
||||
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
|
||||
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$installedlangs = get_list_of_languages(true, true);
|
||||
|
||||
$missingparents = array();
|
||||
$oldlang = isset($SESSION->lang) ? $SESSION->lang : null; // override current lang
|
||||
|
||||
foreach($installedlangs as $l=>$unused) {
|
||||
$SESSION->lang = $l;
|
||||
$parent = get_string('parentlanguage');
|
||||
if ($parent == 'en_utf8') {
|
||||
continue;
|
||||
}
|
||||
if (strpos($parent, '[[') !== false) {
|
||||
continue; // no parent
|
||||
}
|
||||
if (!isset($installedlangs[$parent])) {
|
||||
$missingparents[$l] = $parent;
|
||||
}
|
||||
}
|
||||
if (isset($oldlang)) {
|
||||
$SESSION->lang = $oldlang;
|
||||
} else {
|
||||
unset($SESSION->lang);
|
||||
}
|
||||
|
||||
if ($availablelangs = get_remote_list_of_languages()) {
|
||||
$remote = 1;
|
||||
} else {
|
||||
$remote = 0; //flag for reading from remote or local
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
|
||||
if (!$remote) {
|
||||
print_box_start();
|
||||
print_string('remotelangnotavailable', 'admin', $CFG->dataroot.'/lang/');
|
||||
print_box_end();
|
||||
}
|
||||
|
||||
if ($notice_ok) {
|
||||
$info = implode('<br />', $notice_ok);
|
||||
notify($info, 'notifysuccess');
|
||||
}
|
||||
|
||||
if ($notice_error) {
|
||||
$info = implode('<br />', $notice_error);
|
||||
notify($info, 'notifyproblem');
|
||||
}
|
||||
|
||||
if ($missingparents) {
|
||||
foreach ($missingparents as $l=>$parent) {
|
||||
$a = new object();
|
||||
$a->lang = $installedlangs[$l];
|
||||
$a->parent = $parent;
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == $parent) {
|
||||
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];
|
||||
}
|
||||
$a->parent = $alang[2].' ('.$shortlang.')';
|
||||
}
|
||||
}
|
||||
$info = get_string('missinglangparent', 'admin', $a);
|
||||
notify($info, 'notifyproblem');
|
||||
}
|
||||
}
|
||||
|
||||
print_box_start();
|
||||
echo '<table summary="">';
|
||||
echo '<tr><td align="center" valign="top">';
|
||||
echo '<form id="uninstallform" action="langimport.php?mode='.DELETION_OF_SELECTED_LANG.'" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
|
||||
/// display installed langs here
|
||||
|
||||
echo '<label for="uninstalllang">'.get_string('installedlangs','admin')."</label><br />\n";
|
||||
echo '<select name="uninstalllang" id="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 '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if ($remote) {
|
||||
echo '<form id="updateform" action="langimport.php?mode='.UPDATE_ALL_LANG.'" method="post">';
|
||||
echo '<div>';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
/// Display option to change site language
|
||||
|
||||
/// display to be installed langs here
|
||||
|
||||
echo '</td><td align="center" valign="top">';
|
||||
//availabe langs table
|
||||
$empty = 1; //something to pring
|
||||
|
||||
/// if this language pack is not already installed, then we allow installation
|
||||
|
||||
echo '<form id="installform" method="post" action="langimport.php?mode='.INSTALLATION_OF_SELECTED_LANG.'">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
echo '<label for="pack">'.get_string('availablelangs','admin')."</label><br />\n";
|
||||
if ($remote) {
|
||||
echo '<select name="pack[]" id="pack" size="15" multiple="multiple">';
|
||||
}
|
||||
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == '') {
|
||||
continue;
|
||||
}
|
||||
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></td></tr>';
|
||||
}
|
||||
$empty = 0;
|
||||
}
|
||||
}
|
||||
if ($remote) {
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.$THEME->larrow.' '.get_string('install','admin').'" />';
|
||||
}
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if ($empty) {
|
||||
echo '<br />';
|
||||
print_string('nolanguagetodownload','admin');
|
||||
}
|
||||
|
||||
//close available langs table
|
||||
echo '</td></tr></table>';
|
||||
print_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
/**
|
||||
* Returns a list of available language packs from a
|
||||
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 download components.
|
||||
* this is for site that can't perform fopen
|
||||
* @return array
|
||||
*/
|
||||
function get_local_list_of_languages() {
|
||||
global $CFG;
|
||||
$source = $CFG->dirroot.'/lib/languages.md5';
|
||||
$source = $CFG->wwwroot.'/lib/languages.md5';
|
||||
$availablelangs = array();
|
||||
if ($fp = fopen($source, 'r')) {
|
||||
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,
|
||||
|
||||
/* 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
|
||||
@@ -413,27 +387,38 @@
|
||||
}
|
||||
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;
|
||||
|
||||
/**
|
||||
* Returns the latest list of available language packs from
|
||||
* moodle.org
|
||||
* @return array or false if can not download
|
||||
*/
|
||||
function get_remote_list_of_languages() {
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$availablelangs = array();
|
||||
if ($CFG->proxyhost && $CFG->proxyport) {
|
||||
|
||||
if ($content = download_file_content($source)) {
|
||||
$alllines = split("\n", $content);
|
||||
foreach($alllines as $line) {
|
||||
if (!empty($line)){
|
||||
$availablelangs[] = split(',', $line);
|
||||
}
|
||||
$proxy_fp = fsockopen($CFG->proxyhost, $CFG->proxyport);
|
||||
if (!$proxy_fp) {
|
||||
return false; //failed
|
||||
}
|
||||
return $availablelangs;
|
||||
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 {
|
||||
return false;
|
||||
} 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;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -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(dirname(__FILE__).'/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_somethting() 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);
|
||||
}
|
||||
|
||||
?>
|
||||
+27
-18
@@ -2,11 +2,14 @@
|
||||
// Enables/disables maintenance mode
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
admin_externalpage_setup('maintenancemode');
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You need to be admin to use this page');
|
||||
}
|
||||
|
||||
//Check folder exists
|
||||
if (! make_upload_directory(SITEID)) { // Site folder
|
||||
@@ -19,51 +22,57 @@
|
||||
if (confirm_sesskey()) {
|
||||
if ($form->action == "disable") {
|
||||
unlink($filename);
|
||||
redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
|
||||
redirect('index.php', get_string('sitemaintenanceoff','admin'));
|
||||
} else {
|
||||
$file = fopen($filename, 'w');
|
||||
fwrite($file, stripslashes($form->text));
|
||||
fclose($file);
|
||||
redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
|
||||
redirect('index.php', get_string('sitemaintenanceon', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the header stuff
|
||||
|
||||
admin_externalpage_print_header();
|
||||
$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 '<div style="margin-left:auto;margin-right:auto">';
|
||||
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 '<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 '</div>';
|
||||
echo '</center>';
|
||||
} else { // We are not in maintenance mode
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
echo '<div style="text-align:center;margin-left:auto;margin-right:auto">';
|
||||
echo '<center>';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<div>';
|
||||
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 '<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 '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</center>';
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_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,583 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Adapted for Moodle from the AMFPHP Project at http://www.amfphp.org/
|
||||
* Creates the methodTable for a service class.
|
||||
*
|
||||
* @usage $this->methodTable = MethodTable::create($this);
|
||||
* @author Christophe Herreman
|
||||
* @since 05/01/2005
|
||||
* @version $id$
|
||||
*
|
||||
* Special contributions by Allessandro Crugnola and Ted Milker
|
||||
*/
|
||||
|
||||
if (!defined('T_ML_COMMENT')) {
|
||||
define('T_ML_COMMENT', T_COMMENT);
|
||||
} else {
|
||||
define('T_DOC_COMMENT', T_ML_COMMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string from start of haystack to first occurance of needle, or whole
|
||||
* haystack, if needle does not occur
|
||||
*
|
||||
* @access public
|
||||
* @param $haystack(String) Haystack to search in
|
||||
* @param $needle(String) Needle to look for
|
||||
*/
|
||||
function strrstr($haystack, $needle)
|
||||
{
|
||||
return substr($haystack, 0, strpos($haystack.$needle,$needle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return substring of haystack from end of needle onwards, or FALSE
|
||||
*
|
||||
* @access public
|
||||
* @param $haystack(String) Haystack to search in
|
||||
* @param $needle(String) Needle to look for
|
||||
*/
|
||||
function strstrafter($haystack, $needle)
|
||||
{
|
||||
return substr(strstr($haystack, $needle), strlen($needle));
|
||||
}
|
||||
|
||||
class MethodTable
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Since this class should only be accessed through the static create() method
|
||||
* this constructor should be made private. Unfortunately, this is not possible
|
||||
* in PHP4.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function MethodTable(){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the methodTable for a passed class.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param $sourcePath(String) The path to the file you want to parse
|
||||
* @param $containsClass(Bool) True if the file is a class definition (optional)
|
||||
*/
|
||||
function create($sourcePath, $containsClass = false){
|
||||
|
||||
$methodTable = array();
|
||||
if(!file_exists($sourcePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$source = file_get_contents($sourcePath);
|
||||
$tokens = (array)token_get_all($source);
|
||||
|
||||
$waitingForOpenParenthesis = false;
|
||||
$waitingForFunction = false;
|
||||
$waitingForClassName = false;
|
||||
$bufferingArgs = false;
|
||||
$argBuffer = "";
|
||||
$lastFunction = "";
|
||||
$lastFunctionComment = "";
|
||||
$lastComment = "";
|
||||
$classMethods = array();
|
||||
$realClassName = "";
|
||||
|
||||
if($containsClass) {
|
||||
$openBraces = -10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
$openBraces = 1;
|
||||
}
|
||||
|
||||
$waitingForEndEncapsedString = false;
|
||||
foreach($tokens as $token)
|
||||
{
|
||||
if (is_string($token)) {
|
||||
if($token == '{')
|
||||
{
|
||||
$openBraces++;
|
||||
}
|
||||
if($token == '}')
|
||||
{
|
||||
if($waitingForEndEncapsedString)
|
||||
{
|
||||
$waitingForEndEncapsedString = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastComment = '';
|
||||
$openBraces--;
|
||||
|
||||
if($openBraces == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($waitingForOpenParenthesis && $token == '(')
|
||||
{
|
||||
$bufferingArgs = true;
|
||||
$argBuffer = "";
|
||||
$waitingForOpenParenthesis = false;
|
||||
}
|
||||
elseif($bufferingArgs)
|
||||
{
|
||||
if($token != ')')
|
||||
{
|
||||
$argBuffer .= $token;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($lastFunction != $realClassName)
|
||||
{
|
||||
$classMethods[] = array("name" => $lastFunction,
|
||||
"comment" => $lastFunctionComment,
|
||||
"args" => $argBuffer);
|
||||
|
||||
$bufferingArgs = false;
|
||||
$argBuffer = "";
|
||||
$lastFunction = "";
|
||||
$lastFunctionComment = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// token array
|
||||
list($id, $text) = $token;
|
||||
|
||||
if($bufferingArgs)
|
||||
{
|
||||
$argBuffer .= $text;
|
||||
}
|
||||
switch ($id)
|
||||
{
|
||||
|
||||
case T_COMMENT:
|
||||
case T_ML_COMMENT: // we've defined this
|
||||
case T_DOC_COMMENT: // and this
|
||||
// no action on comments
|
||||
$lastComment = $text;
|
||||
break;
|
||||
case T_FUNCTION:
|
||||
if($openBraces >= 1)
|
||||
{
|
||||
$waitingForFunction = true;
|
||||
}
|
||||
break;
|
||||
case T_STRING:
|
||||
if($waitingForFunction)
|
||||
{
|
||||
$waitingForFunction = false;
|
||||
$waitingForOpenParenthesis = true;
|
||||
$lastFunction = $text;
|
||||
$lastFunctionComment = $lastComment;
|
||||
$lastComment = "";
|
||||
}
|
||||
if($waitingForClassName)
|
||||
{
|
||||
$waitingForClassName = false;
|
||||
$realClassName = $text;
|
||||
}
|
||||
break;
|
||||
case T_CLASS:
|
||||
$openBraces = 0;
|
||||
$waitingForClassName = true;
|
||||
break;
|
||||
case T_CURLY_OPEN:
|
||||
case T_DOLLAR_OPEN_CURLY_BRACES:
|
||||
$waitingForEndEncapsedString = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($classMethods as $key => $value) {
|
||||
$methodSignature = $value['args'];
|
||||
$methodName = $value['name'];
|
||||
$methodComment = $value['comment'];
|
||||
|
||||
$description = MethodTable::getMethodDescription($methodComment) . " " . MethodTable::getMethodCommentAttribute($methodComment, "desc");
|
||||
$description = trim($description);
|
||||
$access = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "access");
|
||||
$roles = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "roles");
|
||||
$instance = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "instance");
|
||||
$returns = MethodTable::getMethodReturnValue($methodComment);
|
||||
$pagesize = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "pagesize");
|
||||
$params = MethodTable::getMethodCommentArguments($methodComment);
|
||||
|
||||
|
||||
//description, arguments, access, [roles, [instance, [returns, [pagesize]]]]
|
||||
$methodTable[$methodName] = array();
|
||||
//$methodTable[$methodName]["signature"] = $methodSignature; //debug purposes
|
||||
$methodTable[$methodName]["description"] = ($description == "") ? "No description given." : $description;
|
||||
$methodTable[$methodName]["arguments"] = MethodTable::getMethodArguments($methodSignature, $params);
|
||||
$methodTable[$methodName]["access"] = ($access == "") ? "private" : $access;
|
||||
|
||||
if($roles != "") $methodTable[$methodName]["roles"] = $roles;
|
||||
if($instance != "") $methodTable[$methodName]["instance"] = $instance;
|
||||
if($returns != "") $methodTable[$methodName]["returns"] = $returns;
|
||||
if($pagesize != "") $methodTable[$methodName]["pagesize"] = $pagesize;
|
||||
}
|
||||
|
||||
return $methodTable;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getMethodCommentServices($comment)
|
||||
{
|
||||
$pieces = explode('@service', $comment);
|
||||
$args = array();
|
||||
if(is_array($pieces) && count($pieces) > 1)
|
||||
{
|
||||
for($i = 0; $i < count($pieces) - 1; $i++)
|
||||
{
|
||||
$ps = strrstr($pieces[$i + 1], '@');
|
||||
$ps = strrstr($ps, '*/');
|
||||
$args[] = MethodTable::cleanComment($ps);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getMethodCommentArguments($comment)
|
||||
{
|
||||
$pieces = explode('@param', $comment);
|
||||
$args = array();
|
||||
if(is_array($pieces) && count($pieces) > 1)
|
||||
{
|
||||
for($i = 0; $i < count($pieces) - 1; $i++)
|
||||
{
|
||||
$ps = strrstr($pieces[$i + 1], '@');
|
||||
$ps = strrstr($ps, '*/');
|
||||
$args[] = MethodTable::cleanComment($ps);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description from the comment.
|
||||
* The description is(are) the first line(s) in the comment.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
*/
|
||||
function getMethodDescription($comment){
|
||||
$comment = MethodTable::cleanComment(strrstr($comment, "@"));
|
||||
return trim($comment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodCommentAttribute($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
return MethodTable::cleanComment($pieces);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodCommentAttributeFirstLine($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, "*");
|
||||
$pieces = strrstr($pieces, "/");
|
||||
$pieces = strrstr($pieces, "-");
|
||||
$pieces = strrstr($pieces, "\n");
|
||||
$pieces = strrstr($pieces, "\r");
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
return MethodTable::cleanComment($pieces);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodReturnValue($comment){
|
||||
$result = array('type' => 'void', 'description' => '');
|
||||
$pieces = strstrafter($comment, '@returns');
|
||||
if(FALSE == $pieces) $pieces = strstrafter($comment, '@return');
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, "*");
|
||||
$pieces = strrstr($pieces, "/");
|
||||
$pieces = strrstr($pieces, "-");
|
||||
$pieces = strrstr($pieces, "\n");
|
||||
$pieces = strrstr($pieces, "\r");
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
$pieces = trim(MethodTable::cleanComment($pieces));
|
||||
@list($result['type'], $result['description']) = explode(' ', $pieces, 2);
|
||||
$result['type'] = MethodTable::standardizeType($result['type']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getMethodCommentAttributeFirstWord($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$val = MethodTable::cleanComment($pieces);
|
||||
return trim(strrstr($val, ' '));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with the arguments of a method.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $methodSignature(String) The method's signature;
|
||||
*/
|
||||
function getMethodArguments($methodSignature, $commentParams){
|
||||
if(strlen($methodSignature) == 0){
|
||||
//no arguments, return an empty array
|
||||
$result = array();
|
||||
}else{
|
||||
//clean the arguments before returning them
|
||||
$result = MethodTable::cleanArguments(explode(",", $methodSignature), $commentParams);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the function or method's return value.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $value(String) The "dirty" value.
|
||||
*/
|
||||
function cleanReturnValue($value){
|
||||
$result = array();
|
||||
$value = trim($value);
|
||||
|
||||
list($result['type'], $result['description']) = explode(' ', $value, 2);
|
||||
|
||||
$result['type'] = MethodTable::standardizeType($result['type']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes a string and returns the XMLRPC type that most closely matches it.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $type(String) The given type string.
|
||||
*/
|
||||
function standardizeType($type) {
|
||||
$type = strtolower($type);
|
||||
if('str' == $type || 'string' == $type) return 'string';
|
||||
if('int' == $type || 'integer' == $type) return 'int';
|
||||
if('bool' == $type || 'boolean' == $type) return 'boolean';
|
||||
|
||||
// Note that object is not a valid XMLRPC type
|
||||
if('object' == $type || 'class' == $type) return 'object';
|
||||
if('float' == $type || 'dbl' == $type || 'double' == $type || 'flt' == $type) return 'double';
|
||||
|
||||
// Note that null is not a valid XMLRPC type. The null type can have
|
||||
// only one value - null.
|
||||
if('null' == $type) return 'null';
|
||||
|
||||
// Note that mixed is not a valid XMLRPC type
|
||||
if('mixed' == $type) return 'mixed';
|
||||
if('array' == $type || 'arr' == $type) return 'array';
|
||||
if('assoc' == $type || 'struct' == $type) return 'struct';
|
||||
|
||||
// Note that this is not a valid XMLRPC type. As references cannot be
|
||||
// serialized or exported, there is no way this could be XML-RPCed.
|
||||
if('reference' == $type || 'ref' == $type) return 'reference';
|
||||
return 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the arguments array.
|
||||
* This method removes all whitespaces and the leading "$" sign from each argument
|
||||
* in the array.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $args(Array) The "dirty" array with arguments.
|
||||
*/
|
||||
function cleanArguments($args, $commentParams){
|
||||
$result = array();
|
||||
|
||||
if(!is_array($args)) return array();
|
||||
|
||||
foreach($args as $index => $arg){
|
||||
$arg = strrstr(str_replace(array('$','&$'), array('','&'), $arg), '=');
|
||||
if(!isset($commentParams[$index]))
|
||||
{
|
||||
$result[] = trim($arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = trim($arg);
|
||||
$end = trim(str_replace('$', '', $commentParams[$index]));
|
||||
|
||||
// Suppress Notice of 'Undefined offset' with @
|
||||
@list($word0, $word1, $tail) = preg_split("/[\s]+/", $end, 3);
|
||||
$word0 = strtolower($word0);
|
||||
$word1 = strtolower($word1);
|
||||
|
||||
$wordBase0 = ereg_replace('^[&$]+','',$word0);
|
||||
$wordBase1 = ereg_replace('^[&$]+','',$word1);
|
||||
$startBase = strtolower(ereg_replace('^[&$]+','',$start));
|
||||
|
||||
if ($wordBase0 == $startBase) {
|
||||
$type = str_replace(array('(',')'),'', $word1);
|
||||
} elseif($wordBase1 == $startBase) {
|
||||
$type = str_replace(array('(',')'),'', $word0);
|
||||
} elseif( ereg('(^[&$]+)|(\()([a-z0-9]+)(\)$)', $word0, $regs) ) {
|
||||
$tail = str_ireplace($word0, '', $end);
|
||||
$type = $regs[3];
|
||||
} else {
|
||||
// default to string
|
||||
$type = 'string';
|
||||
}
|
||||
|
||||
$type = MethodTable::standardizeType($type);
|
||||
/*
|
||||
if($type == 'str') {
|
||||
$type = 'string';
|
||||
} elseif($type == 'int' || $type == 'integer') {
|
||||
$type = 'int';
|
||||
} elseif($type == 'bool' || $type == 'boolean') {
|
||||
$type = 'boolean';
|
||||
} elseif($type == 'object' || $type == 'class') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
$type = 'object';
|
||||
} elseif($type == 'float' || $type == 'dbl' || $type == 'double' || $type == 'flt') {
|
||||
$type = 'double';
|
||||
} elseif($type == 'null') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
// The null type can have only one value - null. Why would
|
||||
// that be an argument to a function? Just in case:
|
||||
$type = 'null';
|
||||
} elseif($type == 'mixed') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
$type = 'mixed';
|
||||
} elseif($type == 'array' || $type == 'arr') {
|
||||
$type = 'array';
|
||||
} elseif($type == 'assoc') {
|
||||
$type = 'struct';
|
||||
} elseif($type == 'reference' || $type == 'ref') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
// As references cannot be serialized or exported, there is
|
||||
// no way this could be XML-RPCed.
|
||||
$type = 'reference';
|
||||
} else {
|
||||
$type = 'string';
|
||||
}
|
||||
*/
|
||||
$result[] = array('type' => $type, 'description' => $start . ' - ' . $tail);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleans the comment string by removing all comment start and end characters.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
*/
|
||||
function cleanComment($comment){
|
||||
$comment = str_replace("/**", "", $comment);
|
||||
$comment = str_replace("*/", "", $comment);
|
||||
$comment = str_replace("*", "", $comment);
|
||||
$comment = str_replace("\n", "\\n", trim($comment));
|
||||
$comment = eregi_replace("[\r\t\n ]+", " ", trim($comment));
|
||||
$comment = str_replace("\"", "\\\"", $comment);
|
||||
return $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function showCode($methodTable){
|
||||
|
||||
if(!is_array($methodTable)) $methodTable = array();
|
||||
|
||||
foreach($methodTable as $methodName=>$methodProps){
|
||||
$result .= "\n\t\"" . $methodName . "\" => array(";
|
||||
|
||||
foreach($methodProps as $key=>$value){
|
||||
$result .= "\n\t\t\"" . $key . "\" => ";
|
||||
|
||||
if($key=="arguments"){
|
||||
$result .= "array(";
|
||||
for($i=0; $i<count($value); $i++){
|
||||
$result .= "\"" . addslashes($value[$i]) . "\"";
|
||||
if($i<count($value)-1){
|
||||
$result .= ", ";
|
||||
}
|
||||
}
|
||||
$result .= ")";
|
||||
}else{
|
||||
$result .= "\"" . $value . "\"";
|
||||
}
|
||||
|
||||
$result .= ",";
|
||||
}
|
||||
|
||||
$result = substr($result, 0, -1);
|
||||
$result .= "\n\t),";
|
||||
}
|
||||
|
||||
$result = substr($result, 0, -1);
|
||||
$result = "\$this->methodTable = array(" . $result;
|
||||
$result .= "\n);";
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,237 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Allows the admin to control user logins from remote moodles.
|
||||
|
||||
require_once dirname(dirname(dirname(__FILE__))) . '/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');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sesskey = sesskey();
|
||||
$formerror = array();
|
||||
|
||||
// grab the mnet hosts and remove the localhost
|
||||
$mnethosts = get_records_menu('mnet_host', '', '', '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 = get_record('mnet_sso_access_control', 'id', $id)) {
|
||||
print_error('recordnoexists','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case "delete":
|
||||
delete_records('mnet_sso_access_control', 'id', $id);
|
||||
redirect('access_control.php', get_string('deleteuserrecord', 'mnet', array($idrec->username, $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($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
} elseif ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($idrec->username, $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(moodle_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($username, $mnethosts[$form->mnet_host_id])));
|
||||
} elseif ($form->accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($username, $mnethosts[$form->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Explain
|
||||
print_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 (get_config('auth/mnet', 'auto_add_remote_users') != true) {
|
||||
$warn .= '<p>' . get_string('authmnetautoadddisabled','mnet').'</p>';
|
||||
}
|
||||
if (!empty($warn)) {
|
||||
$warn = '<p>' . get_string('ssoaclneeds','mnet').'</p>' . $warn;
|
||||
print_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 = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\" />";
|
||||
}
|
||||
$headings[$column] = "<a href=\"?sort=$column&dir=$columndir&\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
$headings['delete'] = '';
|
||||
$acl = get_records('mnet_sso_access_control', '', '', "$sort $dir", '*'); //, $page * $perpage, $perpage);
|
||||
$aclcount = count_records('mnet_sso_access_control');
|
||||
|
||||
if (!$acl) {
|
||||
print_heading(get_string('noaclentries','mnet'));
|
||||
$table = NULL;
|
||||
} else {
|
||||
$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={$USER->sesskey}\">"
|
||||
. get_string('deny', 'mnet') . "</a>)";
|
||||
} else {
|
||||
$accesscolumn = get_string('deny', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=allow&sesskey={$USER->sesskey}\">"
|
||||
. get_string('allow', 'mnet') . "</a>)";
|
||||
}
|
||||
$deletecolumn = "<a href=\"?id={$aclrecord->id}&action=delete&sesskey={$USER->sesskey}\">"
|
||||
. get_string('delete') . "</a>";
|
||||
$table->data[] = array ($aclrecord->username, $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($table)) {
|
||||
print_table($table);
|
||||
echo '<p> </p>';
|
||||
print_paging_bar($aclcount, $page, $perpage, "?sort=$sort&dir=$dir&perpage=$perpage&");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// output the add form
|
||||
print_simple_box_start('center','90%','','20');
|
||||
|
||||
?>
|
||||
<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 '<input type="text" name="username" size="20" maxlength="100" />';
|
||||
|
||||
// choose a remote host
|
||||
echo " " . get_string('remotehost', 'mnet') . ":\n";
|
||||
if (!empty($formerror['mnet_host_id'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
choose_from_menu($mnethosts, 'mnet_host_id');
|
||||
|
||||
// choose an access level
|
||||
echo " " . get_string('accesslevel', 'mnet') . ":\n";
|
||||
if (!empty($formerror['accessctrl'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
$accessmenu['allow'] = get_string('allow', 'mnet');
|
||||
$accessmenu['deny'] = get_string('deny', 'mnet');
|
||||
choose_from_menu($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>";
|
||||
}
|
||||
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Library functions for 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse a file to find out what functions/methods exist in it, and add entries
|
||||
* for the remote-call-enabled functions to the database.
|
||||
*
|
||||
* The path to a file, e.g. auth/mnet/auth.php can be thought of as
|
||||
* type/parentname/docname
|
||||
*
|
||||
* @param string $type mod, auth or enrol
|
||||
* @param string $parentname Implementation of type, e.g. 'mnet' in the
|
||||
* case of auth/mnet/auth.php
|
||||
* @return bool True on success, else false
|
||||
*/
|
||||
function mnet_get_functions($type, $parentname) {
|
||||
global $CFG;
|
||||
$dataobject = new stdClass();
|
||||
$docname = $type.'.php';
|
||||
$publishes = array();
|
||||
if ('mod' == $type) {
|
||||
$docname = 'rpclib.php';
|
||||
$relname = '/mod/'.$parentname.'/'.$docname;
|
||||
$filename = $CFG->dirroot.$relname;
|
||||
if (file_exists($filename)) include_once $filename;
|
||||
$mnet_publishes = $parentname.'_mnet_publishes';
|
||||
if (function_exists($mnet_publishes)) {
|
||||
(array)$publishes = $mnet_publishes();
|
||||
}
|
||||
} else {
|
||||
// auth or enrol
|
||||
$relname = '/'.$type.'/'.$parentname.'/'.$docname;
|
||||
$filename = $CFG->dirroot.$relname;
|
||||
if (file_exists($filename)) include_once $filename;
|
||||
$class = $type.($type=='enrol'? 'ment':'').'_plugin_'.$parentname;
|
||||
if (class_exists($class)) {
|
||||
$object = new $class();
|
||||
if (method_exists($object, 'mnet_publishes')) {
|
||||
(array)$publishes = $object->mnet_publishes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$methodServiceArray = array();
|
||||
foreach($publishes as $service) {
|
||||
if (is_array($service['methods'])) {
|
||||
foreach($service['methods'] as $methodname) {
|
||||
$methodServiceArray[$methodname][] = $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable functions that don't exist (any more) in the source
|
||||
// Should these be deleted? What about their permissions records?
|
||||
$rpcrecords = get_records_select('mnet_rpc', ' parent=\''.$parentname.'\' AND parent_type=\''.$type.'\' ', 'function_name ASC ');
|
||||
if (!empty($rpcrecords)) {
|
||||
foreach($rpcrecords as $rpc) {
|
||||
if (!array_key_exists($rpc->function_name, $methodServiceArray)) {
|
||||
$rpc->enabled = 0;
|
||||
update_record('mnet_rpc', $rpc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($filename)) return false;
|
||||
|
||||
if (extension_loaded('tokenizer')) {
|
||||
include_once "$CFG->dirroot/$CFG->admin/mnet/MethodTable.php";
|
||||
$functions = (array)MethodTable::create($filename,false);
|
||||
}
|
||||
|
||||
foreach($methodServiceArray as $method => $servicearray) {
|
||||
if (!empty($functions[$method])) {
|
||||
$details = $functions[$method];
|
||||
$profile = $details['arguments'];
|
||||
if (!isset($details['returns'])) {
|
||||
array_unshift($profile, array('type' => 'void', 'description' => 'No return value'));
|
||||
} else {
|
||||
array_unshift($profile, $details['returns']);
|
||||
}
|
||||
$dataobject->profile = serialize($profile);
|
||||
$dataobject->help = addslashes($details['description']);
|
||||
} else {
|
||||
$dataobject->profile = serialize(array(array('type' => 'void', 'description' => 'No return value')));
|
||||
$dataobject->help = '';
|
||||
}
|
||||
|
||||
$dataobject->function_name = $method;
|
||||
$dataobject->xmlrpc_path = $type.'/'.$parentname.'/'.$docname.'/'.$method;
|
||||
$dataobject->parent_type = $type;
|
||||
$dataobject->parent = $parentname;
|
||||
$dataobject->enabled = '0';
|
||||
|
||||
if ($record_exists = get_record('mnet_rpc', 'xmlrpc_path', $dataobject->xmlrpc_path)) {
|
||||
$dataobject->id = $record_exists->id;
|
||||
$dataobject->enabled = $record_exists->enabled;
|
||||
update_record('mnet_rpc', $dataobject);
|
||||
} else {
|
||||
$dataobject->id = insert_record('mnet_rpc', $dataobject, true);
|
||||
}
|
||||
|
||||
foreach($servicearray as $service) {
|
||||
$serviceobj = get_record('mnet_service', 'name', $service['name']);
|
||||
if (false == $serviceobj) {
|
||||
$serviceobj = new stdClass();
|
||||
$serviceobj->name = $service['name'];
|
||||
$serviceobj->apiversion = $service['apiversion'];
|
||||
$serviceobj->offer = 1;
|
||||
$serviceobj->id = insert_record('mnet_service', $serviceobj, true);
|
||||
}
|
||||
|
||||
if (false == get_record('mnet_service2rpc', 'rpcid', $dataobject->id, 'serviceid', $serviceobj->id)) {
|
||||
$obj = new stdClass();
|
||||
$obj->rpcid = $dataobject->id;
|
||||
$obj->serviceid = $serviceobj->id;
|
||||
insert_record('mnet_service2rpc', $obj, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function upgrade_RPC_functions($returnurl) {
|
||||
global $CFG;
|
||||
|
||||
$basedir = $CFG->dirroot.'/mod';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('mod', $dir);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$basedir = $CFG->dirroot.'/auth';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('auth', $dir);
|
||||
}
|
||||
}
|
||||
|
||||
$basedir = $CFG->dirroot.'/enrol';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('enrol', $dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => "$CFG->wwwroot/$CFG->admin/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => get_string('mnetsettings', 'mnet'), 'link' => "$CFG->wwwroot/$CFG->admin/mnet/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => get_string('deletehost', 'mnet'), 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$site->shortname: $strmnetsettings", "$site->fullname", $navigation);
|
||||
|
||||
print_heading(get_string('mnetsettings', 'mnet'));
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<table class="generalbox standard" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><span><?php print_string('deleteaserver', 'mnet'); ?>Deleting a Server</span></td>
|
||||
</tr>
|
||||
<?php
|
||||
if (count($warn) > 0){
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right" colspan="2"><?php print_string('receivedwarnings','mnet'); ?>:<br />
|
||||
<?php foreach($warn as $warning) echo $warning .'<br />'; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><?php print_string('reallydeleteserver','mnet'); ?>: "<?php echo $mnet_peer->name; ?>"?</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td width="80">
|
||||
<form method="post" action="delete.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="hostid" value="<?php echo $mnet_peer->id; ?>" />
|
||||
<input type="hidden" name="step" value="delete" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>"/>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="get" action="index.php">
|
||||
<input type="submit" name="ignore" value="<?php print_string('cancel'); ?>"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
require_login();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
$step = optional_param('step', 'verify', PARAM_ALPHA);
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$warn = array();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
redirect('index.php', get_string('postrequired','mnet') ,7);
|
||||
}
|
||||
|
||||
if ('verify' == $step) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$live_users = $mnet_peer->count_live_sessions();
|
||||
if ($live_users > 0) {
|
||||
$warn[] = get_string('usersareonline', 'mnet', $live_users);
|
||||
}
|
||||
include('delete.html');
|
||||
} elseif ('delete' == $step) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$mnet_peer->delete();
|
||||
redirect('peers.php', get_string('hostdeleted', 'mnet'), 5);
|
||||
}
|
||||
?>
|
||||
@@ -1,104 +0,0 @@
|
||||
|
||||
<form id="assignform" method="post" action="">
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
<input type="hidden" name="host" value="<?php p($mnet_peer->id) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<table class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php print_string('existingusers', 'role', count($mnetenrolledusers)); ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php print_string('potentialusers', 'role', $availableusers->_numOfRows); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=false;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($mnetenrolledusers as $enrolleduser) {
|
||||
$fullname = fullname($enrolleduser, true);
|
||||
echo "<option value=\"$enrolleduser->id\">".s($fullname)." (".s($enrolleduser->rolename).")</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="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=false;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($enrolledusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
|
||||
} else {
|
||||
if ($availableusers->_numOfRows > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$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 ="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
getElementById('assignform').previoussearch.value=1;
|
||||
getElementById('assignform').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>
|
||||
<tr>
|
||||
<td valign="top"><?php print_string('otherenrolledusers', 'mnet'); ?>:<br />
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($remtenrolledusers as $enrolleduser) {
|
||||
$fullname = fullname($enrolleduser, true);
|
||||
print '<li>'
|
||||
. s($fullname) . ' (' . s($enrolleduser->rolename) . ') '
|
||||
. s($enrolleduser->enroltype)."</li>\n";
|
||||
}
|
||||
?></ul></td>
|
||||
<td valign="top"></td>
|
||||
<td valign="top"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1,279 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/xmlrpc/client.php');
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
$mnethostid = required_param('host', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
if (!$mnet_peer->set_id($mnethostid)) {
|
||||
print_error('hostcoursenotfound','mnet');
|
||||
}
|
||||
|
||||
$course = get_record('mnet_enrol_course', 'id', $courseid, 'hostid', $mnet_peer->id);
|
||||
|
||||
if (empty($course)) {
|
||||
print_error('hostcoursenotfound','mnet');
|
||||
}
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 5000);
|
||||
|
||||
$add = optional_param('add', 0, PARAM_BOOL);
|
||||
$remove = optional_param('remove', 0, PARAM_BOOL);
|
||||
$showall = optional_param('showall', 0, PARAM_BOOL);
|
||||
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
|
||||
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
|
||||
$errors = array();
|
||||
|
||||
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
|
||||
|
||||
$baseurl = "remote_enrolment.php?courseid={$course->id}&host={$mnet_peer->id}";
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
|
||||
/// Process incoming role assignment
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
|
||||
$timemodified = time();
|
||||
|
||||
foreach ($frm->addselect as $adduser) {
|
||||
if (!$adduser = clean_param($adduser, PARAM_INT)) {
|
||||
continue;
|
||||
}
|
||||
if (! $enrolment->req_enrol_user($adduser, $course->id)) {
|
||||
$errors[] = "Could not add user with id $adduser to course {$course->id}!";
|
||||
}
|
||||
}
|
||||
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
if (! $enrolment->req_unenrol_user($removeuser, $course->id)) {
|
||||
$errors[] = "Could not remove user with id $removeuser from course {$course->id}!";
|
||||
}
|
||||
}
|
||||
} else if ($showall) {
|
||||
$searchtext = '';
|
||||
$previoussearch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepare data for users / enrolled users panes
|
||||
|
||||
|
||||
/// Create a new request object
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
/// Pass it the path to the method that we want to execute
|
||||
$mnet_request->set_method('enrol/mnet/enrol.php/course_enrolments');
|
||||
$mnet_request->add_param($course->remoteid, 'int');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$all_enrolled_users = $mnet_request->response;
|
||||
|
||||
unset($mnet_request);
|
||||
|
||||
$select = '';
|
||||
$all_enrolled_usernames = '';
|
||||
$timemodified = array();
|
||||
/// List all the users (homed on this server) who are enrolled on the course
|
||||
/// This will include mnet-enrolled users, and those who have enrolled
|
||||
/// themselves, etc.
|
||||
if (is_array($all_enrolled_users) && count($all_enrolled_users)) {
|
||||
foreach($all_enrolled_users as $username => $data) {
|
||||
$all_enrolled_usernames .= "'$username', ";
|
||||
}
|
||||
$select = ' u.username IN (' .substr($all_enrolled_usernames, 0, -2) .') AND ';
|
||||
} else {
|
||||
$all_enrolled_users = array();
|
||||
}
|
||||
|
||||
/// Synch our mnet_enrol_assignments with remote server
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
u.username,
|
||||
u.email,
|
||||
a.enroltype,
|
||||
a.id as enrolid,
|
||||
COALESCE(a.hostid, 0) as wehaverecord,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u
|
||||
LEFT JOIN
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
ON
|
||||
a.userid = u.id AND a.courseid={$courseid}
|
||||
WHERE
|
||||
$select
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$enrolledusers = get_records_sql($sql)) {
|
||||
$enrolledusers = array();
|
||||
}
|
||||
|
||||
foreach($enrolledusers as $user) {
|
||||
|
||||
$dataobj = new stdClass();
|
||||
$dataobj->userid = $user->id;
|
||||
$dataobj->hostid = $mnet_peer->id;
|
||||
$dataobj->courseid = $courseid;
|
||||
$dataobj->rolename = $all_enrolled_users[$user->username]['name'];
|
||||
$dataobj->enroltype = $all_enrolled_users[$user->username]['enrol'];
|
||||
|
||||
if ($user->wehaverecord == 0) {
|
||||
$dataobj->enroltime = $all_enrolled_users[$user->username]['timemodified'];
|
||||
$dataobj->id = insert_record('mnet_enrol_assignments', $dataobj);
|
||||
} elseif (array_key_exists($user->username, $all_enrolled_users)) {
|
||||
$dataobj->id = $user->enrolid;
|
||||
update_record('mnet_enrol_assignments', $dataobj);
|
||||
} elseif (is_array($all_enrolled_users) && count($all_enrolled_users)) {
|
||||
delete_record('mnet_enrol_assignments', 'id', $user->enrolid);
|
||||
}
|
||||
}
|
||||
unset($enrolledusers);
|
||||
|
||||
// Read about our remote enrolments in 2 sets
|
||||
// first, get the remote enrolments done via enrol/mnet $mnetenrolledusers
|
||||
// second, get the remote enrolments done with other plugins $remtenrolledusers
|
||||
// NOTE: both arrays are keyed on the userid!
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
a.rolename,
|
||||
a.enroltype,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
WHERE
|
||||
a.userid = u.id AND
|
||||
a.courseid={$courseid} AND
|
||||
a.enroltype = 'mnet' AND
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$mnetenrolledusers = get_records_sql($sql)) {
|
||||
$mnetenrolledusers = array();
|
||||
}
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
a.rolename,
|
||||
a.enroltype,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
WHERE
|
||||
a.userid = u.id AND
|
||||
a.courseid={$courseid} AND
|
||||
a.enroltype != 'mnet' AND
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$remtenrolledusers = get_records_sql($sql)) {
|
||||
$remtenrolledusers = array();
|
||||
}
|
||||
|
||||
$select = '';
|
||||
$exclude = array_merge(array_keys($mnetenrolledusers), array_keys($remtenrolledusers));
|
||||
$exclude[] = 0;
|
||||
$select = 'AND u.username!=\'guest\' AND u.id NOT IN ('. join(',',$exclude) .') ';
|
||||
unset($exclude);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
|
||||
if ($searchtext !== '') { // Search for a subset of remaining users
|
||||
$LIKE = sql_ilike();
|
||||
$FULLNAME = sql_fullname();
|
||||
|
||||
$select .= " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
}
|
||||
|
||||
$sql = ('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user u
|
||||
WHERE deleted = 0 AND confirmed = 1
|
||||
AND mnethostid = '.$CFG->mnet_localhost_id.' '
|
||||
.$select
|
||||
.'ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
$availableusers = get_recordset_sql($sql, 0, MAX_USERS_PER_PAGE);
|
||||
|
||||
|
||||
|
||||
/// Print the page
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
/// Get some language strings
|
||||
|
||||
$strpotentialusers = get_string('potentialusers', 'role');
|
||||
$strexistingusers = get_string('existingusers', 'role');
|
||||
$straction = get_string('assignroles', 'role');
|
||||
$strroletoassign = get_string('roletoassign', 'role');
|
||||
$strcurrentcontext = get_string('currentcontext', 'role');
|
||||
$strsearch = get_string('search');
|
||||
$strshowall = get_string('showall');
|
||||
$strparticipants = get_string('participants');
|
||||
$strsearchresults = get_string('searchresults');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box('<strong>' . s($mnet_peer->name) . ' : '
|
||||
. format_string($course->shortname) .' '. format_string($course->fullname)
|
||||
. '</strong><br />'
|
||||
. get_string("enrolcourseenrol_desc", "mnet"));
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
include(dirname(__FILE__).'/enr_course_enrol.html');
|
||||
|
||||
if (!empty($errors)) {
|
||||
$msg = '<p>';
|
||||
foreach ($errors as $e) {
|
||||
$msg .= $e.'<br />';
|
||||
}
|
||||
$msg .= '</p>';
|
||||
notify($msg);
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
$mnethost = required_param('host', PARAM_INT);
|
||||
$host = get_record('mnet_host', 'id', $mnethost);
|
||||
|
||||
$courses = $enrolment->fetch_remote_courses($mnethost);
|
||||
|
||||
/// Print the page
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box('<strong>' . s($host->name) . ' </strong><br />'
|
||||
. get_string("enrolcourses_desc", "mnet"));
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
|
||||
. '<table class="generaltable">';
|
||||
|
||||
$icon = "<img src=\"$CFG->pixpath/i/course.gif\"".
|
||||
" class=\"icon\" alt=\"".get_string("course")."\" />";
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$link = "$CFG->wwwroot/$CFG->admin/mnet/enr_course_enrol.php?"
|
||||
. "host={$mnethost}&courseid={$course->id}&sesskey={$USER->sesskey}";
|
||||
echo '<tr>'
|
||||
. "<td>$icon</td>"
|
||||
. "<td><a href=\"$link\">".format_string($course->fullname). "</a></td>"
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. '<td>'.format_string($course->shortname). ' - ' .format_string($course->cat_name).'</td>'
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. "<td align=\"left\" >{$course->summary}</td>"
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table></div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box(get_string("remoteenrolhosts_desc", "mnet"));
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
print_box(get_string('mnetdisabled','mnet'));
|
||||
}
|
||||
|
||||
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
|
||||
. '<table cellspacing="0" cellpadding="5" id="hosts" class="generaltable generalbox" >'
|
||||
. '<tr>'
|
||||
. '<th class="header c0"> '.get_string('host', 'mnet').' </th>'
|
||||
. '<th class="header c1"> '.get_string('enrolments', 'mnet').' </th>'
|
||||
. '<th class="header c2"> '.get_string('courses', 'mnet').' </th>'
|
||||
// . '<th class="header c3"> </th>'
|
||||
. '</tr>';
|
||||
$hosts = $enrolment->list_remote_servers();
|
||||
foreach ($hosts as $host) {
|
||||
$coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&sesskey={$USER->sesskey}";
|
||||
$coursecount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_course WHERE hostid={$host->id}");
|
||||
if (empty($coursecount)) {
|
||||
$coursecount = '?';
|
||||
}
|
||||
$enrolcount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_assignments WHERE hostid={$host->id}");
|
||||
|
||||
echo '<tr>'
|
||||
. "<td><a href=\"{$coursesurl}\">{$host->name}</a></td>"
|
||||
. "<td align=\"center\" >$enrolcount</td>"
|
||||
. "<td align=\"center\" >$coursecount - <a href=\"{$coursesurl}\">".get_string('editenrolments', 'mnet')."</a></td>"
|
||||
// TODO: teach report/log/index.php to show per-host-logs
|
||||
// . '<td align="center" ><a href="$CFG->wwwroot/$CFG->admin/report/log/index.php?course_host={$host->id}">'
|
||||
// . get_string('logs', 'mnet').'</a> </td>'
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table>'
|
||||
. '</div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,151 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure mnet stuff
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('net');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nocurl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
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 {
|
||||
error('Invalid action parameter.', '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();
|
||||
notice_yesno(get_string("deletekeycheck", "mnet"),
|
||||
"index.php?sesskey=$USER->sesskey&confirm=".md5($MNET->public_key),
|
||||
"index.php",
|
||||
array('sesskey' => $USER->sesskey),
|
||||
NULL,
|
||||
'post',
|
||||
'get');
|
||||
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 = get_records_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
|
||||
|
||||
admin_externalpage_print_header();
|
||||
?>
|
||||
<center>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><?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>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('net', 'mnet'); ?>:</td>
|
||||
<td><input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="radio" name="mode" value="off" <?php echo ("off" == $CFG->mnet_dispatcher_mode)? 'checked="checked"' : '' ?> /> <?php print_string('off', 'mnet'); ?> <br />
|
||||
<input type="radio" name="mode" value="strict" <?php echo ("strict" == $CFG->mnet_dispatcher_mode)? 'checked="checked"' : '' ?> /> <?php print_string('on', 'mnet'); ?><br />
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td colspan="2" cellpadding="0"><?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 $USER->sesskey ?>" />
|
||||
<input type="hidden" name="deleteKey" value="" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
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', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetdetails');
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
?>
|
||||
<form method="post" action="peers.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="commit" />
|
||||
<input type="hidden" name="last_connect_time" value="<?php echo $mnet_peer->last_connect_time; ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo isset($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationid" value="<?php echo isset($mnet_peer->applicationid)? $mnet_peer->applicationid : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationname" value="<?php echo isset($mnet_peer->application->name)? $mnet_peer->application->name : '' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" width="635">
|
||||
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('site'); ?>:</td>
|
||||
<td valign="top"><input type="text" name="name" size="30" value="<?php echo $mnet_peer->name; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('hostname', 'mnet'); ?>:</td>
|
||||
<td valign="top"><input type="text" name="wwwroot" size="30" value="<?php echo $mnet_peer->wwwroot; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
if (empty($mnet_peer->public_key)) $mnet_peer->public_key = '';
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php
|
||||
print_string('publickey', 'mnet');
|
||||
echo ': <br />';
|
||||
helpbutton("publickey", get_string('publickey', 'mnet'), "mnet", true, true);
|
||||
?></td>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0) {
|
||||
$key = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application->xmlrpc_server_url);
|
||||
$mnet_peer->public_key = clean_param($key, PARAM_PEM);
|
||||
}
|
||||
?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if (empty($mnet_peer->public_key)) {
|
||||
print_string('nopubkey', 'mnet');
|
||||
}
|
||||
?><br />
|
||||
<textarea rows="17" cols="65" name="public_key" style="font-size: 8px;"><?php echo $mnet_peer->public_key; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('expires', 'mnet'); ?>:</td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if($mnet_peer->public_key_expires < time()) {
|
||||
print_string('expired', 'mnet');
|
||||
echo ' ';
|
||||
}
|
||||
echo userdate($mnet_peer->public_key_expires);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
if(!empty($currentkey)) {
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"></td>
|
||||
<td valign="top"><?php print_string('keymismatch', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('currentkey', 'mnet'); ?>:</td>
|
||||
<td valign="top"><pre style="font-size: 8px;"><?php echo $currentkey;?></pre></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('last_connect_time', 'mnet'); ?>:</td>
|
||||
<td valign="top"><?php echo ($mnet_peer->last_connect_time == 0)? get_string('never','mnet') : date('H:i:s d/m/Y',$mnet_peer->last_connect_time);?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0){
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('deleted'); ?>:</td>
|
||||
<td valign="top">
|
||||
<input type="radio" name="deleted" value="0" checked="checked" /> <?php print_string('reenableserver','mnet'); ?><br />
|
||||
<input type="radio" name="deleted" value="1" /> <?php print_string('yes'); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->ip_address) && '' != $mnet_peer->ip_address){
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('ipaddress', 'mnet');
|
||||
echo ': <br />';
|
||||
helpbutton("ipaddress", get_string('ipaddress', 'mnet'), "mnet", true, true);
|
||||
?>:</td>
|
||||
<td valign="top"><?php echo $mnet_peer->ip_address; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges"); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
print_tabs(array($tabs), 'mnetdetails');
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
?>
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('site'); ?>:</td>
|
||||
<td valign="top"><?php echo $mnet_peer->name; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top" colspan="2"><?php print_string('allhosts_no_options'); ?>:</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id && $mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetservices');
|
||||
print_simple_box_start("center", "");
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="mnet_services.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="<?php echo $mnet_peer->nextstep; ?>" />
|
||||
<input type="hidden" name="hostid" value="<?php echo ($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<?php
|
||||
foreach($myservices as $name => $versions) {
|
||||
$version = current($versions);
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<h3><?php echo get_string($name.'_name', $version['parent_type'].'_'.$version['parent'] , $mnet_peer->name); ?></h3>
|
||||
<?php echo get_string($name.'_description', $version['parent_type'].'_'.$version['parent'], $mnet_peer->name); ?>
|
||||
<?php
|
||||
$breakstring = '';
|
||||
foreach($versions as $version){
|
||||
if (count($versions) > 1) {
|
||||
$versionstring = '('.get_string('version','mnet') .' '.$version['apiversion'].')';
|
||||
} else {
|
||||
$versionstring = '';
|
||||
}
|
||||
|
||||
echo $breakstring;
|
||||
?>
|
||||
<input type="hidden" name="exists[<?php echo $version['serviceid']; ?>]" value="1" />
|
||||
<input type="checkbox" name="publish[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_publish']))? 'checked="checked" ': '' ; ?>/>
|
||||
<?php
|
||||
print_string('publish','mnet');
|
||||
echo $versionstring;
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
echo '<a href="#" title="'.get_string('issubscribed','mnet', $mnet_peer->name).'">√</a> ';
|
||||
}
|
||||
if (!empty($version['allhosts_publish'])) {
|
||||
print_string("enabled_for_all",'mnet',!empty($version['I_publish']));
|
||||
}
|
||||
echo '<br />';
|
||||
?>
|
||||
<input type="checkbox" name="subscribe[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_subscribe']))? 'checked="checked" ': '' ; ?>/>
|
||||
<?php
|
||||
print_string('subscribe','mnet');
|
||||
echo $versionstring;
|
||||
if (!empty($version['hostpublishes'])) {
|
||||
echo '<a href="#" title="'.get_string('ispublished','mnet', $mnet_peer->name).'">√</a> ';
|
||||
}
|
||||
if (!empty($version['allhosts_subscribe'])) {
|
||||
print_string("enabled_for_all",'mnet',!empty($version['I_subscribe']));
|
||||
}
|
||||
|
||||
echo '<br />';
|
||||
$breakstring = '. . . . . . . . . . . . . . . . . . . . . . . . <br>';
|
||||
} // end foreach
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} // end foreach
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="pubTreeLoc"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="subTreeLoc"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="formElements"><input type="hidden" name="outer" value="4" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,183 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
// force Go ahead with something we've been warned is strange
|
||||
$step = optional_param('step', NULL, PARAM_ALPHA);
|
||||
$hostid = optional_param('hostid', NULL, PARAM_INT);
|
||||
$nocertstring = '';
|
||||
$nocertmatch = '';
|
||||
$badcert = '';
|
||||
$certerror = '';
|
||||
$noipmatch = '';
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmneteditservices = get_string('reviewhostservices', 'mnet');
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$mnet_peer->set_id($hostid);
|
||||
$treevals = array();
|
||||
foreach($_POST['exists'] as $key => $value) {
|
||||
$host2service = get_record('mnet_host2service', 'hostid', $_POST['hostid'], 'serviceid', $key);
|
||||
$publish = (isset($_POST['publish'][$key]) && $_POST['publish'][$key] == 'on')? 1 : 0;
|
||||
$subscribe = (isset($_POST['subscribe'][$key]) && $_POST['subscribe'][$key] == 'on')? 1 : 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
|
||||
delete_records('mnet_host2service', 'hostid', $_POST['hostid'], 'serviceid', $key);
|
||||
}
|
||||
} elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) {
|
||||
$host2service = new stdClass();
|
||||
$host2service->hostid = $_POST['hostid'];
|
||||
$host2service->serviceid = $key;
|
||||
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
|
||||
$host2service->id = insert_record('mnet_host2service', $host2service);
|
||||
} elseif ($host2service->publish != $publish || $host2service->subscribe != $subscribe) {
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
$tf = update_record('mnet_host2service', $host2service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($hostid)) {
|
||||
if (0 == $mnet_peer->id) $mnet_peer->set_id($hostid);
|
||||
$mnet_peer->nextstep = 'verify';
|
||||
|
||||
$id_list = $mnet_peer->id;
|
||||
if (!empty($CFG->mnet_all_hosts_id)) {
|
||||
$id_list .= ', '.$CFG->mnet_all_hosts_id;
|
||||
}
|
||||
|
||||
$concat = sql_concat('COALESCE(h2s.id,0) ', ' \'-\' ', ' svc.id');
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT
|
||||
$concat as id,
|
||||
svc.id as serviceid,
|
||||
svc.name,
|
||||
svc.offer,
|
||||
svc.apiversion,
|
||||
r.parent_type,
|
||||
r.parent,
|
||||
h2s.hostid,
|
||||
h2s.publish,
|
||||
h2s.subscribe
|
||||
FROM
|
||||
{$CFG->prefix}mnet_service2rpc s2r,
|
||||
{$CFG->prefix}mnet_rpc r,
|
||||
{$CFG->prefix}mnet_service svc
|
||||
LEFT JOIN
|
||||
{$CFG->prefix}mnet_host2service h2s
|
||||
ON
|
||||
h2s.hostid in ($id_list) AND
|
||||
h2s.serviceid = svc.id
|
||||
WHERE
|
||||
svc.offer = '1' AND
|
||||
s2r.serviceid = svc.id AND
|
||||
s2r.rpcid = r.id
|
||||
ORDER BY
|
||||
svc.name ASC";
|
||||
|
||||
$resultset = get_records_sql($query);
|
||||
|
||||
if (is_array($resultset)) {
|
||||
$resultset = array_values($resultset);
|
||||
} else {
|
||||
$resultset = array();
|
||||
}
|
||||
|
||||
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
|
||||
|
||||
$remoteservices = array();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
// Create a new request object
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
// Tell it the path to the method that we want to execute
|
||||
$mnet_request->set_method('system/listServices');
|
||||
$mnet_request->send($mnet_peer);
|
||||
if (is_array($mnet_request->response)) {
|
||||
foreach($mnet_request->response as $service) {
|
||||
$remoteservices[$service['name']][$service['apiversion']] = $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$myservices = array();
|
||||
foreach($resultset as $result) {
|
||||
$result->hostpublishes = false;
|
||||
$result->hostsubscribes = false;
|
||||
if (isset($remoteservices[$result->name][$result->apiversion])) {
|
||||
if ($remoteservices[$result->name][$result->apiversion]['publish'] == 1) {
|
||||
$result->hostpublishes = true;
|
||||
}
|
||||
if ($remoteservices[$result->name][$result->apiversion]['subscribe'] == 1) {
|
||||
$result->hostsubscribes = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($myservices[$result->name][$result->apiversion])) {
|
||||
$myservices[$result->name][$result->apiversion] = array('serviceid' => $result->serviceid,
|
||||
'name' => $result->name,
|
||||
'offer' => $result->offer,
|
||||
'apiversion' => $result->apiversion,
|
||||
'parent_type' => $result->parent_type,
|
||||
'parent' => $result->parent,
|
||||
'hostsubscribes' => $result->hostsubscribes,
|
||||
'hostpublishes' => $result->hostpublishes
|
||||
);
|
||||
}
|
||||
|
||||
// allhosts_publish allows us to tell the admin that even though he
|
||||
// is disabling a service, it's still available to the host because
|
||||
// he's also publishing it to 'all hosts'
|
||||
if ($result->hostid == $CFG->mnet_all_hosts_id && $CFG->mnet_all_hosts_id != $mnet_peer->id) {
|
||||
$myservices[$result->name][$result->apiversion]['allhosts_publish'] = $result->publish;
|
||||
$myservices[$result->name][$result->apiversion]['allhosts_subscribe'] = $result->subscribe;
|
||||
} elseif (!empty($result->hostid)) {
|
||||
$myservices[$result->name][$result->apiversion]['I_publish'] = $result->publish;
|
||||
$myservices[$result->name][$result->apiversion]['I_subscribe'] = $result->subscribe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
redirect('peers.php', get_string('nohostid','mnet'), '5');
|
||||
exit;
|
||||
}
|
||||
|
||||
include('./mnet_services.html');
|
||||
?>
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
print_heading(get_string('themes'));
|
||||
$original_theme = fullclone($THEME);
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id) {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetthemes');
|
||||
|
||||
$themes = get_list_of_plugins("theme");
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">";
|
||||
|
||||
if (count($report)) {
|
||||
echo '<tr>';
|
||||
echo '<td align="center" colspan="2">';
|
||||
echo '<span class="'.$report[1].'">'.$report[0].'</span>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
if (!$USER->screenreader) {
|
||||
echo "<tr class=\"generaltableheader\"><th scope=\"col\">$strtheme</th>";
|
||||
echo "<th scope=\"col\">$strinfo</th></tr>";
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
echo '<td align="center"><span class="informationbox">Choose this option to use your site\'s default theme: <strong>'.$CFG->theme.'</strong>.</span></td>';
|
||||
if ($mnet_peer->theme == '') {
|
||||
echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
|
||||
} else {
|
||||
echo '<td valign="top">';
|
||||
}
|
||||
echo '<p style="font-size:1.5em;font-style:bold;">Site Theme</p>';
|
||||
$options = null;
|
||||
$options['choose'] = $unlikely_name;// Something unlikely to ever be a theme name... initially $unlikely_name = 'ZoqZoqZ';
|
||||
$options['sesskey'] = $sesskey;
|
||||
$options['hostid'] = $mnet_peer->id;
|
||||
print_single_button('mnet_themes.php', $options, $strchoose);
|
||||
echo '</td>';
|
||||
echo "</tr>";
|
||||
|
||||
foreach ($themes as $theme) {
|
||||
|
||||
unset($THEME);
|
||||
|
||||
if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
|
||||
continue;
|
||||
}
|
||||
|
||||
include($CFG->themedir.'/'.$theme.'/config.php');
|
||||
|
||||
$readme = '';
|
||||
$screenshot = '';
|
||||
$screenshotpath = '';
|
||||
|
||||
if (file_exists($CFG->themedir.'/'.$theme.'/README.html')) {
|
||||
$readme = '<li>'.
|
||||
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
|
||||
} else if (file_exists($CFG->themedir.'/'.$theme.'/README.txt')) {
|
||||
$readme = '<li>'.
|
||||
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
|
||||
}
|
||||
if (file_exists("$theme/screenshot.png")) {
|
||||
$screenshotpath = "$theme/screenshot.png";
|
||||
} else if (file_exists("$theme/screenshot.jpg")) {
|
||||
$screenshotpath = "$theme/screenshot.jpg";
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
|
||||
// no point showing this if user is using screen reader
|
||||
if (!$USER->screenreader) {
|
||||
echo "<td align=\"center\">";
|
||||
if ($screenshotpath) {
|
||||
$screenshot = '<li><a href='.$CFG->wwwroot .'/theme/'. $theme.'/screenshot.jpg">'.$strscreenshot.'</a></li>';
|
||||
echo "<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object></td>";
|
||||
} else {
|
||||
echo '<object type="text/html" data="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'" height="200" width="400">'.$theme.'</object></td>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($mnet_peer->theme == $theme) {
|
||||
echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
|
||||
} else {
|
||||
echo '<td valign="top">';
|
||||
}
|
||||
|
||||
if (isset($THEME->sheets)) {
|
||||
echo '<p style="font-size:1.5em;font-style:bold;">'.$theme.'</p>';
|
||||
} else {
|
||||
echo '<p style="font-size:1.5em;font-style:bold;color:red;">'.$theme.' (Moodle 1.4)</p>';
|
||||
}
|
||||
|
||||
if ($screenshot or $readme) {
|
||||
echo '<ul>';
|
||||
if (!$USER->screenreader) {
|
||||
echo '<li><a href="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'">'.$strpreview.'</a></li>';
|
||||
}
|
||||
echo $screenshot.$readme;
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
$options = null;
|
||||
$options['choose'] = $theme;
|
||||
$options['sesskey'] = $sesskey;
|
||||
$options['hostid'] = $mnet_peer->id;
|
||||
print_single_button('mnet_themes.php', $options, $strchoose);
|
||||
echo '</td>';
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
$THEME = $original_theme;
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
if (is_int($hostid)) {
|
||||
$mnet_peer->set_id($hostid);
|
||||
}
|
||||
|
||||
$choose = optional_param("choose",'',PARAM_FILE); // set this theme as default
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strthemes = get_string("themes");
|
||||
$strpreview = get_string("preview");
|
||||
$strchoose = get_string("choose");
|
||||
$strinfo = get_string("info");
|
||||
$strtheme = get_string("theme");
|
||||
$strthemesaved = get_string("themesaved");
|
||||
$strscreenshot = get_string("screenshot");
|
||||
$stroldtheme = get_string("oldtheme");
|
||||
$report = array();
|
||||
$unlikely_name = 'ZoqZoqZ'; // Something unlikely to ever be a theme name
|
||||
|
||||
if ($choose) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($choose == $unlikely_name) {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = '';
|
||||
if ($mnet_peer->commit()) {
|
||||
$report = array(get_string('themesaved'), 'informationbox');
|
||||
} else {
|
||||
$report = array(get_string('themesavederror', 'mnet'), 'errorbox');
|
||||
}
|
||||
} elseif (!is_dir($CFG->themedir .'/'. $choose) || !file_exists($CFG->themedir .'/'. $choose .'/config.php')) {
|
||||
echo 'CHOOSE -'.$choose.' '. $CFG->themedir .'/'. $choose .'/config.php' ;
|
||||
$report = array('This theme is not installed!'.'3', 'errorbox');
|
||||
} else {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = addslashes($choose);
|
||||
if ($mnet_peer->commit()) {
|
||||
$report = array(get_string('themesaved').'1', 'informationbox');
|
||||
} else {
|
||||
$report = array(get_string('themesavederror', 'mnet').'2', 'errorbox');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
require('./mnet_themes.html');
|
||||
?>
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
print_box(get_string('mnetdisabled','mnet'));
|
||||
}
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<form method="post" action="peers.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="updateregisterall" value="1" />
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('registerallhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('registerallhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1"><input type="checkbox" name="registerallhosts" <?php if (!empty($CFG->mnet_register_allhosts)) echo 'checked="checked" '; ?>/></td>
|
||||
<td class="cell c1"> <?php print_string('registerallhosts', 'mnet'); ?> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" colspan="2"><input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox standard" >
|
||||
<tr>
|
||||
<th class="header c0"><?php print_string('site'); ?></th>
|
||||
<th class="header c1"><?php print_string('system','mnet'); ?></th>
|
||||
<th class="header c2"><?php print_string('last_connect_time', 'mnet'); ?></th>
|
||||
<th class="header c3"></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach($hosts as $host) {
|
||||
|
||||
if ($host->last_connect_time == 0) {
|
||||
$last_connect = get_string('never');
|
||||
} else {
|
||||
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time);
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c0"><a href="peers.php?step=update&hostid=<?php echo $host->id; ?>"><?php echo $host->name; ?></a></td>
|
||||
<td class="cell c1"><a href="peers.php?step=update&hostid=<?php echo $host->id; ?>"><?php echo $host->wwwroot; ?></a></td>
|
||||
<td class="cell c2"><?php if ($host->id != $CFG->mnet_all_hosts_id) echo $last_connect; ?></td>
|
||||
<td class="cell c3">
|
||||
<?php if ($host->id != $CFG->mnet_all_hosts_id){ ?>
|
||||
<form method="post" action="delete.php">
|
||||
<div>
|
||||
<input type="hidden" name="hostid" value="<?php echo $host->id; ?>" />
|
||||
<input type="hidden" name="step" value="verify" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>"/>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<form method="post" action="peers.php">
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox standard" >
|
||||
|
||||
<tr>
|
||||
<th class="header c4" colspan="4">
|
||||
<?php print_string('addnewhost', 'mnet'); ?>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="input" />
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c0">wwwroot:</td>
|
||||
<td class="cell c1"><input type="text" name="wwwroot" value="" /></td>
|
||||
<td class="cell c2">
|
||||
<select name="applicationid">
|
||||
<?php
|
||||
foreach($applications as $application) {
|
||||
echo ' <option value="'.$application->id.'">'.$application->display_name."</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="cell c3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c4" align="right" colspan="4"><input type="submit" value="<?php print_string('addhost','mnet'); ?>" /></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,182 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure other Moodle hosts info
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nosite', '');
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nocurl', 'mnet');
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
$step = optional_param('step', NULL, PARAM_ALPHA);
|
||||
$hostid = optional_param('hostid', NULL, PARAM_INT);
|
||||
|
||||
// Fetch some strings for the HTML templates
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', '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->wwwroot)) {
|
||||
// ensure we remove trailing slashes
|
||||
$form->wwwroot = preg_replace(':/$:', '', $form->wwwroot);
|
||||
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($form->wwwroot, 0, 4)) != 'http') {
|
||||
$form->wwwroot = 'http://'.$form->wwwroot;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('xmlrpc_encode_request')) {
|
||||
trigger_error("You must have xml-rpc enabled in your PHP build to use this feature.");
|
||||
print_error('xmlrpc-missing', 'mnet','peers.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($form->updateregisterall)) {
|
||||
if (!empty($form->registerallhosts)) {
|
||||
set_config('mnet_register_allhosts',1);
|
||||
} else {
|
||||
set_config('mnet_register_allhosts',0);
|
||||
}
|
||||
redirect('peers.php', get_string('changessaved'));
|
||||
} else {
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
|
||||
if (!empty($form->id)) {
|
||||
$form->id = clean_param($form->id, PARAM_INT);
|
||||
$mnet_peer->set_id($form->id);
|
||||
} else {
|
||||
// PARAM_URL requires a genuine TLD (I think) This breaks my testing
|
||||
$temp_wwwroot = clean_param($form->wwwroot, PARAM_URL);
|
||||
if ($temp_wwwroot !== $form->wwwroot) {
|
||||
trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc.");
|
||||
print_error("invalidurl", 'mnet','peers.php');
|
||||
exit;
|
||||
}
|
||||
unset($temp_wwwroot);
|
||||
$mnet_peer->set_applicationid($form->applicationid);
|
||||
$application = get_field('mnet_application', 'name', 'id', $form->applicationid);
|
||||
$mnet_peer->bootstrap($form->wwwroot, null, $application);
|
||||
}
|
||||
|
||||
if (isset($form->name) && $form->name != $mnet_peer->name) {
|
||||
$form->name = clean_param($form->name, PARAM_NOTAGS);
|
||||
$mnet_peer->set_name($form->name);
|
||||
}
|
||||
|
||||
if (isset($form->deleted) && ($form->deleted == '0' || $form->deleted == '1')) {
|
||||
$mnet_peer->deleted = $form->deleted;
|
||||
}
|
||||
|
||||
if (isset($form->public_key)) {
|
||||
$form->public_key = clean_param($form->public_key, PARAM_PEM);
|
||||
if (empty($form->public_key)) {
|
||||
print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
exit;
|
||||
} else {
|
||||
$oldkey = $mnet_peer->public_key;
|
||||
$mnet_peer->public_key = $form->public_key;
|
||||
$mnet_peer->public_key_expires = $mnet_peer->check_common_name($form->public_key);
|
||||
if ($mnet_peer->public_key_expires == false) {
|
||||
$mnet_peer->public_key == $oldkey;
|
||||
$errmsg = '<br />';
|
||||
foreach ($mnet_peer->error as $err) {
|
||||
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
|
||||
}
|
||||
error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
//print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $errmsg);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PREVENT DUPLICATE RECORDS ///////////////////////////////////////////
|
||||
if ('input' == $form->step) {
|
||||
if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) {
|
||||
print_error("hostexists", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $mnet_peer->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ('input' == $form->step) {
|
||||
include('./mnet_review.html');
|
||||
} elseif ('commit' == $form->step) {
|
||||
$bool = $mnet_peer->commit();
|
||||
if ($bool) {
|
||||
redirect('peers.php?step=update&hostid='.$mnet_peer->id, get_string('changessaved'));
|
||||
} else {
|
||||
error('Invalid action parameter.', 'index.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (is_int($hostid)) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
|
||||
if($currentkey == $mnet_peer->public_key) unset($currentkey);
|
||||
$form = new stdClass();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
include('./mnet_review.html');
|
||||
} else {
|
||||
include('./mnet_review_allhosts.html');
|
||||
}
|
||||
} else {
|
||||
$hosts = get_records_sql(' SELECT
|
||||
h.id,
|
||||
h.wwwroot,
|
||||
h.ip_address,
|
||||
h.name,
|
||||
h.public_key,
|
||||
h.public_key_expires,
|
||||
h.transport,
|
||||
h.portno,
|
||||
h.last_connect_time,
|
||||
h.last_log_id,
|
||||
h.applicationid,
|
||||
a.name as app_name,
|
||||
a.display_name as app_display_name,
|
||||
a.xmlrpc_server_url
|
||||
FROM
|
||||
'.$CFG->prefix.'mnet_host h,
|
||||
'.$CFG->prefix.'mnet_application a
|
||||
WHERE
|
||||
h.id != \''.$CFG->mnet_localhost_id.'\' AND
|
||||
h.deleted = \'0\' AND
|
||||
h.applicationid=a.id');
|
||||
|
||||
if (empty($hosts)) $hosts = array();
|
||||
$applications = get_records('mnet_application');
|
||||
include('./peers.html');
|
||||
}
|
||||
?>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_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 $USER->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 $USER->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
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('trustedhosts');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
$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) {
|
||||
list($network, $mask) = explode('/', $host.'/');
|
||||
if (empty($network)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
|
||||
if (ip_in_range($test_ip_address, $network, $mask)) {
|
||||
$in_range = true;
|
||||
$validated_by = $network.'/'.$mask;
|
||||
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');
|
||||
?>
|
||||
+24
-13
@@ -2,7 +2,16 @@
|
||||
// module.php - allows admin to edit all local configuration variables for a module
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.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.
|
||||
|
||||
@@ -10,12 +19,11 @@
|
||||
$module = optional_param('module', '', PARAM_SAFEDIR);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
admin_externalpage_setup('modsetting'.$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.
|
||||
@@ -27,8 +35,6 @@
|
||||
$moduleconfig($config);
|
||||
}
|
||||
} else {
|
||||
admin_externalpage_setup('managemodules');
|
||||
|
||||
$moduleprefix = '';
|
||||
}
|
||||
|
||||
@@ -44,26 +50,31 @@
|
||||
|
||||
/// Otherwise print the form.
|
||||
$module = required_param('module', PARAM_SAFEDIR);
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
admin_externalpage_setup('modsetting'.$module);
|
||||
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';
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
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(get_string("configwarning", 'admin'), "center", "60%");
|
||||
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();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+68
-128
@@ -3,24 +3,28 @@
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
|
||||
// defines
|
||||
define('MODULE_TABLE','module_administration_table');
|
||||
|
||||
admin_externalpage_setup('managemodules');
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stractivities = get_string("activities");
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagemodules = get_string("managemodules");
|
||||
$strdelete = get_string("delete");
|
||||
$strversion = get_string("version");
|
||||
$strhide = get_string("hide");
|
||||
@@ -28,7 +32,15 @@
|
||||
$strsettings = get_string("settings");
|
||||
$stractivities = get_string("activities");
|
||||
$stractivitymodule = get_string("activitymodule");
|
||||
$strshowmodulecourse = get_string('showmodulecourse');
|
||||
|
||||
print_header("$site->shortname: $strmanagemodules", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanagemodules");
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
$coursesaffected = false;
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
@@ -36,54 +48,31 @@
|
||||
if (!$module = get_record("modules", "name", $hide)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
// Remember the visibility status in visibleold
|
||||
// and hide...
|
||||
$sql = "UPDATE {$CFG->prefix}course_modules
|
||||
SET visibleold=visible,
|
||||
visible=0
|
||||
WHERE module={$module->id}";
|
||||
execute_sql($sql, false);
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just deleted something
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE visibleold=1 AND module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
set_field('course_modules', 'visibleold', '1', 'visible' ,'1', 'module', $module->id); // Remember the previous visible state so we can toggle this back if the module is unhidden.
|
||||
set_field('course_modules', 'visibleold', '0', 'visible' ,'0', 'module', $module->id);
|
||||
set_field("course_modules", "visible", "0", "module", $module->id); // Hide all related activity modules
|
||||
$coursesaffected = true;
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
if (!$module = get_record("modules", "name", $show)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field('course_modules', 'visible', '1', 'visibleold',
|
||||
'1', 'module', $module->id); // Get the previous saved visible state for the course module.
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just made something visible
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE visible=1 AND module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field('course_modules', 'visible', '1', 'visibleold', '1', 'module', $module->id); // Get the previous saved visible state for the course module.
|
||||
$coursesaffected = true;
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
print_heading($stractivities);
|
||||
|
||||
|
||||
$strmodulename = get_string("modulename", "$delete");
|
||||
|
||||
if (!$confirm) {
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
"modules.php");
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
@@ -105,26 +94,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// delete calendar events
|
||||
if (!delete_records("event", "modulename", $delete)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in calendar event table");
|
||||
}
|
||||
|
||||
// clear course.modinfo for courses
|
||||
// that used this module...
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
|
||||
// Now delete all the course module records
|
||||
if (!delete_records("course_modules", "module", $module->id)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in course_modules table");
|
||||
}
|
||||
|
||||
// Then delete all the logs
|
||||
// Then delete all the logs
|
||||
if (!delete_records("log", "module", $module->name)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in log table");
|
||||
}
|
||||
@@ -139,43 +114,32 @@
|
||||
notify("Error occurred while deleting the $strmodulename record from modules table");
|
||||
}
|
||||
|
||||
// And the module configuration records
|
||||
if (!execute_sql("DELETE FROM {$CFG->prefix}config WHERE name LIKE '{$module->name}_%'")) {
|
||||
notify("Error occurred while deleting the $strmodulename records from the config table");
|
||||
}
|
||||
|
||||
// cleanup the gradebook
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_uninstalled_module($module->name);
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($module->name, "$CFG->dirroot/mod/$module->name/db/install.xml", false);
|
||||
|
||||
// Delete the capabilities that were defined by this module
|
||||
capabilities_cleanup('mod/'.$module->name);
|
||||
|
||||
// remove entent handlers and dequeue pending events
|
||||
events_uninstall('mod/'.$module->name);
|
||||
|
||||
// Perform any custom uninstall tasks
|
||||
if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
|
||||
require_once($CFG->dirroot . '/mod/' . $module->name . '/lib.php');
|
||||
$uninstallfunction = $module->name . '_uninstall';
|
||||
if (function_exists($uninstallfunction)) {
|
||||
if (! $uninstallfunction() ) {
|
||||
notify('Encountered a problem running uninstall function for '. $module->name.'!');
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$module->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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//rebuild_course_cache(); // Because things have changed
|
||||
$coursesaffected = true;
|
||||
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
notice(get_string("moduledeletefiles", "", $a), "modules.php");
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading($stractivities);
|
||||
|
||||
if ($coursesaffected) {
|
||||
rebuild_course_cache(); // Because things have changed
|
||||
}
|
||||
|
||||
|
||||
/// Get and sort the existing modules
|
||||
|
||||
@@ -191,74 +155,50 @@
|
||||
}
|
||||
$modulebyname[$strmodulename] = $module;
|
||||
}
|
||||
ksort($modulebyname, SORT_LOCALE_STRING);
|
||||
ksort($modulebyname);
|
||||
|
||||
/// Print the table of all modules
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(MODULE_TABLE);
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
|
||||
$table->set_attribute('id', 'modules');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$table->head = array ($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings);
|
||||
$table->align = array ("left", "right", "left", "center", "center", "center");
|
||||
$table->wrap = array ("nowrap", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
|
||||
foreach ($modulebyname as $modulename => $module) {
|
||||
|
||||
// took out hspace="\10\", because it does not validate. don't know what to replace with.
|
||||
$icon = "<img src=\"$CFG->modpixpath/$module->name/icon.gif\" class=\"icon\" alt=\"\" />";
|
||||
$icon = "<img src=\"$CFG->modpixpath/$module->name/icon.gif\" hspace=\"10\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" />";
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php")) {
|
||||
$settings = "<a href=\"settings.php?section=modsetting$module->name\">$strsettings</a>";
|
||||
} else if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
|
||||
$settings = "<a href=\"module.php?module=$module->name\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
|
||||
$count = count_records_select("$module->name",'course<>0');
|
||||
if ($count>0) {
|
||||
$countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
|
||||
"&sesskey={$USER->sesskey}\" title=\"$strshowmodulecourse\">$count</a>";
|
||||
}
|
||||
else {
|
||||
$countlink = "$count";
|
||||
}
|
||||
$count = count_records("$module->name");
|
||||
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" class=\"icon\" alt=\"$strhide\" /></a>";
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = " class=\"dimmed_text\"";
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
|
||||
$extra = '';
|
||||
if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) {
|
||||
$extra = ' <span class="notifyproblem">('.get_string('missingfromdisk').')</span>';
|
||||
}
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$icon.' '.$modulename.$extra.'</span>',
|
||||
$countlink,
|
||||
'<span'.$class.'>'.$module->version.'</span>',
|
||||
$visible,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
$table->data[] = array ("<span $class>$icon $modulename</span>", $count, $module->version, $visible, $delete, $settings);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
$table->print_html();
|
||||
echo "<br /><br />";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php /// $Id$
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('multilangupgrade');
|
||||
|
||||
$go = optional_param('go', 0, PARAM_BOOL);
|
||||
|
||||
###################################################################
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_heading(get_string('multilangupgrade', 'admin'));
|
||||
|
||||
$strmultilangupgrade = get_String('multilangupgradeinfo', 'admin');
|
||||
|
||||
if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
|
||||
$optionsyes = array('go'=>1, 'sesskey'=>sesskey());
|
||||
notice_yesno($strmultilangupgrade, 'multilangupgrade.php', 'index.php', $optionsyes, null, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
if (!$tables = $db->Metatables() ) { // No tables yet at all.
|
||||
error("no tables");
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
while(@ob_end_flush());
|
||||
|
||||
echo '<strong>Progress:</strong>';
|
||||
$i = 0;
|
||||
$skiptables = array($CFG->prefix.'config', $CFG->prefix.'user_students', $CFG->prefix.'user_teachers');//, $CFG->prefix.'sessions2');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if (($CFG->prefix && strpos($table, $CFG->prefix) !== 0)
|
||||
or strpos($table, $CFG->prefix.'pma') === 0) { // Not our tables
|
||||
continue;
|
||||
}
|
||||
if (in_array($table, $skiptables)) { // Don't process these
|
||||
continue;
|
||||
}
|
||||
if ($columns = $db->MetaColumns($table, false)) {
|
||||
if (!array_key_exists('id', $columns) and !array_key_exists('ID', $columns)) {
|
||||
continue; // moodle tables have id
|
||||
}
|
||||
foreach ($columns as $column => $data) {
|
||||
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
|
||||
// first find candidate records
|
||||
$rs = get_recordset_sql("SELECT id, $column FROM $table WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'");
|
||||
if ($rs) {
|
||||
while (!$rs->EOF) {
|
||||
$text = $rs->fields[$column];
|
||||
$id = $rs->fields['id'];
|
||||
|
||||
if ($i % 600 == 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
if ($i % 10 == 0) {
|
||||
echo '.';
|
||||
}
|
||||
$i++;
|
||||
$rs->MoveNext();
|
||||
|
||||
if (empty($text) or is_numeric($text)) {
|
||||
continue; // nothing to do
|
||||
}
|
||||
|
||||
$search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)+/is';
|
||||
$newtext = preg_replace_callback($search, 'multilangupgrade_impl', $text);
|
||||
|
||||
if (is_null($newtext)) {
|
||||
continue; // regex error
|
||||
}
|
||||
|
||||
if ($newtext != $text) {
|
||||
$newtext = addslashes($newtext);
|
||||
execute_sql("UPDATE $table SET $column='$newtext' WHERE id=$id", false);
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set conversion flag - switches to new plugin automatically
|
||||
set_config('filter_multilang_converted', 1);
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
notify('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
notify('...finished', 'notifysuccess');
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
|
||||
|
||||
function multilangupgrade_impl($langblock) {
|
||||
$searchtosplit = '/<(?:lang|span) lang="([a-zA-Z0-9_-]*)".*?>(.+?)<\/(?:lang|span)>/is';
|
||||
preg_match_all($searchtosplit, $langblock[0], $rawlanglist);
|
||||
$return = '';
|
||||
foreach ($rawlanglist[1] as $index=>$lang) {
|
||||
$return .= '<span lang="'.$lang.'" class="multilang">'.$rawlanglist[2][$index].'</span>';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
?>
|
||||
+14
-8
@@ -3,13 +3,19 @@
|
||||
if (!isset($CFG)) {
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('oacleanup');
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be an admin to use this script');
|
||||
exit;
|
||||
}
|
||||
|
||||
print_header_simple('Online Assignment Cleanup','Online Assignment Cleanup', 'Admin');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
online_assignment_cleanup(true);
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
print_footer();
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +48,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
$courses = get_records('course');
|
||||
$courses = get_courses();
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
@@ -69,7 +75,7 @@ function online_assignment_cleanup($output=false) {
|
||||
/// cycle through the instances
|
||||
foreach ($instances as $instance) {
|
||||
/// is this an instance of an online assignment
|
||||
$sql = "SELECT a.id
|
||||
$sql = "SELECT a.id
|
||||
FROM {$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}assignment a
|
||||
WHERE cm.id = '$instance' AND
|
||||
@@ -95,7 +101,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = get_record('course_sections', 'id', $newsection))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'<br />';
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '.$course->fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -134,7 +140,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
|
||||
|
||||
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
|
||||
|
||||
}
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once($CFG->libdir.'/pagelib.php');
|
||||
|
||||
define('PAGE_ADMIN', 'admin');
|
||||
|
||||
// Bounds for block widths
|
||||
// more flexible for theme designers taken from theme config.php
|
||||
$lmin = (empty($THEME->block_l_min_width)) ? 0 : $THEME->block_l_min_width;
|
||||
$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
|
||||
$rmin = (empty($THEME->block_r_min_width)) ? 0 : $THEME->block_r_min_width;
|
||||
$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;
|
||||
|
||||
define('BLOCK_L_MIN_WIDTH', $lmin);
|
||||
define('BLOCK_L_MAX_WIDTH', $lmax);
|
||||
define('BLOCK_R_MIN_WIDTH', $rmin);
|
||||
define('BLOCK_R_MAX_WIDTH', $rmax);
|
||||
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
|
||||
class page_admin extends page_base {
|
||||
|
||||
var $section;
|
||||
var $visiblepathtosection;
|
||||
|
||||
// hack alert!
|
||||
// this function works around the inability to store the section name
|
||||
// in default block, maybe we should "improve" the blocks a bit?
|
||||
function init_extra($section) {
|
||||
global $CFG;
|
||||
|
||||
if($this->full_init_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
// fetch the path parameter
|
||||
$this->section = $section;
|
||||
$current =& $adminroot->locate($section, true);
|
||||
$this->visiblepathtosection = array_reverse($current->visiblepath);
|
||||
|
||||
// all done
|
||||
$this->full_init_done = true;
|
||||
}
|
||||
|
||||
function blocks_get_default() {
|
||||
return 'admin_tree,admin_bookmarks';
|
||||
}
|
||||
|
||||
// seems reasonable that the only people that can edit blocks on the admin pages
|
||||
// are the admins... but maybe we want a role for this?
|
||||
function user_allowed_editing() {
|
||||
return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM));
|
||||
}
|
||||
|
||||
// has to be fixed. i know there's a "proper" way to do this
|
||||
function user_is_editing() {
|
||||
global $USER;
|
||||
return $USER->adminediting;
|
||||
}
|
||||
|
||||
function url_get_path() {
|
||||
global $CFG;
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
$root =& $adminroot->locate($this->section);
|
||||
if (is_a($root, 'admin_externalpage')) {
|
||||
return $root->url;
|
||||
} else {
|
||||
return ($CFG->wwwroot . '/' . $CFG->admin . '/settings.php');
|
||||
}
|
||||
}
|
||||
|
||||
function url_get_parameters() { // only handles parameters relevant to the admin pagetype
|
||||
return array('section' => (isset($this->section) ? $this->section : ''));
|
||||
}
|
||||
|
||||
function blocks_get_positions() {
|
||||
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
|
||||
}
|
||||
|
||||
function blocks_default_position() {
|
||||
return BLOCK_POS_LEFT;
|
||||
}
|
||||
|
||||
function blocks_move_position(&$instance, $move) {
|
||||
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
|
||||
return BLOCK_POS_RIGHT;
|
||||
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
|
||||
return BLOCK_POS_LEFT;
|
||||
}
|
||||
return $instance->position;
|
||||
}
|
||||
|
||||
// does anything need to be done here?
|
||||
function init_quick($data) {
|
||||
parent::init_quick($data);
|
||||
}
|
||||
|
||||
function print_header($section = '', $focus='') {
|
||||
global $USER, $CFG, $SITE;
|
||||
|
||||
$this->init_full($section); // we're trusting that init_full() has already been called by now; it should have.
|
||||
// if not, print_header() has to be called with a $section parameter
|
||||
|
||||
// The search page currently doesn't handle block editing
|
||||
if ($this->section != 'search' and $this->user_allowed_editing()) {
|
||||
$buttons = '<div><form '.$CFG->frametarget.' method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<input type="hidden" name="section" value="'.$this->section.'" />'.
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></div></form></div>';
|
||||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
|
||||
$navlinks = array();
|
||||
foreach ($this->visiblepathtosection as $element) {
|
||||
$navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
|
||||
}
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
|
||||
}
|
||||
|
||||
function get_type() {
|
||||
return PAGE_ADMIN;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+26
-20
@@ -2,32 +2,38 @@
|
||||
// phpinfo.php - shows phpinfo for the current server
|
||||
|
||||
require_once("../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('phpinfo');
|
||||
$topframe = optional_param('topframe', false, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', false, PARAM_BOOL);
|
||||
|
||||
admin_externalpage_print_header();
|
||||
require_login();
|
||||
|
||||
echo '<div class="phpinfo">';
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES);
|
||||
$html = ob_get_contents();
|
||||
ob_end_clean();
|
||||
if (!$topframe && !$bottomframe) {
|
||||
?>
|
||||
|
||||
/// Delete styles from output
|
||||
$html = preg_replace('#(\n?<style[^>]*?>.*?</style[^>]*?>)|(\n?<style[^>]*?/>)#is', '', $html);
|
||||
$html = preg_replace('#(\n?<head[^>]*?>.*?</head[^>]*?>)|(\n?<head[^>]*?/>)#is', '', $html);
|
||||
/// Delete DOCTYPE from output
|
||||
$html = preg_replace('/<!DOCTYPE html PUBLIC.*?>/is', '', $html);
|
||||
/// Delete body and html tags
|
||||
$html = preg_replace('/<html.*?>.*?<body.*?>/is', '', $html);
|
||||
$html = preg_replace('/<\/body><\/html>/is', '', $html);
|
||||
<head>
|
||||
<title>PHP info</title>
|
||||
</head>
|
||||
|
||||
echo $html;
|
||||
<frameset rows="80,*">
|
||||
<frame src="phpinfo.php?topframe=true&sesskey=<?php echo $USER->sesskey ?>">
|
||||
<frame src="phpinfo.php?bottomframe=true&sesskey=<?php echo $USER->sesskey ?>">
|
||||
</frameset>
|
||||
|
||||
echo '</div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
<?php
|
||||
} else if ($topframe && confirm_sesskey()) {
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
print_header("$site->shortname: phpinfo", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> PHP info");
|
||||
exit;
|
||||
} else if ($bottomframe && confirm_sesskey()) {
|
||||
phpinfo();
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -16,8 +16,8 @@ if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
|
||||
$subject = get_string('noreplybouncesubject','moodle',$site->fullname);
|
||||
$body = get_string('noreplybouncemessage','moodle',$site->fullname)."\n\n";
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if ($fd) {
|
||||
@@ -54,7 +54,7 @@ if ($modid == '0') { // special
|
||||
}
|
||||
else {
|
||||
$modname = get_field("modules","name","id",$modid);
|
||||
include_once('mod/'.$modname.'/lib.php');
|
||||
require_once('mod/'.$modname.'/lib.php');
|
||||
}
|
||||
$function = $modname.'_process_email';
|
||||
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to manage questiontypes
|
||||
// This page is adapted from modules.php
|
||||
|
||||
// This page is not yet in service, the whole plug-in architecture
|
||||
// for question types is still under construction.
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
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");
|
||||
$strdelete = get_string("delete");
|
||||
$strversion = get_string("version");
|
||||
$strhide = get_string("hide");
|
||||
$strshow = get_string("show");
|
||||
$strsettings = get_string("settings");
|
||||
$strquestions = get_string("questions");
|
||||
$strquestiontype = get_string("questiontype", 'quiz');
|
||||
|
||||
print_header("$site->shortname: $strquestions", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strquestions");
|
||||
|
||||
print_heading($strquestions);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
if (!$qtype = get_record("question_types", "name", $hide)) {
|
||||
error("Question type doesn't exist!");
|
||||
}
|
||||
set_field("question_types", "visible", "0", "id", $qtype->id); // Hide question type
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
if (!$qtype = get_record("question_types", "name", $show)) {
|
||||
error("Question type doesn't exist!");
|
||||
}
|
||||
set_field("question_types", "visible", "1", "id", $qtype->id); // Show question type
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
|
||||
$strqtypename = get_string("qtypename", "qtype_$delete");
|
||||
|
||||
if (!$confirm) {
|
||||
notice_yesno(get_string("qtypedeleteconfirm", "admin", $strqtypename),
|
||||
"questiontypes.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
"questiontypes.php");
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "random") {
|
||||
error("You can not delete the random question type!!");
|
||||
}
|
||||
|
||||
if (!$qtype = get_record("question_types", "name", $delete)) {
|
||||
error("Question type doesn't exist!");
|
||||
}
|
||||
|
||||
// OK, first delete all the questions
|
||||
if ($questions = get_records("quiz_questions", "qtype", $qtype->id)) {
|
||||
foreach ($questions as $question) {
|
||||
if (! quiz_delete_question($coursemod->id, $coursemod->section)) {
|
||||
notify("Could not delete the $strqtypename with id = $question->id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// And the qtype entry itself
|
||||
if (!delete_records("question_types", "name", $qtype->name)) {
|
||||
notify("Error occurred while deleting the $strqtypename record from question_types table");
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$qtype->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->qtype = $strqtypename;
|
||||
$a->directory = "$CFG->dirroot/qtype/$delete";
|
||||
notice(get_string("qtypedeletefiles", "", $a), "questiontypes.php");
|
||||
}
|
||||
}
|
||||
|
||||
/// Get and sort the existing questiontypes
|
||||
|
||||
if (!$qtypes = get_records("question_types")) {
|
||||
error("No question types found!!"); // Should never happen
|
||||
}
|
||||
|
||||
foreach ($qtypes as $qtype) {
|
||||
$strqtypename = get_string("qtypename", "qtype_$qtype->name");
|
||||
$qtypebyname[$strqtypename] = $qtype;
|
||||
}
|
||||
ksort($qtypebyname);
|
||||
|
||||
/// Print the table of all questiontypes
|
||||
|
||||
$table->head = array ($strquestiontype, $strquestions, $strversion, "$strhide/$strshow", $strdelete, $strsettings);
|
||||
$table->align = array ("left", "right", "left", "center", "center", "center");
|
||||
$table->wrap = array ("nowrap", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
|
||||
foreach ($qtypebyname as $qtypename => $qtype) {
|
||||
|
||||
$icon = "<img src=\"$CFG->dirroot/mod/quiz/questiontypes/$qtype->name/icon.gif\" hspace=\"10\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" />";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/quiz/questiontypes/$qtype->name/config.html")) {
|
||||
$settings = "<a href=\"questiontype.php?qtype=$qtype->name\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
|
||||
$count = count_records('quiz_questions', 'qtype', $qtype->id);
|
||||
|
||||
$delete = $count ? '' : "<a href=\"questiontypes.php?delete=$qtype->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
|
||||
if ($qtype->visible) {
|
||||
$visible = "<a href=\"questiontypes.php?hide=$qtype->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"questiontypes.php?show=$qtype->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
if ($qtype->name == "random") {
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$table->data[] = array ("<span $class>$icon $qtypename</span>", $count, $qtype->version, $visible, $delete, $settings);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
echo "<br /><br />";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+96
-94
@@ -5,14 +5,16 @@
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
@@ -24,7 +26,7 @@
|
||||
}
|
||||
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
|
||||
set_config('siteidentifier', random_string(32));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,160 +35,160 @@
|
||||
$stradministration = get_string("administration");
|
||||
$strregistration = get_string("registration");
|
||||
$strregistrationinfo = get_string("registrationinfo");
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strregistration, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$site->shortname: $strregistration", $site->fullname, $navigation);
|
||||
|
||||
print_header("$site->shortname: $strregistration", "$site->fullname",
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
|
||||
|
||||
print_heading($strregistration);
|
||||
|
||||
print_simple_box($strregistrationinfo, "center", "70%");
|
||||
echo "<br />";
|
||||
|
||||
|
||||
/// Print the form
|
||||
|
||||
echo "<form id=\"mform1\" class=\"mform\" action=\"http://moodle.org/register/\" method=\"post\">\n";
|
||||
echo '<fieldset id="registration">';
|
||||
echo '<legend>Registration Information</legend>';
|
||||
print_simple_box_start("center", "");
|
||||
|
||||
echo "<form name=\"form\" action=\"http://moodle.org/register/\" method=\"post\">\n";
|
||||
echo "<table cellpadding=\"9\" border=\"0\">\n";
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"center\" colspan=\"2\">".get_string("location")."</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">Moodle URL:</td>\n";
|
||||
echo "<td>$CFG->wwwroot</td>\n";
|
||||
echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
|
||||
echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
|
||||
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\" />\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\">\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\">\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\">\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\" />\n";
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("currentversion").":</td>\n";
|
||||
echo "<td>$CFG->release ($CFG->version)</td>\n";
|
||||
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\">\n";
|
||||
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>URL</label></div>';
|
||||
echo '<div class="felement ftext">'.$CFG->wwwroot.'</div>';
|
||||
echo '</div>';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("fullsitename").":</td>\n";
|
||||
echo "<td><input size=\"50\" type=\"text\" name=\"sitename\" value=\"$site->fullname\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("currentversion").'</label></div>';
|
||||
echo '<div class="felement ftext">'."$CFG->release ($CFG->version)".'</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="sitename">'.get_string("fullsitename").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo '<input size="50" id="sitename" type="text" name="sitename" value="'.format_string($site->fullname).'" />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menucountry">'.get_string("country").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("country").":</td>\n";
|
||||
echo "<td>";
|
||||
choose_from_menu (get_list_of_countries(), "country", $admin->country, get_string("selectacountry")."...", "", "");
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menupublic">'."<a href=\"http://moodle.org/sites/?country=$admin->country\" title=\"".get_string("publicdirectorytitle")."\">".get_string("publicdirectory")."</a>".'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\"><a href=\"http://moodle.org/sites/?country=$admin->country\" title=\"See the current list of sites\" target=_blank>".get_string("publicdirectory")."</a>:</td>\n";
|
||||
echo "<td>";
|
||||
$options[0] = get_string("publicdirectory0");
|
||||
$options[1] = get_string("publicdirectory1");
|
||||
$options[2] = get_string("publicdirectory2");
|
||||
choose_from_menu ($options, "public", "2", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menucontact">'.get_string("registrationcontact").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("registrationcontact")."</a>:</td>\n";
|
||||
echo "<td>\n";
|
||||
$options[0] = get_string("registrationcontactno");
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
choose_from_menu ($options, "contact", "1", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("statistics")."<br />(".get_string("notpublic").')'.'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("statistics").":";
|
||||
echo "<br />(".get_string("notpublic").')';
|
||||
echo "</td>\n";
|
||||
echo "<td>";
|
||||
|
||||
$count = count_records('course')-1;
|
||||
echo get_string("courses").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courses\" value=\"$count\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"courses\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('user', 'deleted', 0);
|
||||
$count = count_records('user')-1;
|
||||
echo get_string("users").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"users\" value=\"$count\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"users\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
// total number of role assignments
|
||||
$count = count_records('role_assignments');
|
||||
echo get_string('roleassignments', 'role').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"roleassignments\" value=\"$count\" />\n";
|
||||
$count = count_records('user_students');
|
||||
echo get_string("enrolments").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"enrolments\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
// first find all distinct roles with mod/course:update
|
||||
// please change the name and strings to something appropriate to reflect the new data collected
|
||||
$sql = "SELECT COUNT(DISTINCT u.id)
|
||||
FROM {$CFG->prefix}role_capabilities rc,
|
||||
{$CFG->prefix}role_assignments ra,
|
||||
{$CFG->prefix}user u
|
||||
WHERE (rc.capability = 'moodle/course:update' or rc.capability='moodle/site:doanything')
|
||||
AND rc.roleid = ra.roleid
|
||||
AND u.id = ra.userid";
|
||||
|
||||
$count = count_records_sql($sql);
|
||||
$count = count_records('user_teachers');
|
||||
echo get_string("teachers").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courseupdaters\" value=\"$count\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"teachers\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('forum_posts');
|
||||
echo get_string("posts", 'forum').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"posts\" value=\"$count\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"posts\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('question');
|
||||
echo get_string("questions", 'quiz').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"questions\" value=\"$count\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"questions\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('resource');
|
||||
echo get_string("modulenameplural", "resource").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"resources\" value=\"$count\" />\n";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "<input type=\"hidden\" name=\"resources\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="adminname">'.get_string("administrator").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<input size=\"50\" type=\"text\" id=\"adminname\" name=\"adminname\" value=\"".fullname($admin, true)."\" />";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="adminemail">'.get_string("email").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<input size=\"50\" type=\"text\" id=\"adminemail\" name=\"adminemail\" value=\"$admin->email\" />";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"center\" colspan=\"2\"><hr size=\"1\" noshade>".get_string("administrator")."</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menumailme">'.get_string("registrationemail").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("administrator").":</td>\n";
|
||||
echo "<td><input size=\"50\" type=\"text\" name=\"adminname\" value=\"".fullname($admin, true)."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("email").":</td>\n";
|
||||
echo "<td><input size=\"50\" type=\"text\" name=\"adminemail\" value=\"$admin->email\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("registrationemail")."</a>:</td>\n";
|
||||
echo "<td>\n";
|
||||
$options[0] = get_string("registrationno");
|
||||
$options[1] = get_string("registrationyes");
|
||||
choose_from_menu ($options, "mailme", "1", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="felement fsubmit"><input name="submitbutton" value="'.get_string('registrationsend').'" type="submit" id="id_submitbutton" /></div>';
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\"> </td>\n";
|
||||
echo "<td><input type=\"submit\" value=\"".get_string("registrationsend")."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<br />\n";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+30
-24
@@ -2,51 +2,57 @@
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('replace');
|
||||
|
||||
$search = optional_param('search', '', PARAM_RAW);
|
||||
$replace = optional_param('replace', '', PARAM_RAW);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Admins only");
|
||||
}
|
||||
|
||||
###################################################################
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_heading('Search and replace text throughout the whole database');
|
||||
print_header('Search and replace throughout the whole database', 'Replace text within the whole database');
|
||||
|
||||
|
||||
if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form
|
||||
if (!$search or !$replace or !confirm_sesskey()) { /// Print a form
|
||||
|
||||
print_simple_box_start('center');
|
||||
echo '<div align="center">';
|
||||
echo '<form action="replace.php" method="post">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo 'Search whole database for: <input type="text" name="search" /><br />';
|
||||
echo 'Replace with this string: <input type="text" name="replace" /><br />';
|
||||
echo '<input type="submit" value="Yes, do it now" /><br />';
|
||||
echo '<form action="replace.php">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'">';
|
||||
echo 'Search whole database for: <input type="text" name="search"><br />';
|
||||
echo 'Replace with this string: <input type="text" name="replace"><br /></br />';
|
||||
echo '<input type="submit" value="Yes, do it now"><br />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
if (!db_replace($search, $replace)) {
|
||||
error('An error has occured during this process');
|
||||
if (!$tables = $db->Metatables() ) { // No tables yet at all.
|
||||
error("no tables");
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
foreach ($tables as $table) {
|
||||
if (in_array($table, array($CFG->prefix.'config'))) { // Don't process these
|
||||
continue;
|
||||
}
|
||||
if ($columns = $db->MetaColumns($table, false)) {
|
||||
foreach ($columns as $column => $data) {
|
||||
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
|
||||
$db->debug = true;
|
||||
execute_sql("UPDATE $table SET $column = REPLACE($column, '$search', '$replace');");
|
||||
$db->debug = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
notify('Rebuilding course cache...');
|
||||
rebuild_course_cache();
|
||||
notify('...finished');
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php // $Id$
|
||||
// Display all the reports available in admin/report
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You are not allowed to look at this page");
|
||||
}
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strreports = get_string('reports');
|
||||
$strmisc = get_string('miscellaneous');
|
||||
|
||||
print_header($strreports, $strreports,
|
||||
'<a href="index.php">'.$stradmin.'</a> -> <a href="misc.php">'.$strmisc.'</a> ->'.
|
||||
$strreports);
|
||||
|
||||
$directories = get_list_of_plugins('admin/report');
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
echo '<div class="plugin '.$directory.'">';
|
||||
include_once($CFG->dirroot.'/admin/report/'.$directory.'/mod.php'); // Fragment for listing
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php // $Id$
|
||||
// index.php - scheduled backup logs
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/backup/lib.php');
|
||||
|
||||
admin_externalpage_setup('reportbackups');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
|
||||
require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
/// Scheduled backups are disabled by the server admin
|
||||
if (!empty($CFG->disablescheduledbackups)) {
|
||||
print_error('scheduledbackupsdisabled', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Scheduled backups aren't active by the site admin
|
||||
$backup_config = backup_get_config();
|
||||
if (empty($backup_config->backup_sche_active)) {
|
||||
notify(get_string('scheduledbackupsinactive'));
|
||||
}
|
||||
|
||||
/// Get needed strings
|
||||
$backuploglaststatus = get_string("backuploglaststatus");
|
||||
$backuplogdetailed = get_string("backuplogdetailed");
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strbackup = get_string("backup");
|
||||
$strbackupdetails = get_string("backupdetails");
|
||||
$strlogs = get_string("logs");
|
||||
$strftimedatetime = get_string("strftimerecent");
|
||||
$strftimetime = get_string("strftimetime").":%S";
|
||||
$strerror = get_string("error");
|
||||
$strok = get_string("ok");
|
||||
$strunfinished = get_string("unfinished");
|
||||
$strskipped = get_string("skipped");
|
||||
$strcourse = get_string("course");
|
||||
$strtimetaken = get_string("timetaken","quiz");
|
||||
$strstatus = get_string("status");
|
||||
$strnext = get_string("next");
|
||||
|
||||
/// Decide when to show last execution logs or detailed logs
|
||||
/// Lastlog view
|
||||
if (!$courseid) {
|
||||
print_heading($backuploglaststatus);
|
||||
print_simple_box_start('center');
|
||||
/// Now, get every record from backup_courses
|
||||
$courses = get_records("backup_courses");
|
||||
|
||||
if (!$courses) {
|
||||
notify(get_string('nologsfound'));
|
||||
} else {
|
||||
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
||||
//Print table header
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strcourse</font></td>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\"><font size=\"3\">$strtimetaken</font></td>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strstatus</font></td>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strnext</font></td></tr>";
|
||||
foreach ($courses as $course) {
|
||||
/// Get the course shortname
|
||||
$coursename = get_field ("course","fullname","id",$course->courseid);
|
||||
if ($coursename) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\"><a href=\"index.php?courseid=$course->courseid\">".$coursename."</a></font></td>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->laststarttime,$strftimedatetime)."</font></td>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\"> - </font></td>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->lastendtime,$strftimedatetime)."</font></td>";
|
||||
if ($course->laststatus == 1) {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strok."</font></td>";
|
||||
} else if ($course->laststatus == 2) {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strunfinished."</font></td>";
|
||||
} else if ($course->laststatus == 3) {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strskipped."</font></td>";
|
||||
} else {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strerror."</font></td>";
|
||||
}
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->nextstarttime,$strftimedatetime)."</font></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
/// Detailed View !!
|
||||
} else {
|
||||
print_heading($backuplogdetailed);
|
||||
|
||||
$coursename = get_field("course","fullname","id","$courseid");
|
||||
print_heading("$strcourse: $coursename");
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
/// First, me get all the distinct backups for that course in backup_log
|
||||
$executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid'
|
||||
ORDER BY laststarttime DESC");
|
||||
|
||||
/// Iterate over backup executions
|
||||
if (!$executions) {
|
||||
notify(get_string('nologsfound'));
|
||||
} else {
|
||||
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
||||
foreach($executions as $execution) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\">";
|
||||
print_simple_box("<center>".userdate($execution->laststarttime)."</center>", "center");
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
$logs = get_records_sql("SELECT *
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid' AND
|
||||
laststarttime = '$execution->laststarttime'
|
||||
ORDER BY id");
|
||||
if ($logs) {
|
||||
foreach ($logs as $log) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($log->time,$strftimetime)."</font></td>";
|
||||
$log->info = str_replace("- ERROR!!","- <font color=\"red\">ERROR!!</font>",$log->info);
|
||||
$log->info = str_replace("- OK","- <font color=\"green\">OK</font>",$log->info);
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".str_replace(" "," ",$log->info)."</font></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -2,20 +2,19 @@
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportcourseoverview');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM)); // needed?
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("This page is for admins only");
|
||||
}
|
||||
|
||||
$course = get_site();
|
||||
@@ -24,14 +23,16 @@
|
||||
$strreports = get_string('reports');
|
||||
$strcourseoverview = get_string('courseoverview');
|
||||
|
||||
$strnav = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.get_string('administration').'</a> -> <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/report.php">'.$strreports.'</a> -> '.$strcourseoverview;
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend');
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
@@ -43,13 +44,15 @@
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
if (empty($timeoptions)) {
|
||||
print_error('nostatstodisplay', "", $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
print_header($strcourseoverview, $strcourseoverview, $strnav,'','',true,' ');
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n";
|
||||
echo '<div>';
|
||||
|
||||
$table->width = '*';
|
||||
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
@@ -57,63 +60,56 @@
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
print_table($table);
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
print_heading($reportoptions[$report]);
|
||||
|
||||
|
||||
if (!empty($report) && !empty($time)) {
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
if (!empty($param->sql)) {
|
||||
$sql = $param->sql;
|
||||
} else {
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0"
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby;
|
||||
}
|
||||
error_log($sql);
|
||||
|
||||
$courses = get_records_sql($sql, 0, $numcourses);
|
||||
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= ".$param->timeafter
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby
|
||||
." LIMIT ".$numcourses;
|
||||
|
||||
$courses = get_records_sql($sql);
|
||||
|
||||
if (empty($courses)) {
|
||||
notify(get_string('statsnodata'));echo '</td></tr></table>';echo '<p>after notify</p>';
|
||||
|
||||
} else {
|
||||
if (empty($CFG->gdversion)) {
|
||||
echo '<div class="graph">(' . get_string("gdneed") .')</div>';
|
||||
} else {
|
||||
echo '<div class="graph"><img alt="'.get_string('courseoverviewgraph').'" src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></div>';
|
||||
}
|
||||
|
||||
$table = new StdClass;
|
||||
$table->align = array('left','center','center','center');
|
||||
$table->head = array(get_string('course'),$param->line1);
|
||||
if (!empty($param->line2)) {
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
if (!empty($param->line3)) {
|
||||
$table->head[] = $param->line3;
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$a = array();
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
|
||||
|
||||
$a[] = $c->line1;
|
||||
if (isset($c->line2)) {
|
||||
$a[] = $c->line2;
|
||||
}
|
||||
if (isset($c->line3)) {
|
||||
$a[] = round($c->line3,2);
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
error(get_string('statsnodata'),$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/index.php');
|
||||
}
|
||||
|
||||
if (empty($CFG->gdversion)) {
|
||||
echo "<center>(".get_string("gdneed").")</center>";
|
||||
} else {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></center>';
|
||||
}
|
||||
|
||||
$table = new object();
|
||||
$table->align = array('left','center','center','center');
|
||||
$table->head = array(get_string('course'),$param->line1);
|
||||
if (!empty($param->line2)) {
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
if (!empty($param->line3)) {
|
||||
$table->head[] = $param->line3;
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$a = array();
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
|
||||
|
||||
$a[] = $c->line1;
|
||||
if (isset($c->line2)) {
|
||||
$a[] = $c->line2;
|
||||
}
|
||||
if (isset($c->line3)) {
|
||||
$a[] = $c->line3;
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
|
||||
$strreports = get_string('reports');
|
||||
$strcourseoverview = get_string('courseoverview');
|
||||
|
||||
print_heading("$strcourseoverview:");
|
||||
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
$course = get_site();
|
||||
$statsstatus = stats_check_uptodate($course->id);
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
$table->width = '*';
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
echo '<form action="report/courseoverview/index.php" method="post">'."\n";
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
if ($statsstatus !== NULL) {
|
||||
notify ($statsstatus);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -10,28 +10,27 @@
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("You must be an admin to use this page");
|
||||
}
|
||||
|
||||
stats_check_uptodate();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
|
||||
if (!empty($param->sql)) {
|
||||
$sql = $param->sql;
|
||||
} else {
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0"
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby;
|
||||
}
|
||||
|
||||
$courses = get_records_sql($sql, 0, $numcourses);
|
||||
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= ".$param->timeafter
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby
|
||||
." LIMIT ".$numcourses;
|
||||
|
||||
$courses = get_records_sql($sql);
|
||||
|
||||
if (empty($courses)) {
|
||||
print_error('statsnodata', "", $CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
|
||||
error(get_string('statsnodata'),$CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$graph = new graph(750,400);
|
||||
|
||||
@@ -39,8 +38,6 @@
|
||||
$graph->parameter['legend_size'] = 10;
|
||||
$graph->parameter['x_axis_angle'] = 90;
|
||||
$graph->parameter['title'] = false; // moodle will do a nicer job.
|
||||
$graph->y_tick_labels = null;
|
||||
$graph->offset_relation = null;
|
||||
if ($report != STATS_REPORT_ACTIVE_COURSES) {
|
||||
$graph->parameter['y_decimal_left'] = 2;
|
||||
}
|
||||
@@ -53,5 +50,5 @@
|
||||
$graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
|
||||
|
||||
$graph->draw_stack();
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/course/report/log/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportlog');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
|
||||
$course = get_site();
|
||||
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_mnet_log_selector_form($CFG->mnet_localhost_id, $course);
|
||||
|
||||
echo '<br />';
|
||||
print_heading(get_string('chooselivelogs') .':');
|
||||
|
||||
$heading = link_to_popup_window('/course/report/log/live.php?id='. $course->id,
|
||||
'livelog', get_string('livelogs'),
|
||||
500, 800, '', 'none', true);
|
||||
|
||||
print_heading($heading, 'center', 3);
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/course/report/log/lib.php');
|
||||
|
||||
$course = get_site();
|
||||
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_log_selector_form($course);
|
||||
|
||||
echo '<br />';
|
||||
print_heading(get_string('chooselivelogs') .':');
|
||||
|
||||
echo '<center><h3>';
|
||||
link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800);
|
||||
echo '</h3></center>';
|
||||
|
||||
?>
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/question/upgrade.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportquestion');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading(get_string('adminreport', 'question'));
|
||||
|
||||
$probstr = '';
|
||||
$contextupgradeversion = 2007081000;
|
||||
if ($CFG->version < $contextupgradeversion){
|
||||
///cwrqpfs issue
|
||||
$probstr = print_heading(get_string('cwrqpfs', 'question'), '', 3, 'main', true);
|
||||
|
||||
if ($updates = question_cwqpfs_to_update()){
|
||||
|
||||
$probstr .=get_string('cwrqpfsinfo', 'question');
|
||||
$probstr .= '<ul>';
|
||||
$catlist = join(array_keys($updates), ',');
|
||||
//get info about cateogries and no of questions used outside category's course
|
||||
$categories = get_records_sql('SELECT qc.*, c.fullname as coursename FROM '.$CFG->prefix.'question_categories as qc, '
|
||||
.$CFG->prefix.'course as c WHERE qc.course = c.id AND qc.id IN ('.$catlist.')');
|
||||
foreach ($updates as $id => $publish){
|
||||
$categories[$id]->caturl = "$CFG->wwwroot/question/category.php?sesskey=".sesskey().
|
||||
"&edit=$id&courseid=".$categories[$id]->course;
|
||||
if ($categories[$id]->publish){
|
||||
$categories[$id]->changefrom = get_string('published', 'question');
|
||||
$categories[$id]->changeto = get_string('unpublished', 'question');
|
||||
} else {
|
||||
$categories[$id]->changefrom = get_string('unpublished', 'question');
|
||||
$categories[$id]->changeto = get_string('published', 'question');
|
||||
}
|
||||
$probstr .= '<li>'.get_string('changepublishstatuscat', 'question', $categories[$id]);
|
||||
if ($questions = get_records_sql('SELECT q.*, qui.id as quizid, qui.name as quizname, cm.id as cmid, '
|
||||
.'qui.course, c.fullname as coursename FROM '.$CFG->prefix.'question q, '
|
||||
.$CFG->prefix.'quiz_question_instances qqi, '
|
||||
.$CFG->prefix.'quiz qui, '
|
||||
.$CFG->prefix.'course_modules cm, '
|
||||
.$CFG->prefix.'modules m, '
|
||||
.$CFG->prefix.'course c '
|
||||
.'WHERE (q.category = '.$id.' AND qqi.question = q.id '
|
||||
.'AND qqi.quiz = qui.id '
|
||||
.'AND qui.course = c.id '
|
||||
.'AND cm.instance = qui.id '
|
||||
.'AND cm.module = m.id '
|
||||
.'AND m.name = \'quiz\''
|
||||
.'AND ('.$categories[$id]->course.' <> qui.course)) ORDER BY qui.id ASC')){
|
||||
|
||||
$probstr .= '<ul>';
|
||||
foreach ($questions as $question){
|
||||
$question->quizurl = "$CFG->wwwroot/mod/quiz/edit.php?cmid=".$question->cmid;
|
||||
$question->qurl = "$CFG->wwwroot/question/question.php?cmid={$question->cmid}&id={$question->id}&returnurl=".urlencode($FULLME);
|
||||
$probstr .= '<li>'.get_string('questionaffected', 'question', $question).'</li>';
|
||||
}
|
||||
$probstr .= '</ul>';
|
||||
}
|
||||
$probstr .= '</li>';
|
||||
}
|
||||
$probstr .= '</ul>';
|
||||
} else {
|
||||
$probstr .=('<p>'.get_string('cwrqpfsnoprob', 'question').'</p>');
|
||||
}
|
||||
}
|
||||
if ($probstr) {
|
||||
print_box($probstr);
|
||||
} else {
|
||||
print_box(get_string('noprobs', 'question'), 'boxwidthnarrow boxaligncenter generalbox');
|
||||
}
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A SimpleTest report format for Moodle.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @version $Id$
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/simpletestlib/reporter.php');
|
||||
|
||||
/**
|
||||
* Extended in-browser test displayer. HtmlReporter generates
|
||||
* only failure messages and a pass count. ExHtmlReporter also
|
||||
* generates pass messages and a time-stamp.
|
||||
*
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class ExHtmlReporter extends HtmlReporter {
|
||||
|
||||
// Options set when the class is created.
|
||||
var $showpasses;
|
||||
|
||||
// Lang strings. Set in the constructor.
|
||||
var $strrunonlyfolder;
|
||||
var $strrunonlyfile;
|
||||
|
||||
var $strseparator;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bool $showpasses Whether this reporter should output anything for passes.
|
||||
*/
|
||||
function ExHtmlReporter($showpasses) {
|
||||
global $CFG, $THEME;
|
||||
|
||||
$this->HtmlReporter();
|
||||
$this->showpasses = $showpasses;
|
||||
|
||||
$this->strrunonlyfolder = $this->get_string('runonlyfolder');
|
||||
$this->strrunonlyfile = $this->get_string('runonlyfile');
|
||||
$this->strseparator = get_separator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a pass needs to be output.
|
||||
*/
|
||||
function paintPass($message) {
|
||||
//(Implicitly call grandparent, as parent not implemented.)
|
||||
parent::paintPass($message);
|
||||
if ($this->showpasses) {
|
||||
$this->_paintPassFail('pass', $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a fail needs to be output.
|
||||
*/
|
||||
function paintFail($message) {
|
||||
// Explicitly call grandparent, not parent::paintFail.
|
||||
SimpleScorer::paintFail($message);
|
||||
$this->_paintPassFail('fail', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an error (uncaught exception or PHP error) needs to be output.
|
||||
*/
|
||||
function paintError($message) {
|
||||
// Explicitly call grandparent, not parent::paintFail.
|
||||
SimpleScorer::paintError($message);
|
||||
$this->_paintPassFail('exception', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method. Used by printPass/Fail/Error.
|
||||
*/
|
||||
function _paintPassFail($passorfail, $message) {
|
||||
global $FULLME, $CFG;
|
||||
|
||||
print_simple_box_start('', '100%', '', 5, $passorfail . ' generalbox');
|
||||
$url = $this->_htmlEntities($this->_stripParameterFromUrl($FULLME, 'path'));
|
||||
echo '<b class="', $passorfail, '">', $this->get_string($passorfail), '</b>: ';
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
$file = array_shift($breadcrumb);
|
||||
$pathbits = preg_split('/\/|\\\\/', substr($file, strlen($CFG->dirroot) + 1));
|
||||
$file = array_pop($pathbits);
|
||||
$folder = '';
|
||||
foreach ($pathbits as $pathbit) {
|
||||
$folder .= $pathbit . '/';
|
||||
echo "<a href=\"{$url}path=$folder\" title=\"$this->strrunonlyfolder\">$pathbit</a>/";
|
||||
}
|
||||
echo "<a href=\"{$url}path=$folder$file\" title=\"$this->strrunonlyfile\">$file</a>";
|
||||
echo $this->strseparator, implode($this->strseparator, $breadcrumb);
|
||||
echo $this->strseparator, '<br />', $this->_htmlEntities($message), "\n\n";
|
||||
print_simple_box_end();
|
||||
flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a notice needs to be output.
|
||||
*/
|
||||
function paintNotice($message) {
|
||||
$this->paintMessage($this->_htmlEntities($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a simple supplementary message.
|
||||
* @param string $message Text to display.
|
||||
*/
|
||||
function paintMessage($message) {
|
||||
if ($this->showpasses) {
|
||||
print_simple_box_start('', '100%');
|
||||
echo '<span class="notice">', $this->get_string('notice'), '</span>: ';
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
echo implode($this->strseparator, $breadcrumb);
|
||||
echo $this->strseparator, '<br />', $message, "\n";
|
||||
print_simple_box_end();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output anything that should appear above all the test output.
|
||||
*/
|
||||
function paintHeader($test_name) {
|
||||
// We do this the moodle way instead.
|
||||
}
|
||||
|
||||
/**
|
||||
* Output anything that should appear below all the test output, e.g. summary information.
|
||||
*/
|
||||
function paintFooter($test_name) {
|
||||
$summarydata = new stdClass;
|
||||
$summarydata->run = $this->getTestCaseProgress();
|
||||
$summarydata->total = $this->getTestCaseCount();
|
||||
$summarydata->passes = $this->getPassCount();
|
||||
$summarydata->fails = $this->getFailCount();
|
||||
$summarydata->exceptions = $this->getExceptionCount();
|
||||
|
||||
if ($summarydata->fails == 0 && $summarydata->exceptions == 0) {
|
||||
$status = "passed";
|
||||
} else {
|
||||
$status = "failed";
|
||||
}
|
||||
echo '<div class="unittestsummary ', $status, '">';
|
||||
echo $this->get_string('summary', $summarydata);
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="performanceinfo">',
|
||||
$this->get_string('runat', date('<b>d-m-Y H:i T</b>')),
|
||||
$this->get_string('version', SimpleTestOptions::getVersion()),
|
||||
'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip a specified parameter from the query string of a URL, if present.
|
||||
* Adds a separator to the end of the URL, so that a new parameter
|
||||
* can easily be appended. For example (assuming $param = 'frog'):
|
||||
*
|
||||
* http://example.com/index.php -> http://example.com/index.php?
|
||||
* http://example.com/index.php?frog=1 -> http://example.com/index.php?
|
||||
* http://example.com/index.php?toad=1 -> http://example.com/index.php?toad=1&
|
||||
* http://example.com/index.php?frog=1&toad=1 -> http://example.com/index.php?toad=1&
|
||||
*
|
||||
* @param string $url the URL to modify.
|
||||
* @param string $param the parameter to strip from the URL, if present.
|
||||
*
|
||||
* @return string The modified URL.
|
||||
*/
|
||||
function _stripParameterFromUrl($url, $param) {
|
||||
$url = preg_replace('/(\?|&)' . $param . '=[^&]*&?/', '$1', $url);
|
||||
if (strpos($url, '?') === false) {
|
||||
$url = $url . '?';
|
||||
} else {
|
||||
$url = $url . '&';
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a lang string in the appropriate file.
|
||||
*/
|
||||
function get_string($identifier, $a = NULL) {
|
||||
return get_string($identifier, 'simpletest', $a);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A SimpleTest GroupTest that automatically finds all the
|
||||
* test files in a directory tree according to certain rules.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @version $Id$
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/simpletestlib/test_case.php');
|
||||
|
||||
/**
|
||||
* This is a composite test class for finding test cases and
|
||||
* other RunnableTest classes in a directory tree and combining
|
||||
* them into a group test.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class AutoGroupTest extends GroupTest {
|
||||
|
||||
var $thorough;
|
||||
var $showsearch;
|
||||
|
||||
function AutoGroupTest($showsearch, $thorough, $test_name = null) {
|
||||
$this->GroupTest($test_name);
|
||||
$this->showsearch = $showsearch;
|
||||
$this->thorough = $thorough;
|
||||
}
|
||||
|
||||
function setLabel($test_name) {
|
||||
//:HACK: there is no GroupTest::setLabel, so access parent::_label.
|
||||
$this->_label = $test_name;
|
||||
}
|
||||
|
||||
function addIgnoreFolder($ignorefolder) {
|
||||
$this->ignorefolders[]=$ignorefolder;
|
||||
}
|
||||
|
||||
function _recurseFolders($path) {
|
||||
if ($this->showsearch) {
|
||||
echo '<li>' . basename(realpath($path)) . '<ul>';
|
||||
}
|
||||
|
||||
$files = scandir($path);
|
||||
static $s_count = 0;
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
$file_path = $path . '/' . $file;
|
||||
if (is_dir($file_path)) {
|
||||
if ($file != 'CVS' && !in_array($file_path, $this->ignorefolders)) {
|
||||
$this->_recurseFolders($file_path);
|
||||
}
|
||||
} elseif (preg_match('/simpletest(\/|\\\\)test.*\.php$/', $file_path) ||
|
||||
($this->thorough && preg_match('/simpletest(\/|\\\\)slowtest.*\.php$/', $file_path))) {
|
||||
|
||||
$s_count++;
|
||||
// OK, found: this shows as a 'Notice' for any 'simpletest/test*.php' file.
|
||||
$this->addTestCase(new FindFileNotice($file_path, 'Found unit test file, '. $s_count));
|
||||
|
||||
// addTestFile: Unfortunately this doesn't return fail/success (bool).
|
||||
$this->addTestFile($file_path, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->showsearch) {
|
||||
echo '</ul></li>';
|
||||
}
|
||||
return $s_count;
|
||||
}
|
||||
|
||||
function findTestFiles($dir) {
|
||||
if ($this->showsearch) {
|
||||
echo '<p>Searching folder: ' . realpath($dir) . '</p><ul>';
|
||||
}
|
||||
$path = $dir;
|
||||
$count = $this->_recurseFolders($path);
|
||||
if ($count <= 0) {
|
||||
$this->addTestCase(new BadAutoGroupTest($path, 'Search complete. No unit test files found'));
|
||||
} else {
|
||||
$this->addTestCase(new AutoGroupTestNotice($path, 'Search complete. Total unit test files found: '. $count));
|
||||
}
|
||||
if ($this->showsearch) {
|
||||
echo '</ul>';
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function addTestFile($file, $internalcall = false) {
|
||||
if ($this->showsearch) {
|
||||
if ($internalcall) {
|
||||
echo '<li><b>' . basename($file) . '</b></li>';
|
||||
} else {
|
||||
echo '<p>Adding test file: ' . realpath($file) . '</p>';
|
||||
}
|
||||
// Make sure that syntax errors show up suring the search, otherwise you often
|
||||
// get blank screens because evil people turn down error_reporting elsewhere.
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
if(!is_file($file) ){
|
||||
parent::addTestCase(new BadTest($file, 'Not a file or does not exist'));
|
||||
}
|
||||
parent::addTestFile($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ======================================================================= */
|
||||
// get_class_ex: Insert spaces to prettify the class-name.
|
||||
function get_class_ex($object) {
|
||||
return preg_replace('/(.?)([A-Z])/', '${1} ${2}', get_class($object));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A failing test base-class for when a test suite has NOT loaded properly.
|
||||
* See class, simple_test.php: BadGroupTest.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class BadTest {
|
||||
|
||||
var $label;
|
||||
var $error;
|
||||
|
||||
function BadTest($label, $error) {
|
||||
$this->label = $label;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
function run(&$reporter) {
|
||||
$reporter->paintGroupStart(basename(__FILE__), $this->getSize());
|
||||
$reporter->paintFail(get_class_ex($this) .' [' . $this->getLabel() .
|
||||
'] with error [' . $this->error . ']');
|
||||
$reporter->paintGroupEnd($this->getLabel());
|
||||
return $reporter->getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the number of test cases starting.
|
||||
*/
|
||||
function getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An informational notice base-class for when a test suite is being processed.
|
||||
* See class, simple_test.php: BadGroupTest.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class Notice {
|
||||
|
||||
var $label;
|
||||
var $status;
|
||||
|
||||
function Notice($label, $error) {
|
||||
$this->label = $label;
|
||||
$this->status = $error;
|
||||
}
|
||||
|
||||
function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
function run(&$reporter) {
|
||||
$reporter->paintGroupStart(basename(__FILE__), $this->getSize());
|
||||
$reporter->paintNotice(get_class_ex($this) .
|
||||
' ['. $this->getLabel() .'] with status [' . $this->status . ']');
|
||||
$reporter->paintGroupEnd($this->getLabel());
|
||||
return $reporter->getStatus();
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A failing folder test for when the test-user specifies an invalid directory
|
||||
* (run.php?folder=woops).
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class BadFolderTest extends BadTest { }
|
||||
|
||||
/**
|
||||
* A failing auto test for when no unit test files are found.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class BadAutoGroupTest extends BadTest { }
|
||||
|
||||
/**
|
||||
* Auto group test notices - 1. Search complete. 2. A test file has been found.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class AutoGroupTestNotice extends Notice { }
|
||||
|
||||
class FindFileNotice extends Notice { }
|
||||
?>
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Run the unit tests.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @version $Id$
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
|
||||
/** */
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/simpletestlib.php');
|
||||
require_once('ex_simple_test.php');
|
||||
require_once('ex_reporter.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
/* The UNITTEST constant can be checked elsewhere if you need to know
|
||||
* when your code is being run as part of a unit test. */
|
||||
define('UNITTEST', true);
|
||||
$langfile = 'simpletest';
|
||||
|
||||
// CGI arguments
|
||||
$path = optional_param('path', null, PARAM_PATH);
|
||||
$showpasses = optional_param('showpasses', false, PARAM_BOOL);
|
||||
$showsearch = optional_param('showsearch', false, PARAM_BOOL);
|
||||
$thorough = optional_param('thorough', false, PARAM_BOOL);
|
||||
|
||||
// Print the header.
|
||||
admin_externalpage_setup('reportsimpletest');
|
||||
$strtitle = get_string('unittests', $langfile);
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (!is_null($path)) {
|
||||
// Create the group of tests.
|
||||
$test =& new AutoGroupTest($showsearch, $thorough);
|
||||
|
||||
// OU specific. We use the _nonproject folder for stuff we want to
|
||||
// keep in CVS, but which is not really relevant. It does no harm
|
||||
// to leave this here.
|
||||
$test->addIgnoreFolder($CFG->dirroot . '/_nonproject');
|
||||
|
||||
// Make the reporter, which is what displays the results.
|
||||
$reporter = new ExHtmlReporter($showpasses);
|
||||
|
||||
if ($showsearch) {
|
||||
print_heading('Searching for test cases');
|
||||
}
|
||||
flush();
|
||||
|
||||
// Work out what to test.
|
||||
if (substr($path, 0, 1) == '/') {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
$path = $CFG->dirroot . '/' . $path;
|
||||
if (substr($path, -1) == '/') {
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
$displaypath = substr($path, strlen($CFG->dirroot) + 1);
|
||||
$ok = true;
|
||||
if (is_file($path)) {
|
||||
$test->addTestFile($path);
|
||||
} else if (is_dir($path)){
|
||||
$test->findTestFiles($path);
|
||||
} else {
|
||||
print_simple_box(get_string('pathdoesnotexist', $langfile, $path), '', '', '', '', 'errorbox');
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
// If we have something to test, do it.
|
||||
if ($ok) {
|
||||
if ($path == $CFG->dirroot) {
|
||||
$title = get_string('moodleunittests', $langfile, get_string('all', $langfile));
|
||||
} else {
|
||||
$title = get_string('moodleunittests', $langfile, $displaypath);
|
||||
}
|
||||
print_heading($title);
|
||||
$test->run($reporter);
|
||||
}
|
||||
|
||||
$formheader = get_string('retest', $langfile);
|
||||
} else {
|
||||
$displaypath = '';
|
||||
$formheader = get_string('rununittests', $langfile);
|
||||
}
|
||||
// Print the form for adjusting options.
|
||||
print_simple_box_start('center', '70%');
|
||||
echo '<form method="get" action="index.php">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
print_heading($formheader);
|
||||
echo '<p>'; print_checkbox('showpasses', 1, $showpasses, get_string('showpasses', $langfile)); echo '</p>';
|
||||
echo '<p>'; print_checkbox('showsearch', 1, $showsearch, get_string('showsearch', $langfile)); echo '</p>';
|
||||
echo '<p>'; print_checkbox('thorough', 1, $thorough, get_string('thorough', $langfile)); echo '</p>';
|
||||
echo '<p>';
|
||||
echo '<label for="path">', get_string('onlytest', $langfile), '</label> ';
|
||||
echo '<input type="text" id="path" name="path" value="', $displaypath, '" size="40" />';
|
||||
echo '</p>';
|
||||
echo '<input type="submit" value="' . get_string('runtests', $langfile) . '" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
print_simple_box_end();
|
||||
|
||||
// Footer.
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -4,31 +4,22 @@
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
if (empty($CFG->enablestats)) {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
|
||||
admin_externalpage_setup('reportstats');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$roleid = 0;
|
||||
|
||||
if ($report > 50) {
|
||||
$roleid = substr($report,1);
|
||||
$report = 5;
|
||||
}
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time, '', 3);
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
@@ -42,34 +33,31 @@
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
if (!isteacher($course->id)) {
|
||||
error("You need to be a teacher to use this page");
|
||||
}
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$menu = report_stats_mode_menu($course, $mode, $time);
|
||||
|
||||
|
||||
// $strreports = get_string("reports");
|
||||
// $strstats = get_string('stats');
|
||||
//
|
||||
// $menu = report_stats_mode_menu($course, $mode, $time); // add 4th $url parameter if uncommented!
|
||||
//
|
||||
//
|
||||
// $crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
// <a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
|
||||
// $strstats";
|
||||
|
||||
// print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
// $crumb, '', '', true, ' ', $menu);
|
||||
|
||||
$crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
<a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
|
||||
$strstats";
|
||||
|
||||
print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
$crumb, '', '', true, ' ', $menu);
|
||||
|
||||
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
print_footer();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php //$Id$
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<p style="text-align:center;">';
|
||||
echo '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
|
||||
echo '</p>';
|
||||
$statsstatus = stats_check_uptodate($course->id);
|
||||
if ($statsstatus !== NULL) {
|
||||
notify ($statsstatus);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* this page defines what roles can access (grant user that role and override that roles'
|
||||
* capabilities in different context. For example, we can say that Teachers can only grant
|
||||
* student role or modify student role's capabilities. Note that you need both the right
|
||||
* capability moodle/role:assign or moodle/role:manage and this database table roles_deny_grant
|
||||
* to be able to grant roles. If a user has moodle/role:manage at site level assignment
|
||||
* then he can modify the roles_allow_assign table via this interface.
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
/// form processiong here
|
||||
|
||||
/// get all roles
|
||||
|
||||
$roles = get_all_roles();
|
||||
|
||||
if ($grant = data_submitted()) {
|
||||
|
||||
foreach ($grant as $grole => $val) {
|
||||
if ($grole == 'dummy') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$string = explode('_', $grole);
|
||||
$temp[$string[1]][$string[2]] = 1; // if set, means can access
|
||||
}
|
||||
|
||||
// if current assignment is in data_submitted, ignore, else, write deny into db
|
||||
foreach ($roles as $srole) {
|
||||
foreach ($roles as $trole) {
|
||||
if (isset($temp[$srole->id][$trole->id])) { // if set, need to write to db
|
||||
if (!$record = get_record('role_allow_assign', 'roleid', $srole->id, 'allowassign', $trole->id)) {
|
||||
allow_assign($srole->id, $trole->id);
|
||||
}
|
||||
} else { //if set, means can access, attempt to remove it from db
|
||||
delete_records('role_allow_assign', 'roleid', $srole->id, 'allowassign', $trole->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// updated allowassigns sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
}
|
||||
/// displaying form here
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$currenttab='allowassign';
|
||||
require_once('managetabs.php');
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->align[] = 'right';
|
||||
|
||||
/// get all the roles identifier
|
||||
foreach ($roles as $role) {
|
||||
$rolesname[] = format_string($role->name);
|
||||
$roleids[] = $role->id;
|
||||
$table->align[] = 'center';
|
||||
$table->wrap[] = 'nowrap';
|
||||
}
|
||||
|
||||
$table->head = array_merge(array(''), $rolesname);
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$beta = get_box_list($role->id, $roleids);
|
||||
$table->data[] = array_merge(array(format_string($role->name)), $beta);
|
||||
}
|
||||
|
||||
print_simple_box(get_string('configallowassign', 'admin'), 'center');
|
||||
|
||||
echo '<form action="allowassign.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '</div></form>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
|
||||
|
||||
function get_box_list($roleid, $arraylist){
|
||||
|
||||
foreach ($arraylist as $targetid) {
|
||||
if (get_record('role_allow_assign', 'roleid', $roleid, 'allowassign', $targetid)) {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" checked="checked"/>';
|
||||
} else {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
?>
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* this page defines what roles can override (override roles in different context. For example,
|
||||
* we can say that Admin can override teacher roles in a course
|
||||
* To be able to override roles. If a user has moodle/role:override at context level
|
||||
* and be in the roles_allow_override table.
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
/// form processiong here
|
||||
|
||||
/// get all roles
|
||||
|
||||
$roles = get_all_roles();
|
||||
|
||||
if ($grant = data_submitted()) {
|
||||
|
||||
foreach ($grant as $grole => $val) {
|
||||
if ($grole == 'dummy') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$string = explode('_', $grole);
|
||||
$temp[$string[1]][$string[2]] = 1; // if set, means can access
|
||||
}
|
||||
|
||||
// if current assignment is in data_submitted, ignore, else, write deny into db
|
||||
foreach ($roles as $srole) {
|
||||
foreach ($roles as $trole) {
|
||||
if (isset($temp[$srole->id][$trole->id])) { // if set, need to write to db
|
||||
if (!$record = get_record('role_allow_override', 'roleid', $srole->id, 'allowoverride', $trole->id)) {
|
||||
allow_override($srole->id, $trole->id);
|
||||
}
|
||||
} else { //if set, means can access, attempt to remove it from db
|
||||
delete_records('role_allow_override', 'roleid', $srole->id, 'allowoverride', $trole->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// updated allowoverride sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
}
|
||||
/// displaying form here
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$currenttab='allowoverride';
|
||||
require_once('managetabs.php');
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->align[] = 'right';
|
||||
|
||||
/// get all the roles identifier
|
||||
foreach ($roles as $role) {
|
||||
$rolesname[] = format_string($role->name);
|
||||
$roleids[] = $role->id;
|
||||
$table->align[] = 'center';
|
||||
$table->wrap[] = 'nowrap';
|
||||
}
|
||||
|
||||
$table->head = array_merge(array(''), $rolesname);
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$beta = get_box_list($role->id, $roleids);
|
||||
$table->data[] = array_merge(array(format_string($role->name)), $beta);
|
||||
}
|
||||
|
||||
print_simple_box(get_string('configallowoverride', 'admin'), 'center');
|
||||
|
||||
echo '<form action="allowoverride.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '</div></form>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
// returns array
|
||||
function get_box_list($roleid, $arraylist){
|
||||
|
||||
foreach ($arraylist as $targetid) {
|
||||
if (get_record('role_allow_override', 'roleid', $roleid, 'allowoverride', $targetid)) {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" checked="checked"/>';
|
||||
} else {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
?>
|
||||
@@ -1,112 +0,0 @@
|
||||
<form id="assignform" method="post" action="">
|
||||
<div style="text-align:center;">
|
||||
<label for="extendperiod"><?php print_string('enrolperiod') ?></label> <?php choose_from_menu($periodmenu, "extendperiod", $defaultperiod, $unlimitedperiod); ?>
|
||||
<label for="extendbase"><?php print_string('startingfrom') ?></label> <?php choose_from_menu($basemenu, "extendbase", 3, ""); ?>
|
||||
|
||||
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
|
||||
<input type="hidden" name="userid" value="<?php p($userid) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<table summary="" style="margin-left:auto;margin-right:auto" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<label for="removeselect"><?php print_string('existingusers', 'role', count($contextusers)); ?></label>
|
||||
<br />
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=false;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;">
|
||||
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($contextusers as $contextuser) {
|
||||
$fullname = fullname($contextuser, true);
|
||||
if ($contextuser->hidden) {
|
||||
$hidden=' ('.get_string('hiddenassign').') ';
|
||||
} else {
|
||||
$hidden="";
|
||||
}
|
||||
echo "<option value=\"$contextuser->id\">".$fullname.", ".$contextuser->email.$hidden."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
if ($i==0) {
|
||||
echo '<option/>'; // empty select breaks xhtml strict
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<label title="<?php print_string('hiddenassign') ?>">
|
||||
<input type="checkbox" name="hidden" value="1" />
|
||||
<img src="<?php echo $CFG->pixpath; ?>/t/hide.gif" alt="<?php print_string('hiddenassign') ?>" class="hide-show-image" />
|
||||
<?php helpbutton('hiddenassign', get_string('hiddenassign')); ?>
|
||||
</label>
|
||||
<?php check_theme_arrows(); ?>
|
||||
<p class="arrow_button">
|
||||
<input name="add" id="add" type="submit" value="<?php echo $THEME->larrow.' '.get_string('add'); ?>" title="<?php print_string('add'); ?>" /><br />
|
||||
<input name="remove" id="remove" type="submit" value="<?php echo get_string('remove').' '.$THEME->rarrow; ?>" title="<?php print_string('remove'); ?>" />
|
||||
</p>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<label for="addselect"><?php print_string('potentialusers', 'role', $usercount); ?></label>
|
||||
<br />
|
||||
<select name="addselect[]" size="20" id="addselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=false;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
$i=0;
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $usercount . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
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 {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($i==0) {
|
||||
echo '<option/>'; // empty select breaks xhtml strict
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<label for="searchtext" class="accesshide"><?php p($strsearch) ?></label>
|
||||
<input type="text" name="searchtext" id="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onfocus ="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
getElementById('assignform').previoussearch.value=1;
|
||||
getElementById('assignform').submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchtext)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -1,462 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Script to assign users to contexts
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 5000);
|
||||
define("MAX_USERS_TO_LIST_PER_ROLE", 10);
|
||||
|
||||
$contextid = required_param('contextid',PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // required role id
|
||||
$add = optional_param('add', 0, PARAM_BOOL);
|
||||
$remove = optional_param('remove', 0, PARAM_BOOL);
|
||||
$showall = optional_param('showall', 0, PARAM_BOOL);
|
||||
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
|
||||
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
|
||||
$hidden = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
|
||||
$extendperiod = optional_param('extendperiod', 0, PARAM_INT);
|
||||
$extendbase = optional_param('extendbase', 0, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
|
||||
$errors = array();
|
||||
|
||||
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
|
||||
|
||||
$baseurl = 'assign.php?contextid='.$contextid;
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
if (!empty($courseid)) {
|
||||
$baseurl .= '&courseid='.$courseid;
|
||||
}
|
||||
|
||||
if (! $context = get_context_instance_by_id($contextid)) {
|
||||
error("Context ID was incorrect (can't find it)");
|
||||
}
|
||||
|
||||
$inmeta = 0;
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseid = $context->instanceid;
|
||||
if ($course = get_record('course', 'id', $courseid)) {
|
||||
$inmeta = $course->metacourse;
|
||||
} else {
|
||||
error('Invalid course id');
|
||||
}
|
||||
|
||||
} else if (!empty($courseid)){ // we need this for user tabs in user context
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Invalid course id');
|
||||
}
|
||||
|
||||
} else {
|
||||
$courseid = SITEID;
|
||||
$course = clone($SITE);
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
require_capability('moodle/role:assign', $context);
|
||||
|
||||
/// needed for tabs.php
|
||||
|
||||
$overridableroles = get_overridable_roles($context, 'name', ROLENAME_BOTH);
|
||||
$assignableroles = get_assignable_roles($context, 'name', ROLENAME_BOTH);
|
||||
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
$strpotentialusers = get_string('potentialusers', 'role');
|
||||
$strexistingusers = get_string('existingusers', 'role');
|
||||
$straction = get_string('assignroles', 'role');
|
||||
$strroletoassign = get_string('roletoassign', 'role');
|
||||
$strsearch = get_string('search');
|
||||
$strshowall = get_string('showall');
|
||||
$strparticipants = get_string('participants');
|
||||
$strsearchresults = get_string('searchresults');
|
||||
|
||||
$unlimitedperiod = get_string('unlimited');
|
||||
$defaultperiod = $course->enrolperiod;
|
||||
for ($i=1; $i<=365; $i++) {
|
||||
$seconds = $i * 86400;
|
||||
$periodmenu[$seconds] = get_string('numdays', '', $i);
|
||||
}
|
||||
|
||||
$timeformat = get_string('strftimedate');
|
||||
$today = time();
|
||||
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
|
||||
|
||||
// MDL-12420, preventing course start date showing up as an option at system context and front page roles.
|
||||
if ($course->startdate > 0) {
|
||||
$basemenu[0] = get_string('startdate') . ' (' . userdate($course->startdate, $timeformat) . ')';
|
||||
}
|
||||
if ($course->enrollable != 2 || ($course->enrolstartdate == 0 || $course->enrolstartdate <= $today) && ($course->enrolenddate == 0 || $course->enrolenddate > $today)) {
|
||||
$basemenu[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
|
||||
}
|
||||
if($course->enrollable == 2) {
|
||||
if($course->enrolstartdate > 0) {
|
||||
$basemenu[4] = get_string('courseenrolstartdate') . ' (' . userdate($course->enrolstartdate, $timeformat) . ')';
|
||||
}
|
||||
if($course->enrolenddate > 0) {
|
||||
$basemenu[5] = get_string('courseenrolenddate') . ' (' . userdate($course->enrolenddate, $timeformat) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
/// Make sure this user can assign that role
|
||||
|
||||
if ($roleid) {
|
||||
if (!user_can_assign($context, $roleid)) {
|
||||
error ('you can not override this role in this context');
|
||||
}
|
||||
}
|
||||
|
||||
if ($userid) {
|
||||
$user = get_record('user', 'id', $userid);
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
}
|
||||
|
||||
|
||||
/// Print the header and tabs
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
/// course header
|
||||
$navlinks = array();
|
||||
if ($courseid != SITEID) {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');
|
||||
}
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$fullname", "$fullname", $navigation, "", "", true, " ", navmenu($course));
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$course->fullname: $fullname", $course->fullname, $navigation, "", "", true, " ", navmenu($course));
|
||||
}
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'assign';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
admin_externalpage_setup('assignroles');
|
||||
admin_externalpage_print_header();
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
admin_externalpage_setup('frontpageroles');
|
||||
admin_externalpage_print_header();
|
||||
$currenttab = 'assign';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
$currenttab = 'assign';
|
||||
include_once('tabs.php');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Process incoming role assignment
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
|
||||
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
|
||||
|
||||
foreach ($frm->addselect as $adduser) {
|
||||
if (!$adduser = clean_param($adduser, PARAM_INT)) {
|
||||
continue;
|
||||
}
|
||||
$allow = true;
|
||||
if ($inmeta) {
|
||||
if (has_capability('moodle/course:managemetacourse', $context, $adduser)) {
|
||||
//ok
|
||||
} else {
|
||||
$managerroles = get_roles_with_capability('moodle/course:managemetacourse', CAP_ALLOW, $context);
|
||||
if (!empty($managerroles) and !array_key_exists($roleid, $managerroles)) {
|
||||
$erruser = get_record('user', 'id', $adduser, '','','','', 'id, firstname, lastname');
|
||||
$errors[] = get_string('metaassignerror', 'role', fullname($erruser));
|
||||
$allow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($allow) {
|
||||
switch($extendbase) {
|
||||
case 0:
|
||||
$timestart = $course->startdate;
|
||||
break;
|
||||
case 3:
|
||||
$timestart = $today;
|
||||
break;
|
||||
case 4:
|
||||
$timestart = $course->enrolstartdate;
|
||||
break;
|
||||
case 5:
|
||||
$timestart = $course->enrolenddate;
|
||||
break;
|
||||
}
|
||||
|
||||
if($extendperiod > 0) {
|
||||
$timeend = $timestart + $extendperiod;
|
||||
} else {
|
||||
$timeend = 0;
|
||||
}
|
||||
if (! role_assign($roleid, $adduser, 0, $context->id, $timestart, $timeend, $hidden)) {
|
||||
$errors[] = "Could not add user with id $adduser to this role!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$topleveladmin = false;
|
||||
|
||||
// we only worry about this if the role has doanything capability at site level
|
||||
if ($context->id == $sitecontext->id && $adminroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext)) {
|
||||
foreach ($adminroles as $adminrole) {
|
||||
if ($adminrole->id == $roleid) {
|
||||
$topleveladmin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
|
||||
if ($topleveladmin && ($removeuser == $USER->id)) { // Prevent unassigning oneself from being admin
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! role_unassign($roleid, $removeuser, 0, $context->id)) {
|
||||
$errors[] = "Could not remove user with id $removeuser from this role!";
|
||||
} else if ($inmeta) {
|
||||
sync_metacourse($courseid);
|
||||
$newroles = get_user_roles($context, $removeuser, false);
|
||||
if (!empty($newroles) and !array_key_exists($roleid, $newroles)) {
|
||||
$erruser = get_record('user', 'id', $removeuser, '','','','', 'id, firstname, lastname');
|
||||
$errors[] = get_string('metaunassignerror', 'role', fullname($erruser));
|
||||
$allow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
} else if ($showall) {
|
||||
$searchtext = '';
|
||||
$previoussearch = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
print_heading_with_help(get_string('frontpageroles', 'admin'), 'assignroles');
|
||||
} else {
|
||||
print_heading_with_help(get_string('assignrolesin', 'role', print_context_name($context)), 'assignroles');
|
||||
}
|
||||
|
||||
if ($context->contextlevel==CONTEXT_SYSTEM) {
|
||||
print_box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
if ($roleid) { /// prints a form to swap roles
|
||||
|
||||
/// Get all existing participants in this context.
|
||||
// Why is this not done with get_users???
|
||||
|
||||
if (!$contextusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname, u.email, ra.hidden')) {
|
||||
$contextusers = array();
|
||||
}
|
||||
|
||||
$select = "username <> 'guest' AND deleted = 0 AND confirmed = 1";
|
||||
|
||||
$usercount = count_records_select('user', $select) - count($contextusers);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
|
||||
if ($searchtext !== '') { // Search for a subset of remaining users
|
||||
$LIKE = sql_ilike();
|
||||
$FULLNAME = sql_fullname();
|
||||
|
||||
$selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
$select .= $selectsql;
|
||||
} else {
|
||||
$selectsql = "";
|
||||
}
|
||||
|
||||
if ($context->contextlevel > CONTEXT_COURSE) { // mod or block (or group?)
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* context level is above or equal course context level *
|
||||
* in this case we pull out all users matching search criteria (if any) *
|
||||
* *
|
||||
* MDL-11324 *
|
||||
* a mini get_users_by_capability() call here, this is done instead of *
|
||||
* get_users_by_capability() because *
|
||||
* 1) get_users_by_capability() does not deal with searching by name *
|
||||
* 2) exceptions array can be potentially large for large courses *
|
||||
* 3) get_recordset_sql() is more efficient *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
if ($possibleroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context)) {
|
||||
|
||||
$doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$validroleids = array();
|
||||
foreach ($possibleroles as $possiblerole) {
|
||||
if (isset($doanythingroles[$possiblerole->id])) { // We don't want these included
|
||||
continue;
|
||||
}
|
||||
if ($caps = role_context_capabilities($possiblerole->id, $context, 'moodle/course:view')) { // resolved list
|
||||
if (isset($caps['moodle/course:view']) && $caps['moodle/course:view'] > 0) { // resolved capability > 0
|
||||
$validroleids[] = $possiblerole->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($validroleids) {
|
||||
$roleids = '('.implode(',', $validroleids).')';
|
||||
|
||||
$select = " SELECT u.id, u.firstname, u.lastname, u.email";
|
||||
$countselect = "SELECT COUNT(u.id)";
|
||||
$from = " FROM {$CFG->prefix}user u
|
||||
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id
|
||||
INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid";
|
||||
$where = " WHERE ra.contextid ".get_related_contexts_string($context)."
|
||||
AND u.deleted = 0
|
||||
AND ra.roleid in $roleids";
|
||||
$excsql = " AND u.id NOT IN (
|
||||
SELECT u.id
|
||||
FROM {$CFG->prefix}role_assignments r,
|
||||
{$CFG->prefix}user u
|
||||
WHERE r.contextid = $contextid
|
||||
AND u.id = r.userid
|
||||
AND r.roleid = $roleid
|
||||
$selectsql)";
|
||||
|
||||
$availableusers = get_recordset_sql($select . $from . $where . $selectsql . $excsql);
|
||||
}
|
||||
|
||||
$usercount = $availableusers->_numOfRows;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* context level is above or equal course context level *
|
||||
* in this case we pull out all users matching search criteria (if any) *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/// MDL-11111 do not include user already assigned this role in this context as available users
|
||||
/// so that the number of available users is right and we save time looping later
|
||||
$availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user
|
||||
WHERE '.$select.'
|
||||
AND id NOT IN (
|
||||
SELECT u.id
|
||||
FROM '.$CFG->prefix.'role_assignments r,
|
||||
'.$CFG->prefix.'user u
|
||||
WHERE r.contextid = '.$contextid.'
|
||||
AND u.id = r.userid
|
||||
AND r.roleid = '.$roleid.'
|
||||
'.$selectsql.')
|
||||
ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
$usercount = $availableusers->_numOfRows;
|
||||
}
|
||||
|
||||
echo '<div class="selector">';
|
||||
$assignableroles = array('0'=>get_string('listallroles', 'role').'...') + $assignableroles;
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/roles/assign.php?userid=$userid&courseid=$courseid&contextid=$contextid&roleid=",
|
||||
$assignableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletoassign);
|
||||
echo '</div>';
|
||||
|
||||
print_simple_box_start('center');
|
||||
include('assign.html');
|
||||
print_simple_box_end();
|
||||
|
||||
if (!empty($errors)) {
|
||||
$msg = '<p>';
|
||||
foreach ($errors as $e) {
|
||||
$msg .= $e.'<br />';
|
||||
}
|
||||
$msg .= '</p>';
|
||||
print_simple_box_start('center');
|
||||
notify($msg);
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
} else { // Print overview table
|
||||
|
||||
// sync metacourse enrolments if needed
|
||||
if ($inmeta) {
|
||||
sync_metacourse($course);
|
||||
}
|
||||
|
||||
// Get the names of role holders for roles with between 1 and MAX_USERS_TO_LIST_PER_ROLE users,
|
||||
// and so determine whether to show the extra column.
|
||||
$rolehodlercount = array();
|
||||
$rolehodlernames = array();
|
||||
$strmorethanten = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
$showroleholders = false;
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$countusers = count_role_users($roleid, $context);
|
||||
$rolehodlercount[$roleid] = $countusers;
|
||||
$roleusers = '';
|
||||
if (0 < $countusers && $countusers <= MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$roleusers = get_role_users($roleid, $context, false, 'u.id, u.lastname, u.firstname');
|
||||
if (!empty($roleusers)) {
|
||||
$strroleusers = array();
|
||||
foreach ($roleusers as $user) {
|
||||
$strroleusers[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '" >' . fullname($user) . '</a>';
|
||||
}
|
||||
$rolehodlernames[$roleid] = implode('<br />', $strroleusers);
|
||||
$showroleholders = true;
|
||||
}
|
||||
} else if ($countusers > MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$rolehodlernames[$roleid] = '<a href="'.$baseurl.'&roleid='.$roleid.'">'.$strmorethanten.'</a>';
|
||||
} else {
|
||||
$rolehodlernames[$roleid] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Print overview table
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('roles', 'role'), get_string('description'), get_string('users'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center');
|
||||
if ($showroleholders) {
|
||||
$table->head[] = '';
|
||||
$table->wrap[] = 'nowrap';
|
||||
$table->align[] = 'left';
|
||||
}
|
||||
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$description = format_string(get_field('role', 'description', 'id', $roleid));
|
||||
$row = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>',$description, $rolehodlercount[$roleid]);
|
||||
if ($showroleholders) {
|
||||
$row[] = $rolehodlernames[$roleid];
|
||||
}
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
@@ -1,219 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$submitlabel = get_string('addrole', 'role');
|
||||
break;
|
||||
case 'edit':
|
||||
default:
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
|
||||
if ($action == 'view') {
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form id="rolesform" action="manage.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="action" value="<?php if ($action != 'view') { echo p($action); } ?>" />
|
||||
</fieldset>
|
||||
<table class="roledesc" cellpadding="9" cellspacing="0">
|
||||
<?php if ($action == 'view') { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('name') ?>:</td>
|
||||
<td><?php p($role->name); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('shortname') ?>:</td>
|
||||
<td><?php p($role->shortname); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('description') ?>:</td>
|
||||
<td><?php p($role->description); $usehtmleditor = false; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('legacytype', 'role') ?>:</td>
|
||||
<td><?php
|
||||
$usehtmleditor = false;
|
||||
if (empty($role->legacytype)) {
|
||||
print_string('none');
|
||||
} else {
|
||||
print_string('legacy:'.$role->legacytype, 'role');
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="name"><?php print_string('name') ?></label></td>
|
||||
<td><?php
|
||||
echo '<input type="text" id="name" name="name" maxlength="254" size="50" value="'.s($role->name).'" />';
|
||||
if (isset($errors["name"])) formerr($errors["name"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="shortname"><?php print_string('shortname') ?></label></td>
|
||||
<td><?php
|
||||
echo '<input type="text" id="shortname" name="shortname" maxlength="100" size="15" value="'.s($role->shortname).'" />';
|
||||
if (isset($errors["shortname"])) formerr($errors["shortname"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="edit-description"><?php print_string('description') ?></label></td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menulegacytype"><?php print_string('legacytype', 'role') ?></label></td>
|
||||
<td><?php
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
$legacyroles = get_legacy_roles();
|
||||
foreach($legacyroles as $ltype=>$lcap) {
|
||||
$options[$ltype] = get_string('legacy:'.$ltype, 'role');
|
||||
}
|
||||
choose_from_menu($options, 'legacytype', $role->legacytype, '');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
print_heading_with_help(get_string('permissions','role'), 'permissions');
|
||||
|
||||
$strinherit = get_string('notset','role');
|
||||
$strallow = get_string('allow','role');
|
||||
$strprevent = get_string('prevent','role');
|
||||
$strprohibit = get_string('prohibit','role');
|
||||
?>
|
||||
|
||||
<table class="rolecap">
|
||||
|
||||
<tr>
|
||||
<th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
|
||||
<th class="inherit" scope="col"><?php p($strinherit); ?></th>
|
||||
<th class="allow" scope="col"><?php p($strallow); ?></th>
|
||||
<th class="prevent" scope="col"><?php p($strprevent); ?></th>
|
||||
<th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
|
||||
<th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
// init these 2
|
||||
$contextlevel = 0;
|
||||
$component = '';
|
||||
|
||||
$strrisks = s(get_string('risks', 'role'));
|
||||
// MDL-11687
|
||||
$strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
|
||||
|
||||
// prepare legacy defaults
|
||||
if (!empty($role->legacytype)) {
|
||||
$defaultcaps = get_default_capabilities($role->legacytype);
|
||||
} else {
|
||||
$defaultcaps = false;
|
||||
}
|
||||
|
||||
foreach ($capabilities as $capability) {
|
||||
|
||||
//legacy caps have their own selector
|
||||
if (islegacy($capability->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prints a breaker if component or name or context level
|
||||
if (component_level_changed($capability, $component, $contextlevel)) {
|
||||
//if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
|
||||
get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
|
||||
}
|
||||
|
||||
// these 2 are used to see to group same mod/core capabilities together
|
||||
$contextlevel = $capability->contextlevel;
|
||||
$component = $capability->component;
|
||||
|
||||
if (empty($errors)) {
|
||||
// check the capability override for this cap, this role in this context
|
||||
$localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
|
||||
} else {
|
||||
$localoverride = new object();
|
||||
$localoverride->permission = $role->{$capability->name};
|
||||
}
|
||||
|
||||
$disabled = ($action != 'edit' and $action != 'add') ? ' disabled="disabled" ' : '';
|
||||
|
||||
$riskinfo = '<td class="risk managetrust">';
|
||||
$rowclasses = '';
|
||||
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskmanagetrust';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk config">';
|
||||
if (RISK_CONFIG & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskconfig';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk xss">';
|
||||
if (RISK_XSS & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskxss';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk personal">';
|
||||
if (RISK_PERSONAL & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskpersonal';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk spam">';
|
||||
if (RISK_SPAM & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
$riskinfo .= '</td>';
|
||||
|
||||
$isinherit = (!isset($defaultcaps[$capability->name]) or $defaultcaps[$capability->name] == CAP_INHERIT) ? 'capdefault' : '';
|
||||
$isallow = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_ALLOW) ? 'capdefault' : '';
|
||||
$isprevent = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PREVENT) ? 'capdefault' : '';
|
||||
$isprohibit = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PROHIBIT) ? 'capdefault' : '';
|
||||
|
||||
?>
|
||||
|
||||
<tr class="rolecap <?php echo $rowclasses; ?>">
|
||||
<td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
<td class="inherit <?php echo $isinherit ?>">
|
||||
<input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_INHERIT ?>" <?php if (!isset($localoverride->permission) || $localoverride->permission==CAP_INHERIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="allow <?php echo $isallow ?>">
|
||||
<input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_ALLOW ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_ALLOW){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prevent <?php echo $isprevent ?>" >
|
||||
<input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PREVENT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PREVENT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prohibit <?php echo $isprohibit ?>" >
|
||||
<input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PROHIBIT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PROHIBIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
|
||||
<?php echo $riskinfo; ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php if ($action != 'view') { ?>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" value="<?php p($submitlabel) ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
@@ -1,575 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editing a role
|
||||
$name = optional_param('name', '', PARAM_MULTILANG); // new role name
|
||||
$shortname = optional_param('shortname', '', PARAM_RAW); // new role shortname, special cleaning before storage
|
||||
$description = optional_param('description', '', PARAM_CLEAN); // new role desc
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
if ($cancel) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
$newrole = false;
|
||||
|
||||
$roles = get_all_roles();
|
||||
$rolescount = count($roles);
|
||||
|
||||
/// fix sort order if needed
|
||||
$rolesort = array();
|
||||
$i = 0;
|
||||
foreach ($roles as $rolex) {
|
||||
$rolesort[$i] = $rolex->id;
|
||||
if ($rolex->sortorder != $i) {
|
||||
$r = new object();
|
||||
$r->id = $rolex->id;
|
||||
$r->sortorder = $i;
|
||||
update_record('role', $r);
|
||||
$roles[$rolex->id]->sortorder = $i;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// do not delete these default system roles
|
||||
$defaultroles = array();
|
||||
$defaultroles[] = $CFG->notloggedinroleid;
|
||||
$defaultroles[] = $CFG->guestroleid;
|
||||
$defaultroles[] = $CFG->defaultuserroleid;
|
||||
$defaultroles[] = $CFG->defaultcourseroleid;
|
||||
|
||||
/// form processing, editing a role, adding a role, deleting a role etc.
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$shortname = moodle_strtolower(clean_param(clean_filename($shortname), PARAM_SAFEDIR)); // only lowercase safe ASCII characters
|
||||
$legacytype = required_param('legacytype', PARAM_RAW);
|
||||
|
||||
$legacyroles = get_legacy_roles();
|
||||
if (!array_key_exists($legacytype, $legacyroles)) {
|
||||
$legacytype = '';
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = get_string('errorbadrolename', 'role');
|
||||
} else if (count_records('role', 'name', $name)) {
|
||||
$errors['name'] = get_string('errorexistsrolename', 'role');
|
||||
}
|
||||
|
||||
if (empty($shortname)) {
|
||||
$errors['shortname'] = get_string('errorbadroleshortname', 'role');
|
||||
} else if (count_records('role', 'shortname', $shortname)) {
|
||||
$errors['shortname'] = get_string('errorexistsroleshortname', 'role');
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
$newroleid = create_role($name, $shortname, $description);
|
||||
|
||||
// set proper legacy type
|
||||
if (!empty($legacytype)) {
|
||||
assign_capability($legacyroles[$legacytype], CAP_ALLOW, $newroleid, $sitecontext->id);
|
||||
}
|
||||
|
||||
} else {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
$capabilities = fetch_context_capabilities($sitecontext); // capabilities applicable in this context
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
if (!isset($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// legacy caps have their own selector
|
||||
if (islegacy($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
assign_capability($capname, $value, $newroleid, $sitecontext->id);
|
||||
} else {
|
||||
$newrole->$capname = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// added a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
if (empty($errors)) {
|
||||
$rolename = get_field('role', 'name', 'id', $newroleid);
|
||||
add_to_log(SITEID, 'role', 'add', 'admin/roles/manage.php?action=add', $rolename, '', $USER->id);
|
||||
redirect('manage.php');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$shortname = moodle_strtolower(clean_param(clean_filename($shortname), PARAM_SAFEDIR)); // only lowercase safe ASCII characters
|
||||
$legacytype = required_param('legacytype', PARAM_RAW);
|
||||
|
||||
$legacyroles = get_legacy_roles();
|
||||
if (!array_key_exists($legacytype, $legacyroles)) {
|
||||
$legacytype = '';
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = get_string('errorbadrolename', 'role');
|
||||
} else if ($rs = get_records('role', 'name', $name)) {
|
||||
unset($rs[$roleid]);
|
||||
if (!empty($rs)) {
|
||||
$errors['name'] = get_string('errorexistsrolename', 'role');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($shortname)) {
|
||||
$errors['shortname'] = get_string('errorbadroleshortname', 'role');
|
||||
} else if ($rs = get_records('role', 'shortname', $shortname)) {
|
||||
unset($rs[$roleid]);
|
||||
if (!empty($rs)) {
|
||||
$errors['shortname'] = get_string('errorexistsroleshortname', 'role');
|
||||
}
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
$capabilities = fetch_context_capabilities($sitecontext); // capabilities applicable in this context
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
if (!isset($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// legacy caps have their own selector
|
||||
if (islegacy($data->{$cap->name}) === 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$newrole->$capname = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
// edit default caps
|
||||
$SQL = "SELECT * FROM {$CFG->prefix}role_capabilities
|
||||
WHERE roleid = $roleid AND capability = '$capname'
|
||||
AND contextid = $sitecontext->id";
|
||||
|
||||
$localoverride = get_record_sql($SQL);
|
||||
|
||||
if ($localoverride) { // update current overrides
|
||||
if ($value == CAP_INHERIT) { // inherit = delete
|
||||
unassign_capability($capname, $roleid, $sitecontext->id);
|
||||
|
||||
} else {
|
||||
$localoverride->permission = $value;
|
||||
$localoverride->timemodified = time();
|
||||
$localoverride->modifierid = $USER->id;
|
||||
update_record('role_capabilities', $localoverride);
|
||||
}
|
||||
} else { // insert a record
|
||||
if ($value != CAP_INHERIT) {
|
||||
assign_capability($capname, $value, $roleid, $sitecontext->id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
// update normal role settings
|
||||
$role->id = $roleid;
|
||||
$role->name = $name;
|
||||
$role->shortname = $shortname;
|
||||
$role->description = $description;
|
||||
|
||||
if (!update_record('role', $role)) {
|
||||
error('Could not update role!');
|
||||
}
|
||||
|
||||
// set proper legacy type
|
||||
foreach($legacyroles as $ltype=>$lcap) {
|
||||
if ($ltype == $legacytype) {
|
||||
assign_capability($lcap, CAP_ALLOW, $roleid, $sitecontext->id);
|
||||
} else {
|
||||
unassign_capability($lcap, $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
// edited a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
add_to_log(SITEID, 'role', 'edit', 'admin/roles/manage.php?action=edit&roleid='.$role->id, $role->name, '', $USER->id);
|
||||
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
// edited a role sitewide - with errors, but still...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if (in_array($roleid, $defaultroles)) {
|
||||
error('This role is used as one of the default system roles, it can not be deleted');
|
||||
}
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
if (!delete_role($roleid)) {
|
||||
|
||||
// partially deleted a role sitewide...?
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
error('Could not delete role with ID '.$roleid);
|
||||
}
|
||||
// deleted a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
} else if (confirm_sesskey()){
|
||||
// show confirmation
|
||||
admin_externalpage_print_header();
|
||||
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = (int)count_records('role_assignments', 'roleid', $roleid);
|
||||
notice_yesno(get_string('deleterolesure', 'role', $a), 'manage.php', 'manage.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'moveup':
|
||||
if (array_key_exists($roleid, $roles) and confirm_sesskey()) {
|
||||
$role = $roles[$roleid];
|
||||
if ($role->sortorder > 0) {
|
||||
$above = $roles[$rolesort[$role->sortorder - 1]];
|
||||
|
||||
if (!switch_roles($role, $above)) {
|
||||
error("Cannot move role with ID $roleid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'movedown':
|
||||
if (array_key_exists($roleid, $roles) and confirm_sesskey()) {
|
||||
$role = $roles[$roleid];
|
||||
if ($role->sortorder + 1 < $rolescount) {
|
||||
$below = $roles[$rolesort[$role->sortorder + 1]];
|
||||
|
||||
if (!switch_roles($role, $below)) {
|
||||
error("Cannot move role with ID $roleid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'duplicate':
|
||||
if (!array_key_exists($roleid, $roles)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
//ok - lets duplicate!
|
||||
} else {
|
||||
// show confirmation
|
||||
admin_externalpage_print_header();
|
||||
$optionsyes = array('action'=>'duplicate', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
notice_yesno(get_string('duplicaterolesure', 'role', $a), 'manage.php', 'manage.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// duplicate current role
|
||||
$sourcerole = get_record('role','id',$roleid);
|
||||
|
||||
$fullname = $sourcerole->name;
|
||||
$shortname = $sourcerole->shortname;
|
||||
$currentfullname = "";
|
||||
$currentshortname = "";
|
||||
$counter = 0;
|
||||
|
||||
// find a name for the duplicated role
|
||||
do {
|
||||
if ($counter) {
|
||||
$suffixfull = " ".get_string("copyasnoun")." ".$counter;
|
||||
$suffixshort = "_".$counter;
|
||||
} else {
|
||||
$suffixfull = "";
|
||||
$suffixshort = "";
|
||||
}
|
||||
$currentfullname = $fullname.$suffixfull;
|
||||
// Limit the size of shortname - database column accepts <= 100 chars
|
||||
$currentshortname = substr($shortname, 0, 100 - strlen($suffixshort)).$suffixshort;
|
||||
$coursefull = get_record("role","name",addslashes($currentfullname));
|
||||
$courseshort = get_record("role","shortname",addslashes($currentshortname));
|
||||
$counter++;
|
||||
} while ($coursefull || $courseshort);
|
||||
|
||||
$description = 'duplicate of '.$fullname;
|
||||
if ($newrole = create_role($currentfullname, $currentshortname, $description)) {
|
||||
// dupilcate all the capabilities
|
||||
role_cap_duplicate($sourcerole, $newrole);
|
||||
|
||||
// dup'ed a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
}
|
||||
$rolename = get_field('role', 'name', 'id', $newrole);
|
||||
add_to_log(SITEID, 'role', 'duplicate', 'admin/roles/manage.php?roleid='.$newrole.'&action=duplicate', $rolename, '', $USER->id);
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'reset':
|
||||
if (!array_key_exists($roleid, $roles)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
reset_role_capabilities($roleid);
|
||||
|
||||
// reset a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?roleid='.$roleid.'&action=reset', $rolename, '', $USER->id);
|
||||
|
||||
redirect('manage.php?action=view&roleid='.$roleid);
|
||||
|
||||
} else {
|
||||
// show confirmation
|
||||
admin_externalpage_print_header();
|
||||
$optionsyes = array('action'=>'reset', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->legacytype = get_legacy_type($roleid);
|
||||
if (empty($a->legacytype)) {
|
||||
$warning = get_string('resetrolesurenolegacy', 'role', $a);
|
||||
} else {
|
||||
$warning = get_string('resetrolesure', 'role', $a);
|
||||
}
|
||||
notice_yesno($warning, 'manage.php', 'manage.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/// print UI now
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
include_once('managetabs.php');
|
||||
|
||||
if (($roleid and ($action == 'view' or $action == 'edit')) or $action == 'add') { // view or edit role details
|
||||
|
||||
if ($action == 'add') {
|
||||
$roleid = 0;
|
||||
if (empty($errors) or empty($newrole)) {
|
||||
$role = new object();
|
||||
$role->name = '';
|
||||
$role->shortname = '';
|
||||
$role->description = '';
|
||||
$role->legacytype = '';
|
||||
} else {
|
||||
$role = stripslashes_safe($newrole);
|
||||
}
|
||||
} else if ($action == 'edit' and !empty($errors) and !empty($newrole)) {
|
||||
$role = stripslashes_safe($newrole);
|
||||
} else {
|
||||
if(!$role = get_record('role', 'id', $roleid)) {
|
||||
error('Incorrect role ID!');
|
||||
}
|
||||
$role->legacytype = get_legacy_type($role->id);
|
||||
}
|
||||
|
||||
foreach ($roles as $rolex) {
|
||||
$roleoptions[$rolex->id] = strip_tags(format_string($rolex->name));
|
||||
}
|
||||
|
||||
// this is the array holding capabilities of this role sorted till this context
|
||||
$r_caps = role_context_capabilities($roleid, $sitecontext);
|
||||
|
||||
// this is the available capabilities assignable in this context
|
||||
$capabilities = fetch_context_capabilities($sitecontext);
|
||||
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
print_heading_with_help(get_string('addrole', 'role'), 'roles');
|
||||
break;
|
||||
case 'view':
|
||||
print_heading_with_help(get_string('viewrole', 'role'), 'roles');
|
||||
break;
|
||||
case 'edit':
|
||||
print_heading_with_help(get_string('editrole', 'role'), 'roles');
|
||||
break;
|
||||
}
|
||||
|
||||
echo '<div class="selector">';
|
||||
if ($action == 'view') {
|
||||
popup_form('manage.php?action=view&roleid=', $roleoptions, 'switchrole', $roleid, '', '', '',
|
||||
false, 'self', get_string('selectrole', 'role'));
|
||||
|
||||
echo '<div class="buttons">';
|
||||
|
||||
$legacytype = get_legacy_type($roleid);
|
||||
$options = array();
|
||||
$options['roleid'] = $roleid;
|
||||
$options['action'] = 'edit';
|
||||
print_single_button('manage.php', $options, get_string('edit'));
|
||||
$options['action'] = 'reset';
|
||||
if (empty($legacytype)) {
|
||||
print_single_button('manage.php', $options, get_string('resetrolenolegacy', 'role'));
|
||||
} else {
|
||||
print_single_button('manage.php', $options, get_string('resetrole', 'role'));
|
||||
}
|
||||
$options['action'] = 'duplicate';
|
||||
print_single_button('manage.php', $options, get_string('duplicaterole', 'role'));
|
||||
print_single_button('manage.php', null, get_string('listallroles', 'role'));
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
print_simple_box_start('center');
|
||||
include_once('manage.html');
|
||||
print_simple_box_end();
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor('description');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
print_heading_with_help(get_string('roles', 'role'), 'roles');
|
||||
|
||||
$table = new object;
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->align = array('right', 'left', 'left', 'left');
|
||||
$table->wrap = array('nowrap', '', 'nowrap','nowrap');
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->data = array();
|
||||
|
||||
$table->head = array(get_string('name'),
|
||||
get_string('description'),
|
||||
get_string('shortname'),
|
||||
get_string('edit'));
|
||||
|
||||
/*************************
|
||||
* List all current roles *
|
||||
**************************/
|
||||
|
||||
foreach ($roles as $role) {
|
||||
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
|
||||
$row = array();
|
||||
$row[0] = '<a href="manage.php?roleid='.$role->id.'&action=view">'.format_string($role->name).'</a>';
|
||||
$row[1] = format_text($role->description, FORMAT_HTML);
|
||||
$row[2] = s($role->shortname);
|
||||
$row[3] = '<a title="'.$stredit.'" href="manage.php?action=edit&roleid='.$role->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.$stredit.'" /></a> ';
|
||||
if (in_array($role->id, $defaultroles)) {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
} else {
|
||||
$row[3] .= '<a title="'.$strdelete.'" href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.'" /></a> ';
|
||||
}
|
||||
if ($role->sortorder != 0) {
|
||||
$row[3] .= '<a title="'.$strmoveup.'" href="manage.php?action=moveup&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" class="iconsmall" alt="'.$strmoveup.'" /></a> ';
|
||||
} else {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
}
|
||||
if ($role->sortorder+1 < $rolescount) {
|
||||
$row[3] .= '<a title="'.$strmovedown.'" href="manage.php?action=movedown&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" class="iconsmall" alt="'.$strmovedown.'" /></a> ';
|
||||
} else {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
$options = new object();
|
||||
$options->action = 'add';
|
||||
echo '<div class="buttons">';
|
||||
print_single_button('manage.php', $options, get_string('addrole', 'role'), 'get');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
// this page deals with the 2 tabs for manage.php and grant.php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$toprow = array();
|
||||
|
||||
$toprow[] = new tabobject('manage', $CFG->wwwroot.'/'.$CFG->admin.'/roles/manage.php', get_string('manageroles', 'role'));
|
||||
|
||||
$toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allowassign.php', get_string('allowassign', 'role'));
|
||||
|
||||
$toprow[] = new tabobject('allowoverride', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allowoverride.php', get_string('allowoverride', 'role'));
|
||||
|
||||
$tabs = array($toprow);
|
||||
|
||||
print_tabs($tabs, $currenttab);
|
||||
|
||||
?>
|
||||
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
$strinherit = get_string('inherit','role');
|
||||
$strallow = get_string('allow','role');
|
||||
$strprevent = get_string('prevent','role');
|
||||
$strprohibit = get_string('prohibit','role');
|
||||
?>
|
||||
|
||||
<form id="overrideform" action="override.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="userid" value="<?php p($userid) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
</fieldset>
|
||||
|
||||
<table class="rolecap">
|
||||
<tr>
|
||||
<th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
|
||||
<th class="inherit" scope="col"><?php p($strinherit); ?></th>
|
||||
<th class="allow" scope="col"><?php p($strallow); ?></th>
|
||||
<th class="prevent" scope="col"><?php p($strprevent); ?></th>
|
||||
<th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
|
||||
<th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// init these 2
|
||||
$contextlevel = 0;
|
||||
$component = '';
|
||||
|
||||
$strrisks = s(get_string('risks', 'role'));
|
||||
// MDL-11687
|
||||
$strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
|
||||
|
||||
foreach ($capabilities as $capability) {
|
||||
|
||||
// legacy caps should not be overriden - we must use proper capabilities if needed
|
||||
if (islegacy($capability->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prints a breaker if component or name or context level
|
||||
//if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
if (component_level_changed($capability, $component, $contextlevel)) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
|
||||
}
|
||||
|
||||
// these 2 are used to see to group same mod/core capabilities together
|
||||
$contextlevel = $capability->contextlevel;
|
||||
$component = $capability->component;
|
||||
|
||||
// check the capability override for this cap, this role in this context
|
||||
if (isset($localoverrides[$capability->name])) {
|
||||
$localpermission = $localoverrides[$capability->name]->permission;
|
||||
} else {
|
||||
$localpermission = 0; // Just inherit
|
||||
}
|
||||
|
||||
if (isset($r_caps[$capability->name])) {
|
||||
$isallow = $r_caps[$capability->name] > 0;
|
||||
$isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500;
|
||||
$isprohibit = $r_caps[$capability->name] <= -500;
|
||||
} else {
|
||||
$isallow = 0;
|
||||
$isprevent = 0;
|
||||
$isprohibit = 0;
|
||||
}
|
||||
|
||||
$isdisabled = $isprohibit;
|
||||
|
||||
$riskinfo = '<td class="risk managetrust">';
|
||||
$rowclasses = '';
|
||||
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskmanagetrust';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk config">';
|
||||
if (RISK_CONFIG & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskconfig';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk xss">';
|
||||
if (RISK_XSS & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskxss';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk personal">';
|
||||
if (RISK_PERSONAL & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskpersonal';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk spam">';
|
||||
if (RISK_SPAM & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
$riskinfo .= '</td>';
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<tr class="rolecap <?php echo $rowclasses; ?>">
|
||||
<td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
|
||||
<td class="inherit">
|
||||
<input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="0"
|
||||
<?php
|
||||
if ($localpermission == CAP_INHERIT) {echo 'checked="checked" ';}
|
||||
if ($isdisabled) {echo 'disabled="disabled"';}?> />
|
||||
</td>
|
||||
|
||||
<td class="allow <?php if ($isallow) {echo ' capcurrent';} ?>">
|
||||
<input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>"
|
||||
<?php echo ' value="'.CAP_ALLOW.'"';
|
||||
if ($localpermission == CAP_ALLOW) {echo ' checked="checked" ';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
|
||||
<td class="prevent <?php if ($isprevent) {echo ' capcurrent';} ?>">
|
||||
<input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>"
|
||||
<?php echo ' value="'.CAP_PREVENT.'"';
|
||||
if ($localpermission == CAP_PREVENT) {echo ' checked="checked" ';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
|
||||
<td class="prohibit <?php if ($isprohibit) {echo ' capcurrent';} ?>">
|
||||
<input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>"
|
||||
<?php echo ' value="'.CAP_PROHIBIT.'"';
|
||||
if ($localpermission == CAP_PROHIBIT) {echo ' checked="checked" ';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
<?php echo $riskinfo; ?>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" value="<?php print_string('savechanges') ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
</form>
|
||||
@@ -1,212 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // requested role id
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
if (!$context = get_record('context', 'id', $contextid)) {
|
||||
error('Bad context ID');
|
||||
}
|
||||
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
|
||||
error('No site ID');
|
||||
}
|
||||
|
||||
if ($context->id == $sitecontext->id) {
|
||||
error('Can not override base role capabilities');
|
||||
}
|
||||
|
||||
if (!has_capability('moodle/role:override', $context)) {
|
||||
error('You do not have permission to change overrides in this context!');
|
||||
}
|
||||
|
||||
if ($courseid) {
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Bad course ID');
|
||||
}
|
||||
} else {
|
||||
$course = clone($SITE);
|
||||
$courseid = SITEID;
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$baseurl = 'override.php?contextid='.$context->id;
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
if ($courseid != SITEID) {
|
||||
$baseurl .= '&courseid='.$courseid;
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
/// needed for tabs.php
|
||||
$overridableroles = get_overridable_roles($context, 'name', ROLENAME_BOTH);
|
||||
$assignableroles = get_assignable_roles($context, 'name', ROLENAME_BOTH);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
$strroletooverride = get_string('roletooverride', 'role');
|
||||
$straction = get_string('overrideroles', 'role');
|
||||
$strcurrentrole = get_string('currentrole', 'role');
|
||||
$strparticipants = get_string('participants');
|
||||
|
||||
/// Make sure this user can override that role
|
||||
|
||||
if ($roleid) {
|
||||
if (!user_can_override($context, $roleid)) {
|
||||
error ('you can not override this role in this context');
|
||||
}
|
||||
}
|
||||
|
||||
if ($userid) {
|
||||
$user = get_record('user', 'id', $userid);
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
}
|
||||
|
||||
/// get all cababilities
|
||||
$capabilities = fetch_context_capabilities($context);
|
||||
|
||||
/// Process incoming role override
|
||||
if ($data = data_submitted() and $roleid and confirm_sesskey()) {
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
|
||||
$localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
|
||||
'', 'capability, permission, id');
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
|
||||
if (!isset($data->{$cap->name})) {
|
||||
//cap not specified in form
|
||||
continue;
|
||||
}
|
||||
|
||||
if (islegacy($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($localoverrides[$capname])) {
|
||||
// Something exists, so update it
|
||||
assign_capability($capname, $value, $roleid, $context->id, true);
|
||||
} else { // insert a record
|
||||
if ($value != CAP_INHERIT) { // Ignore inherits
|
||||
assign_capability($capname, $value, $roleid, $context->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// force accessinfo refresh for users visiting this context...
|
||||
mark_context_dirty($context->path);
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
|
||||
/// Print the header and tabs
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
$navlinks = array();
|
||||
/// course header
|
||||
if ($course->id != SITEID) {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');
|
||||
}
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$fullname", "$fullname", $navigation, "", "", true, " ", navmenu($course));
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$course->fullname: $fullname", $course->fullname, $navigation, "", "", true, " ", navmenu($course));
|
||||
}
|
||||
$showroles = 1;
|
||||
$currenttab = 'override';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('frontpageroles');
|
||||
admin_externalpage_print_header();
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
}
|
||||
|
||||
print_heading_with_help(get_string('overridepermissionsin', 'role', print_context_name($context)), 'overrides');
|
||||
|
||||
if ($roleid) {
|
||||
/// prints a form to swap roles
|
||||
echo '<div class="selector">';
|
||||
$overridableroles = array('0'=>get_string('listallroles', 'role').'...') + $overridableroles;
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/roles/override.php?userid=$userid&courseid=$courseid&contextid=$contextid&roleid=",
|
||||
$overridableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletooverride);
|
||||
echo '</div>';
|
||||
|
||||
$parentcontexts = get_parent_contexts($context);
|
||||
if (!empty($parentcontexts)) {
|
||||
$parentcontext = array_shift($parentcontexts);
|
||||
$parentcontext = get_context_instance_by_id($parentcontext);
|
||||
} else {
|
||||
$parentcontext = $context; // site level in override??
|
||||
}
|
||||
|
||||
$r_caps = role_context_capabilities($roleid, $parentcontext);
|
||||
|
||||
$localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
|
||||
'', 'capability, permission, id');
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
if (!empty($capabilities)) {
|
||||
// Print the capabilities overrideable in this context
|
||||
print_simple_box_start('center');
|
||||
include_once('override.html');
|
||||
print_simple_box_end();
|
||||
|
||||
} else {
|
||||
notice(get_string('nocapabilitiesincontext', 'role'),
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/'.$baseurl);
|
||||
}
|
||||
|
||||
} else { // Print overview table
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('roles', 'role'), get_string('description'), get_string('overrides', 'role'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center');
|
||||
|
||||
foreach ($overridableroles as $roleid => $rolename) {
|
||||
$countusers = 0;
|
||||
$overridecount = count_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id");
|
||||
$description = format_string(get_field('role', 'description', 'id', $roleid));
|
||||
$table->data[] = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>', $description, $overridecount);
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
@@ -1,229 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Handles headers and tabs for the roles control at any level apart from SYSTEM level
|
||||
// We also assume that $currenttab, $assignableroles and $overridableroles are defined
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$navlinks = array();
|
||||
if ($currenttab != 'update') {
|
||||
switch ($context->contextlevel) {
|
||||
|
||||
case CONTEXT_SYSTEM:
|
||||
$stradministration = get_string('administration');
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => '../index.php', 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header($SITE->fullname, "$SITE->fullname", $navigation);
|
||||
break;
|
||||
|
||||
case CONTEXT_USER:
|
||||
print_header();
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSECAT:
|
||||
$category = get_record('course_categories', 'id', $context->instanceid);
|
||||
$strcategories = get_string("categories");
|
||||
$strcategory = get_string("category");
|
||||
$strcourses = get_string("courses");
|
||||
|
||||
$navlinks[] = array('name' => $strcategories,
|
||||
'link' => "$CFG->wwwroot/course/index.php",
|
||||
'type' => 'misc');
|
||||
$navlinks[] = array('name' => $category->name,
|
||||
'link' => "$CFG->wwwroot/course/category.php?id=$category->id",
|
||||
'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses", $navigation, "", "", true);
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSE:
|
||||
if ($context->instanceid != SITEID) {
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
|
||||
$course = get_record('course', 'id', $context->instanceid);
|
||||
|
||||
require_login($course);
|
||||
$navlinks[] = array('name' => get_string('roles'),
|
||||
'link' => "$CFG->wwwroot/admin/roles/assign.php?contextid=$context->id",
|
||||
'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header($streditcoursesettings, $course->fullname, $navigation);
|
||||
}
|
||||
break;
|
||||
|
||||
case CONTEXT_GROUP:
|
||||
break;
|
||||
|
||||
case CONTEXT_MODULE:
|
||||
// get module type?
|
||||
if (!$cm = get_record('course_modules','id',$context->instanceid)) {
|
||||
error('Bad course module ID');
|
||||
}
|
||||
if (!$module = get_record('modules','id',$cm->module)) { //$module->name;
|
||||
error('Bad module ID');
|
||||
}
|
||||
if (!$course = get_record('course','id',$cm->course)) {
|
||||
error('Bad course ID');
|
||||
}
|
||||
if (!$instance = get_record($module->name, 'id', $cm->instance)) {
|
||||
error("The required instance of this module doesn't exist");
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$fullmodulename = get_string("modulename", $module->name);
|
||||
$streditinga = get_string("editinga", "moodle", $fullmodulename);
|
||||
$strmodulenameplural = get_string("modulenameplural", $module->name);
|
||||
|
||||
if ($module->name == "label") {
|
||||
$focuscursor = "";
|
||||
} else {
|
||||
$focuscursor = "form.name";
|
||||
}
|
||||
|
||||
$navlinks[] = array('name' => $strmodulenameplural,
|
||||
'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id",
|
||||
'type' => 'misc');
|
||||
|
||||
$navlinks[] = array('name' => $instance->name,
|
||||
'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id",
|
||||
'type' => 'misc');
|
||||
|
||||
$navlinks[] = array('name' => $streditinga,
|
||||
'link' => "$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey(),
|
||||
'type' => 'misc');
|
||||
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header_simple($streditinga, '', $navigation, $focuscursor, "", false);
|
||||
|
||||
break;
|
||||
|
||||
case CONTEXT_BLOCK:
|
||||
if ($blockinstance = get_record('block_instance', 'id', $context->instanceid)) {
|
||||
if ($block = get_record('block', 'id', $blockinstance->blockid)) {
|
||||
$blockname = print_context_name($context);
|
||||
|
||||
|
||||
switch ($blockinstance->pagetype) {
|
||||
case 'course-view':
|
||||
if ($course = get_record('course', 'id', $blockinstance->pageid)) {
|
||||
|
||||
require_login($course);
|
||||
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $blockname", $course->fullname, $navigation);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'blog-view':
|
||||
$strblogs = get_string('blogs','blog');
|
||||
$navlinks[] = array('name' => $strblogs,
|
||||
'link' => $CFG->wwwroot.'/blog/index.php',
|
||||
'type' => 'misc');
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $strblogs", $SITE->fullname, $navigation);
|
||||
break;
|
||||
|
||||
case 'tag-index':
|
||||
$strtags = get_string('tags');
|
||||
$navlinks[] = array('name' => $strtags,
|
||||
'link' => $CFG->wwwroot.'/tag/index.php',
|
||||
'type' => 'misc');
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $strtags", $SITE->fullname, $navigation);
|
||||
break;
|
||||
|
||||
default:
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $blockname", $SITE->fullname, $navigation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
error ('This is an unknown context (' . $context->contextlevel . ') in admin/roles/tabs.php!');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$toprow = array();
|
||||
$inactive = array();
|
||||
$activetwo = array();
|
||||
|
||||
|
||||
if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything except SYSTEM context
|
||||
|
||||
if ($context->contextlevel == CONTEXT_MODULE) { // Only show update button if module
|
||||
|
||||
$toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.
|
||||
$context->instanceid.'&return=true&sesskey='.sesskey(), get_string('settings'));
|
||||
|
||||
}
|
||||
|
||||
if (!empty($assignableroles)) {
|
||||
$toprow[] = new tabobject('assign',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
|
||||
get_string('localroles', 'role'),
|
||||
get_string('showallroles', 'role'),
|
||||
true);
|
||||
}
|
||||
|
||||
if (!empty($overridableroles)) {
|
||||
$toprow[] = new tabobject('override',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id,
|
||||
get_string('overridepermissions', 'role'),
|
||||
get_string('showallroles', 'role'),
|
||||
true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Here other core tabs should go (always calling tabs.php files)
|
||||
/// All the logic to decide what to show must be self-contained in the tabs file
|
||||
/// eg:
|
||||
/// include_once($CFG->dirroot . '/grades/tabs.php');
|
||||
|
||||
/// Finally, we support adding some 'on-the-fly' tabs here
|
||||
/// All the logic to decide what to show must be self-cointained in the tabs file
|
||||
if (isset($CFG->extratabs) && !empty($CFG->extratabs)) {
|
||||
if ($extratabs = explode(',', $CFG->extratabs)) {
|
||||
asort($extratabs);
|
||||
foreach($extratabs as $extratab) {
|
||||
/// Each extra tab must be one $CFG->dirroot relative file
|
||||
if (file_exists($CFG->dirroot . '/' . $extratab)) {
|
||||
include_once($CFG->dirroot . '/' . $extratab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$inactive[] = $currenttab;
|
||||
|
||||
$tabs = array($toprow);
|
||||
|
||||
/// If there are any secondrow defined, let's introduce it
|
||||
if (isset($secondrow) && is_array($secondrow) && !empty($secondrow)) {
|
||||
$tabs[] = $secondrow;
|
||||
}
|
||||
|
||||
print_tabs($tabs, $currenttab, $inactive, $activetwo);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// searches for admin settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$query = trim(stripslashes(optional_param('query', '', PARAM_NOTAGS))); // Search string
|
||||
|
||||
$adminroot =& admin_get_root(); // need all settings here
|
||||
$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
$focus = '';
|
||||
|
||||
admin_externalpage_setup('search'); // now hidden page
|
||||
|
||||
// now we'll deal with the case that the admin has submitted the form with changed settings
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
if (admin_write_settings($data)) {
|
||||
$statusmsg = get_string('changessaved');
|
||||
}
|
||||
$adminroot =& admin_get_root(true); //reload tree
|
||||
|
||||
if (!empty($adminroot->errors)) {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
$focus = $firsterror->id;
|
||||
}
|
||||
}
|
||||
|
||||
// and finally, if we get here, then there are matching settings and we have to print a form
|
||||
// to modify them
|
||||
admin_externalpage_print_header($focus);
|
||||
|
||||
if ($errormsg !== '') {
|
||||
notify ($errormsg);
|
||||
|
||||
} else if ($statusmsg !== '') {
|
||||
notify ($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
$resultshtml = admin_search_settings_html($query); // case insensitive search only
|
||||
|
||||
echo '<form action="search.php" method="post" id="adminsettings">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="query" value="'.s($query).'" />';
|
||||
echo '</div>';
|
||||
echo '<fieldset>';
|
||||
echo '<div class="clearer"><!-- --></div>';
|
||||
if ($resultshtml != '') {
|
||||
echo $resultshtml;
|
||||
} else {
|
||||
echo get_string('noresults','admin');
|
||||
}
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,172 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
|
||||
|
||||
$section = required_param('section', PARAM_SAFEDIR);
|
||||
$return = optional_param('return','', PARAM_ALPHA);
|
||||
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
|
||||
/// no guest autologin
|
||||
require_login(0, false);
|
||||
|
||||
$adminroot =& admin_get_root(); // need all settings
|
||||
$page =& $adminroot->locate($section);
|
||||
|
||||
if (empty($page) or !is_a($page, 'admin_settingpage')) {
|
||||
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
die;
|
||||
}
|
||||
|
||||
if (!($page->check_access())) {
|
||||
print_error('accessdenied', 'admin');
|
||||
die;
|
||||
}
|
||||
|
||||
/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
|
||||
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
$focus = '';
|
||||
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
if (admin_write_settings($data)) {
|
||||
$statusmsg = get_string('changessaved');
|
||||
}
|
||||
|
||||
if (empty($adminroot->errors)) {
|
||||
switch ($return) {
|
||||
case 'site': redirect("$CFG->wwwroot/");
|
||||
case 'admin': redirect("$CFG->wwwroot/$CFG->admin/");
|
||||
}
|
||||
} else {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
$focus = $firsterror->id;
|
||||
}
|
||||
$adminroot =& admin_get_root(true); //reload tree
|
||||
$page =& $adminroot->locate($section);
|
||||
}
|
||||
|
||||
/// very hacky page setup
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
|
||||
$PAGE->init_extra($section);
|
||||
$CFG->pagepath = 'admin/setting/'.$section;
|
||||
|
||||
if (!isset($USER->adminediting)) {
|
||||
$USER->adminediting = false;
|
||||
}
|
||||
|
||||
if ($PAGE->user_allowed_editing()) {
|
||||
if ($adminediting == 1) {
|
||||
$USER->adminediting = true;
|
||||
} elseif ($adminediting == 0) {
|
||||
$USER->adminediting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// print header stuff ------------------------------------------------------------
|
||||
|
||||
if (empty($SITE->fullname)) {
|
||||
print_header($page->visiblename, $page->visiblename, '', $focus);
|
||||
print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
|
||||
|
||||
if ($errormsg !== '') {
|
||||
notify ($errormsg);
|
||||
|
||||
} else if ($statusmsg !== '') {
|
||||
notify ($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
echo '<form action="settings.php" method="post" id="adminsettings">';
|
||||
echo '<div class="settingsform clearfix">';
|
||||
echo '<input type="hidden" name="section" value="'.$PAGE->section.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
|
||||
echo $page->output_html();
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
} else {
|
||||
$pageblocks = blocks_setup($PAGE);
|
||||
|
||||
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
|
||||
BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
|
||||
BLOCK_R_MAX_WIDTH);
|
||||
|
||||
$PAGE->print_header('', $focus);
|
||||
|
||||
echo '<table id="layout-table"><tr>';
|
||||
$lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
|
||||
foreach ($lt as $column) {
|
||||
switch ($column) {
|
||||
case 'left':
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'middle':
|
||||
echo '<td id="middle-column">';
|
||||
print_container_start();
|
||||
echo '<a name="startofcontent"></a>';
|
||||
|
||||
if ($errormsg !== '') {
|
||||
notify ($errormsg);
|
||||
|
||||
} else if ($statusmsg !== '') {
|
||||
notify ($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
echo '<form action="settings.php" method="post" id="adminsettings">';
|
||||
echo '<div class="settingsform clearfix">';
|
||||
echo '<input type="hidden" name="section" value="'.$PAGE->section.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
print_heading($page->visiblename);
|
||||
|
||||
echo $page->output_html();
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'right':
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo '</tr></table>';
|
||||
}
|
||||
|
||||
if (!empty($CFG->adminusehtmleditor)) {
|
||||
use_html_editor();
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "appearance" category
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$ADMIN->add('appearance', new admin_category('themes', get_string('themes')));
|
||||
// "themesettings" settingpage
|
||||
$temp = new admin_settingpage('themesettings', get_string('themesettings', 'admin'));
|
||||
$temp->add(new admin_setting_configtext('themelist', get_string('themelist', 'admin'), get_string('configthemelist','admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserthemes', get_string('allowuserthemes', 'admin'), get_string('configallowuserthemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowcoursethemes', get_string('allowcoursethemes', 'admin'), get_string('configallowcoursethemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowcategorythemes', get_string('allowcategorythemes', 'admin'), get_string('configallowcategorythemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('showblocksonmodpages', get_string('showblocksonmodpages', 'admin'), get_string('configshowblocksonmodpages', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configselect('hideactivitytypenavlink', get_string('hideactivitytypenavlink', 'admin'), get_string('confighideactivitytypenavlink', 'admin'), 0,
|
||||
array(
|
||||
0 => get_string('hidefromnone', 'admin'),
|
||||
1 => get_string('hidefromstudents', 'admin'),
|
||||
2 => get_string('hidefromall', 'admin')
|
||||
)));
|
||||
$ADMIN->add('themes', $temp);
|
||||
$ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php'));
|
||||
|
||||
// calendar
|
||||
$temp = new admin_settingpage('calendar', get_string('calendarsettings','admin'));
|
||||
$temp->add(new admin_setting_special_adminseesall());
|
||||
//this is hacky because we do not want to include the stuff from calendar/lib.php
|
||||
$temp->add(new admin_setting_configselect('calendar_site_timeformat', get_string('pref_timeformat', 'calendar'),
|
||||
get_string('explain_site_timeformat', 'calendar'), '0',
|
||||
array('0' => get_string('default', 'calendar'),
|
||||
'%I:%M %p' => get_string('timeformat_12', 'calendar'),
|
||||
'%H:%M' => get_string('timeformat_24', 'calendar'))));
|
||||
$temp->add(new admin_setting_configselect('calendar_startwday', get_string('configstartwday', 'admin'), get_string('helpstartofweek', 'admin'), 0,
|
||||
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')
|
||||
)));
|
||||
$temp->add(new admin_setting_special_calendar_weekend());
|
||||
$temp->add(new admin_setting_configtext('calendar_lookahead',get_string('configlookahead','admin'),get_string('helpupcominglookahead', 'admin'),21,PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('calendar_maxevents',get_string('configmaxevents','admin'),get_string('helpupcomingmaxevents', 'admin'),10,PARAM_INT));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// "htmleditor" settingpage
|
||||
$temp = new admin_settingpage('htmleditor', get_string('htmleditor', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('htmleditor', get_string('usehtmleditor', 'admin'), get_string('confightmleditor','admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('editorbackgroundcolor', get_string('editorbackgroundcolor', 'admin'), get_string('edhelpbgcolor'), '#ffffff', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configtext('editorfontfamily', get_string('editorfontfamily', 'admin'), get_string('edhelpfontfamily'), 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configtext('editorfontsize', get_string('editorfontsize', 'admin'), get_string('edhelpfontsize'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_special_editorfontlist());
|
||||
$temp->add(new admin_setting_configcheckbox('editorkillword', get_string('editorkillword', 'admin'), get_string('edhelpcleanword'), 1));
|
||||
if (!empty($CFG->aspellpath)) { // make aspell settings disappear if path isn't set
|
||||
$temp->add(new admin_setting_configcheckbox('editorspelling', get_string('editorspelling', 'admin'), get_string('editorspellinghelp', 'admin'), 0));
|
||||
$temp->add(new admin_setting_special_editordictionary());
|
||||
}
|
||||
$temp->add(new admin_setting_special_editorhidebuttons());
|
||||
$temp->add(new admin_setting_emoticons());
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// "documentation" settingpage
|
||||
$temp = new admin_settingpage('documentation', get_string('moodledocs'));
|
||||
$temp->add(new admin_setting_configtext('docroot', get_string('docroot', 'admin'), get_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL));
|
||||
$temp->add(new admin_setting_configcheckbox('doctonewwindow', get_string('doctonewwindow', 'admin'), get_string('configdoctonewwindow', 'admin'), 0));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$temp = new admin_settingpage('mymoodle', get_string('mymoodle', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('mymoodleredirect', get_string('mymoodleredirect', 'admin'), get_string('configmymoodleredirect', 'admin'), 0));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// new CFG variable for coursemanager (what roles to display)
|
||||
$temp = new admin_settingpage('coursemanager', get_string('coursemanager', 'admin'));
|
||||
$temp->add(new admin_setting_special_coursemanager());
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$temp = new admin_settingpage('ajax', get_string('ajaxuse'));
|
||||
$temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('disablecourseajax', get_string('disablecourseajax', 'admin'), get_string('configdisablecourseajax', 'admin'),
|
||||
isset($CFG->disablecourseajax) ? 1 : empty($CFG->enableajax)));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// link to tag management interface
|
||||
$ADMIN->add('appearance', new admin_externalpage('managetags', get_string('managetags', 'tag'), "$CFG->wwwroot/tag/manage.php"));
|
||||
|
||||
} // end of speedup
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "courses" category
|
||||
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/site:backup', $systemcontext)
|
||||
or has_capability('moodle/category:update', $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
|
||||
$ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on','moodle/category:update'));
|
||||
|
||||
$ADMIN->add('courses', new admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php'));
|
||||
|
||||
// "courserequests" settingpage
|
||||
$temp = new admin_settingpage('courserequest', get_string('courserequest'));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0));
|
||||
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1));
|
||||
$ADMIN->add('courses', $temp);
|
||||
|
||||
// "backups" settingpage
|
||||
if (!empty($CFG->backup_version)) {
|
||||
$bi = array();
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_modules', get_string('includemodules'), get_string('backupincludemoduleshelp'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_withuserdata', get_string('includemoduleuserdata'), get_string('backupincludemoduleuserdatahelp'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_metacourse', get_string('metacourse'), get_string('backupmetacoursehelp'), 0);
|
||||
$bi[] = new admin_setting_configselect('backup_sche_users', get_string('users'), get_string('backupusershelp'),
|
||||
0, array(0 => get_string('all'), 1 => get_string('course')));
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_logs', get_string('logs'), get_string('backuplogshelp'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_userfiles', get_string('userfiles'), get_string('backupuserfileshelp'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_coursefiles', get_string('coursefiles'), get_string('backupcoursefileshelp'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_sitefiles', get_string('sitefiles'), get_string('backupsitefileshelp'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0);
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0);
|
||||
$bi[] = new admin_setting_configselect('backup_sche_keep', get_string('keep'),
|
||||
get_string('backupkeephelp'), 1, array(0 => get_string('all'), 1 => '1',
|
||||
2 => '2',
|
||||
5 => '5',
|
||||
10 => '10',
|
||||
20 => '20',
|
||||
30 => '30',
|
||||
40 => '40',
|
||||
50 => '50',
|
||||
100 => '100',
|
||||
200 => '200',
|
||||
300 => '300',
|
||||
400 => '400',
|
||||
500 => '500'));
|
||||
$bi[] = new admin_setting_configcheckbox('backup_sche_active', get_string('active'), get_string('backupactivehelp'), 0);
|
||||
$bi[] = new admin_setting_special_backupdays();
|
||||
$bi[] = new admin_setting_configtime('backup_sche_hour', 'backup_sche_minute', get_string('executeat'),
|
||||
get_string('backupexecuteathelp'), array('h' => 0, 'm' => 0));
|
||||
$bi[] = new admin_setting_configdirectory('backup_sche_destination', get_string('saveto'), get_string('backupsavetohelp'), '');
|
||||
|
||||
$temp = new admin_settingpage('backups', get_string('backups','admin'), 'moodle/site:backup');
|
||||
foreach ($bi as $backupitem) {
|
||||
$backupitem->plugin = 'backup';
|
||||
$temp->add($backupitem);
|
||||
}
|
||||
$ADMIN->add('courses', $temp);
|
||||
}
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines everything related to frontpage
|
||||
|
||||
if (get_site()) { //do not use during installation
|
||||
$frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
|
||||
|
||||
if ($hassiteconfig or has_any_capability(array(
|
||||
'moodle/course:update',
|
||||
'moodle/role:assign',
|
||||
'moodle/site:restore',
|
||||
'moodle/site:backup',
|
||||
'moodle/course:managefiles',
|
||||
'moodle/question:add',
|
||||
'moodle/question:editmine',
|
||||
'moodle/question:editall',
|
||||
'moodle/question:viewmine',
|
||||
'moodle/question:viewall',
|
||||
'moodle/question:movemine',
|
||||
'moodle/question:moveall'), $frontpagecontext)) {
|
||||
|
||||
// "frontpage" settingpage
|
||||
$temp = new admin_settingpage('frontpagesettings', get_string('frontpagesettings','admin'), 'moodle/course:update', false, $frontpagecontext);
|
||||
$temp->add(new admin_setting_sitesettext('fullname', get_string('fullsitename'), '', NULL)); // no default
|
||||
$temp->add(new admin_setting_sitesettext('shortname', get_string('shortsitename'), '', NULL)); // no default
|
||||
$temp->add(new admin_setting_special_frontpagedesc());
|
||||
$temp->add(new admin_setting_courselist_frontpage(false)); // non-loggedin version of the setting (that's what the parameter is for :) )
|
||||
$temp->add(new admin_setting_courselist_frontpage(true)); // loggedin version of the setting
|
||||
$temp->add(new admin_setting_sitesetcheckbox('numsections', get_string('sitesection'), get_string('sitesectionhelp','admin'), 1));
|
||||
$temp->add(new admin_setting_sitesetselect('newsitems', get_string('newsitemsnumber'), '', 3,
|
||||
array('0' => '0',
|
||||
'1' => '1',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
'5' => '5',
|
||||
'6' => '6',
|
||||
'7' => '7',
|
||||
'8' => '8',
|
||||
'9' => '9',
|
||||
'10' => '10')));
|
||||
$temp->add(new admin_setting_configtext('coursesperpage', get_string('coursesperpage', 'admin'), get_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
|
||||
$temp->add(new admin_setting_configcheckbox('allowvisiblecoursesinhiddencategories', get_string('allowvisiblecoursesinhiddencategories', 'admin'), get_string('configvisiblecourses', 'admin'), 0));
|
||||
|
||||
// front page default role
|
||||
$roleoptions = array(0=>get_string('none')); // roles to choose from
|
||||
if ($roles = get_all_roles()) {
|
||||
foreach ($roles as $role) {
|
||||
$roleoptions[$role->id] = strip_tags(format_string($role->name, true));
|
||||
}
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', 0, $roleoptions));
|
||||
|
||||
$ADMIN->add('frontpage', $temp);
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpageroles', get_string('frontpageroles', 'admin'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $frontpagecontext->id, 'moodle/role:assign', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagebackup', get_string('frontpagebackup', 'admin'), $CFG->wwwroot.'/backup/backup.php?id='.SITEID, 'moodle/site:backup', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', get_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/files/index.php?id='.SITEID.'&wdir=/backupdata', 'moodle/site:restore', false, $frontpagecontext));
|
||||
|
||||
$questioncapabilites = array(
|
||||
'moodle/question:add',
|
||||
'moodle/question:editmine',
|
||||
'moodle/question:editall',
|
||||
'moodle/question:viewmine',
|
||||
'moodle/question:viewall',
|
||||
'moodle/question:movemine',
|
||||
'moodle/question:moveall');
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagequestions', get_string('frontpagequestions', 'admin'), $CFG->wwwroot.'/question/edit.php?courseid='.SITEID, $questioncapabilites, false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('sitefiles', get_string('sitefiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID, 'moodle/course:managefiles', false, $frontpagecontext));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,195 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "grades" section
|
||||
|
||||
if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
or has_capability('moodle/grade:manageletters', $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// General settings
|
||||
|
||||
$temp = new admin_settingpage('gradessettings', get_string('generalsettings', 'grades'), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
require_once $CFG->libdir.'/grade/constants.php';
|
||||
|
||||
// new CFG variable for gradebook (what roles to display)
|
||||
$temp->add(new admin_setting_special_gradebookroles());
|
||||
|
||||
// enable outcomes checkbox
|
||||
$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_grade_profilereport());
|
||||
|
||||
$temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'),
|
||||
get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
|
||||
array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
|
||||
GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades'))));
|
||||
|
||||
$temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', get_string('includescalesinaggregation', 'grades'), get_string('configincludescalesinaggregation', 'grades'), 1));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0));
|
||||
|
||||
// enable publishing in exports/imports
|
||||
$temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
|
||||
get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
|
||||
array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
|
||||
GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
|
||||
GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'),
|
||||
get_string('configexportdecimalpoints', 'grades'), 2,
|
||||
array( '0' => '0',
|
||||
'1' => '1',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
'5' => '5')));
|
||||
|
||||
$temp->add(new admin_setting_special_gradeexport());
|
||||
}
|
||||
$ADMIN->add('grades', $temp);
|
||||
|
||||
/// Grade category settings
|
||||
$temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
$temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', get_string('hideforcedsettings', 'grades'), get_string('confighideforcedsettings', 'grades'), '1'));
|
||||
|
||||
$strnoforce = get_string('noforce', 'grades');
|
||||
|
||||
// Aggregation type
|
||||
$options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'),
|
||||
GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
|
||||
GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'),
|
||||
GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'),
|
||||
GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'),
|
||||
GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades'));
|
||||
$defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false);
|
||||
$temp->add(new admin_setting_gradecat_combo('grade_aggregation', get_string('aggregation', 'grades'), get_string('aggregationhelp', 'grades'), $defaults, $options));
|
||||
|
||||
$options = array(0 => get_string('no'), 1 => get_string('yes'));
|
||||
|
||||
$defaults = array('value'=>1, 'forced'=>false, 'adv'=>true);
|
||||
$temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', get_string('aggregateonlygraded', 'grades'),
|
||||
get_string('aggregateonlygradedhelp', 'grades'), $defaults, $options));
|
||||
$defaults = array('value'=>0, 'forced'=>false, 'adv'=>true);
|
||||
$temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', get_string('aggregateoutcomes', 'grades'),
|
||||
get_string('aggregateoutcomeshelp', 'grades'), $defaults, $options));
|
||||
$temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', get_string('aggregatesubcats', 'grades'),
|
||||
get_string('aggregatesubcatshelp', 'grades'), $defaults, $options));
|
||||
|
||||
$options = array(0 => get_string('none'));
|
||||
for ($i=1; $i<=20; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
|
||||
$defaults['value'] = 0;
|
||||
$defaults['forced'] = true;
|
||||
$temp->add(new admin_setting_gradecat_combo('grade_keephigh', get_string('keephigh', 'grades'),
|
||||
get_string('keephighhelp', 'grades'), $defaults, $options));
|
||||
$defaults['forced'] = false;
|
||||
$temp->add(new admin_setting_gradecat_combo('grade_droplow', get_string('droplow', 'grades'),
|
||||
get_string('droplowhelp', 'grades'), $defaults, $options));
|
||||
}
|
||||
$ADMIN->add('grades', $temp);
|
||||
|
||||
|
||||
/// Grade item settings
|
||||
$temp = new admin_settingpage('gradeitemsettings', get_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
$temp->add(new admin_setting_configselect('grade_displaytype', get_string('gradedisplaytype', 'grades'),
|
||||
get_string('configgradedisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
|
||||
array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
|
||||
GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
|
||||
GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('decimalpoints', 'grades'),
|
||||
get_string('configdecimalpoints', 'grades'), 2,
|
||||
array( '0' => '0',
|
||||
'1' => '1',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
'5' => '5')));
|
||||
|
||||
$temp->add(new admin_setting_configmultiselect('grade_item_advanced', get_string('gradeitemadvanced', 'grades'), get_string('configgradeitemadvanced', 'grades'),
|
||||
array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'),
|
||||
array('iteminfo' => get_string('iteminfo', 'grades'),
|
||||
'idnumber' => get_string('idnumbermod'),
|
||||
'gradetype' => get_string('gradetype', 'grades'),
|
||||
'scaleid' => get_string('scale'),
|
||||
'grademin' => get_string('grademin', 'grades'),
|
||||
'grademax' => get_string('grademax', 'grades'),
|
||||
'gradepass' => get_string('gradepass', 'grades'),
|
||||
'plusfactor' => get_string('plusfactor', 'grades'),
|
||||
'multfactor' => get_string('multfactor', 'grades'),
|
||||
'display' => get_string('gradedisplaytype', 'grades'),
|
||||
'decimals' => get_string('decimalpoints', 'grades'),
|
||||
'hidden' => get_string('hidden', 'grades'),
|
||||
'hiddenuntil' => get_string('hiddenuntil', 'grades'),
|
||||
'locked' => get_string('locked', 'grades'),
|
||||
'locktime' => get_string('locktime', 'grades'),
|
||||
'aggregationcoef' => get_string('aggregationcoef', 'grades'),
|
||||
'parentcategory' => get_string('parentcategory', 'grades'))));
|
||||
}
|
||||
$ADMIN->add('grades', $temp);
|
||||
|
||||
|
||||
/// Scales and outcomes
|
||||
|
||||
$scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
|
||||
$ADMIN->add('grades', $scales);
|
||||
$outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
|
||||
$ADMIN->add('grades', $outcomes);
|
||||
$letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/edit.php', 'moodle/grade:manageletters');
|
||||
$ADMIN->add('grades', $letters);
|
||||
|
||||
// The plugins must implement a settings.php file that adds their admin settings to the $settings object
|
||||
|
||||
// Reports
|
||||
$ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades')));
|
||||
foreach (get_list_of_plugins('grade/report') as $plugin) {
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php');
|
||||
}
|
||||
$ADMIN->add('gradereports', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
// Imports
|
||||
$ADMIN->add('grades', new admin_category('gradeimports', get_string('importsettings', 'grades')));
|
||||
foreach (get_list_of_plugins('grade/import') as $plugin) {
|
||||
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php');
|
||||
}
|
||||
$ADMIN->add('gradeimports', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Exports
|
||||
$ADMIN->add('grades', new admin_category('gradeexports', get_string('exportsettings', 'grades')));
|
||||
foreach (get_list_of_plugins('grade/export') as $plugin) {
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php');
|
||||
}
|
||||
$ADMIN->add('gradeexports', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "appearance" category
|
||||
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/site:langeditmaster', $systemcontext)
|
||||
or has_capability('moodle/site:langeditlocal', $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// "languageandlocation" settingpage
|
||||
$temp = new admin_settingpage('langsettings', get_string('languagesettings', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('autolang', get_string('autolang', 'admin'), get_string('configautolang', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_list_of_languages())); // $CFG->lang might be set in installer already, default en or en_utf8 is in setup.php
|
||||
$temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1));
|
||||
$temp->add(new admin_setting_langlist());
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE));
|
||||
|
||||
// new CFG variable for excel encoding
|
||||
$temp->add(new admin_setting_configselect('latinexcelexport', get_string('latinexcelexport', 'admin'), get_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin')));
|
||||
|
||||
|
||||
$ADMIN->add('language', $temp);
|
||||
|
||||
$ADMIN->add('language', new admin_externalpage('langedit', get_string('langedit', 'admin'), "$CFG->wwwroot/$CFG->admin/lang.php", array('moodle/site:langeditmaster', 'moodle/site:langeditlocal') ));
|
||||
$ADMIN->add('language', new admin_externalpage('langimport', get_string('langpacks', 'admin'), "$CFG->wwwroot/$CFG->admin/langimport.php"));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// "locations" settingpage
|
||||
$temp = new admin_settingpage('locationsettings', get_string('locationsettings', 'admin'));
|
||||
$options = get_list_of_timezones();
|
||||
$options[99] = get_string('serverlocaltime');
|
||||
$temp->add(new admin_setting_configselect('timezone', get_string('timezone','admin'), get_string('configtimezone', 'admin'), 99, $options));
|
||||
$options[99] = get_string('timezonenotforced', 'admin');
|
||||
$temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options));
|
||||
$options = get_list_of_countries();
|
||||
$options[0] = get_string('choose') .'...';
|
||||
$temp->add(new admin_setting_configselect('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0, $options));
|
||||
|
||||
$temp->add(new admin_setting_heading('iplookup', get_string('iplookup', 'admin'), get_string('iplookupinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configfile('geoipfile', get_string('geoipfile', 'admin'), get_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
|
||||
$temp->add(new admin_setting_configtext('googlemapkey', get_string('googlemapkey', 'admin'), get_string('configgooglemapkey', 'admin', $CFG->wwwroot), ''));
|
||||
|
||||
$ADMIN->add('location', $temp);
|
||||
|
||||
|
||||
$ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "$CFG->wwwroot/$CFG->admin/timezoneimport.php"));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// * Miscellaneous settings
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// Experimental settings page
|
||||
$temp = new admin_settingpage('experimental', get_string('experimental', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('smartpix', get_string('smartpix', 'admin'), get_string('configsmartpix', 'admin'), 0));
|
||||
$item = new admin_setting_configcheckbox('enablehtmlpurifier', get_string('enablehtmlpurifier', 'admin'), get_string('configenablehtmlpurifier', 'admin'), 0);
|
||||
$item->set_updatedcallback('reset_text_filters_cache');
|
||||
$temp->add($item);
|
||||
$temp->add(new admin_setting_configcheckbox('enablegroupings', get_string('enablegroupings', 'admin'), get_string('configenablegroupings', 'admin'), 0));
|
||||
|
||||
$ADMIN->add('misc', $temp);
|
||||
|
||||
// XMLDB editor
|
||||
$ADMIN->add('misc', new admin_externalpage('xmldbeditor', get_string('xmldbeditor'), "$CFG->wwwroot/$CFG->admin/xmldb/"));
|
||||
|
||||
|
||||
// hidden scripts linked from elsewhere
|
||||
$ADMIN->add('misc', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
|
||||
$ADMIN->add('misc', new admin_externalpage('upgradeforumread', 'Upgrade forum', $CFG->wwwroot.'/'.$CFG->admin.'/upgradeforumread.php', 'moodle/site:config', true));
|
||||
$ADMIN->add('misc', new admin_externalpage('upgradelogs', 'Upgrade logs', $CFG->wwwroot.'/'.$CFG->admin.'/upgradelogs.php', 'moodle/site:config', true));
|
||||
$ADMIN->add('misc', new admin_externalpage('multilangupgrade', get_string('multilangupgrade', 'admin'), $CFG->wwwroot.'/'.$CFG->admin.'/multilangupgrade.php', 'moodle/site:config', !empty($CFG->filter_multilang_converted)));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user