Compare commits
1100 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 367dfbd905 | |||
| b17e52001c | |||
| 153fd875b5 | |||
| a43dc9df02 | |||
| f9f150290f | |||
| 8779cb8b46 | |||
| d7378d19ec | |||
| 6219022575 | |||
| d9ec40f57f | |||
| ea790c7db1 | |||
| f0403cbba2 | |||
| 88b5f9b726 | |||
| 4d0ec2a375 | |||
| 7cb4fb6a88 | |||
| 504317a519 | |||
| 110351a2a6 | |||
| 9599ee24b9 | |||
| 78baa1aaad | |||
| 1f4025a70e | |||
| 7e147392e1 | |||
| b7f0d27621 | |||
| 0428d11d76 | |||
| b5a5a482bd | |||
| 699768ebbc | |||
| 6bd9066b7f | |||
| 6af4e1c8c4 | |||
| a5c41b6a5a | |||
| 0bffc5576e | |||
| 21982b71a6 | |||
| 41a5c34f91 | |||
| d08b6757e6 | |||
| dfeb385672 | |||
| b36064f742 | |||
| 3dfb5e4379 | |||
| 7f9f7ec944 | |||
| 1828849b1e | |||
| ff7253c2c1 | |||
| 52257f15d7 | |||
| 4c1af19cf6 | |||
| 48a2b5ad42 | |||
| 9e8cabd7eb | |||
| e28cc09b24 | |||
| 6282be2fd9 | |||
| e6b8565063 | |||
| bce83e8c76 | |||
| e2bf5eec99 | |||
| 87ab475575 | |||
| 9022696d6d | |||
| 418cc2032b | |||
| 25769ccd61 | |||
| d0e6183436 | |||
| ca3c1ddf40 | |||
| ec9f7c117e | |||
| 7f0984c1f3 | |||
| dc8207c52a | |||
| 4419fe33a5 | |||
| ba0dabcc31 | |||
| 3810ca294d | |||
| f493763e04 | |||
| 3140dc600d | |||
| 30739f6651 | |||
| 071d36c917 | |||
| 0540d3479c | |||
| 721a2de984 | |||
| 78d68eb5b2 | |||
| 5c5cb3ec7e | |||
| b06855297c | |||
| dbd0f586a2 | |||
| eb2a36fb55 | |||
| a45296043e | |||
| 4bf57cbfa6 | |||
| 43d78a231d | |||
| 45d44e7e80 | |||
| ff6bc9fbc2 | |||
| 4bdf76ae71 | |||
| 97feab527e | |||
| 903f3f54ed | |||
| a1fec0e3ce | |||
| e07f4ac436 | |||
| 25a37d70ff | |||
| 5446beaa73 | |||
| cb6281b339 | |||
| 3696a3723e | |||
| 8fa821d514 | |||
| 9bb4b97e3d | |||
| 87c39bf549 | |||
| 91f54796bd | |||
| fd52f257ff | |||
| 94c9630d78 | |||
| 84718c0056 | |||
| 0a16d1722a | |||
| abb8f34ecf | |||
| 8af16cbfdb | |||
| 54c5ce36db | |||
| 0b17d072cf | |||
| cd4469af52 | |||
| 01d0a4f289 | |||
| 8f8f6e7c92 | |||
| 90fe299739 | |||
| bceb6eb9d8 | |||
| 7989f2ee28 | |||
| 78a0f36730 | |||
| b2a48214f8 | |||
| 76d9513015 | |||
| 4d89cba698 | |||
| e8189c3074 | |||
| af17ae8a1b | |||
| 8626d4bc24 | |||
| f0b99a9fec | |||
| fcb9e23701 | |||
| ab496d313c | |||
| 0e53408ad7 | |||
| 4b1f48e2ae | |||
| 5530732c16 | |||
| 5b4e26864a | |||
| 1081ccc99b | |||
| c0ad0e5a98 | |||
| b6db8ab49d | |||
| ce455a9a79 | |||
| b6d3fccd59 | |||
| 78be3cdb8b | |||
| 837588a772 | |||
| f398c77963 | |||
| 2fd2fdbdb9 | |||
| 92d3d576fb | |||
| ef06f7f85b | |||
| e7a5ad8da9 | |||
| d8882ec822 | |||
| e21f0b1042 | |||
| b6057d4afa | |||
| bf18b2aa09 | |||
| db365a121d | |||
| d243cd17c5 | |||
| 01be5c29cc | |||
| 1ac2df9163 | |||
| 800fa68224 | |||
| 4876f94726 | |||
| c5c47d0c43 | |||
| 731f877fdb | |||
| acb417721d | |||
| 60f8f5bf42 | |||
| df18c3141e | |||
| 4edc434002 | |||
| 3ce66e9f7b | |||
| fb3501f935 | |||
| 757d66b504 | |||
| 9861a3997a | |||
| e05e5d132e | |||
| 6488b3be2e | |||
| 748e20f006 | |||
| da0dcaef1b | |||
| 9babd808f8 | |||
| 57c07037a7 | |||
| 2eb862ba18 | |||
| e5c482b517 | |||
| 61c7621b80 | |||
| 595687a2f1 | |||
| 6e2e65e499 | |||
| 997a36bb09 | |||
| 8b03cdac79 | |||
| 6b0bfc914c | |||
| 9f5ceda372 | |||
| d550a1409b | |||
| e56a129d56 | |||
| 9a8d870765 | |||
| be724f381e | |||
| c6a0fc48df | |||
| 61e6471fce | |||
| 3ad11e88b2 | |||
| 156f63c804 | |||
| ca9de648a8 | |||
| 66d6716a02 | |||
| 19906f7074 | |||
| b8dececceb | |||
| 068be51fa0 | |||
| 85a430d5be | |||
| 3b00cdbff0 | |||
| 9e0bad4909 | |||
| b430f84c4c | |||
| 014161956c | |||
| 5f842b21bd | |||
| ca3a97b8c1 | |||
| 5b6af116c1 | |||
| a9fd5db642 | |||
| 2f26b36af3 | |||
| c2fe49c5e7 | |||
| 7df5ccc871 | |||
| cf507be4c0 | |||
| 9e8bc0e590 | |||
| b50965414e | |||
| f2592eb65e | |||
| e9d837a1a2 | |||
| a650e7bb3a | |||
| 974dde3777 | |||
| 0ba544e97d | |||
| 72395f4d2a | |||
| 74780decb8 | |||
| f167056a18 | |||
| 375016e822 | |||
| ec6c6dae3f | |||
| 463b6cbe64 | |||
| 08f4e03f53 | |||
| 593d5992c0 | |||
| 671a35735b | |||
| c7bbf43c12 | |||
| 8dd4116941 | |||
| 821a2a750b | |||
| 4351ce8a6b | |||
| d97feb678a | |||
| 1f49b80193 | |||
| 2edb2fbaf1 | |||
| 7aa8c1329f | |||
| 04f64ffbe0 | |||
| bdc1bb3358 | |||
| 8e42353e0e | |||
| 1ab3830750 | |||
| 45ce915b79 | |||
| 2a28db59c3 | |||
| f18d2309fb | |||
| bc516d11c1 | |||
| 75ee3dfa69 | |||
| 7dac46e80c | |||
| 23cbd7e82b | |||
| e2612a5522 | |||
| 41fd2c3924 | |||
| 7020a2ac33 | |||
| cf3f87a641 | |||
| 2500eb7ead | |||
| 0115262560 | |||
| 7c944b7cbe | |||
| e264752381 | |||
| 075f61025c | |||
| 085fecaf86 | |||
| 970d2432d7 | |||
| 0d8057b119 | |||
| 2786c8fd73 | |||
| e1555199db | |||
| 6defede491 | |||
| 47e1151f92 | |||
| e8dc4c6cb1 | |||
| db8598ca48 | |||
| b0252a5c00 | |||
| 47cc07674c | |||
| 29f26fd747 | |||
| 9c336062b7 | |||
| 594f4f574a | |||
| 3802128b59 | |||
| 657ed64b03 | |||
| b39a349ec4 | |||
| 8c30f7fc26 | |||
| 81de99d733 | |||
| 7235680eed | |||
| ce5a0d7b65 | |||
| 89719f7030 | |||
| 1d03d41680 | |||
| de161d3c49 | |||
| 509b0c983d | |||
| 877d109b01 | |||
| dc5ea21614 | |||
| 4a08d3bac9 | |||
| f555bfac15 | |||
| 5fb8a656c1 | |||
| bfc8a717df | |||
| b65b99cab8 | |||
| 296f9b6a82 | |||
| 7409a0e99a | |||
| f08318d7fb | |||
| 890cdce488 | |||
| 5a739340da | |||
| 751ad21e9c | |||
| a9a72d76f9 | |||
| 31e0c05036 | |||
| 2a0d5695b3 | |||
| cf9281719f | |||
| 8cde300d8c | |||
| 50d1bd1c2a | |||
| 58cac329b7 | |||
| 011dd960f4 | |||
| 0389288693 | |||
| e5b094bed6 | |||
| 4a0d23143a | |||
| bdd5bba791 | |||
| 1159927f08 | |||
| b9a69f5b1f | |||
| 947e63afb8 | |||
| d221dc7482 | |||
| 14da408e08 | |||
| 4ca9e54f7f | |||
| 154877b2ff | |||
| 303c064224 | |||
| e521d0f799 | |||
| 4d4b237efb | |||
| 727929f1fa | |||
| 26e8b7a96e | |||
| 4d59b9d9fa | |||
| 7c018f428c | |||
| 3c3ff8ace3 | |||
| 70c6b92b97 | |||
| b27229da41 | |||
| 0801278026 | |||
| d9bda8a421 | |||
| 42f8e247d2 | |||
| ed3ee5e357 | |||
| 8b4a8f616f | |||
| f470cf47b7 | |||
| e43202e7a3 | |||
| e70d37080c | |||
| 98d6d9288b | |||
| 1c2ecdd3dd | |||
| 1d94add47e | |||
| dd1ac4af5c | |||
| 9982cf19c9 | |||
| 7d72568ba9 | |||
| 2ad6c7b8fe | |||
| c73628d1dc | |||
| d976a7d9dc | |||
| 2683c51739 | |||
| 7262b0c5a9 | |||
| 26be3a96c4 | |||
| 33ca51fbdf | |||
| 642a7105e5 | |||
| 4233e8b7b6 | |||
| f7352c8340 | |||
| 90b7248055 | |||
| 3c13c14e59 | |||
| 0cf15fb3e6 | |||
| c966aa2c71 | |||
| d367b64be3 | |||
| 862dd9d01a | |||
| 675c2419d1 | |||
| 3453faf411 | |||
| 9fcb7001e6 | |||
| 6a9c63b3c4 | |||
| f248698fed | |||
| 5510929c42 | |||
| 8cbaea4f7a | |||
| bb52c312de | |||
| 152fa94009 | |||
| a59462f1a4 | |||
| 8f08bf55d9 | |||
| 85c23c24f6 | |||
| 174e5dfc05 | |||
| 3ed3433efd | |||
| 6cb344928f | |||
| 2c56bea007 | |||
| 6ac70d87d4 | |||
| e58d9e9f8e | |||
| 80f91aad31 | |||
| fa1df4db7b | |||
| ce499284a0 | |||
| 5359b97581 | |||
| f3f60456ff | |||
| e0e1d29889 | |||
| 42ce3dfc9f | |||
| 71338fc369 | |||
| 7aae797ec1 | |||
| c5749e312f | |||
| 17f32ca725 | |||
| 7648eae997 | |||
| 62a29aa8e0 | |||
| 93727c9b8e | |||
| b2681766d7 | |||
| afd38cb133 | |||
| d3fcae7237 | |||
| 6b66913982 | |||
| 68875532e6 | |||
| 519c36a6fb | |||
| 93f30556b3 | |||
| b3f180f91b | |||
| ac76e8c5bf | |||
| 3c4e7ea962 | |||
| 3d83f4255a | |||
| 21e5dd9414 | |||
| 9b6b1f3afa | |||
| 148c0decf6 | |||
| 0df7a3d616 | |||
| 46385c64bd | |||
| 91b890f705 | |||
| 683b038d09 | |||
| a04aa7c7df | |||
| 8e2958d1a1 | |||
| 39d860b52d | |||
| 7c37e6755c | |||
| d21dbfd55d | |||
| 723a084744 | |||
| 1ace15420e | |||
| 1df5e775ff | |||
| b547c1396f | |||
| ffbbe44116 | |||
| 7a7056e0bb | |||
| ab505564c9 | |||
| 527bd0664c | |||
| 6285e5af65 | |||
| 792f362b93 | |||
| db69332665 | |||
| 94a7bfecb0 | |||
| 8665733354 | |||
| a6abb7fda7 | |||
| 380199a948 | |||
| 2da1b09809 | |||
| a75dde8a5c | |||
| 3c98b96d40 | |||
| 3bd8388689 | |||
| 5ceee287f3 | |||
| 319e0b4d9a | |||
| 84bed3d71b | |||
| 381b712d96 | |||
| 87c9582273 | |||
| ae9910b3aa | |||
| 91607e97ed | |||
| 71c7eb7260 | |||
| 5b6037f3ac | |||
| d2ae521e17 | |||
| 11f0eb9979 | |||
| 4e1af8f1b3 | |||
| a68c438d5c | |||
| 9a7b7e38b9 | |||
| 43e57712eb | |||
| 55ebb7277b | |||
| 0ca2898178 | |||
| d1910944e2 | |||
| 257343b354 | |||
| 7989c3edc6 | |||
| accaf2e9f6 | |||
| 15f93e462f | |||
| d628dcedd2 | |||
| 8b42d3bbb7 | |||
| c92a464165 | |||
| 08410ed897 | |||
| aea1aa849b | |||
| fe2f0270d3 | |||
| bd6cea2f98 | |||
| b13b2b54a6 | |||
| 5a16abc079 | |||
| 0dd1864b73 | |||
| c23b03b50c | |||
| c5c150c146 | |||
| a555df3d69 | |||
| 87b270ef6a | |||
| 3f8f8601e2 | |||
| ad0957be6d | |||
| 5bdb86e23b | |||
| cb55f92d17 | |||
| 9c3d643dad | |||
| af053ebd3e | |||
| f241382c56 | |||
| 055d04ad68 | |||
| 02cac21426 | |||
| ee031ca12d | |||
| 2332c5b8da | |||
| a2842bc86c | |||
| 8d0db8766b | |||
| 746be7faee | |||
| 3b117ede45 | |||
| af5f09db42 | |||
| 48988ba271 | |||
| 1060c5998e | |||
| 9f5d13105d | |||
| 777816e6c7 | |||
| 0e0fd96278 | |||
| 5aa3fe9c10 | |||
| 882a1343ab | |||
| cb48f665eb | |||
| 0a786db090 | |||
| e9dec637ff | |||
| 954e74f2dd | |||
| dc3906acce | |||
| 4fc9ea71f9 | |||
| abe58b4a43 | |||
| 662231384d | |||
| c76465c42b | |||
| e2a73d8a93 | |||
| 7764cd6cc7 | |||
| 0a870ce21a | |||
| 55be7faa95 | |||
| 60afff1419 | |||
| 1c8d340d1b | |||
| 31d3c58089 | |||
| 4a900a1e3b | |||
| 2564d898d3 | |||
| cea03e39c7 | |||
| e38e49335c | |||
| 8d137d3be6 | |||
| 766b1926ed | |||
| 842721d87f | |||
| 247147c8dd | |||
| 75108f21ad | |||
| 9fa06fc780 | |||
| ed90d891a1 | |||
| d8f6207bee | |||
| 381fd47442 | |||
| f868caa529 | |||
| 4378a0456e | |||
| f829d4a446 | |||
| b49d086945 | |||
| 0aa07c2fa0 | |||
| 4d15a1932a | |||
| c2540e76e1 | |||
| c3c4013f08 | |||
| 210deee299 | |||
| 9c71a2396b | |||
| 6ba16921db | |||
| 245505f928 | |||
| d086c991ee | |||
| c8c625a0be | |||
| a71dd3f315 | |||
| a40fe0a766 | |||
| b2a39ba822 | |||
| 845c5d725b | |||
| ac12e36125 | |||
| 08a7bbc9ff | |||
| 52b0b2684c | |||
| 7c96968699 | |||
| c629a2ef7f | |||
| d500edf243 | |||
| b666f6f3aa | |||
| f66e4015b8 | |||
| a84533fee3 | |||
| b49beecf63 | |||
| 74b111bc7f | |||
| a8c5a14b7c | |||
| f9ad31d809 | |||
| db26bf99f5 | |||
| e4857c41fb | |||
| 37d9720b15 | |||
| 24e6ae8cc6 | |||
| e31d492145 | |||
| e5708be88c | |||
| c34713bfca | |||
| 364f72aa05 | |||
| 4e5d63c403 | |||
| 79bad718b6 | |||
| 01ed826fff | |||
| d842884534 | |||
| b51bfdd111 | |||
| db47e0ffbb | |||
| ceab443d08 | |||
| 5675d86412 | |||
| ad0d007abd | |||
| 69e5d0ef95 | |||
| f32f831749 | |||
| cdd0bfcc1a | |||
| 6153b68ff9 | |||
| 716f1ef9f1 | |||
| 101fb762f1 | |||
| 368cc39e7e | |||
| 806b78fd12 | |||
| 6c619b41c8 | |||
| f02f53f09b | |||
| c4acc71042 | |||
| a5fe571a1c | |||
| 9fa998f63b | |||
| 4b6776536a | |||
| b7a99c865f | |||
| 059c9be198 | |||
| f132783767 | |||
| 26ee0fa9cd | |||
| d3c653c13f | |||
| 1f6823d18f | |||
| 4d833069bd | |||
| 03b17f7a0d | |||
| 5b549b306d | |||
| 6c9ac19b6f | |||
| 83523cccd6 | |||
| 4846e7e856 | |||
| ad9c1a9966 | |||
| 67c80485b9 | |||
| b764301306 | |||
| 993c547bd6 | |||
| 558bfc50fe | |||
| dc13c4f8a3 | |||
| d485515725 | |||
| f8a7befdd5 | |||
| ad5cbccfd3 | |||
| f07794ae81 | |||
| 9930ae9e6b | |||
| 6bcb0ad140 | |||
| 78066f113a | |||
| e2e91ea8ce | |||
| 3b0b90d5c1 | |||
| ad890b4490 | |||
| ea369699c4 | |||
| 87db2759da | |||
| 6bd4ab8c5e | |||
| c887b2c522 | |||
| 02f54468a8 | |||
| d9316decdd | |||
| 39cc4b9f1a | |||
| 9cd9700ad6 | |||
| 6c9ceb3c2e | |||
| d52eafd9ae | |||
| 14f409f698 | |||
| 762b68827e | |||
| c4257b0ff9 | |||
| 76e4168089 | |||
| a58e869ce2 | |||
| 8798f3049f | |||
| 0d163e9ece | |||
| cb7e142c73 | |||
| 17e05203ff | |||
| 92ac252418 | |||
| c9dc31afe8 | |||
| 493dd6c934 | |||
| a2adf92023 | |||
| 005072a3ef | |||
| 8bed6c33cd | |||
| 0ac7fcd7da | |||
| 8aec60b652 | |||
| d4f4fa2abe | |||
| 7620c403ec | |||
| df1a564fa6 | |||
| e20fd196ce | |||
| fd10b9422d | |||
| 80f7504f86 | |||
| a203cb09be | |||
| 131015e234 | |||
| 8494b4356c | |||
| 3b1bd3405b | |||
| d4e2861046 | |||
| 008809ad21 | |||
| 89a750dbeb | |||
| c0db85f0b2 | |||
| ef02670d09 | |||
| 7764e1afe0 | |||
| 2c36ba5bb8 | |||
| 1f046e1625 | |||
| 31a8a7e4e1 | |||
| 120f722403 | |||
| 2854559b92 | |||
| 696d638772 | |||
| 2e0b0c94f8 | |||
| d6070215b8 | |||
| 7ca5f47dcb | |||
| 008c431636 | |||
| 17e44aad44 | |||
| cad170cba8 | |||
| b215544c31 | |||
| 5d10e3f43d | |||
| 354cd59314 | |||
| 1ede3a6712 | |||
| 8558e34ed5 | |||
| 614b05ec8b | |||
| ed2bc33154 | |||
| 1ab501974f | |||
| 87753e76d1 | |||
| 0b06840128 | |||
| 9abc42b262 | |||
| 90080d990a | |||
| e7fcbec49e | |||
| 1576c4d233 | |||
| 6ac068ae5c | |||
| 7074cb559f | |||
| 9138c1f9a8 | |||
| 98ed0ea1af | |||
| 6abfa47012 | |||
| 59b08215b2 | |||
| c7c1adeb8d | |||
| 9230c9417b | |||
| 23f0f6f72d | |||
| 7eb1d32847 | |||
| fadb4b239b | |||
| f319b5bf61 | |||
| 4a373dbaf9 | |||
| c612f884dc | |||
| b543159952 | |||
| 667fdd514e | |||
| 951f480ab9 | |||
| bcbb41a0fa | |||
| ba39176b59 | |||
| 4305306220 | |||
| 8864d0f442 | |||
| 741162fbbe | |||
| f1e4622ccb | |||
| 4241549aed | |||
| 9e0d96f36b | |||
| 7e5b0b4e9c | |||
| 9be2fc8f19 | |||
| f8cbf4713a | |||
| 1a7d693572 | |||
| 31922db550 | |||
| 3cf94d16ed | |||
| ae471b7ab6 | |||
| f00c241f7d | |||
| cbd20ae8ba | |||
| 7bbe252c59 | |||
| a7d6e5b0f7 | |||
| e4edbb9e0b | |||
| 80895066a2 | |||
| 40385816cd | |||
| 1be6adbd3e | |||
| d416d809a1 | |||
| bf3c381651 | |||
| 9338d432f9 | |||
| b2ef8fc07e | |||
| 53ff8d79ee | |||
| ed55a25fd5 | |||
| c92727ae6b | |||
| 5cc8148eb8 | |||
| 92b2d0f2dd | |||
| ec27637e08 | |||
| 319047dfb1 | |||
| 67145bac78 | |||
| 7675f212ee | |||
| 25e0480339 | |||
| 8a286fda3e | |||
| 5e73ea768b | |||
| fdecc5c6da | |||
| f3e4a7a514 | |||
| f966e024ef | |||
| f3410ae74b | |||
| 7e70535f09 | |||
| 8def180d7a | |||
| e123a4e191 | |||
| df5ee47979 | |||
| b18207cd3a | |||
| f750f104ca | |||
| cc1b52fddf | |||
| e6f1411d72 | |||
| 90f08155c5 | |||
| 24f49eaa7e | |||
| 086617bac8 | |||
| 088f9942ef | |||
| 6befbe8050 | |||
| 62385afcd3 | |||
| b9f7637ea8 | |||
| 5e435e4635 | |||
| 362af1586a | |||
| c8305b464f | |||
| f5303bd518 | |||
| d040f940a2 | |||
| c97ab4b00a | |||
| 5e8720e3a3 | |||
| 3cef39f10a | |||
| 0e938d8e6c | |||
| 6a9781ab1f | |||
| 18ecdd56aa | |||
| f9452850dd | |||
| d2925a9397 | |||
| 537cef4fdd | |||
| 8319d93b45 | |||
| 41a96d7c4d | |||
| 1b88c2ef22 | |||
| 0d4057f406 | |||
| 07182b5324 | |||
| 0070770144 | |||
| 03240ae37b | |||
| 0ee01f0cda | |||
| 23febf1491 | |||
| cf299069d4 | |||
| b3abd77235 | |||
| 45c65f2b7e | |||
| 6ef50f6983 | |||
| 378d834f44 | |||
| 9a1e5c1750 | |||
| 6a691a2dba | |||
| a44d38fc25 | |||
| 826153a73d | |||
| 1e76d6529c | |||
| 6dce2448c4 | |||
| 828a4b2350 | |||
| 8300665144 | |||
| 4ccdd406cb | |||
| fc5711d43c | |||
| 1e35150951 | |||
| af6ca730d4 | |||
| e60154c553 | |||
| b2a2b9af0c | |||
| a3fcc4d416 | |||
| 1809c83ef3 | |||
| 88b5a2a15c | |||
| ee9534257d | |||
| 4b612862c7 | |||
| 75bf99a13c | |||
| fd10cafb1a | |||
| 831a8bae99 | |||
| 36b84580e0 | |||
| 4bb8788c44 | |||
| e8e5f86657 | |||
| be310ffda8 | |||
| cacc23f041 | |||
| 72a4c9a290 | |||
| 5d68b50a62 | |||
| 6a1055bf37 | |||
| 67e43279bb | |||
| 3f4bcbd03a | |||
| 74acff4411 | |||
| d6a54ada6e | |||
| d556c2aeaa | |||
| df313f0e94 | |||
| 4d4ef0e0b8 | |||
| 9717970b60 | |||
| 4f2ae57c31 | |||
| 6266a81cf7 | |||
| d0f6aa914a | |||
| 4c7701a6d9 | |||
| b1d476b800 | |||
| eae483c5a4 | |||
| 22da58c579 | |||
| 9b657e0dec | |||
| 8e6f38a406 | |||
| 537515d8e8 | |||
| 3c5f492e9d | |||
| 1301de5879 | |||
| 87698fefb6 | |||
| 7fd096aa14 | |||
| 78dea37dbc | |||
| 8117a6dc8a | |||
| 866002a1ef | |||
| c4a0e8dab6 | |||
| b3f66a5f13 | |||
| 78fb084d02 | |||
| 08f1de55d0 | |||
| 29949f0031 | |||
| 24dea5f76b | |||
| f5f53ceb7a | |||
| 3638683cdd | |||
| ed1061fd15 | |||
| fab77ea872 | |||
| ebb351fa65 | |||
| c8bf751abf | |||
| fc10786ff1 | |||
| 841c716376 | |||
| ca36c9581f | |||
| c03b88f607 | |||
| abf7820411 | |||
| 6cdd66e3c5 | |||
| 316e201245 | |||
| 54c9dab53b | |||
| c60272d855 | |||
| d7895072ac | |||
| 3a1d81851f | |||
| 3e82837cc0 | |||
| 6f0c99c7a8 | |||
| 7dbf7695da | |||
| 0c64299b01 | |||
| 70f97a5995 | |||
| a9530ec147 | |||
| fe5cf88b17 | |||
| 9f79ed8a3c | |||
| 868d207889 | |||
| c28941370e | |||
| 5c0cd26dbf | |||
| 8e9aa7d060 | |||
| 49cb76f312 | |||
| d91d2fa6d3 | |||
| 20dbeadfb3 | |||
| 8ed24b7dda | |||
| 1ca7a8001b | |||
| 5aab521e4d | |||
| a1332df845 | |||
| eb2d09c49c | |||
| e2c0f78d63 | |||
| d7440e481e | |||
| 5fd7a8cc89 | |||
| 7429a293b7 | |||
| a31fec1556 | |||
| a8cecdc232 | |||
| b0d3c33001 | |||
| b3ede2a6f5 | |||
| a804689232 | |||
| 62e0242116 | |||
| 0321eb66d0 | |||
| 604c996ca6 | |||
| ba7b72a53d | |||
| 077b7e99c1 | |||
| 7099595c4d | |||
| e723db1680 | |||
| 19043b2c61 | |||
| 97b0c002ec | |||
| 3c9367fb62 | |||
| a064e86c8b | |||
| f0cb717a7e | |||
| ed14ae8128 | |||
| 05888cfc84 | |||
| cca1df961b | |||
| fb4f768789 | |||
| 1fda1af9d2 | |||
| 6d338ba5f9 | |||
| 63d4e986d0 | |||
| 9595f6a388 | |||
| c50d4d9039 | |||
| 1a5d7ed12e | |||
| e18bb176e1 | |||
| 42fd053ddc | |||
| d873273749 | |||
| cba3313110 | |||
| 122ea396cf | |||
| 1b068b9049 | |||
| 8069349d65 | |||
| 1de8317f92 | |||
| 0ff7b38264 | |||
| 9fc48040ba | |||
| 1752044872 | |||
| 685ecea312 | |||
| ef90bd2c06 | |||
| bcf99ba3b9 | |||
| 48e385f582 | |||
| f9baa9c1cc | |||
| 564f9b03e6 | |||
| a270bb477a | |||
| 23f4b83ec6 | |||
| 28c5a47afc | |||
| b52e9a106c | |||
| 0d2fdd9cd9 | |||
| 591234f350 | |||
| 1b2f2b82f0 | |||
| 85e21f03a1 | |||
| 864dbb4ae7 | |||
| 247475fc9f | |||
| 2fb18d1cdc | |||
| 74f65d5ef6 | |||
| 3443f0a7b2 | |||
| ab05be1a23 | |||
| 0aba3fd198 | |||
| 2466ff5d77 | |||
| fc0966ba1f | |||
| 83e674cd7f | |||
| 9468a32a8e | |||
| 01cd957389 | |||
| d0d30cb9a0 | |||
| 3bbc55a650 | |||
| 0f1d2d8c94 | |||
| da8b22453c | |||
| d490ba1476 | |||
| 408a5a1b03 | |||
| 0ec5eaa5ca | |||
| e4173bf72a | |||
| 55a96b2f3e | |||
| 1a42831794 | |||
| 571acdabaa | |||
| f7396c7867 | |||
| c1bfa6076c | |||
| f9e8f1118d | |||
| 8d1ea9fbed | |||
| 9197f258b9 | |||
| bbaae076fa | |||
| 7ba21c9f41 | |||
| 8f211852b7 | |||
| 0a1dc0b126 | |||
| 104b23ff7f | |||
| d7355da165 | |||
| 64a985181b | |||
| 9fb2199303 | |||
| 0e4429dfec | |||
| 09a47d4232 | |||
| f39c91312f | |||
| f0769c5367 | |||
| 68199074d8 | |||
| 8807ea9497 | |||
| 60061f9d34 | |||
| 4cbb779866 | |||
| 7add89d356 | |||
| a3faf996f5 | |||
| 1dd6d5a8a2 | |||
| c4020445c4 | |||
| 3b455ec7d2 | |||
| 760f271b07 | |||
| bf28e6d08a | |||
| 13f366f87b | |||
| c9c2c6df00 | |||
| ba1fa71220 | |||
| 08afbd8644 | |||
| 3e1a16bbbc | |||
| 2620831e61 | |||
| 040c22892d | |||
| 43059890b7 | |||
| 03796898f6 | |||
| ecaa25ff09 | |||
| 9a055d09c9 | |||
| c95fff4fa9 | |||
| 324480d4b2 | |||
| 4d4a11fd68 | |||
| 89a8bdc8cc | |||
| 8a2bccf264 | |||
| f697f01e35 | |||
| 976fe7c655 | |||
| e6ecbb498b | |||
| 37e6138a3c | |||
| e7514ae3f1 | |||
| 81f9b42660 | |||
| 7c5bebadf1 | |||
| d1a0531ca4 | |||
| 5f536e23ed | |||
| 16d42c3776 | |||
| ca108ade8d | |||
| 8997698305 | |||
| 9cb996a977 | |||
| 6f7fcae9f2 | |||
| 44089f2cb4 | |||
| 5140419a14 | |||
| d0bc1c59ae | |||
| f3726ba3b2 | |||
| e1079fc4f1 | |||
| a8500a96f8 | |||
| 325bbaaa17 | |||
| 12961dfd4d | |||
| c646026617 | |||
| 6dfa18dff6 | |||
| 269a213980 | |||
| 311a061ce1 | |||
| f152f333d0 | |||
| 24ec651269 | |||
| 8abe956ca8 | |||
| 8e1ae566f2 | |||
| b0b359cd73 | |||
| 1ad395e023 | |||
| b1e07b8879 | |||
| 4d78c38a37 | |||
| bb9cae5afc | |||
| 9051e08619 | |||
| cec1b35f86 | |||
| 2fe45c4a0a | |||
| b40e18c325 | |||
| d72975122f | |||
| 7508d0918f | |||
| a91a3c5c79 | |||
| a30e48bc6a | |||
| 6cb0f10970 | |||
| a0de778c07 | |||
| b866247504 | |||
| 33dc359ccc | |||
| 9b6c468b16 | |||
| de028f7715 | |||
| 4be0a0c1b5 | |||
| 7873f331ea | |||
| f8961f9bc0 | |||
| d0949f39e9 | |||
| 042699bf23 | |||
| 49163d4fb6 | |||
| 6ad9639961 | |||
| 694c70e8e6 | |||
| 4398b01077 | |||
| 95df21e3ae | |||
| 6fe671e94a | |||
| 92fa909b5e | |||
| 7b23572651 | |||
| e9369e5282 | |||
| 74b0c7ac01 | |||
| e01a96ef15 | |||
| 00d69809d4 | |||
| 02d7853dab | |||
| 7f5f0ae62b | |||
| b5a814308a | |||
| f22675fed9 | |||
| 1f45359727 | |||
| 7fe0a5d596 | |||
| e83bdb2c03 | |||
| 3b253287d7 | |||
| bf252c1d4a | |||
| cf0d9e996b | |||
| 670eea76db | |||
| 59359cde79 | |||
| 2794229c55 | |||
| 626caefd89 | |||
| 6880e3bb16 | |||
| ed0dd58cf2 | |||
| 1c52f98506 | |||
| 5aac129459 | |||
| 43efbf3deb | |||
| 408964a73b | |||
| b0c015e156 | |||
| b47138f834 | |||
| 40652b156b | |||
| afa39a8fa8 | |||
| c52128df17 | |||
| c0234d300b | |||
| ddc35e5bd5 | |||
| fb904d1889 | |||
| 5d7850d42e | |||
| 52657c4298 | |||
| bd2930f2b1 | |||
| 6cebd028b9 | |||
| 1e006c3d5f | |||
| d5ebb85dce | |||
| be653a00cc | |||
| a1dfc10135 | |||
| e67dfebaca | |||
| 33a9f3495e | |||
| e1f8632d26 | |||
| 82192c1bd8 | |||
| b59efda13c | |||
| 044f9df97e | |||
| 3743bfe506 | |||
| 90beaec2eb | |||
| f758baa9ac | |||
| 42a5861017 | |||
| c9ddd414c7 | |||
| 6b0ee8e3d7 | |||
| e4db399ca5 | |||
| 43b3cb4230 | |||
| 8bf4dbe31c | |||
| 471a2de79c | |||
| a0ba79ded7 | |||
| 252b76e7aa | |||
| fe6ed5c2c2 | |||
| ea95720fe5 | |||
| 916ad6bf7e | |||
| ef10c059ef | |||
| 770f2e2ab1 | |||
| e364a5368d |
-339
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
+294
-279
@@ -1,315 +1,330 @@
|
||||
<?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');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('userauthentication', $adminroot);
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('userauthentication', $adminroot);
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$authsavailable = get_list_of_plugins('auth');
|
||||
|
||||
//revert auth_plugins_enabled
|
||||
if (isset($CFG->auth_plugins_enabled)) {
|
||||
set_config('auth', $CFG->auth_plugins_enabled);
|
||||
delete_records('config', 'name', 'auth_plugins_enabled');
|
||||
unset($CFG->auth_plugins_enabled);
|
||||
}
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
$authsenabled = array();
|
||||
} else {
|
||||
$authsenabled = explode(',', $CFG->auth);
|
||||
}
|
||||
|
||||
if (!isset($CFG->registerauth)) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
|
||||
if (!isset($CFG->auth_instructions)) {
|
||||
set_config('auth_instructions', '');
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
error(get_string('pluginnotinstalled', 'auth', $auth), $url);
|
||||
}
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
$focus = '';
|
||||
|
||||
$status = '';
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
switch ($action) {
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
case 'save':
|
||||
if (data_submitted() and confirm_sesskey()) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
// save settings
|
||||
set_config('guestloginbutton', required_param('guestloginbutton', PARAM_BOOL));
|
||||
set_config('alternateloginurl', stripslashes(trim(required_param('alternateloginurl', PARAM_RAW))));
|
||||
set_config('registerauth', required_param('register', PARAM_SAFEDIR));
|
||||
set_config('auth_instructions', stripslashes(trim(required_param('auth_instructions', PARAM_RAW))));
|
||||
$config = (array)$config;
|
||||
|
||||
// enable registerauth in $CFG->auth if needed
|
||||
if (!empty($CFG->registerauth) and !in_array($CFG->registerauth, $authsenabled)) {
|
||||
$authsenabled[] = $CFG->registerauth;
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
// 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";
|
||||
}
|
||||
$status = get_string('changessaved');
|
||||
}
|
||||
break;
|
||||
|
||||
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) {
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
}
|
||||
// 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) {
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
// display strings
|
||||
$txt = get_strings(array('authenticationplugins', 'users', 'administration',
|
||||
'settings', 'edit', 'name', 'enable', 'disable',
|
||||
'up', 'down', 'none'));
|
||||
$txt->updown = "$txt->up/$txt->down";
|
||||
|
||||
// construct the display array, with enabled auth plugins at the top, in order
|
||||
$displayauths = array();
|
||||
$registrationauths = array();
|
||||
$registrationauths[''] = $txt->disable;
|
||||
foreach ($authsenabled as $auth) {
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
/// Get the auth title (from core or own auth lang files)
|
||||
$authtitle = get_string("auth_{$auth}title", "auth");
|
||||
if ($authtitle == "[[auth_{$auth}title]]") {
|
||||
$authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
|
||||
}
|
||||
/// Apply titles
|
||||
$displayauths[$auth] = $authtitle;
|
||||
if ($authplugin->can_signup()) {
|
||||
$registrationauths[$auth] = $authtitle;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($authsavailable as $auth) {
|
||||
if (array_key_exists($auth, $displayauths)) {
|
||||
continue; //already in the list
|
||||
}
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
/// Get the auth title (from core or own auth lang files)
|
||||
$authtitle = get_string("auth_{$auth}title", "auth");
|
||||
if ($authtitle == "[[auth_{$auth}title]]") {
|
||||
$authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
|
||||
}
|
||||
/// Apply titles
|
||||
$displayauths[$auth] = $authtitle;
|
||||
if ($authplugin->can_signup()) {
|
||||
$registrationauths[$auth] = $authtitle;
|
||||
}
|
||||
}
|
||||
|
||||
// build the display table
|
||||
$table = new flexible_table('auth_admin_table');
|
||||
$table->define_columns(array('name', 'enable', 'order', 'settings'));
|
||||
$table->define_headers(array($txt->name, $txt->enable, $txt->updown, $txt->settings));
|
||||
$table->define_baseurl("{$CFG->wwwroot}/{$CFG->admin}/auth.php");
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
//add always enabled plugins first
|
||||
$displayname = "<span>".$displayauths['manual']."</span>";
|
||||
$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&auth=manual\">{$txt->settings}</a>";
|
||||
$table->add_data(array($displayname, '', '', $settings));
|
||||
$displayname = "<span>".$displayauths['nologin']."</span>";
|
||||
$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&auth=nologin\">{$txt->settings}</a>";
|
||||
$table->add_data(array($displayname, '', '', $settings));
|
||||
|
||||
|
||||
// iterate through auth plugins and add to the display table
|
||||
$updowncount = 1;
|
||||
$authcount = count($authsenabled);
|
||||
$url = "auth.php?sesskey=" . sesskey();
|
||||
foreach ($displayauths as $auth => $name) {
|
||||
if ($auth == 'manual' or $auth == 'nologin') {
|
||||
continue;
|
||||
}
|
||||
// hide/show link
|
||||
if (in_array($auth, $authsenabled)) {
|
||||
$hideshow = "<a href=\"$url&action=disable&auth=$auth\">";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" /></a>";
|
||||
// $hideshow = "<a href=\"$url&action=disable&auth=$auth\"><input type=\"checkbox\" checked /></a>";
|
||||
$enabled = true;
|
||||
$displayname = "<span>$name</span>";
|
||||
}
|
||||
else {
|
||||
$hideshow = "<a href=\"$url&action=enable&auth=$auth\">";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" /></a>";
|
||||
// $hideshow = "<a href=\"$url&action=enable&auth=$auth\"><input type=\"checkbox\" /></a>";
|
||||
$enabled = false;
|
||||
$displayname = "<span class=\"dimmed_text\">$name</span>";
|
||||
}
|
||||
|
||||
// up/down link (only if auth is enabled)
|
||||
$updown = '';
|
||||
if ($enabled) {
|
||||
if ($updowncount > 1) {
|
||||
$updown .= "<a href=\"$url&action=up&auth=$auth\">";
|
||||
$updown .= "<img src=\"{$CFG->pixpath}/t/up.gif\" alt=\"up\" /></a> ";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" /> ";
|
||||
}
|
||||
if ($updowncount < $authcount) {
|
||||
$updown .= "<a href=\"$url&action=down&auth=$auth\">";
|
||||
$updown .= "<img src=\"{$CFG->pixpath}/t/down.gif\" alt=\"down\" /></a>";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />";
|
||||
}
|
||||
++ $updowncount;
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
}
|
||||
|
||||
// settings link
|
||||
$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&auth=$auth\">{$txt->settings}</a>";
|
||||
$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;
|
||||
}
|
||||
|
||||
// add a row to the table
|
||||
$table->add_data(array($displayname, $hideshow, $updown, $settings));
|
||||
}
|
||||
// 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','');
|
||||
}
|
||||
|
||||
// output form
|
||||
admin_externalpage_print_header($adminroot);
|
||||
$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");
|
||||
|
||||
//print stus messages
|
||||
if ($status !== '') {
|
||||
notify($status, 'notifysuccess');
|
||||
}
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
|
||||
print_simple_box(get_string('configauthenticationplugins', 'admin'), 'center', '700');
|
||||
$createoptions[0] = get_string("no");
|
||||
$createoptions[1] = get_string("yes");
|
||||
|
||||
$table->print_html();
|
||||
$strauthentication = get_string("authentication");
|
||||
$strauthenticationoptions = get_string("authenticationoptions","auth");
|
||||
$strsettings = get_string("settings");
|
||||
$strusers = get_string("users");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
$guestoptions = array();
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
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");
|
||||
|
||||
echo '<hr />';
|
||||
echo ' ';
|
||||
|
||||
echo '<form '.$CFG->frametarget.' id="adminsettings" method="post" action="auth.php">';
|
||||
echo '<div class="settingsform">';
|
||||
print_heading(get_string('auth_common_settings', 'auth'));
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="action" value="save" />';
|
||||
echo '<fieldset>';
|
||||
##echo '<table cellspacing="0" cellpadding="5" border="0" style="margin-left:auto;margin-right:auto">';
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
|
||||
// User self registration
|
||||
echo '<div class="form-item" id="admin-register">';
|
||||
echo '<label for = "menuregister">' . get_string("selfregistration", "auth");
|
||||
echo '<span class="form-shortname">registerauth</span>';
|
||||
echo '</label>';
|
||||
choose_from_menu($registrationauths, "register", $CFG->registerauth, "");
|
||||
echo '<div class="description">' . get_string("selfregistration_help", "auth") . '</div>';
|
||||
echo '</div>';
|
||||
echo "</b></center><br />";
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
// Login as guest button enabled
|
||||
echo '<div class="form-item" id="admin-guestloginbutton">';
|
||||
echo '<label for = "menuguestloginbutton">' . get_string("guestloginbutton", "auth");
|
||||
echo '<span class="form-shortname">guestloginbutton</span>';
|
||||
echo '</label>';
|
||||
choose_from_menu($guestoptions, "guestloginbutton", $CFG->guestloginbutton, "");
|
||||
echo '<div class="description">' . get_string("showguestlogin", "auth") . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
/// An alternate url for the login form. It means we can use login forms that are integrated
|
||||
/// into non-moodle pages
|
||||
echo '<div class="form-item" id="admin-alternateloginurl">';
|
||||
echo '<label for = "alternateloginurl">' . get_string("alternateloginurl", "auth");
|
||||
echo '<span class="form-shortname">alternateloginurl</span>';
|
||||
echo '</label>';
|
||||
echo '<input type="text" size="60" name="alternateloginurl" id="alternateloginurl" value="'.$CFG->alternateloginurl."\" />\n";
|
||||
echo '<div class="description">' . get_string("alternatelogin", "auth", htmlspecialchars($CFG->wwwroot.'/login/index.php')) . '</div>';
|
||||
echo '</div>';
|
||||
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>';
|
||||
|
||||
/// Instructions about login/password
|
||||
/// to be showed to users
|
||||
echo '<div class="form-item" id="admin-auth_instructions">';
|
||||
echo '<label for = "auth_instructions">' . get_string("instructions", "auth");
|
||||
echo '<span class="form-shortname">auth_instructions</span>';
|
||||
echo '</label>';
|
||||
echo '<textarea cols="30" rows="4" name="auth_instructions" id="auth_instructions">'.s($CFG->auth_instructions)."</textarea>\n";
|
||||
echo '<div class="description">' . get_string("authinstructions", "auth") . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</table>';
|
||||
echo '<p align="center"><input type="submit" value="'.get_string('savechanges').'"></p>';
|
||||
echo '</form>';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Edit configuration for an individual auth plugin
|
||||
*/
|
||||
|
||||
require_once '../config.php';
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('userauthentication', $adminroot);
|
||||
$auth = required_param('auth', PARAM_SAFEDIR);
|
||||
$CFG->pagepath = 'auth/' . $auth;
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
$err = array();
|
||||
|
||||
// save configuration changes
|
||||
if ($frm = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$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("auth.php");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$frm = get_config("auth/$auth");
|
||||
}
|
||||
|
||||
$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 = get_string("auth_{$auth}title", "auth");
|
||||
if ($authtitle == "[[auth_{$auth}title]]") {
|
||||
$authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
|
||||
}
|
||||
/// Get the auth descriptions (from core or own auth lang files)
|
||||
$authdescription = get_string("auth_{$auth}description", "auth");
|
||||
if ($authdescription == "[[auth_{$auth}description]]") {
|
||||
$authdescription = get_string("auth_{$auth}description", "auth_{$auth}");
|
||||
}
|
||||
|
||||
// output configuration form
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
// 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($adminroot);
|
||||
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];
|
||||
} 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>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+1
-1
@@ -59,7 +59,7 @@
|
||||
|
||||
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">';
|
||||
|
||||
+14
-22
@@ -17,6 +17,7 @@
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
@@ -28,7 +29,6 @@
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
if (!$block = blocks_get_record($multiple)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$block->multiple = intval(!$block->multiple);
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
}
|
||||
|
||||
@@ -165,8 +165,11 @@
|
||||
$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) {
|
||||
@@ -179,28 +182,16 @@
|
||||
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
|
||||
$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\" >$count</a>";
|
||||
}
|
||||
else {
|
||||
$blocklist = "$count";
|
||||
}
|
||||
|
||||
$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()) {
|
||||
@@ -217,8 +208,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,
|
||||
@@ -237,8 +228,9 @@
|
||||
$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();
|
||||
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$focus = '';
|
||||
|
||||
if ($site = get_site()) { // If false then this is a new installation
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
}
|
||||
|
||||
/// 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)) {
|
||||
error("Error: Could not update $name to $value");
|
||||
}
|
||||
} else {
|
||||
if (! insert_record('config', $conf)) {
|
||||
error("Error: could not add new variable $name !");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect('index.php');
|
||||
exit;
|
||||
|
||||
} 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="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,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) );
|
||||
|
||||
/// enabletrusttext
|
||||
$permissions['enabletrusttext'] = new configvar (get_string('configenabletrusttext', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'enabletrusttext', $config->enabletrusttext, '', '', '', 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) );
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
?>
|
||||
+34
-91
@@ -17,11 +17,7 @@
|
||||
/// 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()
|
||||
@@ -33,51 +29,39 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
/// extra safety
|
||||
@session_write_close();
|
||||
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
if (!$alreadyadmin = has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
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;
|
||||
}
|
||||
|
||||
//unset test cookie, user must login again anyway
|
||||
setcookie('MoodleSessionTest'.$CFG->sessioncookie, '', time() - 3600, '/');
|
||||
|
||||
/// 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;
|
||||
/// switch to site language and locale
|
||||
if (!empty($CFG->courselang)) {
|
||||
unset ($CFG->courselang);
|
||||
}
|
||||
if (!empty($SESSION->lang)) {
|
||||
unset ($SESSION->lang);
|
||||
}
|
||||
$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');
|
||||
@header('Content-Type: text/html; charset='.current_charset());
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
@header('Content-Type: text/plain; charset='.current_charset());
|
||||
}
|
||||
|
||||
/// 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');
|
||||
|
||||
@@ -98,21 +82,11 @@
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
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.");
|
||||
}
|
||||
}
|
||||
@@ -137,8 +111,6 @@
|
||||
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.');
|
||||
}
|
||||
}
|
||||
@@ -149,31 +121,18 @@
|
||||
|
||||
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
|
||||
");
|
||||
mtrace($rs_enrol->RecordCount().' to delete');
|
||||
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) {
|
||||
if ($oldenrolments = get_records_select('role_assignments', "timeend > 0 AND timeend < '$timenow'")) {
|
||||
mtrace(count($oldenrolments).' to delete');
|
||||
foreach ($oldenrolments as $oldenrolment) {
|
||||
if (role_unassign($oldenrolment->roleid, $oldenrolment->userid, 0, $oldenrolment->contextid)) {
|
||||
mtrace("Deleted expired role assignment $oldenrolment->roleid for user $oldenrolment->userid from context $oldenrolment->contextid");
|
||||
}
|
||||
}
|
||||
mtrace('Done');
|
||||
} else {
|
||||
mtrace('none found');
|
||||
@@ -198,7 +157,7 @@
|
||||
foreach ($assigns as $assign) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (role_unassign(0, $assign->id, 0, $context->id)) {
|
||||
mtrace("removing user $assign->id from course $assign->courseid as they have not accessed the course for over $CFG->longtimenosee days");
|
||||
mtrace("Deleted student enrolment for user $assign->id from course $assign->courseid");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,8 +183,8 @@
|
||||
|
||||
/// Delete users who haven't completed profile within required period
|
||||
|
||||
if (!empty($CFG->deleteincompleteusers)) {
|
||||
$cuttime = $timenow - ($CFG->deleteincompleteusers * 3600);
|
||||
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)) {
|
||||
@@ -272,7 +231,7 @@
|
||||
p.id as prefid
|
||||
FROM {$CFG->prefix}user u
|
||||
JOIN {$CFG->prefix}user_preferences p ON u.id=p.userid
|
||||
WHERE p.name='create_password' AND p.value='1' AND u.email !='' ");
|
||||
WHERE p.name='create_password' AND p.value=1 AND u.email !='' ");
|
||||
|
||||
foreach ($newusers as $newuserid => $newuser) {
|
||||
$newuser->emailstop = 0; // send email regardless
|
||||
@@ -345,26 +304,10 @@
|
||||
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)) {
|
||||
|
||||
// check we're not before our runtime
|
||||
$timetocheck = strtotime("today $CFG->statsruntimestarthour:$CFG->statsruntimestartminute");
|
||||
$timetocheck = strtotime("$CFG->statsruntimestarthour:$CFG->statsruntimestartminute today");
|
||||
|
||||
if (time() > $timetocheck) {
|
||||
$time = 60*60*20; // set it to 20 here for first run... (overridden by $CFG)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
if (!empty($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
|
||||
"<a $CFG->frametarget href=\"index.php\">$stradministration</a> -> Database performance");
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> Database performance");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,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') {
|
||||
|
||||
+4
-7
@@ -52,9 +52,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);
|
||||
@@ -64,7 +63,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
|
||||
@@ -75,7 +73,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') {
|
||||
@@ -98,8 +96,7 @@
|
||||
|
||||
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($adminroot);
|
||||
|
||||
+14
-7
@@ -44,10 +44,17 @@
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
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>";
|
||||
|
||||
|
||||
/// Choose an enrolment method
|
||||
echo get_string('chooseenrolmethod').': ';
|
||||
choose_from_menu ($options, "enrol", $enrol, "",
|
||||
"document.location='enrol_config.php?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%");
|
||||
@@ -61,11 +68,11 @@
|
||||
|
||||
$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>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
exit;
|
||||
|
||||
@@ -91,7 +91,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;
|
||||
@@ -121,11 +121,11 @@
|
||||
}
|
||||
|
||||
/// 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();
|
||||
|
||||
|
||||
+1
-195
@@ -80,6 +80,7 @@
|
||||
<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" />
|
||||
@@ -101,201 +102,6 @@
|
||||
<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>
|
||||
</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="required">
|
||||
<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="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.0" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.2.8" 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="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+3
-3
@@ -74,21 +74,21 @@
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_heading( $filtername );
|
||||
|
||||
print_simple_box(get_string("configwarning", "admin"), "center", "50%");
|
||||
print_simple_box("<center>".get_string("configwarning", "admin")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center",'');
|
||||
|
||||
?>
|
||||
<form action="filter.php?filter=<?php echo urlencode($param->filter); ?>" method="post">
|
||||
<div style="text-align: center">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
|
||||
<?php include "$CFG->dirroot/$param->filter/filterconfig.html"; ?>
|
||||
|
||||
<center>
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
<input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
|
||||
</div>
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
+13
-8
@@ -182,10 +182,15 @@
|
||||
// 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', 'filters');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$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
|
||||
@@ -196,13 +201,13 @@
|
||||
// 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\" class=\"icon\" alt=\"$txt->hide\" /></a>";
|
||||
$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\" class=\"icon\" alt=\"$txt->show\" /></a>";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" height=\"16\" width=\"16\" alt=\"show\" /></a>";
|
||||
$hidden = true;
|
||||
$displayname = "<span class=\"dimmed_text\">$name</span>";
|
||||
}
|
||||
@@ -212,17 +217,17 @@
|
||||
if (!$hidden) {
|
||||
if ($updowncount>1) {
|
||||
$updown .= "<a href=\"$myurl&action=up&filterpath=$upath\">";
|
||||
$updown .= "<img src=\"$img/up.gif\" alt=\"$txt->up\" /></a> ";
|
||||
$updown .= "<img src=\"$img/up.gif\" alt=\"up\" /></a> ";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" /> ";
|
||||
$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=\"$txt->down\" /></a>";
|
||||
$updown .= "<img src=\"$img/down.gif\" alt=\"down\" /></a>";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" />";
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" height=\"16\" width=\"16\" alt=\"\" />";
|
||||
}
|
||||
++$updowncount;
|
||||
}
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
/**
|
||||
* SCRIPT CONFIGURATION
|
||||
*/
|
||||
$starttimer = time()+microtime();
|
||||
|
||||
$settings = array();
|
||||
$settings['verbose'] = false;
|
||||
$settings['username'] = null;
|
||||
$settings['password'] = null;
|
||||
$settings['eolchar'] = '<br />'; // Character used to break lines
|
||||
|
||||
// Argument arrays: 0=>short name, 1=>long name
|
||||
$arguments = array(
|
||||
array('short'=>'u', 'long'=>'username', 'help' => 'Your moodle username', 'type'=>'STRING', 'default' => ''),
|
||||
array('short'=>'pw', 'long'=>'password', 'help' => 'Your moodle password', 'type'=>'STRING', 'default' => ''),
|
||||
array('short'=>'v', 'long' => 'verbose', 'help' => 'Display extra information about the process')
|
||||
);
|
||||
|
||||
// Building the USAGE output of the command line version
|
||||
if (isset($argv) && isset($argc)) {
|
||||
$help = "Moodle User Pix Fix. Restores user profile images that were not properly moved during 1.8.2 upgrade to newer versions.\n\n"
|
||||
. "Usage: {$argv[0]}; [OPTION] ...\n"
|
||||
. "Options:\n"
|
||||
. " -h, -?, -help, --help This output\n";
|
||||
|
||||
foreach ($arguments as $arg_array) {
|
||||
$equal = '';
|
||||
if (!empty($arg_array['type'])) {
|
||||
$equal = "={$arg_array['type']}";
|
||||
}
|
||||
|
||||
$padding1 = 5 - strlen($arg_array['short']);
|
||||
$padding2 = 30 - (strlen($arg_array['long']) + strlen($equal));
|
||||
$paddingstr1 = '';
|
||||
for ($i = 0; $i < $padding1; $i++) {
|
||||
$paddingstr1 .= ' ';
|
||||
}
|
||||
$paddingstr2 = '';
|
||||
for ($i = 0; $i < $padding2; $i++) {
|
||||
$paddingstr2 .= ' ';
|
||||
}
|
||||
|
||||
$help .= " -{$arg_array['short']},$paddingstr1--{$arg_array['long']}$equal$paddingstr2{$arg_array['help']}\n";
|
||||
}
|
||||
|
||||
$help .= "\nEmail nicolasconnault@gmail.com for any suggestions or bug reports.\n";
|
||||
|
||||
if ($argc == 1 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
|
||||
echo $help;
|
||||
die();
|
||||
|
||||
} else {
|
||||
|
||||
$settings['eolchar'] = "\n";
|
||||
$argv = arguments($argv);
|
||||
$argscount = 0;
|
||||
|
||||
foreach ($arguments as $arg_array) {
|
||||
$value = null;
|
||||
if (in_array($arg_array['short'], array_keys($argv))) {
|
||||
$value = $argv[$arg_array['short']];
|
||||
unset($argv[$arg_array['short']]);
|
||||
} elseif (in_array($arg_array['long'], array_keys($argv))) {
|
||||
$value = $argv[$arg_array['long']];
|
||||
unset($argv[$arg_array['long']]);
|
||||
}
|
||||
if (!is_null($value)) {
|
||||
$settings[$arg_array['long']] = $value;
|
||||
$argscount++;
|
||||
}
|
||||
}
|
||||
|
||||
// If some params are left in argv, it means they are not supported
|
||||
if ($argscount == 0 || count($argv) > 0) {
|
||||
echo $help;
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SCRIPT SETUP
|
||||
*/
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
require_once($CFG->dirroot .'/course/lib.php');
|
||||
verbose("Loading libraries...");
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
/**
|
||||
* WEB INTERFACE FORM
|
||||
*/
|
||||
|
||||
class pixfix_form extends moodleform {
|
||||
function definition() {
|
||||
global $arguments;
|
||||
$mform =& $this->_form;
|
||||
|
||||
foreach ($arguments as $arg_array) {
|
||||
$type = 'advcheckbox';
|
||||
|
||||
$label = ucfirst(str_replace('-', ' ', $arg_array['long']));
|
||||
if (!empty($arg_array['type'])) {
|
||||
$type = 'text';
|
||||
}
|
||||
|
||||
if ($arg_array['long'] == 'password' || $arg_array['long'] == 'username') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mform->addElement($type, $arg_array['long'], $label);
|
||||
|
||||
if (isset($arg_array['default'])) {
|
||||
$mform->setDefault($arg_array['long'], $arg_array['default']);
|
||||
}
|
||||
}
|
||||
$this->add_action_buttons(false, 'Restore Images');
|
||||
}
|
||||
|
||||
function definition_after_data() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$run_script = true;
|
||||
$web_interface = false;
|
||||
|
||||
// If eolchar is still <br />, load the web interface
|
||||
if ($settings['eolchar'] == '<br />') {
|
||||
print_header("User Pix-Fix");
|
||||
print_heading("User Pix-Fix");
|
||||
$mform = new pixfix_form();
|
||||
|
||||
if ($data = $mform->get_data(false)) {
|
||||
foreach ($arguments as $arg_array) {
|
||||
if (!empty($data->{$arg_array['long']})) {
|
||||
$settings[$arg_array['long']] = $data->{$arg_array['long']};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$run_script = false;
|
||||
}
|
||||
|
||||
if (!has_capability('moodle/site:doanything', $systemcontext)) {
|
||||
// If not logged in, give link to login page for current site
|
||||
notify("You must be logged in as administrator before using this script.");
|
||||
require_login();
|
||||
} else {
|
||||
$mform->display();
|
||||
}
|
||||
|
||||
$web_interface = true;
|
||||
}
|
||||
|
||||
if ($run_script) {
|
||||
|
||||
// User authentication
|
||||
if (!$web_interface) {
|
||||
if (empty($settings['username'])) {
|
||||
echo "You must enter a valid username for a moodle administrator account on this site.{$settings['eolchar']}";
|
||||
die();
|
||||
} elseif (empty($settings['password'])) {
|
||||
echo "You must enter a valid password for a moodle administrator account on this site.{$settings['eolchar']}";
|
||||
die();
|
||||
} else {
|
||||
if (!$user = authenticate_user_login($settings['username'], $settings['password'])) {
|
||||
echo "Invalid username or password!{$settings['eolchar']}";
|
||||
die();
|
||||
}
|
||||
$USER = complete_user_login($user);
|
||||
if (!has_capability('moodle/site:doanything', $systemcontext)) {
|
||||
echo "You do not have administration privileges on this Moodle site. These are required for running the restore script.{$settings['eolchar']}";
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Script code here
|
||||
|
||||
// Look for old moodledata/users directory
|
||||
$oldusersdir = $CFG->dataroot . '/users';
|
||||
|
||||
if (!file_exists($oldusersdir)) {
|
||||
notify('The old directory for user profile images ('.$oldusersdir.') does not exist. Pictures cannot be restored!');
|
||||
} else {
|
||||
// Find user profile images that are not yet in the new directory
|
||||
$folders = get_directory_list($oldusersdir, '', false, true, false);
|
||||
|
||||
$restored_count = 0;
|
||||
|
||||
foreach ($folders as $userid) {
|
||||
$olddir = $oldusersdir . '/' . $userid;
|
||||
$files = get_directory_list($olddir);
|
||||
|
||||
if (empty($files)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create new user directory
|
||||
if (!$newdir = make_user_directory($userid)) {
|
||||
// some weird directory - do not stop the upgrade, just ignore it
|
||||
continue;
|
||||
}
|
||||
|
||||
// Move contents of old directory to new one
|
||||
if (file_exists($olddir) && file_exists($newdir)) {
|
||||
$restored = false;
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!file_exists($newdir . '/' . $file)) {
|
||||
copy($olddir . '/' . $file, $newdir . '/' . $file);
|
||||
verbose("Moved $olddir/$file into $newdir/$file");
|
||||
$restored = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($restored) {
|
||||
$restored_count++;
|
||||
}
|
||||
} else {
|
||||
notify("Could not move the contents of $olddir into $newdir!");
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($settings['eolchar'] == '<br />') {
|
||||
print_box_start('generalbox centerpara');
|
||||
}
|
||||
if ($restored_count > 0) {
|
||||
echo "Successfully restored profile images for $restored_count users!" . $settings['eolchar'];
|
||||
} else {
|
||||
echo "Did not find any user profile images in need of restoring." . $settings['eolchar'];
|
||||
}
|
||||
if ($settings['eolchar'] == '<br />') {
|
||||
print_box_end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($settings['eolchar'] == '<br />') {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the standard $argv into an associative array taking var=val arguments into account
|
||||
* @param array $argv
|
||||
* @return array $_ARG
|
||||
*/
|
||||
function arguments($argv) {
|
||||
$_ARG = array();
|
||||
foreach ($argv as $arg) {
|
||||
if (ereg('--?([^=]+)=(.*)',$arg,$reg)) {
|
||||
$_ARG[$reg[1]] = $reg[2];
|
||||
} elseif(ereg('-([a-zA-Z0-9]+)',$arg,$reg)) {
|
||||
$_ARG[$reg[1]] = 'true';
|
||||
}
|
||||
}
|
||||
return $_ARG;
|
||||
}
|
||||
|
||||
/**
|
||||
* If verbose is switched on, prints a string terminated by the global eolchar string.
|
||||
* @param string $string The string to STDOUT
|
||||
*/
|
||||
function verbose($string) {
|
||||
global $settings;
|
||||
if ($settings['verbose'] && !$settings['quiet']) {
|
||||
echo $string . $settings['eolchar'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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);
|
||||
|
||||
+1
-193
@@ -525,203 +525,11 @@ class problem_000011 extends problem_base {
|
||||
}
|
||||
return 'Error counter was cleared.';
|
||||
} else {
|
||||
return '<p>Session errors can be caused by:</p><ul>' .
|
||||
'<li>unresolved problem in server software (aka random switching of users),</li>' .
|
||||
'<li>blocked or modified cookies,</li>' .
|
||||
'<li>deleting of active session files.</li>' .
|
||||
'</ul><p><a href="'.me().'&resetsesserrorcounter=1">Reset counter</a></p>';
|
||||
return '<p>Session errors can be caused by:<ul><li>unresolved problem in server software (aka random switching of users),</li><li>blocked or modified cookies,</li><li>deleting of active session files.</li></ul></p><p><a href="'.me().'&resetsesserrorcounter=1">Reset counter.</a></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000012 extends problem_base {
|
||||
function title() {
|
||||
return 'Random questions data consistency';
|
||||
}
|
||||
function exists() {
|
||||
return record_exists_select('question', "qtype = 'random' AND parent <> id");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>For random questions, question.parent should equal question.id. ' .
|
||||
'There are some questions in your database for which this is not true. ' .
|
||||
'One way that this could have happened is for random questions restored from backup before ' .
|
||||
'<a href="http://tracker.moodle.org/browse/MDL-5482">MDL-5482</a> was fixed.</p>';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the SQL</p>' .
|
||||
'<pre>UPDATE ' . $CFG->prefix . 'question SET parent = id WHERE qtype = \'random\' and parent <> id;</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000013 extends problem_base {
|
||||
function title() {
|
||||
return 'Multi-answer questions data consistency';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$positionexpr = sql_position(sql_concat("','", "q.id", "','"),
|
||||
sql_concat("','", "qma.sequence", "','"));
|
||||
return record_exists_sql("
|
||||
SELECT * FROM {$CFG->prefix}question q
|
||||
JOIN {$CFG->prefix}question_multianswer qma ON $positionexpr > 0
|
||||
WHERE qma.question <> q.parent") ||
|
||||
record_exists_sql("
|
||||
SELECT * FROM {$CFG->prefix}question q
|
||||
JOIN {$CFG->prefix}question parent_q ON parent_q.id = q.parent
|
||||
WHERE q.category <> parent_q.category");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>For each sub-question whose id is listed in ' .
|
||||
'question_multianswer.sequence, its question.parent field should equal ' .
|
||||
'question_multianswer.question; and each sub-question should be in the same ' .
|
||||
'category as its parent. There are questions in your database for ' .
|
||||
'which this is not the case. One way that this could have happened is ' .
|
||||
'for multi-answer questions restored from backup before ' .
|
||||
'<a href="http://tracker.moodle.org/browse/MDL-14750">MDL-14750</a> was fixed.</p>';
|
||||
}
|
||||
function solution() {
|
||||
return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the ' .
|
||||
'code in question_multianswer_fix_subquestion_parents_and_categories in ' .
|
||||
'<a href="http://cvs.moodle.org/moodle/question/type/multianswer/db/upgrade.php?revision=1.1.10.2&view=markup">/question/type/multianswer/db/upgrade.php' .
|
||||
'from the 1.9 stable branch</a>.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000014 extends problem_base {
|
||||
function title() {
|
||||
return 'Only multianswer and random questions should be the parent of another question';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return record_exists_sql("
|
||||
SELECT * FROM {$CFG->prefix}question q
|
||||
JOIN {$CFG->prefix}question parent_q ON parent_q.id = q.parent
|
||||
WHERE parent_q.qtype NOT IN ('random', 'multianswer')");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>You have questions that violate this in your databse. ' .
|
||||
'You will need to investigate to determine how this happened.</p>';
|
||||
}
|
||||
function solution() {
|
||||
return '<p>It is impossible to give a solution without knowing more about ' .
|
||||
' how the problem was caused. You may be able to get help from the ' .
|
||||
'<a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a>.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000017 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories tree structure';
|
||||
}
|
||||
function find_problems() {
|
||||
static $answer = null;
|
||||
|
||||
if (is_null($answer)) {
|
||||
$categories = get_records('question_categories', '', '', 'id');
|
||||
|
||||
// Look for missing parents.
|
||||
$missingparent = array();
|
||||
foreach ($categories as $category) {
|
||||
if ($category->parent != 0 && !array_key_exists($category->parent, $categories)) {
|
||||
$missingparent[$category->id] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for loops.
|
||||
$loops = array();
|
||||
while (!empty($categories)) {
|
||||
$current = array_pop($categories);
|
||||
$thisloop = array($current->id => $current);
|
||||
while (true) {
|
||||
if (isset($thisloop[$current->parent])) {
|
||||
// Loop detected
|
||||
$loops[$current->id] = $thisloop;
|
||||
break;
|
||||
} else if (!isset($categories[$current->parent])) {
|
||||
// Got to the top level, or a category we already know is OK.
|
||||
break;
|
||||
} else {
|
||||
// Continue following the path.
|
||||
$current = $categories[$current->parent];
|
||||
$thisloop[$current->id] = $current;
|
||||
unset($categories[$current->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$answer = array($missingparent, $loops);
|
||||
}
|
||||
|
||||
return $answer;
|
||||
}
|
||||
function exists() {
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
return !empty($missingparent) || !empty($loops);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
|
||||
$description = '<p>The question categories should be arranged into tree ' .
|
||||
' structures by the question_categories.parent field. Sometimes ' .
|
||||
' this tree structure gets messed up.</p>';
|
||||
|
||||
if (!empty($missingparent)) {
|
||||
$description .= '<p>The following categories are missing their parents:</p><ul>';
|
||||
foreach ($missingparent as $cat) {
|
||||
$description .= "<li>Category $cat->id: " . s($cat->name) . "</li>\n";
|
||||
}
|
||||
$description .= "</ul>\n";
|
||||
}
|
||||
|
||||
if (!empty($loops)) {
|
||||
$description .= '<p>The following categories form a loop of parents:</p><ul>';
|
||||
foreach ($loops as $loop) {
|
||||
$description .= "<li><ul>\n";
|
||||
foreach ($loop as $cat) {
|
||||
$description .= "<li>Category $cat->id: " . s($cat->name) . " has parent $cat->parent</li>\n";
|
||||
}
|
||||
$description .= "</ul></li>\n";
|
||||
}
|
||||
$description .= "</ul>\n";
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
|
||||
$solution = '<p>Consider executing the following SQL queries. These fix ' .
|
||||
'the problem by moving some categories to the top level.</p>';
|
||||
|
||||
if (!empty($missingparent)) {
|
||||
$solution .= "<pre>UPDATE " . $CFG->prefix . "question_categories\n" .
|
||||
" SET parent = 0\n" .
|
||||
" WHERE id IN (" . implode(',', array_keys($missingparent)) . ");</pre>\n";
|
||||
}
|
||||
|
||||
if (!empty($loops)) {
|
||||
$solution .= "<pre>UPDATE " . $CFG->prefix . "question_categories\n" .
|
||||
" SET parent = 0\n" .
|
||||
" WHERE id IN (" . implode(',', array_keys($loops)) . ");</pre>\n";
|
||||
}
|
||||
|
||||
return $solution;
|
||||
}
|
||||
}
|
||||
|
||||
class problem_00000x extends problem_base {
|
||||
function title() {
|
||||
|
||||
+73
-149
@@ -28,8 +28,7 @@
|
||||
$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);
|
||||
$agreelicence = optional_param('agreelicence',0, PARAM_BOOL);
|
||||
$ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
|
||||
|
||||
/// check upgrade status first
|
||||
@@ -38,11 +37,6 @@
|
||||
}
|
||||
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>';
|
||||
@@ -59,11 +53,11 @@
|
||||
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
|
||||
if (empty($CFG->prefix) && $CFG->dbtype != '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
|
||||
if ($CFG->dbtype == 'oci8po' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
|
||||
error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
|
||||
}
|
||||
|
||||
@@ -97,14 +91,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.
|
||||
@@ -122,43 +108,31 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$linktoscrolltoerrors = '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>';
|
||||
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');
|
||||
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");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", 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");
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup,
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
"", $linktoscrolltoerrors, false, " ", " ");
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
error_reporting($CFG->debug);
|
||||
@@ -169,11 +143,6 @@
|
||||
/// 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
|
||||
@@ -183,22 +152,13 @@
|
||||
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. 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) {
|
||||
//ugly hack - install new groups: MDL-9217
|
||||
require("$CFG->dirroot/group/version.php");
|
||||
set_config('group_version', $group_version);
|
||||
//install_group_db();
|
||||
|
||||
// Install the roles system.
|
||||
moodle_install_roles();
|
||||
set_config('statsrolesupgraded',time());
|
||||
|
||||
|
||||
// Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
|
||||
// (this should only have any effect during initial install).
|
||||
$adminroot = admin_get_root();
|
||||
@@ -214,19 +174,15 @@
|
||||
'enrol' => 'manual',
|
||||
'enrol_plugins_enabled' => 'manual',
|
||||
'guestloginbutton' => 1,
|
||||
'registerauth' => 'email',
|
||||
'style' => 'default',
|
||||
'template' => 'default',
|
||||
'theme' => 'standardwhite',
|
||||
'filter_multilang_converted' => 1));
|
||||
'theme' => 'standardwhite'));
|
||||
|
||||
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');
|
||||
die;
|
||||
}
|
||||
|
||||
@@ -234,6 +190,13 @@
|
||||
/// Check version of Moodle code on disk compared with database
|
||||
/// and upgrade if possible.
|
||||
|
||||
if ( is_readable("$CFG->dirroot/version.php")) {
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
}
|
||||
if (!$version) {
|
||||
error('Main version.php was not readable or specified');# without version, stop
|
||||
}
|
||||
|
||||
if (file_exists("$CFG->dirroot/lib/db/$CFG->dbtype.php")) {
|
||||
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines old upgrades
|
||||
}
|
||||
@@ -246,12 +209,6 @@
|
||||
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);
|
||||
@@ -267,47 +224,41 @@
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
|
||||
exit;
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
} else if (empty($confirmrelease)) {
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
print_simple_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'center');
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
print_heading(get_string('environment', 'admin'));
|
||||
remove_dir($CFG->dataroot . '/environment'); /// Always delete downloaded env. info to force use of the released one. MDL-9796
|
||||
if (!check_moodle_environment($release, $environment_results, true)) {
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
print_box_end();
|
||||
if (check_moodle_environment($release, $environment_results, true)) {
|
||||
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 '<form action="index.php">';
|
||||
echo '<input type="hidden" name="confirmupgrade" 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 '<div class="continuebutton"><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
print_footer('none');
|
||||
die;
|
||||
exit;
|
||||
|
||||
} else {
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
"", $linktoscrolltoerrors, false, " ", " ");
|
||||
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
@@ -332,10 +283,6 @@
|
||||
/// If successful, continue upgrading roles and setting everything properly
|
||||
if ($status) {
|
||||
if (empty($CFG->rolesactive)) {
|
||||
// ugly hack - upgrade to new groups (from 1.6) : MDL-9217
|
||||
// require_once("$CFG->dirroot/group/db/upgrade.php");
|
||||
// MDL-11062, proper group upgrade code is done in lib/db/upgrade.php
|
||||
// install_group_db();
|
||||
// Upgrade to the roles system.
|
||||
moodle_install_roles();
|
||||
set_config('rolesactive', 1);
|
||||
@@ -350,17 +297,13 @@
|
||||
remove_dir($CFG->dataroot . '/cache', true); // flush cache
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("upgradesettings.php");
|
||||
print_footer('none');
|
||||
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');
|
||||
print_footer('none');
|
||||
die;
|
||||
notify("Upgrade failed! See /version.php");
|
||||
}
|
||||
upgrade_log_finish();
|
||||
}
|
||||
@@ -383,11 +326,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// ugly hack - convert to new groups if upgrading from 1.7; must be reworked
|
||||
require_once("$CFG->dirroot/group/db/upgrade.php");
|
||||
upgrade_group_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
|
||||
/// 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
|
||||
@@ -415,27 +353,14 @@
|
||||
/// 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
|
||||
|
||||
|
||||
/// 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.
|
||||
if (! $site = get_site()) {
|
||||
// We are about to create the site "course"
|
||||
@@ -499,7 +424,18 @@
|
||||
|
||||
/// 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 !!!");
|
||||
}
|
||||
}
|
||||
@@ -507,7 +443,7 @@
|
||||
|
||||
/// Set up the admin user
|
||||
if (empty($CFG->rolesactive)) {
|
||||
create_admin_user();
|
||||
redirect('user.php');
|
||||
}
|
||||
|
||||
/// Check for valid admin user
|
||||
@@ -519,7 +455,7 @@
|
||||
|
||||
/// check that site is properly customized
|
||||
if (empty($site->shortname) or empty($site->shortname)) {
|
||||
redirect('settings.php?section=frontpagesettings&return=site');
|
||||
redirect('settings.php?section=frontpage&return=site');
|
||||
}
|
||||
|
||||
/// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
|
||||
@@ -540,51 +476,43 @@
|
||||
|
||||
/// 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"));
|
||||
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');
|
||||
print_simple_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'center', '60%');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
/// If no recently cron run
|
||||
/// If no recently cron run
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
|
||||
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 to display the utf-8 migration button (if !unicode yet and DB is MySQL or PG)
|
||||
if (empty($CFG->unicodedb) && in_array($CFG->dbtype, array('mysql', 'postgres7'))) {
|
||||
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
|
||||
@@ -592,40 +520,36 @@
|
||||
if (!isset($CFG->registered) || $CFG->registered < (time() - 3600*24*30*6)) {
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_box_start('generalbox adminwarning');
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<div align="center">';
|
||||
print_string('pleaseregister', 'admin');
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
print_box_end();
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
$registrationbuttonshown = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// 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 />'.
|
||||
'<a href="http://docs.moodle.org/en/Release">'.$CFG->release.'</a> ('.$CFG->version.')<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');
|
||||
echo '<p class="copyright">'.$copyrighttext.'</p>';
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
if (empty($registrationbuttonshown)) {
|
||||
echo '<div align="center">';
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
if (optional_param('dbmigrate')) { // ??? Is this actually used?
|
||||
print_box_start();
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/utfdbmigrate.php');
|
||||
db_migrate2utf8();
|
||||
print_box_end();
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_heading('Convert all MySQL tables from MYISAM to InnoDB');
|
||||
|
||||
if ($CFG->dbfamily != 'mysql') {
|
||||
if ($CFG->dbtype != 'mysql') {
|
||||
notice('This function is for MySQL databases only!', 'index.php');
|
||||
}
|
||||
|
||||
|
||||
+123
-221
@@ -1,6 +1,38 @@
|
||||
<?PHP // $Id$
|
||||
/**
|
||||
* Display the admin/language menu and process strings translation.
|
||||
*
|
||||
* CHANGES
|
||||
*
|
||||
* 2006/11/07 mudrd8mz
|
||||
* Fixed bug MDL-7361. Thanks to Dan Poltawski for the patch proposal.
|
||||
*
|
||||
* 2006/06/08 mudrd8mz
|
||||
* 1) Fixed bug 5745 reported by Harry Smith so now can edit en_utf8_local pack
|
||||
* 2) More notification messages included
|
||||
*
|
||||
* 2006/05/30 mudrd8mz
|
||||
* Merged with version by Mitsuhiro Yoshida - display icon links instead of text links
|
||||
* (I have changed the position of arrow icons to not to be so close each other)
|
||||
*
|
||||
* 2006/05/19 mudrd8mz
|
||||
* A lot of changes to support translation of *_utf8_local langugage packs. Needs testing
|
||||
*
|
||||
* 2006/05/16 mudrd8mz
|
||||
* 1) LANG_DEFAULT_FILE can be now set. moodle.php used to be opened automatically.
|
||||
* As it was (and still is) one of the biggest files it usually took a long time to load the page
|
||||
* even if you just want to choose the file to translate.
|
||||
* 2) added links from "missing" to "compare" mode page
|
||||
* 3) english strings are now key-sorted in "missing" mode
|
||||
* 4) list of files with missing strings is now displayed at the top of "missing" page
|
||||
*
|
||||
* 2006/05/14 mudrd8mz Improvements of lang.php,v 1.65 2006/04/10 22:15:57 stronk7 Exp
|
||||
* 1) "go to first missing string" link can be displayed (see LANG_DISPLAY_MISSING_LINKS)
|
||||
* 2) "go to next missing" link can be displayed (see LANG_DISPLAY_MISSING_LINKS)
|
||||
* 3) submit button may be repeated (see LANG_SUBMIT_REPEAT*)
|
||||
* 4) added (empty) "summary" attribute for the <table>'s
|
||||
* 5) added error_reporting(E_ALL ^ E_NOTICE); in "compare" mode (even in debug environment
|
||||
* we know that missing keys are missing strings here, not bugs ;-)
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
@@ -14,8 +46,6 @@
|
||||
define('LANG_DEFAULT_FILE', ''); // default file to translate. Empty allowed
|
||||
define('LANG_LINK_MISSING_STRINGS', 1); // create links from "missing" page to "compare" page?
|
||||
define('LANG_DEFAULT_USELOCAL', 0); // should *_utf8_local be used by default?
|
||||
define('LANG_MISSING_TEXT_MAX_LEN', 60); // maximum length of the missing text to display
|
||||
define('LANG_KEEP_ORPHANS', 1); // keep orphaned strings (i.e. strings w/o English reference)
|
||||
|
||||
$mode = optional_param('mode', '', PARAM_ALPHA);
|
||||
$currentfile = optional_param('currentfile', LANG_DEFAULT_FILE, PARAM_FILE);
|
||||
@@ -37,37 +67,42 @@
|
||||
$streditstrings = get_string("editstrings", 'admin');
|
||||
$stredithelpdocs = get_string("edithelpdocs", 'admin');
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$strgotofirst = get_string('gotofirst','admin');
|
||||
$strfilestoredin = get_string('filestoredin', 'admin');
|
||||
$strfilestoredinhelp = get_string('filestoredinhelp', 'admin');
|
||||
$strswitchlang = get_string('switchlang', 'admin');
|
||||
$strchoosefiletoedit = get_string('choosefiletoedit', 'admin');
|
||||
$strgotofirst = get_string('gotofirstmissing','admin');
|
||||
$strfilestoredin = get_string('langstorein', 'admin');
|
||||
$strfilestoredinhelp = get_string('langstoreinhelp', 'admin');
|
||||
$strswitchlangdirbtn = get_string('langstoreswitch', 'admin');
|
||||
$strchoosefiletoedit = get_string('langchoosefile', 'admin');
|
||||
$streditennotallowed = get_string('langnoeditenglish', 'admin');
|
||||
$strfilecreated = get_string('filecreated', 'admin');
|
||||
$strprev = get_string('previous');
|
||||
$strnext = get_string('next');
|
||||
$strfilecreated = get_string('langfilecreated', 'admin');
|
||||
|
||||
// FIXME / TODO
|
||||
// remove following lines after adding string into proper english lang pack
|
||||
$strgotofirst = 'go to first missing string';
|
||||
$strfilestoredin = 'Save file into folder :';
|
||||
$strfilestoredinhelp = 'Where the file will be stored';
|
||||
$strswitchlangdirbtn = 'switch';
|
||||
$strchoosefiletoedit = 'Choose file to edit from the box above';
|
||||
$streditennotallowed = 'Language en_utf8 cannot be edited with this page - switch to local';
|
||||
$strfilecreated = 'New file created';
|
||||
|
||||
$currentlang = current_language();
|
||||
|
||||
|
||||
switch ($mode) {
|
||||
case "missing":
|
||||
// Missing array keys are not bugs here but missing strings
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $strmissingstrings";
|
||||
$title = $strmissingstrings;
|
||||
$button = '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<div>'.
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="submit" value="'.$streditstrings.'" /></div></form>';
|
||||
'<input type="submit" value="'.$streditstrings.'" /></form>';
|
||||
break;
|
||||
case "compare":
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $streditstrings";
|
||||
$title = $streditstrings;
|
||||
$button = '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<div>'.
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="missing" />'.
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></div></form>';
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></form>';
|
||||
break;
|
||||
default:
|
||||
$title = $strlanguage;
|
||||
@@ -80,14 +115,21 @@
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
if (!$mode) {
|
||||
print_box_start();
|
||||
print_simple_box_start('center','80%');
|
||||
echo '<div align="center">';
|
||||
print_string('editlang','admin');
|
||||
echo '<br />';
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages(false, true);
|
||||
popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", false, 'self', $strcurrentlanguage.':');
|
||||
$langs = get_list_of_languages();
|
||||
echo "<b>$strcurrentlanguage:</b>";
|
||||
echo '<br />';
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
$options["lang"] = $currentlang;
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare\">$streditstrings</a>");
|
||||
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
|
||||
print_box_end();
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
exit;
|
||||
}
|
||||
@@ -141,7 +183,7 @@
|
||||
} else {
|
||||
$fileismissing = 1;
|
||||
// notify(get_string("filemissing", "", "$langdir/$file"));
|
||||
$o .= '<div class="notifyproblem">'.get_string("filemissing", "", "$langdir/$file").'</div><br />';
|
||||
$o .= '<div class="notifyproblem" align="center">'.get_string("filemissing", "", "$langdir/$file").'</div><br />';
|
||||
$string = array();
|
||||
}
|
||||
|
||||
@@ -169,9 +211,6 @@
|
||||
$missinglinkstart = '';
|
||||
$missinglinkend = '';
|
||||
}
|
||||
if (strlen($value) > LANG_MISSING_TEXT_MAX_LEN) {
|
||||
$value = lang_xhtml_save_substr($value, 0, LANG_MISSING_TEXT_MAX_LEN) . ' ...'; // MDL-8852
|
||||
}
|
||||
$o .= "$"."string['".$missinglinkstart.$key.$missinglinkend."'] = \"$value\";<br />";
|
||||
}
|
||||
}
|
||||
@@ -181,7 +220,12 @@
|
||||
}
|
||||
|
||||
if ($m <> '') {
|
||||
print_box($m, 'filenames');
|
||||
echo '<br />';
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center><font size="2">';
|
||||
echo $m;
|
||||
echo '</font></center>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
echo $o;
|
||||
|
||||
@@ -211,7 +255,7 @@
|
||||
if (!empty($somethingfound)) {
|
||||
print_continue("lang.php");
|
||||
} else {
|
||||
notice(get_string("languagegood"), "lang.php", '', $adminroot);
|
||||
notice(get_string("languagegood"), "lang.php");
|
||||
}
|
||||
|
||||
} else if ($mode == "compare") {
|
||||
@@ -220,7 +264,7 @@
|
||||
if (!lang_make_directory($langbase) ){
|
||||
error('ERROR: Could not create base lang directory ' . $langbase);
|
||||
} else {
|
||||
echo '<div class="notifysuccess">Created directory '.
|
||||
echo '<div class="notifysuccess" align="center">Created directory '.
|
||||
$langbase .'</div>'."<br />\n";
|
||||
}
|
||||
}
|
||||
@@ -228,17 +272,17 @@
|
||||
if (!lang_make_directory($langdir)) {
|
||||
error('ERROR: Could not create directory '.$langdir);
|
||||
} else {
|
||||
echo '<div class="notifysuccess">Created directory '.
|
||||
echo '<div class="notifysuccess" align="center">Created directory '.
|
||||
$langdir .'</div>'."<br />\n";
|
||||
}
|
||||
}
|
||||
if ($uselocal && !file_exists($locallangdir)) {
|
||||
if (!lang_make_directory($locallangdir)) {
|
||||
echo '<div class="notifyproblem">ERROR: Could not create directory '.
|
||||
echo '<div class="notifyproblem" align="center">ERROR: Could not create directory '.
|
||||
$locallangdir .'</div>'."<br />\n";
|
||||
$uselocal = 0;
|
||||
} else {
|
||||
echo '<div class="notifysuccess">Created directory '.
|
||||
echo '<div class="notifysuccess" align="center">Created directory '.
|
||||
$locallangdir .'</div>'."<br />\n";
|
||||
}
|
||||
}
|
||||
@@ -281,7 +325,8 @@
|
||||
|
||||
print_heading_with_help($streditstrings, "langedit");
|
||||
|
||||
print_box_start('generalbox editstrings');
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center><font size="2">';
|
||||
foreach ($stringfiles as $file) {
|
||||
if ($file == $currentfile) {
|
||||
echo "<b>$file</b> ";
|
||||
@@ -289,37 +334,37 @@
|
||||
echo "<a href=\"lang.php?mode=compare&currentfile=$file\">$file</a> ";
|
||||
}
|
||||
}
|
||||
print_box_end();
|
||||
echo '</font></center>';
|
||||
print_simple_box_end();
|
||||
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>", "center", 4); // one-click way back
|
||||
|
||||
print_box_start();
|
||||
echo $strfilestoredin;
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center>'.$strfilestoredin.' <strong>';
|
||||
echo $uselocal ? "{$currentlang}_local" : $currentlang;
|
||||
echo '</strong> ';
|
||||
helpbutton('langswitchstorage', $strfilestoredinhelp, 'moodle');
|
||||
|
||||
echo '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<div>'.
|
||||
echo '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="hidden" name="currentfile" value="'.$currentfile.'" />'.
|
||||
'<input type="hidden" name="uselocal" value="'.(1 - $uselocal % 2).'" />'.
|
||||
'<input type="submit" value="'.$strswitchlang.'" />'.
|
||||
'</div></form>';
|
||||
print_box_end();
|
||||
'<input type="submit" value="'.$strswitchlangdirbtn.'" />'.
|
||||
'</form></center>';
|
||||
print_simple_box_end();
|
||||
|
||||
if ($currentfile <> '') {
|
||||
$saveto = $uselocal ? $locallangdir : $langdir;
|
||||
error_reporting(0);
|
||||
if (!file_exists("$saveto/$currentfile")) {
|
||||
if (!@touch("$saveto/$currentfile")) {
|
||||
print_heading(get_string("filemissing", "", "$saveto/$currentfile"), '', 4, 'error');
|
||||
print_heading(get_string("filemissing", "", "$saveto/$currentfile"), "center", 4, "error");
|
||||
} else {
|
||||
print_heading($strfilecreated, '', 4, 'notifysuccess');
|
||||
print_heading($strfilecreated, "center", 4, "notifysuccess");
|
||||
}
|
||||
}
|
||||
if ($currentlang == "en_utf8" && !$uselocal) {
|
||||
$editable = false;
|
||||
print_heading($streditennotallowed, '', 4);
|
||||
print_heading($streditennotallowed, 'center', 4);
|
||||
} elseif ($f = fopen("$saveto/$currentfile","r+")) {
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
@@ -329,9 +374,9 @@
|
||||
}
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
print_heading("$currentfile", "", 4);
|
||||
print_heading("$currentfile", "center", 4);
|
||||
if (LANG_DISPLAY_MISSING_LINKS && $editable) {
|
||||
print_heading('<a href="#missing1">'.$strgotofirst.'</a>', "", 4);
|
||||
print_heading('<a href="#missing1">'.$strgotofirst.'</a>', "center", 4);
|
||||
}
|
||||
|
||||
unset($string);
|
||||
@@ -339,7 +384,7 @@
|
||||
$enstring = $string;
|
||||
if ($currentlang != 'en' and $currentfile == 'moodle.php') {
|
||||
$enstring['thislanguage'] = "<< TRANSLATORS: Specify the name of your language here. If possible use Unicode Numeric Character References >>";
|
||||
$enstring['thischarset'] = "<< TRANSLATORS: Charset encoding - always use utf-8 >>";
|
||||
$enstring['thischarset'] = "<< TRANSLATORS: Specify the character set of your language here. Note that all text created while this language is active will be stored using this character set, so don't change it once you have set it. Example: iso-8859-1 >>";
|
||||
$enstring['thisdirection'] = "<< TRANSLATORS: This string specifies the direction of your text, either left-to-right or right-to-left. Insert either 'ltr' or 'rtl' here. >>";
|
||||
$enstring['parentlanguage'] = "<< TRANSLATORS: If your language has a Parent Language that Moodle should use when strings are missing from your language pack, then specify the code for it here. If you leave this blank then English will be used. Example: nl >>";
|
||||
}
|
||||
@@ -354,16 +399,15 @@
|
||||
@include("$langdir/$currentfile");
|
||||
|
||||
if ($editable) {
|
||||
echo "<form id=\"$currentfile\" action=\"lang.php\" method=\"post\">";
|
||||
echo '<div>';
|
||||
echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
|
||||
}
|
||||
echo "<table summary=\"\" width=\"100%\" class=\"translator\">";
|
||||
echo "<table summary=\"\" width=\"100%\" cellpadding=\"2\" cellspacing=\"3\" border=\"0\" class=\"generalbox\">";
|
||||
$linescounter = 0;
|
||||
$missingcounter = 0;
|
||||
foreach ($enstring as $key => $envalue) {
|
||||
$linescounter++ ;
|
||||
if (LANG_SUBMIT_REPEAT && $editable && $linescounter % LANG_SUBMIT_REPEAT_EVERY == 0) {
|
||||
echo '<tr><td> </td><td><br />';
|
||||
echo '<tr><td colspan="2"> <td><br />';
|
||||
echo ' <input type="submit" name="update" value="'.get_string('savechanges').': '.$currentfile.'" />';
|
||||
echo '<br /> </td></tr>';
|
||||
}
|
||||
@@ -372,18 +416,9 @@
|
||||
$envalue = str_replace("%%","%",$envalue);
|
||||
$envalue = str_replace("\\","",$envalue); // Delete all slashes
|
||||
|
||||
echo "\n\n".'<tr class="';
|
||||
if ($linescounter % 2 == 0) {
|
||||
echo 'r0';
|
||||
} else {
|
||||
echo 'r1';
|
||||
}
|
||||
echo '">';
|
||||
echo '<td dir="ltr" lang="en">';
|
||||
echo '<span class="stren">'.$envalue.'</span>';
|
||||
echo '<br />'."\n";
|
||||
echo '<span class="strkey">'.$key.'</span>';
|
||||
echo '</td>'."\n";
|
||||
echo "\n\n".'<tr>';
|
||||
echo '<td dir="ltr" lang="en" width="20%" nowrap="nowrap" valign="top">'.$key.'</td>'."\n";
|
||||
echo '<td dir="ltr" lang="en" width="40%" valign="top">'.$envalue.'</td>'."\n";
|
||||
|
||||
// Missing array keys are not bugs here but missing strings
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
@@ -405,17 +440,17 @@
|
||||
// green #AAFFAA - translation present in both system and local but is different
|
||||
if (!$value) {
|
||||
if (!$value2) {
|
||||
$cellcolour = 'class="bothmissing"';
|
||||
$cellcolour = 'style="background-color: #ef6868"'; // TODO: replace by CSS class
|
||||
} else {
|
||||
$cellcolour = 'class="mastermissing"';
|
||||
$cellcolour = 'style="background-color: #feff7f"'; // TODO: replace by CSS class
|
||||
}
|
||||
$missingcounter++;
|
||||
if (LANG_DISPLAY_MISSING_LINKS) {
|
||||
$missingtarget = '<a name="missing'.$missingcounter.'"></a>';
|
||||
$missingnext = '<a href="#missing'.($missingcounter+1).'">'.
|
||||
'<img src="' . $CFG->pixpath . '/t/down.gif" class="iconsmall" alt="'.$strnext.'" /></a>';
|
||||
'<img src="' . $CFG->pixpath . '/t/down.gif" height="11" width="11" border="0" alt="" /></a>';
|
||||
$missingprev = '<a href="#missing'.($missingcounter-1).'">'.
|
||||
'<img src="' . $CFG->pixpath . '/t/up.gif" class="iconsmall" alt="'.$strprev.'" /></a>';
|
||||
'<img src="' . $CFG->pixpath . '/t/up.gif" height="11" width="11" border="0" alt="" /></a>';
|
||||
} else {
|
||||
$missingtarget = '';
|
||||
$missingnext = '';
|
||||
@@ -423,7 +458,7 @@
|
||||
}
|
||||
} else {
|
||||
if ($value <> $value2 && $value2 <> '') {
|
||||
$cellcolour = 'class="localdifferent"';
|
||||
$cellcolour = 'style="background-color: #AAFFAA"'; // TODO: replace by CSS class
|
||||
} else {
|
||||
$cellcolour = '';
|
||||
}
|
||||
@@ -433,13 +468,13 @@
|
||||
}
|
||||
|
||||
if ($editable) {
|
||||
echo '<td '.$cellcolour.' valign="top">'. $missingprev . $missingtarget."\n";
|
||||
echo '<td width="40%" '.$cellcolour.' valign="top">'. $missingprev . $missingtarget."\n";
|
||||
if (isset($string[$key])) {
|
||||
$valuelen = strlen($value);
|
||||
} else {
|
||||
$valuelen = strlen($envalue);
|
||||
}
|
||||
$cols=40;
|
||||
$cols=50;
|
||||
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
|
||||
$rows = ceil($valuelen / $cols);
|
||||
echo '<textarea name="stringXXX'.lang_form_string_key($key).'" cols="'.$cols.'" rows="'.$rows.'">'.$value.'</textarea>'."\n";
|
||||
@@ -455,12 +490,11 @@
|
||||
echo $missingnext . '</td>';
|
||||
|
||||
} else {
|
||||
echo '<td '.$cellcolour.' valign="top">'.$value.'</td>';
|
||||
echo '<td width="40%" bgcolor="'.$cellcolour.'" valign="top">'.$value.'</td>';
|
||||
}
|
||||
echo '</tr>'."\n";
|
||||
}
|
||||
if ($editable) {
|
||||
echo '<tr><td> </td><td><br />';
|
||||
echo '<tr><td colspan="2"> <td><br />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo ' <input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
echo ' <input type="hidden" name="mode" value="compare" />';
|
||||
@@ -468,14 +502,11 @@
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
if ($editable) {
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
} else {
|
||||
// no $currentfile specified
|
||||
print_heading($strchoosefiletoedit, "", 4);
|
||||
print_heading($strchoosefiletoedit, "center", 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,18 +531,6 @@
|
||||
*/
|
||||
function lang_save_file($path, $file, $strings, $local, $packstrings) {
|
||||
global $CFG, $USER;
|
||||
if (LANG_KEEP_ORPHANS) {
|
||||
// let us load the current content of the file
|
||||
unset($string);
|
||||
@include("$path/$file");
|
||||
if (isset($string)) {
|
||||
$orphans = $string;
|
||||
unset($string);
|
||||
} else {
|
||||
$orphans = array();
|
||||
}
|
||||
}
|
||||
// let us rewrite the file
|
||||
if (!$f = @fopen("$path/$file","w")) {
|
||||
return false;
|
||||
}
|
||||
@@ -525,22 +544,18 @@ function lang_save_file($path, $file, $strings, $local, $packstrings) {
|
||||
ksort($strings);
|
||||
foreach ($strings as $key => $value) {
|
||||
@list($id, $stringname) = explode('XXX',$key);
|
||||
$value = lang_fix_value_before_save($value);
|
||||
if ($CFG->lang != "zh_hk" and $CFG->lang != "zh_tw") { // Some MB languages include backslash bytes
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
}
|
||||
$value = str_replace("'", "\\'", $value); // Add slashes for '
|
||||
$value = str_replace('"', "\\\"", $value); // Add slashes for "
|
||||
$value = str_replace("%","%%",$value); // Escape % characters
|
||||
$value = str_replace("\r", "",$value); // Remove linefeed characters
|
||||
$value = trim($value); // Delete leading/trailing white space
|
||||
if ($id == "string" and $value != ""){
|
||||
if ((!$local) || (lang_fix_value_from_file($packstrings[$stringname]) <> lang_fix_value_from_file($value))) {
|
||||
// Either we are saving the master language pack
|
||||
// or we are saving local language pack and the strings differ.
|
||||
fwrite($f,"\$string['$stringname'] = '$value';\n");
|
||||
}
|
||||
if (LANG_KEEP_ORPHANS && isset($orphans[$stringname])) {
|
||||
unset($orphans[$stringname]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (LANG_KEEP_ORPHANS) {
|
||||
// let us add orphaned strings, i.e. already translated strings without the English referential source
|
||||
foreach ($orphans as $key => $value) {
|
||||
fwrite($f,"\$string['$key'] = '".lang_fix_value_before_save($value)."'; // ORPHANED\n");
|
||||
}
|
||||
}
|
||||
fwrite($f,"\n?>\n");
|
||||
@@ -549,11 +564,7 @@ function lang_save_file($path, $file, $strings, $local, $packstrings) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix value of the translated string after it is load from the file.
|
||||
*
|
||||
* These modifications are typically necessary to work with the same string coming from two sources.
|
||||
* We need to compare the content of these sources and we want to have e.g. "This string\r\n"
|
||||
* to be the same as " This string\n".
|
||||
* Fix value of string to translate.
|
||||
*
|
||||
* @param string $value Original string from the file
|
||||
* @return string Fixed value
|
||||
@@ -564,40 +575,12 @@ function lang_fix_value_from_file($value='') {
|
||||
$value = trim($value); // Delete leading/trailing white space
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
$value = str_replace("%%","%",$value);
|
||||
$value = str_replace("&","&",$value); // Fixes MDL-9248
|
||||
$value = str_replace("<","<",$value);
|
||||
$value = str_replace(">",">",$value);
|
||||
$value = str_replace('"',""",$value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix value of the translated string before it is saved into the file
|
||||
*
|
||||
* @uses $CFG
|
||||
* @param string $value Raw string to be saved into the lang pack
|
||||
* @return string Fixed value
|
||||
*/
|
||||
function lang_fix_value_before_save($value='') {
|
||||
global $CFG;
|
||||
if ($CFG->lang != "zh_hk" and $CFG->lang != "zh_tw") { // Some MB languages include backslash bytes
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
}
|
||||
if (ini_get_bool('magic_quotes_sybase')) { // Unescape escaped sybase quotes
|
||||
$value = str_replace("''", "'", $value);
|
||||
}
|
||||
// escape all embedded variables
|
||||
$value = str_replace('$', '\$', $value); // Add slashes for $
|
||||
// unescape placeholders: only $a and $a->something are allowed. All other $variables are left escaped
|
||||
$value = preg_replace('/\\\\\$a($|[^_a-zA-Z0-9\-]|\->[a-zA-Z0-9_]+)/', '$a\\1', $value);
|
||||
$value = str_replace("'", "\\'", $value); // Add slashes for '
|
||||
$value = str_replace('"', "\\\"", $value); // Add slashes for "
|
||||
$value = str_replace("%","%%",$value); // Escape % characters
|
||||
$value = str_replace("\r", "",$value); // Remove linefeed characters
|
||||
$value = trim($value); // Delete leading/trailing white space
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try and create a new language directory.
|
||||
*
|
||||
@@ -617,99 +600,18 @@ function lang_make_directory($dir, $shownotices=true) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string key name for use in HTML form.
|
||||
*
|
||||
* Required because '.' in form input names get replaced by '_' by PHP.
|
||||
*
|
||||
* @param string $keyfromfile The key name containing '.'
|
||||
* @return string The key name without '.'
|
||||
*/
|
||||
|
||||
|
||||
/// Following functions are required because '.' in form input names
|
||||
/// get replaced by '_' by PHP.
|
||||
|
||||
function lang_form_string_key($keyfromfile) {
|
||||
return str_replace('.', '##46#', $keyfromfile); /// Derived from ., the ascii value for a period.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string key name for use in file.
|
||||
*
|
||||
* Required because '.' in form input names get replaced by '_' by PHP.
|
||||
*
|
||||
* @param string $keyfromfile The key name without '.'
|
||||
* @return string The key name containing '.'
|
||||
*/
|
||||
function lang_file_string_key($keyfromform) {
|
||||
return str_replace('##46#', '.', $keyfromform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the substring of the string and take care of XHTML compliance.
|
||||
*
|
||||
* There was a problem with pure substr() which could possibly produce XHTML parsing error:
|
||||
* substr('Marks & Spencer', 0, 9) -> 'Marks &am' ... is not XHTML compliance
|
||||
* This function takes care of these cases. Fixes MDL-8852.
|
||||
*
|
||||
* Thanks to kovacsendre, the author of the function at http://php.net/substr
|
||||
*
|
||||
* @param string $str The original string
|
||||
* @param int $start Start position in the $value string
|
||||
* @param int $length Optional length of the returned substring
|
||||
* @return string The substring as returned by substr() with XHTML compliance
|
||||
* @todo Seems the function does not work with negative $start together with $length being set
|
||||
*/
|
||||
function lang_xhtml_save_substr($str, $start, $length = NULL) {
|
||||
if ($length === 0) {
|
||||
//stop wasting our time ;)
|
||||
return "";
|
||||
}
|
||||
|
||||
//check if we can simply use the built-in functions
|
||||
if (strpos($str, '&') === false) {
|
||||
// No entities. Use built-in functions
|
||||
if ($length === NULL) {
|
||||
return substr($str, $start);
|
||||
} else {
|
||||
return substr($str, $start, $length);
|
||||
}
|
||||
}
|
||||
|
||||
// create our array of characters and html entities
|
||||
$chars = preg_split('/(&[^;\s]+;)|/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
|
||||
$html_length = count($chars);
|
||||
|
||||
// check if we can predict the return value and save some processing time, i.e.:
|
||||
// input string was empty OR
|
||||
// $start is longer than the input string OR
|
||||
// all characters would be omitted
|
||||
if (($html_length === 0) or ($start >= $html_length) or (isset($length) and ($length <= -$html_length))) {
|
||||
return '';
|
||||
}
|
||||
|
||||
//calculate start position
|
||||
if ($start >= 0) {
|
||||
$real_start = $chars[$start][1];
|
||||
} else {
|
||||
//start'th character from the end of string
|
||||
$start = max($start,-$html_length);
|
||||
$real_start = $chars[$html_length+$start][1];
|
||||
}
|
||||
|
||||
if (!isset($length)) {
|
||||
// no $length argument passed, return all remaining characters
|
||||
return substr($str, $real_start);
|
||||
} elseif ($length > 0) {
|
||||
// copy $length chars
|
||||
if ($start+$length >= $html_length) {
|
||||
// return all remaining characters
|
||||
return substr($str, $real_start);
|
||||
} else {
|
||||
//return $length characters
|
||||
return substr($str, $real_start, $chars[max($start,0)+$length][1] - $real_start);
|
||||
}
|
||||
} else {
|
||||
//negative $length. Omit $length characters from end
|
||||
return substr($str, $real_start, $chars[$html_length+$length][1] - $real_start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+5
-5
@@ -40,7 +40,7 @@
|
||||
|
||||
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang','',$adminroot);
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
// Shall I save POSTed data?
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey", $adminroot);
|
||||
error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@
|
||||
// Get all files from /docs directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
error("Could not find English language docs files!",'',$adminroot);
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
|
||||
$options = array();
|
||||
@@ -81,7 +81,7 @@
|
||||
// Get all files from /help directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
error("Could not find English language help files!",'',$adminroot);
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
@@ -169,7 +169,7 @@ $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.'" />';
|
||||
|
||||
|
||||
+75
-62
@@ -20,40 +20,34 @@
|
||||
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;
|
||||
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
//reset and diagnose lang cache permissions
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
if (file_exists($CFG->dataroot.'/cache/languages')) {
|
||||
notify('Language cache can not be deleted, please check permissions in dataroot.');
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
|
||||
|
||||
switch ($mode){
|
||||
|
||||
|
||||
case INSTALLATION_OF_SELECTED_LANG: ///installation of selected language pack
|
||||
|
||||
|
||||
if (confirm_sesskey()) {
|
||||
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
|
||||
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case ERROR:
|
||||
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';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
@@ -62,8 +56,8 @@
|
||||
break;
|
||||
|
||||
case INSTALLED:
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack), -1, $adminroot);
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack));
|
||||
break;
|
||||
|
||||
case UPTODATE:
|
||||
@@ -92,7 +86,7 @@
|
||||
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
|
||||
|
||||
if (!$confirm && confirm_sesskey()) {
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode=4&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
'langimport.php');
|
||||
} else if (confirm_sesskey()) {
|
||||
@@ -109,16 +103,16 @@
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
//delete the direcotries
|
||||
if ($rm1 or $rm2) {
|
||||
redirect('langimport.php', get_string('langpackremoved','admin'), 3, $adminroot);
|
||||
redirect('langimport.php', get_string('langpackremoved','admin'));
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
error('An error has occurred, language pack is not completely uninstalled, please check file permissions');
|
||||
}
|
||||
}
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
break;
|
||||
|
||||
|
||||
case UPDATE_ALL_LANG: //1 click update for all updatable language packs
|
||||
|
||||
//0th pull a list from download.moodle.org,
|
||||
@@ -126,7 +120,8 @@
|
||||
$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
|
||||
|
||||
@@ -190,7 +185,7 @@
|
||||
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';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
@@ -213,13 +208,13 @@
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php', NULL, $adminroot);
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php');
|
||||
} else {
|
||||
notice(get_string('nolangupdateneeded','admin'), 'langimport.php', NULL, $adminroot);
|
||||
notice(get_string('nolangupdateneeded','admin'), 'langimport.php');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
default: //display choice mode
|
||||
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
@@ -241,52 +236,72 @@
|
||||
}
|
||||
*/
|
||||
if (!$remote) {
|
||||
print_box_start();
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<div align="center">';
|
||||
print_string('remotelangnotavailable','admin',$CFG->dataroot.'/lang/');
|
||||
print_box_end();
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
print_box_start();
|
||||
echo '<table summary="">';
|
||||
|
||||
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 id="uninstallform" action="langimport.php?mode=4" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<form name="uninstallform" action="langimport.php?mode=4" method="POST">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
$installedlangs = get_list_of_languages(false, true);
|
||||
unset($CFG->langlist); // ignore admin's langlist
|
||||
$installedlangs = get_list_of_languages();
|
||||
|
||||
/// display installed langs here
|
||||
|
||||
echo '<label for="uninstalllang">'.get_string('installedlangs','admin')."</label><br />\n";
|
||||
echo '<select name="uninstalllang" id="uninstalllang" size="15">';
|
||||
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 '</fieldset>';
|
||||
echo '</form>';
|
||||
echo '<form id="updateform" action="langimport.php?mode=5" method="post">';
|
||||
echo '<div>';
|
||||
echo '<form name="updateform" action="langimport.php?mode=5" method="POST">';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
echo '<p />';
|
||||
|
||||
/// Display option to change site language
|
||||
|
||||
/// Erm... this doesn't seem to work. Plus it's redundant. -vinkmar
|
||||
|
||||
// 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">';
|
||||
//availabe langs table
|
||||
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 id="installform" method="post" action="langimport.php?mode=2">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<form name="installform" method="POST" action="langimport.php?mode=2">';
|
||||
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">';
|
||||
echo '<select name="pack" size="15">';
|
||||
}
|
||||
|
||||
foreach ($availablelangs as $alang) {
|
||||
@@ -301,24 +316,25 @@
|
||||
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>';
|
||||
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="'.$THEME->larrow.' '.get_string('install','admin').'" />';
|
||||
echo '<br/ ><input type="submit" value="<-- '.get_string('install','admin').'">';
|
||||
}
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if ($empty) {
|
||||
echo '<br />';
|
||||
echo '<tr><td align="center">';
|
||||
print_string('nolanguagetodownload','admin');
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
//close available langs table
|
||||
echo '</td><tr></table>'; //close available langs table
|
||||
echo '<form>';
|
||||
echo '</td></tr></table>';
|
||||
print_simple_box_end();
|
||||
|
||||
@@ -327,7 +343,7 @@
|
||||
} //close of main switch
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
/* returns a list of available language packs from a
|
||||
* local copy shipped with standard moodle distro
|
||||
* this is for site that can't perform fopen
|
||||
@@ -344,8 +360,8 @@
|
||||
}
|
||||
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
|
||||
@@ -359,7 +375,7 @@
|
||||
}
|
||||
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) {
|
||||
@@ -372,16 +388,13 @@
|
||||
return false; //failed
|
||||
}
|
||||
fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
|
||||
|
||||
$headers_done = false;
|
||||
while(!feof($proxy_fp)) {
|
||||
$i = 0;
|
||||
while(!feof($proxy_fp)) {
|
||||
$string = fgets($proxy_fp, 1024);
|
||||
if(!$headers_done){
|
||||
// A new line indicates end of HTTP headers
|
||||
$headers_done = ("\r\n" == $string);
|
||||
} else {
|
||||
if ($i > 11) { //12 lines of info skipped
|
||||
$availablelangs[] = split(',', $string);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
fclose($proxy_fp);
|
||||
|
||||
|
||||
+10
-12
@@ -37,29 +37,27 @@
|
||||
/// 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();
|
||||
|
||||
@@ -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,239 +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();
|
||||
$adminroot = admin_get_root();
|
||||
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol', $adminroot);
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
$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)) {
|
||||
error(get_string('nomodifyacl','mnet'));
|
||||
}
|
||||
|
||||
// fetch the record in question
|
||||
$id = required_param('id', PARAM_INT);
|
||||
if (!$idrec = get_record('mnet_sso_access_control', 'id', $id)) {
|
||||
error(get_string('recordnoexists','mnet'), "/$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') {
|
||||
error(get_string('invalidaccessparam', 'mnet') , "/$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->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)) {
|
||||
error(get_string('nomodifyacl','mnet'), "/$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 (s($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($adminroot);
|
||||
|
||||
?>
|
||||
@@ -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', addslashes_recursive($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,52 +0,0 @@
|
||||
<?php
|
||||
print_header("$site->shortname: $strmnetsettings", "$site->fullname",
|
||||
'<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.$stradministration.'</a> -> '.
|
||||
'<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/mnet/index.php">'.get_string('mnetsettings', 'mnet').'</a> -> Delete host');
|
||||
|
||||
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,50 +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);
|
||||
}
|
||||
|
||||
require_sesskey();
|
||||
|
||||
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,293 +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()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('mnetenrol', $adminroot);
|
||||
$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);
|
||||
$raw_all_enrolled_users = $mnet_request->response;
|
||||
unset($mnet_request);
|
||||
|
||||
$all_enrolled_users = array();
|
||||
if (!empty($raw_all_enrolled_users)) {
|
||||
// Try to repair keying of remote users array, numeric usernames get lost in the fracas
|
||||
foreach ($raw_all_enrolled_users as $username => $userdetails) {
|
||||
if (empty($userdetails['username']) || !is_numeric($username)) {
|
||||
//Not able to repair, or no need to repair
|
||||
$all_enrolled_users[$username] = $userdetails;
|
||||
} else {
|
||||
$all_enrolled_users[$userdetails['username']] = $userdetails;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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
|
||||
|
||||
$strassignusers = get_string('assignusers', 'role');
|
||||
$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($adminroot);
|
||||
|
||||
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($adminroot);
|
||||
|
||||
?>
|
||||
@@ -1,58 +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()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('mnetenrol', $adminroot);
|
||||
$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($adminroot);
|
||||
|
||||
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($adminroot);
|
||||
|
||||
?>
|
||||
@@ -1,62 +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');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('mnetenrol', $adminroot);
|
||||
$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($adminroot);
|
||||
|
||||
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}/admin/report/log/index.php?course_host={$host->id}">'
|
||||
// . get_string('logs', 'mnet').'</a> </td>'
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table>'
|
||||
. '</div>';
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
@@ -1,152 +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();
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('net', $adminroot);
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
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($adminroot);
|
||||
?>
|
||||
<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($adminroot);
|
||||
?>
|
||||
@@ -1,135 +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($adminroot);
|
||||
|
||||
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('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' ; ?>" />
|
||||
<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->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($adminroot);
|
||||
?>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
$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);
|
||||
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($adminroot);
|
||||
?>
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
$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);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id) $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($adminroot);
|
||||
?>
|
||||
@@ -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();
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('mnetpeers', $adminroot);
|
||||
|
||||
$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');
|
||||
$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,94 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
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="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<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"></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($adminroot);
|
||||
?>
|
||||
@@ -1,158 +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();
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('mnetpeers', $adminroot);
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_error('nocurl', 'mnet', '', 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', 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');
|
||||
|
||||
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.");
|
||||
error(get_string('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.");
|
||||
error(get_string("invalidurl", 'mnet'),'peers.php');
|
||||
exit;
|
||||
}
|
||||
unset($temp_wwwroot);
|
||||
$mnet_peer->bootstrap($form->wwwroot);
|
||||
}
|
||||
|
||||
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;
|
||||
$mnet_peer->updateparams->deleted = $form->deleted;
|
||||
}
|
||||
|
||||
if (isset($form->public_key)) {
|
||||
$form->public_key = clean_param($form->public_key, PARAM_PEM);
|
||||
if (empty($form->public_key)) {
|
||||
error(get_string("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->updateparams->public_key = $form->public_key;
|
||||
$mnet_peer->public_key_expires = $mnet_peer->check_common_name($form->public_key);
|
||||
$mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($form->public_key);
|
||||
if ($mnet_peer->public_key_expires == false) {
|
||||
$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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PREVENT DUPLICATE RECORDS ///////////////////////////////////////////
|
||||
if ('input' == $form->step) {
|
||||
if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) {
|
||||
error(get_string("hostexists", 'mnet', $mnet_peer->id),'peers.php?step=update&hostid='.$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);
|
||||
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_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
|
||||
if (empty($hosts)) $hosts = array();
|
||||
include('./peers.html');
|
||||
}
|
||||
?>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header($adminroot);
|
||||
?>
|
||||
<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($adminroot);
|
||||
?>
|
||||
@@ -1,72 +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();
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('trustedhosts', $adminroot);
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header($adminroot);
|
||||
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');
|
||||
?>
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
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.
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
/// Otherwise print the form.
|
||||
$module = required_param('module', PARAM_SAFEDIR);
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
$strmodulename = get_string("modulename", $module);
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
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", "");
|
||||
|
||||
+33
-73
@@ -2,15 +2,10 @@
|
||||
// Allows the admin to manage activity modules
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// defines
|
||||
define('MODULE_TABLE','module_administration_table');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('managemodules', $adminroot);
|
||||
require_once('../course/lib.php');
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
@@ -28,51 +23,34 @@
|
||||
$strsettings = get_string("settings");
|
||||
$stractivities = get_string("activities");
|
||||
$stractivitymodule = get_string("activitymodule");
|
||||
$strshowmodulecourse = get_string('showmodulecourse');
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
print_heading($stractivities);
|
||||
|
||||
$coursesaffected = false;
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
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);
|
||||
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);
|
||||
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()) {
|
||||
@@ -105,15 +83,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 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");
|
||||
@@ -149,12 +118,20 @@
|
||||
// Delete the capabilities that were defined by this module
|
||||
capabilities_cleanup('mod/'.$module->name);
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
if ($coursesaffected) {
|
||||
rebuild_course_cache(); // Because things have changed
|
||||
}
|
||||
|
||||
|
||||
/// Get and sort the existing modules
|
||||
|
||||
if (!$modules = get_records("modules")) {
|
||||
@@ -172,19 +149,16 @@
|
||||
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>";
|
||||
|
||||
@@ -195,40 +169,26 @@
|
||||
}
|
||||
|
||||
$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";
|
||||
}
|
||||
|
||||
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 = "";
|
||||
}
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$icon.' '.$modulename.'</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($adminroot);
|
||||
|
||||
|
||||
@@ -1,124 +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');
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('multilangupgrade', $adminroot);
|
||||
|
||||
$go = optional_param('go', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
###################################################################
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
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($adminroot);
|
||||
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 and $rs->RecordCount() > 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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($adminroot);
|
||||
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;
|
||||
}
|
||||
?>
|
||||
+1
-1
@@ -99,7 +99,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;
|
||||
}
|
||||
|
||||
|
||||
+9
-16
@@ -4,18 +4,11 @@ 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',0);
|
||||
define('BLOCK_L_MAX_WIDTH',210);
|
||||
define('BLOCK_R_MIN_WIDTH',0);
|
||||
define('BLOCK_R_MAX_WIDTH',210);
|
||||
|
||||
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 {
|
||||
@@ -116,12 +109,12 @@ class page_admin extends page_base {
|
||||
$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').'" />'.
|
||||
if ($this->user_allowed_editing()) {
|
||||
$buttons = '<table><tr><td><form target="' . $CFG->framename . '" method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<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>';
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></form></td>' .
|
||||
'</tr></table>';
|
||||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
|
||||
@@ -20,14 +20,8 @@
|
||||
$html = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
/// 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);
|
||||
|
||||
echo $html;
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
+87
-74
@@ -34,94 +34,98 @@
|
||||
$strregistration = get_string("registration");
|
||||
$strregistrationinfo = get_string("registrationinfo");
|
||||
|
||||
print_header("$site->shortname: $strregistration", $site->fullname,
|
||||
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 '<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 "<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 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 '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("statistics")."<br />(".get_string("notpublic").')'.'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
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);
|
||||
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";
|
||||
echo "<input type=\"hidden\" name=\"roleassignments\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
// first find all distinct roles with mod/course:update
|
||||
@@ -136,55 +140,64 @@
|
||||
|
||||
$count = count_records_sql($sql);
|
||||
echo get_string("teachers").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courseupdaters\" value=\"$count\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"courseupdaters\" 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 '<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 "<input type=\"hidden\" name=\"resources\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
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 "</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=\"center\" colspan=\"2\"><hr size=\"1\" noshade>".get_string("administrator")."</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
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();
|
||||
|
||||
?>
|
||||
|
||||
+4
-4
@@ -25,10 +25,10 @@ if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Pr
|
||||
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 '<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();
|
||||
|
||||
@@ -1,140 +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');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
|
||||
admin_externalpage_setup('reportbackups', $adminroot);
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
|
||||
require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
/// 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();
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
@@ -17,7 +17,7 @@
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID)); // needed?
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3, $adminroot);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
if (empty($timeoptions)) {
|
||||
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id, $adminroot);
|
||||
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n";
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
|
||||
$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),
|
||||
@@ -60,7 +60,6 @@
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
print_table($table);
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($report) && !empty($time)) {
|
||||
@@ -80,13 +79,13 @@
|
||||
$courses = get_records_sql($sql, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
notify(get_string('statsnodata'));echo '</td></tr></table>';echo '<p>after notify</p>';
|
||||
notify(get_string('statsnodata'));
|
||||
|
||||
} else {
|
||||
if (empty($CFG->gdversion)) {
|
||||
echo '<div class="boxaligncenter">(' . get_string("gdneed") .')</div>';
|
||||
echo '<div align="center">(' . get_string("gdneed") .')</div>';
|
||||
} else {
|
||||
echo '<div class="boxaligncenter"><img alt="'.get_string('courseoverviewgraph').'" src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></div>';
|
||||
echo '<div align="center"><img src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></div>';
|
||||
}
|
||||
|
||||
$table = new StdClass;
|
||||
@@ -115,6 +114,7 @@
|
||||
print_table($table);
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
stats_check_uptodate();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
|
||||
|
||||
@@ -16,18 +16,16 @@
|
||||
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_mnet_log_selector_form($CFG->mnet_localhost_id, $course);
|
||||
print_log_selector_form($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);
|
||||
echo '<center><h3>';
|
||||
link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800);
|
||||
echo '</h3></center>';
|
||||
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/question/upgrade.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('reportquestion', $adminroot);
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
print_heading(page_doc_link(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&id=".$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($adminroot);
|
||||
?>
|
||||
@@ -1,123 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/report/security/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
$issue = optional_param('issue', '', PARAM_FILE); // show detailed info about one issue only
|
||||
|
||||
$issues = report_security_get_issue_list();
|
||||
|
||||
// test if issue valid string
|
||||
if (array_search($issue, $issues, true) === false) {
|
||||
$issue = '';
|
||||
}
|
||||
|
||||
// we may need a bit more memory and this may take a long time to process
|
||||
@raise_memory_limit('128M');
|
||||
@set_time_limit(0);
|
||||
|
||||
// Print the header.
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('reportsecurity', $adminroot);
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
print_heading(get_string('reportsecurity', 'report_security'));
|
||||
|
||||
while(@ob_end_flush());
|
||||
@flush();
|
||||
|
||||
$strok = '<span class="statusok">'.get_string('statusok', 'report_security').'</span>';
|
||||
$strinfo = '<span class="statusinfo">'.get_string('statusinfo', 'report_security').'</span>';
|
||||
$strwarning = '<span class="statuswarning">'.get_string('statuswarning', 'report_security').'</span>';
|
||||
$strserious = '<span class="statusserious">'.get_string('statusserious', 'report_security').'</span>';
|
||||
$strcritical = '<span class="statuscritical">'.get_string('statuscritical', 'report_security').'</span>';
|
||||
|
||||
$strissue = get_string('issue', 'report_security');
|
||||
$strstatus = get_string('status', 'report_security');
|
||||
$strdesc = get_string('description', 'report_security');
|
||||
$strconfig = get_string('configuration', 'report_security');
|
||||
|
||||
$statusarr = array(REPORT_SECURITY_OK => $strok,
|
||||
REPORT_SECURITY_INFO => $strinfo,
|
||||
REPORT_SECURITY_WARNING => $strwarning,
|
||||
REPORT_SECURITY_SERIOUS => $strserious,
|
||||
REPORT_SECURITY_CRITICAL => $strcritical);
|
||||
|
||||
$url = "$CFG->wwwroot/$CFG->admin/report/security/index.php";
|
||||
|
||||
if ($issue and ($result = $issue(true))) {
|
||||
$table = new object();
|
||||
$table->head = array($strissue, $strstatus, $strdesc, $strconfig);
|
||||
$table->size = array('30%', '10%', '50%', '10%' );
|
||||
$table->align = array('left', 'left', 'left', 'left');
|
||||
$table->width = '90%';
|
||||
$table->data = array();
|
||||
|
||||
// print detail of one issue only
|
||||
$row = array();
|
||||
$row[0] = report_security_doc_link($issue, $result->name);
|
||||
$row[1] = $statusarr[$result->status];
|
||||
$row[2] = $result->info;
|
||||
$row[3] = is_null($result->link) ? ' ' : $result->link;
|
||||
|
||||
$CFG->pagepath = "report/security/$issue"; // help link in footer
|
||||
|
||||
$table->data[] = $row;
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_box($result->details, 'generalbox boxwidthnormal boxaligncenter'); // TODO: add proper css
|
||||
|
||||
print_continue($url);
|
||||
|
||||
} else {
|
||||
$table = new object();
|
||||
$table->head = array($strissue, $strstatus, $strdesc);
|
||||
$table->size = array('30%', '10%', '60%' );
|
||||
$table->align = array('left', 'left', 'left');
|
||||
$table->width = '90%';
|
||||
$table->data = array();
|
||||
|
||||
foreach ($issues as $issue) {
|
||||
$result = $issue(false);
|
||||
if (!$result) {
|
||||
// ignore this test
|
||||
continue;
|
||||
}
|
||||
$row = array();
|
||||
$row[0] = "<a href='$url?issue=$result->issue'>$result->name</a>";
|
||||
$row[1] = $statusarr[$result->status];
|
||||
$row[2] = $result->info;
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
@@ -1,779 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once("$CFG->libdir/adminlib.php");
|
||||
|
||||
|
||||
define('REPORT_SECURITY_OK', 'ok');
|
||||
define('REPORT_SECURITY_INFO', 'info');
|
||||
define('REPORT_SECURITY_WARNING', 'warning');
|
||||
define('REPORT_SECURITY_SERIOUS', 'serious');
|
||||
define('REPORT_SECURITY_CRITICAL', 'critical');
|
||||
|
||||
function report_security_get_issue_list() {
|
||||
return array(
|
||||
'report_security_check_globals',
|
||||
'report_security_check_unsecuredataroot',
|
||||
'report_security_check_displayerrors',
|
||||
'report_security_check_noauth',
|
||||
'report_security_check_embed',
|
||||
'report_security_check_mediafilterswf',
|
||||
'report_security_check_openprofiles',
|
||||
'report_security_check_google',
|
||||
'report_security_check_passwordsaltmain',
|
||||
'report_security_check_configrw',
|
||||
'report_security_check_defaultuserrole',
|
||||
'report_security_check_guestrole',
|
||||
'report_security_check_defaultcourserole',
|
||||
'report_security_check_courserole',
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
function report_security_doc_link($issue, $name) {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->docroot)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
$str = "<a onclick=\"this.target='docspopup'\" href=\"$CFG->docroot/$lang/report/security/$issue\">";
|
||||
$str .= "<img class=\"iconhelp\" src=\"$CFG->httpswwwroot/pix/docs.gif\" alt=\"\" />$name</a>";
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
///=============================================
|
||||
/// Issue checks
|
||||
///=============================================
|
||||
|
||||
|
||||
/**
|
||||
* Verifies register globals PHP setting.
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_globals($detailed=false) {
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_globals';
|
||||
$result->name = get_string('check_globals_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
|
||||
if (ini_get_bool('register_globals')) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_globals_error', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_globals_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_globals_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies unsupported noauth setting
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_noauth($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_noauth';
|
||||
$result->name = get_string('check_noauth_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/auth.php\">".get_string('authentication').'</a>';
|
||||
|
||||
if (is_enabled_auth('none')) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_noauth_error', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_noauth_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_noauth_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies sloppy embedding - this should have been removed long ago!!
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_embed($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_embed';
|
||||
$result->name = get_string('check_embed_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=sitepolicies\">".get_string('sitepolicies', 'admin').'</a>';
|
||||
|
||||
if (!empty($CFG->allowobjectembed)) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_embed_error', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_embed_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_embed_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies sloppy swf embedding - this should have been removed long ago!!
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_mediafilterswf($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_mediafilterswf';
|
||||
$result->name = get_string('check_mediafilterswf_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/filters.php\">".get_string('filtersettings', 'admin').'</a>';
|
||||
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$activefilters = explode(',', $CFG->textfilters);
|
||||
} else {
|
||||
$activefilters = array();
|
||||
}
|
||||
|
||||
if (array_search('filter/mediaplugin', $activefilters) !== false and !empty($CFG->filter_mediaplugin_enable_swf)) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_mediafilterswf_error', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_mediafilterswf_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_mediafilterswf_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies fatal misconfiguration of dataroot
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_unsecuredataroot($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_unsecuredataroot';
|
||||
$result->name = get_string('check_unsecuredataroot_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
|
||||
$insecuredataroot = is_dataroot_insecure();
|
||||
|
||||
if ($insecuredataroot) {
|
||||
$result->status = REPORT_SECURITY_SERIOUS;
|
||||
$result->info = get_string('check_unsecuredataroot_warning', 'report_security', $CFG->dataroot);
|
||||
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_unsecuredataroot_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_unsecuredataroot_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies disaplying of errors - problem for lib files and 3rd party code
|
||||
* because we can not disable debugging in these scripts (they do not include config.php)
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_displayerrors($detailed=false) {
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_displayerrors';
|
||||
$result->name = get_string('check_displayerrors_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
|
||||
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_displayerrors_error', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_displayerrors_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_displayerrors_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies open profiles - originaly open by default, not anymore because spammer abused it a lot
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_openprofiles($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_openprofiles';
|
||||
$result->name = get_string('check_openprofiles_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=sitepolicies\">".get_string('sitepolicies', 'admin').'</a>';
|
||||
|
||||
if (empty($CFG->forcelogin) and empty($CFG->forceloginforprofiles)) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_openprofiles_error', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_openprofiles_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_openprofiles_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies google access not combined with disabled guest access
|
||||
* because attackers might gain guest access by modifying browser signature.
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_google($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_google';
|
||||
$result->name = get_string('check_google_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=sitepolicies\">".get_string('sitepolicies', 'admin').'</a>';
|
||||
|
||||
if (empty($CFG->opentogoogle)) {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_google_ok', 'report_security');
|
||||
} else if (!empty($CFG->guestloginbutton)) {
|
||||
$result->status = REPORT_SECURITY_INFO;
|
||||
$result->info = get_string('check_google_info', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_SERIOUS;
|
||||
$result->info = get_string('check_google_error', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_google_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies config.php is not writable anymore after installation,
|
||||
* config files were changed on several outdated server.
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_configrw($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_configrw';
|
||||
$result->name = get_string('check_configrw_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
|
||||
if (is_writable($CFG->dirroot.'/config.php')) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_configrw_warning', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_configrw_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_configrw_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies sanity of default user role.
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_defaultuserrole($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_defaultuserrole';
|
||||
$result->name = get_string('check_defaultuserrole_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=userpolicies\">".get_string('userpolicies', 'admin').'</a>';;
|
||||
|
||||
if (!$default_role = get_record('role', 'id', $CFG->defaultuserroleid)) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_defaultuserrole_notset', 'report_security');
|
||||
$result->details = $result->info;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// first test if do anything enabled - that would be really crazy!
|
||||
$sql = "SELECT COUNT(DISTINCT rc.contextid)
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability = 'moodle/site:doanything'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $default_role->id";
|
||||
|
||||
$anythingcount = count_records_sql($sql);
|
||||
|
||||
// risky caps - usually very dangerous
|
||||
$sql = "SELECT COUNT(DISTINCT rc.contextid)
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
JOIN {$CFG->prefix}capabilities cap ON cap.name = rc.capability
|
||||
WHERE ".sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG))." <> 0
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $default_role->id";
|
||||
|
||||
$riskycount = count_records_sql($sql);
|
||||
|
||||
// default role can not have view cap in all courses - this would break moodle badly
|
||||
$viewcap = record_exists('role_capabilities', 'roleid', $default_role->id, 'permission', CAP_ALLOW, 'capability', 'moodle/course:view');
|
||||
|
||||
// it may have either no or 'user' legacy type - nothing else, or else it would break during upgrades badly
|
||||
$legacyok = false;
|
||||
$sql = "SELECT rc.capability, 1
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability LIKE 'moodle/legacy:%'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $default_role->id";
|
||||
$legacycaps = get_records_sql($sql);
|
||||
if (!$legacycaps) {
|
||||
$legacyok = true;
|
||||
} else if (count($legacycaps) == 1 and isset($legacycaps['moodle/legacy:user'])) {
|
||||
$legacyok = true;
|
||||
}
|
||||
|
||||
if ($anythingcount or $riskycount or $viewcap or !$legacyok) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_defaultuserrole_error', 'report_security', format_string($default_role->name));
|
||||
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_defaultuserrole_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_defaultuserrole_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies sanity of guest role
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_guestrole($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_guestrole';
|
||||
$result->name = get_string('check_guestrole_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=userpolicies\">".get_string('userpolicies', 'admin').'</a>';;
|
||||
|
||||
if (!$guest_role = get_record('role', 'id', $CFG->guestroleid)) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_guestrole_notset', 'report_security');
|
||||
$result->details = $result->info;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// first test if do anything enabled - that would be really crazy!
|
||||
$sql = "SELECT COUNT(DISTINCT rc.contextid)
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability = 'moodle/site:doanything'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $guest_role->id";
|
||||
|
||||
$anythingcount = count_records_sql($sql);
|
||||
|
||||
// risky caps - usually very dangerous
|
||||
$sql = "SELECT COUNT(DISTINCT rc.contextid)
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
JOIN {$CFG->prefix}capabilities cap ON cap.name = rc.capability
|
||||
WHERE ".sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG))." <> 0
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $guest_role->id";
|
||||
|
||||
$riskycount = count_records_sql($sql);
|
||||
|
||||
// it may have either no or 'guest' legacy type - nothing else, or else it would break during upgrades badly
|
||||
$legacyok = false;
|
||||
$sql = "SELECT rc.capability, 1
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability LIKE 'moodle/legacy:%'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $guest_role->id";
|
||||
$legacycaps = get_records_sql($sql);
|
||||
if (!$legacycaps) {
|
||||
$legacyok = true;
|
||||
} else if (count($legacycaps) == 1 and isset($legacycaps['moodle/legacy:guest'])) {
|
||||
$legacyok = true;
|
||||
}
|
||||
|
||||
if ($anythingcount or $riskycount or !$legacyok) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_guestrole_error', 'report_security', format_string($guest_role->name));
|
||||
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_guestrole_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_guestrole_details', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies sanity of site default course role.
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_defaultcourserole($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$problems = array();
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_defaultcourserole';
|
||||
$result->name = get_string('check_defaultcourserole_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=userpolicies\">".get_string('userpolicies', 'admin').'</a>';;
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_defaultcourserole_details', 'report_security');
|
||||
}
|
||||
|
||||
if (!$student_role = get_record('role', 'id', $CFG->defaultcourseroleid)) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_defaultcourserole_notset', 'report_security');
|
||||
$result->details = get_string('check_defaultcourserole_details', 'report_security');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// first test if do anything enabled - that would be really crazy!
|
||||
$sql = "SELECT DISTINCT rc.contextid
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability = 'moodle/site:doanything'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $student_role->id";
|
||||
|
||||
if ($anything_contexts = get_records_sql($sql)) {
|
||||
foreach($anything_contexts as $contextid) {
|
||||
if ($contextid == SYSCONTEXTID) {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/manage.php?action=view&roleid=$CFG->defaultcourseroleid";
|
||||
} else {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid&roleid=$CFG->defaultcourseroleid";
|
||||
}
|
||||
$problems[] = get_string('check_defaultcourserole_anything', 'report_security', $a);
|
||||
}
|
||||
}
|
||||
|
||||
// risky caps - usually very dangerous
|
||||
$sql = "SELECT DISTINCT rc.contextid
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
JOIN {$CFG->prefix}capabilities cap ON cap.name = rc.capability
|
||||
WHERE ".sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG))." <> 0
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $student_role->id";
|
||||
|
||||
if ($riskycontexts = get_records_sql($sql)) {
|
||||
foreach($riskycontexts as $contextid=>$unused) {
|
||||
if ($contextid == SYSCONTEXTID) {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/manage.php?action=view&roleid=$CFG->defaultcourseroleid";
|
||||
} else {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid&roleid=$CFG->defaultcourseroleid";
|
||||
}
|
||||
$problems[] = get_string('check_defaultcourserole_risky', 'report_security', $a);
|
||||
}
|
||||
}
|
||||
|
||||
// course creator or administrator does not make any sense here
|
||||
$sql = "SELECT rc.capability, 1
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability LIKE 'moodle/legacy:%'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid = $student_role->id";
|
||||
$legacycaps = get_records_sql($sql);
|
||||
if (isset($legacycaps['moodle/legacy:coursecreator']) or isset($legacycaps['moodle/legacy:admin'])) {
|
||||
$problems[] = get_string('check_defaultcourserole_legacy', 'report_security');
|
||||
}
|
||||
|
||||
if ($problems) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_defaultcourserole_error', 'report_security', format_string($student_role->name));
|
||||
if ($detailed) {
|
||||
$result->details .= "<ul>";
|
||||
foreach ($problems as $problem) {
|
||||
$result->details .= "<li>$problem</li>";
|
||||
}
|
||||
$result->details .= "</ul>";
|
||||
}
|
||||
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_defaultcourserole_ok', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies sanity of default roles in courses.
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_courserole($detailed=false) {
|
||||
global $CFG, $SITE;
|
||||
|
||||
$problems = array();
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_courserole';
|
||||
$result->name = get_string('check_courserole_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
|
||||
if ($detailed) {
|
||||
$result->details = get_string('check_courserole_details', 'report_security');
|
||||
}
|
||||
|
||||
// get list of all student roles selected in courses excluding the default course role
|
||||
$sql = "SELECT r.*
|
||||
FROM {$CFG->prefix}role r
|
||||
JOIN {$CFG->prefix}course c ON c.defaultrole = r.id
|
||||
WHERE c.id <> $SITE->id AND r.id <> $CFG->defaultcourseroleid";
|
||||
|
||||
if (!$student_roles = get_records_sql($sql)) {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_courserole_notyet', 'report_security');
|
||||
$result->details = get_string('check_courserole_details', 'report_security');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$roleids = array_keys($student_roles);
|
||||
|
||||
$sql = "SELECT DISTINCT rc.roleid
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE (rc.capability = 'moodle/legacy:coursecreator' OR rc.capability = 'moodle/legacy:admin'
|
||||
OR rc.capability = 'moodle/legacy:teacher' OR rc.capability = 'moodle/legacy:editingteacher')
|
||||
AND rc.permission = ".CAP_ALLOW."";
|
||||
|
||||
$riskyroleids = get_records_sql($sql);
|
||||
$riskyroleids = array_keys($riskyroleids);
|
||||
|
||||
|
||||
// first test if do anything enabled - that would be really crazy!!!!!!
|
||||
$inroles = implode(',', $roleids);
|
||||
$sql = "SELECT rc.roleid, rc.contextid
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
WHERE rc.capability = 'moodle/site:doanything'
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid IN ($inroles)
|
||||
GROUP BY rc.roleid, rc.contextid
|
||||
ORDER BY rc.roleid, rc.contextid";
|
||||
|
||||
$rs = get_recordset_sql($sql);
|
||||
while ($res = rs_fetch_next_record($rs)) {
|
||||
$roleid = $res->roleid;
|
||||
$contextid = $res->contextid;
|
||||
if ($contextid == SYSCONTEXTID) {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/manage.php?action=view&roleid=$roleid";
|
||||
} else {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid&roleid=$roleid";
|
||||
}
|
||||
$problems[] = get_string('check_courserole_anything', 'report_security', $a);
|
||||
}
|
||||
rs_close($rs);
|
||||
|
||||
// any XSS legacy cap does not make any sense here!
|
||||
$inroles = implode(',', $riskyroleids);
|
||||
$sql = "SELECT DISTINCT c.id, c.shortname
|
||||
FROM {$CFG->prefix}course c
|
||||
WHERE c.defaultrole IN ($inroles)
|
||||
ORDER BY c.sortorder";
|
||||
if ($courses = get_records_sql($sql)) {
|
||||
foreach ($courses as $course) {
|
||||
$a = (object)array('url'=>"$CFG->wwwroot/course/edit.php?id=$course->id", 'shortname'=>$course->shortname);
|
||||
$problems[] = get_string('check_courserole_riskylegacy', 'report_security', $a);
|
||||
}
|
||||
} else {
|
||||
$course = array();
|
||||
}
|
||||
|
||||
// risky caps in any level for roles not marked as risky yet - usually very dangerous!!
|
||||
if ($checkroles = array_diff($roleids, $riskyroleids)) {
|
||||
$inroles = implode(',', $checkroles);
|
||||
$sql = "SELECT rc.roleid, rc.contextid
|
||||
FROM {$CFG->prefix}role_capabilities rc
|
||||
JOIN {$CFG->prefix}capabilities cap ON cap.name = rc.capability
|
||||
WHERE ".sql_bitand('cap.riskbitmask', (RISK_XSS | RISK_CONFIG))." <> 0
|
||||
AND rc.permission = ".CAP_ALLOW."
|
||||
AND rc.roleid IN ($inroles)
|
||||
GROUP BY rc.roleid, rc.contextid
|
||||
ORDER BY rc.roleid, rc.contextid";
|
||||
$rs = get_recordset_sql($sql);
|
||||
while ($res = rs_fetch_next_record($rs)) {
|
||||
$roleid = $res->roleid;
|
||||
$contextid = $res->contextid;
|
||||
if ($contextid == SYSCONTEXTID) {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/manage.php?action=view&roleid=$roleid";
|
||||
} else {
|
||||
$a = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid&roleid=$roleid";
|
||||
}
|
||||
$problems[] = get_string('check_courserole_risky', 'report_security', $a);
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
|
||||
|
||||
if ($problems) {
|
||||
$result->status = REPORT_SECURITY_CRITICAL;
|
||||
$result->info = get_string('check_courserole_error', 'report_security');
|
||||
if ($detailed) {
|
||||
$result->details .= "<ul>";
|
||||
foreach ($problems as $problem) {
|
||||
$result->details .= "<li>$problem</li>";
|
||||
}
|
||||
$result->details .= "</ul>";
|
||||
}
|
||||
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_courserole_ok', 'report_security');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a password salt has been defined
|
||||
*
|
||||
* @param bool $detailed
|
||||
* @return object result
|
||||
*/
|
||||
function report_security_check_passwordsaltmain($detailed=false) {
|
||||
global $CFG;
|
||||
|
||||
$result = new object();
|
||||
$result->issue = 'report_security_check_passwordsaltmain';
|
||||
$result->name = get_string('check_passwordsaltmain_name', 'report_security');
|
||||
$result->info = null;
|
||||
$result->details = null;
|
||||
$result->status = null;
|
||||
$result->link = null;
|
||||
|
||||
if (empty($CFG->passwordsaltmain)) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_passwordsaltmain_warning', 'report_security');
|
||||
} else if ($CFG->passwordsaltmain === 'a_very_long_random_string_of_characters#@6&*1'
|
||||
|| trim($CFG->passwordsaltmain) === '' || preg_match('/^([a-z0-9]{0,10})$/i', $CFG->passwordsaltmain)) {
|
||||
$result->status = REPORT_SECURITY_WARNING;
|
||||
$result->info = get_string('check_passwordsaltmain_weak', 'report_security');
|
||||
} else {
|
||||
$result->status = REPORT_SECURITY_OK;
|
||||
$result->info = get_string('check_passwordsaltmain_ok', 'report_security');
|
||||
}
|
||||
|
||||
if ($detailed) {
|
||||
$docspath = $CFG->docroot.'/'.str_replace('_utf8', '', current_language()).'/report/security/report_security_check_passwordsaltmain';
|
||||
$result->details = get_string('check_passwordsaltmain_details', 'report_security', $docspath);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -38,14 +38,14 @@ class ExHtmlReporter extends HtmlReporter {
|
||||
* @param bool $showpasses Whether this reporter should output anything for passes.
|
||||
*/
|
||||
function ExHtmlReporter($showpasses) {
|
||||
global $CFG, $THEME;
|
||||
global $CFG;
|
||||
|
||||
$this->HtmlReporter();
|
||||
$this->showpasses = $showpasses;
|
||||
|
||||
$this->strrunonlyfolder = $this->get_string('runonlyfolder');
|
||||
$this->strrunonlyfile = $this->get_string('runonlyfile');
|
||||
$this->strseparator = get_separator();
|
||||
$this->strseparator = ' <img src="' . $CFG->pixpath . '/a/r_breadcrumb.gif" class="resize" alt="" /> ';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,18 +90,16 @@ if (!is_null($path)) {
|
||||
}
|
||||
// Print the form for adjusting options.
|
||||
print_simple_box_start('center', '70%');
|
||||
echo '<form method="get" action="index.php">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<form method="GET" action="index.php">';
|
||||
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 '<input type="text" id="path" name="path" value="', $displaypath, '" size="60" />';
|
||||
echo '</p>';
|
||||
echo '<input type="submit" value="' . get_string('runtests', $langfile) . '" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
@@ -1,372 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Spam Cleaner
|
||||
*
|
||||
* Helps an admin to clean up spam in Moodle
|
||||
*
|
||||
* @version $Id$
|
||||
* @authors Dongsheng Cai, Martin Dougiamas, Amr Hourani
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
|
||||
// Configuration
|
||||
|
||||
// List of known spammy keywords, please add more here
|
||||
|
||||
$autokeywords = array(
|
||||
"<img",
|
||||
"fuck",
|
||||
"casino",
|
||||
"porn",
|
||||
"xxx",
|
||||
"cialis",
|
||||
"viagra",
|
||||
"poker",
|
||||
"warcraft"
|
||||
);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
function delete_user($user) {
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time());
|
||||
$updateuser->email = '';
|
||||
$updateuser->idnumber = '';
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record('user', $updateuser)) {
|
||||
role_unassign(0, $user->id);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$keyword = optional_param('keyword', '', PARAM_RAW);
|
||||
$autodetect = optional_param('autodetect', '', PARAM_RAW);
|
||||
$del = optional_param('del', '', PARAM_RAW);
|
||||
$delall = optional_param('delall', '', PARAM_RAW);
|
||||
$ignore = optional_param('ignore', '', PARAM_RAW);
|
||||
$reset = optional_param('reset', '', PARAM_RAW);
|
||||
$id = optional_param('id', '', PARAM_INT);
|
||||
|
||||
require_login();
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('reportspamcleaner', $adminroot);
|
||||
|
||||
// Implement some AJAX calls
|
||||
|
||||
// Delete one user
|
||||
if (!empty($del) && confirm_sesskey() && ($id != $USER->id)) {
|
||||
if (isset($SESSION->users_result[$id])) {
|
||||
$user = $SESSION->users_result[$id];
|
||||
if (delete_user($user)) {
|
||||
unset($SESSION->users_result[$id]);
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete lots of users
|
||||
if (!empty($delall) && confirm_sesskey()) {
|
||||
if (!empty($SESSION->users_result)) {
|
||||
foreach ($SESSION->users_result as $userid => $user) {
|
||||
if ($userid != $USER->id) {
|
||||
if (delete_user($user)) {
|
||||
unset($SESSION->users_result[$userid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo 1;
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($ignore)) {
|
||||
unset($SESSION->users_result[$id]);
|
||||
echo 1;
|
||||
exit;
|
||||
}
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
// Print headers and things
|
||||
|
||||
print_spamcleaner_javascript();
|
||||
|
||||
print_box(get_string('spamcleanerintro', 'report_spamcleaner'));
|
||||
|
||||
print_box_start(); // The forms section at the top
|
||||
|
||||
?>
|
||||
|
||||
<div class="mdl-align">
|
||||
|
||||
<form method="post" action="index.php">
|
||||
<div>
|
||||
<input type="text" name="keyword" id="keyword_el" value="<?php p($keyword) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
|
||||
<input type="submit" value="<?php echo get_string('spamsearch', 'report_spamcleaner')?>" />
|
||||
</div>
|
||||
</form>
|
||||
<p><?php echo get_string('spameg', 'report_spamcleaner');?></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<form method="post" action="index.php">
|
||||
<div>
|
||||
<input type="submit" name="autodetect" value="<?php echo get_string('spamauto', 'report_spamcleaner');?>" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
print_box_end();
|
||||
|
||||
echo '<div id="result" class="mdl-align">';
|
||||
|
||||
// Print list of resulting profiles
|
||||
|
||||
if (!empty($keyword)) { // Use the keyword(s) supplied by the user
|
||||
$keywords = explode(',', $keyword);
|
||||
foreach ($keywords as $key => $keyword) {
|
||||
$keywords[$key] = trim($keyword);
|
||||
}
|
||||
search_spammers($keywords);
|
||||
|
||||
} else if (!empty($autodetect)) { // Use the inbuilt keyword list to detect users
|
||||
search_spammers($autokeywords);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/// Functions
|
||||
|
||||
|
||||
function search_spammers($keywords) {
|
||||
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
if (!is_array($keywords)) {
|
||||
$keywords = array($keywords); // Make it into an array
|
||||
}
|
||||
|
||||
$like = sql_ilike();
|
||||
|
||||
$keywordfull = array();
|
||||
foreach ($keywords as $keyword) {
|
||||
$keyword = addslashes($keyword); // Just to be safe
|
||||
$keywordfull[] = " description $like '%$keyword%' ";
|
||||
$keywordfull2[] = " p.summary $like '%$keyword%' ";
|
||||
}
|
||||
$conditions = '( '.implode(' OR ', $keywordfull).' )';
|
||||
$conditions2 = '( '.implode(' OR ', $keywordfull2).' )';
|
||||
|
||||
$sql = "SELECT * FROM {$CFG->prefix}user WHERE deleted = 0 AND id <> {$USER->id} AND $conditions"; // Exclude oneself
|
||||
$sql2= "SELECT u.*, p.summary FROM {$CFG->prefix}user AS u, {$CFG->prefix}post AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> {$USER->id}";
|
||||
$spamusers_desc = get_recordset_sql($sql);
|
||||
$spamusers_blog = get_recordset_sql($sql2);
|
||||
|
||||
$keywordlist = implode(', ', $keywords);
|
||||
print_box(get_string('spamresult', 'report_spamcleaner').s($keywordlist)).' ...';
|
||||
|
||||
print_user_list(array($spamusers_desc, $spamusers_blog), $keywords);
|
||||
|
||||
}
|
||||
|
||||
function print_user_list($users_rs, $keywords) {
|
||||
global $CFG, $SESSION;
|
||||
|
||||
// reset session everytime this function is called
|
||||
$SESSION->users_result = array();
|
||||
$count = 0;
|
||||
|
||||
foreach ($users_rs as $rs) {
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (!$count) {
|
||||
echo '<table border="1" width="100%" id="data-grid"><tr><th> </th><th>'.get_string('user','admin').'</th><th>'.get_string('spamdesc', 'report_spamcleaner').'</th><th>'.get_string('spamoperation', 'report_spamcleaner').'</th></tr>';
|
||||
}
|
||||
$count++;
|
||||
filter_user($user, $keywords, $count);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$count) {
|
||||
echo get_string('spamcannotfinduser', 'report_spamcleaner');
|
||||
|
||||
} else {
|
||||
echo '</table>';
|
||||
echo '<div class="mld-align">
|
||||
<button id="removeall_btn">'.get_string('spamdeleteall', 'report_spamcleaner').'</button>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
function filter_user($user, $keywords, $count) {
|
||||
global $CFG;
|
||||
$image_search = false;
|
||||
if (in_array('<img', $keywords)) {
|
||||
$image_search = true;
|
||||
}
|
||||
if (isset($user->summary)) {
|
||||
$user->description = '<h3>'.get_string('spamfromblog', 'report_spamcleaner').'</h3>'.$user->summary;
|
||||
unset($user->summary);
|
||||
}
|
||||
if (preg_match('#<img.*src=[\"\']('.$CFG->pixpath.')#', $user->description, $matches)
|
||||
&& $image_search) {
|
||||
$result = false;
|
||||
foreach ($keywords as $keyword) {
|
||||
if (preg_match('#'.$keyword.'#', $user->description)
|
||||
&& ($keyword != '<img')) {
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
if ($result) {
|
||||
echo print_user_entry($user, $keywords, $count);
|
||||
} else {
|
||||
unset($user);
|
||||
}
|
||||
} else {
|
||||
echo print_user_entry($user, $keywords, $count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function print_user_entry($user, $keywords, $count) {
|
||||
|
||||
global $SESSION, $CFG;
|
||||
|
||||
$smalluserobject = new object; // All we need to delete them later
|
||||
$smalluserobject->id = $user->id;
|
||||
$smalluserobject->email = $user->email;
|
||||
$smalluserobject->auth = $user->auth;
|
||||
$smalluserobject->firstname = $user->firstname;
|
||||
$smalluserobject->lastname = $user->lastname;
|
||||
|
||||
if (empty($SESSION->users_result[$user->id])) {
|
||||
$SESSION->users_result[$user->id] = $smalluserobject;
|
||||
$html = '<tr valign="top" id="row-'.$user->id.'" class="result-row">';
|
||||
$html .= '<td width="10">'.$count.'</td>';
|
||||
$html .= '<td width="30%" align="left"><a href="'.$CFG->wwwroot."/user/view.php?course=1&id=".$user->id.'" title="'.s($user->username).'">'.fullname($user).'</a>';
|
||||
|
||||
$html .= "<ul>";
|
||||
$profile_set = array('city'=>true, 'country'=>true, 'email'=>true);
|
||||
foreach ($profile_set as $key=>$value) {
|
||||
if (isset($user->$key)){
|
||||
$html .= '<li>'.$user->$key.'</li>';
|
||||
}
|
||||
}
|
||||
$html .= "</ul>";
|
||||
$html .= '</td>';
|
||||
|
||||
foreach ($keywords as $keyword) {
|
||||
$user->description = highlight($keyword, $user->description);
|
||||
}
|
||||
|
||||
$html .= '<td align="left">'.format_text($user->description, FORMAT_MOODLE).'</td>';
|
||||
$html .= '<td width="100px" align="center">';
|
||||
$html .= '<button onclick="del_user(this,'.$user->id.')">'.get_string('deleteuser', 'admin').'</button><br />';
|
||||
$html .= '<button onclick="ignore_user(this,'.$user->id.')">'.get_string('ignore', 'admin').'</button>';
|
||||
$html .= '</td>';
|
||||
$html .= '</tr>';
|
||||
return $html;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function print_spamcleaner_javascript() {
|
||||
global $CFG;
|
||||
|
||||
$sesskey = sesskey();
|
||||
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo $CFG->wwwroot;?>/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->wwwroot;?>/lib/yui/connection/connection-min.js"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var row = null;
|
||||
var delall_cb = {
|
||||
success: function(o){
|
||||
var resp = o.responseText;
|
||||
if(resp){
|
||||
window.location.href=window.location.href;
|
||||
}
|
||||
}
|
||||
}
|
||||
function init() {
|
||||
YAHOO.util.Event.addListener("removeall_btn", "click", function(){
|
||||
var yes = confirm('<?php echo get_string('spamdeleteallconfirm', 'report_spamcleaner');?>');
|
||||
if(yes){
|
||||
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?delall=yes&sesskey=<?php echo $sesskey;?>', delall_cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
var del_cb = {
|
||||
success: function(o) {
|
||||
var resp = o.responseText;
|
||||
if(row) {
|
||||
if(resp){
|
||||
while(row.tagName != 'TR') {
|
||||
row = row.parentNode;
|
||||
}
|
||||
row.parentNode.removeChild(row);
|
||||
row = null;
|
||||
} else {
|
||||
alert('<?php echo get_string('spamcannotdelete', 'report_spamcleaner');?>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var ignore_cb = {
|
||||
success: function(o){
|
||||
var resp = o.responseText;
|
||||
if(row) {
|
||||
if(resp){
|
||||
while(row.tagName != 'TR') {
|
||||
row = row.parentNode;
|
||||
}
|
||||
row.parentNode.removeChild(row);
|
||||
row = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function del_user(obj, id) {
|
||||
var yes = confirm('<?php echo get_string('spamdeleteconfirm', 'report_spamcleaner');?>');
|
||||
if(yes){
|
||||
row = obj;
|
||||
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?del=yes&sesskey=<?php echo $sesskey;?>&id='+id, del_cb);
|
||||
}
|
||||
}
|
||||
function ignore_user(obj, id) {
|
||||
row = obj;
|
||||
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?ignore=yes&sesskey=<?php echo $sesskey;?>&id='+id, ignore_cb);
|
||||
}
|
||||
window.onload = function(){
|
||||
init();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
// spam cleaner
|
||||
$ADMIN->add('reports', new admin_externalpage('reportspamcleaner', get_string('spamcleaner','report_spamcleaner'), "$CFG->wwwroot/$CFG->admin/report/spamcleaner/index.php", 'moodle/site:config'));
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time, '', 3, $adminroot);
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
@@ -46,7 +46,7 @@
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3, $adminroot);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'));
|
||||
}
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
@@ -59,7 +59,7 @@
|
||||
// $strreports = get_string("reports");
|
||||
// $strstats = get_string('stats');
|
||||
//
|
||||
// $menu = report_stats_mode_menu($course, $mode, $time); // add 4th $url parameter if uncommented!
|
||||
// $menu = report_stats_mode_menu($course, $mode, $time);
|
||||
//
|
||||
//
|
||||
// $crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
$roles = get_all_roles();
|
||||
|
||||
if ($grant = data_submitted() and confirm_sesskey()) {
|
||||
if ($grant = data_submitted()) {
|
||||
|
||||
foreach ($grant as $grole => $val) {
|
||||
if ($grole == 'dummy' or !strpos($grole, '_')) {
|
||||
if ($grole == 'dummy') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,9 @@
|
||||
|
||||
echo '<form action="allowassign.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '</div></form>';
|
||||
echo '</form>';
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
$roles = get_all_roles();
|
||||
|
||||
if ($grant = data_submitted() and confirm_sesskey()) {
|
||||
if ($grant = data_submitted()) {
|
||||
|
||||
foreach ($grant as $grole => $val) {
|
||||
if ($grole == 'dummy' or !strpos($grole, '_')) {
|
||||
if ($grole == 'dummy') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -78,10 +78,9 @@
|
||||
|
||||
echo '<form action="allowoverride.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '</div></form>';
|
||||
echo '</form>';
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
+59
-58
@@ -1,21 +1,27 @@
|
||||
<form id="assignform" method="post" action="">
|
||||
<div>
|
||||
|
||||
<form name="assignform" id="assignform" method="post" action="">
|
||||
<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">
|
||||
<table align="center" 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 print_string('existingusers', 'role', count($contextusers)); ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php print_string('potentialusers', 'role', $usercount); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple
|
||||
onFocus="document.assignform.add.disabled=true;
|
||||
document.assignform.remove.disabled=false;
|
||||
document.assignform.addselect.selectedIndex=-1;" />
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($contextusers as $contextuser) {
|
||||
@@ -32,78 +38,73 @@
|
||||
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')); ?>
|
||||
<img src="<?php echo $CFG->pixpath; ?>/t/hide.gif" alt="<?php print_string('hiddenassign') ?>" class="hide-show-image" /> <?
|
||||
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>
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</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;">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple
|
||||
onFocus="document.assignform.add.disabled=false;
|
||||
document.assignform.remove.disabled=true;
|
||||
document.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"
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($contextusers[$user->id])) {
|
||||
$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 {
|
||||
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
|
||||
}
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($contextusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</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;"
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onFocus ="document.assignform.add.disabled=true;
|
||||
document.assignform.remove.disabled=true;
|
||||
document.assignform.removeselect.selectedIndex=-1;
|
||||
document.assignform.addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
getElementById('assignform').previoussearch.value=1;
|
||||
getElementById('assignform').submit();
|
||||
document.assignform.previoussearch.value=1;
|
||||
document.assignform.submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchtext)) {
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
+33
-131
@@ -36,6 +36,7 @@
|
||||
error("Context ID was incorrect (can't find it)");
|
||||
}
|
||||
|
||||
|
||||
$inmeta = 0;
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseid = $context->instanceid;
|
||||
@@ -50,11 +51,9 @@
|
||||
}
|
||||
} else {
|
||||
$courseid = SITEID;
|
||||
$course = clone($SITE);
|
||||
$course = get_site();
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
require_login($context->instanceid);
|
||||
} else {
|
||||
@@ -63,9 +62,7 @@
|
||||
|
||||
require_capability('moodle/role:assign', $context);
|
||||
|
||||
/// needed for tabs.php
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
@@ -103,13 +100,13 @@
|
||||
if ($courseid != SITEID) {
|
||||
print_header("$fullname", "$fullname",
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
|
||||
<a href=\"$CFG->wwwroot/user/index.php?id=$course->id\">$strparticipants</a> -> <a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">$fullname</a> ->".$straction,
|
||||
<a href=\"$CFG->wwwroot/user/index.php?id=$course->id\">$strparticipants</a> -> <a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">$fullname</a> ->".$straction,
|
||||
"", "", true, " ", navmenu($course));
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
print_header("$course->fullname: $fullname", $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">$fullname</a> -> $straction", "", "", true, " ", navmenu($course));
|
||||
print_header("$course->fullname: $fullname", "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">$fullname</a> -> $straction", "", "", true, " ", navmenu($course));
|
||||
}
|
||||
|
||||
$showroles = 1;
|
||||
@@ -119,19 +116,13 @@
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('assignroles', $adminroot);
|
||||
admin_externalpage_print_header($adminroot);
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('frontpageroles', $adminroot);
|
||||
admin_externalpage_print_header($adminroot);
|
||||
$currenttab = '';
|
||||
$tabsmode = 'assign';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
$currenttab = '';
|
||||
$tabsmode = 'assign';
|
||||
include_once('tabs.php');
|
||||
}
|
||||
|
||||
|
||||
/// Process incoming role assignment
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
@@ -163,14 +154,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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) {
|
||||
@@ -179,7 +168,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
|
||||
@@ -199,28 +188,20 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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('assignroles', 'role'), 'assignroles');
|
||||
}
|
||||
|
||||
print_heading_with_help(get_string('assignroles', 'role'), 'assignroles');
|
||||
|
||||
if ($context->contextlevel==CONTEXT_SYSTEM) {
|
||||
print_box(get_string('globalroleswarning', 'role'));
|
||||
print_simple_box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
|
||||
if ($roleid) { /// prints a form to swap roles
|
||||
|
||||
/// Get all existing participants in this context.
|
||||
@@ -230,8 +211,8 @@
|
||||
$contextusers = array();
|
||||
}
|
||||
|
||||
$select = "username <> 'guest' AND deleted = 0 AND confirmed = 1";
|
||||
|
||||
$select = "username <> 'guest' AND username <> 'changeme' AND deleted = 0 AND confirmed = 1";
|
||||
|
||||
$usercount = count_records_select('user', $select) - count($contextusers);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
@@ -240,104 +221,25 @@
|
||||
$LIKE = sql_ilike();
|
||||
$FULLNAME = sql_fullname();
|
||||
|
||||
$selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
$select .= $selectsql;
|
||||
} else {
|
||||
$selectsql = "";
|
||||
$select .= " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
}
|
||||
|
||||
if ($context->contextlevel > CONTEXT_COURSE) { // mod or block (or group?)
|
||||
$availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user
|
||||
WHERE '.$select.'
|
||||
ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* 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;
|
||||
|
||||
}
|
||||
/// In the .html file below we loop through these results and exclude any in $contextusers
|
||||
|
||||
echo '<div style="text-align:center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
$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>';
|
||||
echo '<form name="rolesform" action="assign.php" method="post">';
|
||||
echo '<div align="center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
if ($userid) {
|
||||
echo '<input type="hidden" name="userid" value="'.$userid.'" />';
|
||||
}
|
||||
echo '<input type="hidden" name="courseid" value="'.$courseid.'" />';
|
||||
echo '<input type="hidden" name="contextid" value="'.$context->id.'" />'.$strroletoassign.': ';
|
||||
choose_from_menu ($assignableroles, 'roleid', $roleid, get_string('listallroles', 'role').'...', $script='rolesform.submit()');
|
||||
echo '</div></form>';
|
||||
|
||||
print_simple_box_start('center');
|
||||
include('assign.html');
|
||||
@@ -378,7 +280,7 @@
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM or ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID)) {
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
} else {
|
||||
print_footer($course);
|
||||
|
||||
+61
-122
@@ -4,106 +4,72 @@
|
||||
case 'add':
|
||||
$submitlabel = get_string('addrole', 'role');
|
||||
break;
|
||||
case 'view':
|
||||
$submitlabel = get_string('listallroles', 'role');
|
||||
break;
|
||||
case 'edit':
|
||||
default:
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
?>
|
||||
|
||||
if ($action == 'view') {
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form id="rolesform" action="manage.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
|
||||
<form name="rolesform" action="manage.php" method="post">
|
||||
<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="20" 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 cellpadding="9" cellspacing="0" align="center">
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('name') ?>:</td>
|
||||
<td><?php
|
||||
if ($action == 'view') {
|
||||
p($role->name);
|
||||
} else {
|
||||
echo '<input type="text" 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"><?php print_string('shortname') ?>:</td>
|
||||
<td><?php
|
||||
if ($action == 'view') {
|
||||
p($role->shortname);
|
||||
} else {
|
||||
echo '<input type="text" name="shortname" maxlength="20" size="15" value="'.s($role->shortname).'" />';
|
||||
if (isset($errors["shortname"])) formerr($errors["shortname"]);
|
||||
} ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('description') ?>:</td>
|
||||
<td><?php
|
||||
if ($action == 'view') {
|
||||
p($role->description);
|
||||
$usehtmleditor = false;
|
||||
} else {
|
||||
print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
|
||||
} ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
print_heading_with_help(get_string('permissions','role'), 'permissions');
|
||||
|
||||
$strinherit = get_string('notset','role');
|
||||
$strinherit = get_string('inherit','role');
|
||||
$strallow = get_string('allow','role');
|
||||
$strprevent = get_string('prevent','role');
|
||||
$strprohibit = get_string('prohibit','role');
|
||||
?>
|
||||
|
||||
<table class="rolecap">
|
||||
<table class="rolecap" align="center">
|
||||
|
||||
<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>
|
||||
<th class="name" align="left"><?php print_string('capability','role') ?></th>
|
||||
<th class="inherit"><?php p($strinherit); ?></th>
|
||||
<th class="allow"><?php p($strallow); ?></th>
|
||||
<th class="prevent"><?php p($strprevent); ?></th>
|
||||
<th class="prohibit"><?php p($strprohibit); ?></th>
|
||||
<th class="risk" colspan="5"><?php print_string('risks','role') ?></th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
@@ -113,23 +79,9 @@ $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;
|
||||
}
|
||||
$strcapabilities = s(get_string('capabilities', 'role'));
|
||||
|
||||
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 ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
|
||||
@@ -142,6 +94,7 @@ foreach ($capabilities as $capability) {
|
||||
|
||||
if (empty($errors)) {
|
||||
// check the capability override for this cap, this role in this context
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
$localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
|
||||
} else {
|
||||
$localoverride = new object();
|
||||
@@ -153,53 +106,39 @@ foreach ($capabilities as $capability) {
|
||||
$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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">T</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">C</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">X</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">P</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">S</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>
|
||||
<td class="name"><span class="cap-desc"><a 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></label></td>
|
||||
<td class="inherit"><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"><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" ><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" ><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; ?>
|
||||
|
||||
@@ -208,11 +147,11 @@ foreach ($capabilities as $capability) {
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php if ($action != 'view') { ?>
|
||||
<div class="submit buttons">
|
||||
<div class="submit" align="center">
|
||||
<input type="submit" value="<?php p($submitlabel) ?>" />
|
||||
<?php if ($action != 'view') { ?>
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
+32
-211
@@ -15,8 +15,7 @@
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
if ($cancel) {
|
||||
@@ -44,12 +43,6 @@
|
||||
$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) {
|
||||
@@ -57,12 +50,6 @@
|
||||
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');
|
||||
@@ -77,19 +64,12 @@
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$newrole = create_role($name, $shortname, $description);
|
||||
} else {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
@@ -99,12 +79,6 @@
|
||||
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)) {
|
||||
@@ -112,31 +86,21 @@
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
assign_capability($capname, $value, $newroleid, $sitecontext->id);
|
||||
assign_capability($capname, $value, $newrole, $sitecontext->id);
|
||||
} else {
|
||||
$newrole->$capname = $value;
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -157,10 +121,9 @@
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
@@ -170,12 +133,6 @@
|
||||
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)) {
|
||||
@@ -209,7 +166,6 @@
|
||||
assign_capability($capname, $value, $roleid, $sitecontext->id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
@@ -222,26 +178,12 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
add_to_log(SITEID, 'role', 'edit', 'admin/roles/manage.php?action=edit&roleid='.$role->id, $role->name, '', $USER->id);
|
||||
redirect('manage.php');
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
error('Could not delete role with ID '.$roleid);
|
||||
@@ -294,98 +236,9 @@
|
||||
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($adminroot);
|
||||
$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($adminroot);
|
||||
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 <= 15 chars
|
||||
$currentshortname = substr($shortname, 0, 15 - 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);
|
||||
}
|
||||
$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);
|
||||
$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($adminroot);
|
||||
$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($adminroot);
|
||||
die;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/// print UI now
|
||||
@@ -401,10 +254,9 @@
|
||||
$roleid = 0;
|
||||
if (empty($errors) or empty($newrole)) {
|
||||
$role = new object();
|
||||
$role->name = '';
|
||||
$role->shortname = '';
|
||||
$role->description = '';
|
||||
$role->legacytype = '';
|
||||
$role->name='';
|
||||
$role->shortname='';
|
||||
$role->description='';
|
||||
} else {
|
||||
$role = stripslashes_safe($newrole);
|
||||
}
|
||||
@@ -414,7 +266,6 @@
|
||||
if(!$role = get_record('role', 'id', $roleid)) {
|
||||
error('Incorrect role ID!');
|
||||
}
|
||||
$role->legacytype = get_legacy_type($role->id);
|
||||
}
|
||||
|
||||
foreach ($roles as $rolex) {
|
||||
@@ -441,28 +292,18 @@
|
||||
break;
|
||||
}
|
||||
|
||||
echo '<div class="selector">';
|
||||
echo '<div align="center" 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 get_string('selectrole', 'role').': ';
|
||||
echo '<form style="display:inline;" name="switchrole" action="manage.php" method="get">';
|
||||
echo '<input type="hidden" name="action" value="view" />';
|
||||
choose_from_menu ($roleoptions, 'roleid', $roleid, get_string('listallroles', 'role').'...', $script='switchrole.submit()');
|
||||
echo '</form>';
|
||||
echo '<form style="display:inline;" name="editrole" action="manage.php" method="get">';
|
||||
echo '<input type="hidden" name="roleid" value="'.$roleid.'" />';
|
||||
echo '<input type="hidden" name="action" value="edit" />';
|
||||
echo '<input type="submit" value="'.get_string('edit').'" />';
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
@@ -510,25 +351,21 @@
|
||||
$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> ';
|
||||
}
|
||||
$row[3] = '<a title="'.$stredit.'" href="manage.php?action=edit&roleid='.$role->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" alt="'.$stredit.'" /></a> ';
|
||||
$row[3] .= '<a title="'.$strdelete.'" href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/delete.gif" height="11" width="11" border="0" 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> ';
|
||||
$row[3] .= '<a title="'.$strmoveup.'" href="manage.php?action=moveup&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" height="11" width="11" border="0" alt="'.$strmoveup.'" /></a> ';
|
||||
} else {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" height="11" width="11" border="0" 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> ';
|
||||
$row[3] .= '<a title="'.$strmovedown.'" href="manage.php?action=movedown&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" height="11" width="11" border="0" alt="'.$strmovedown.'" /></a> ';
|
||||
} else {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" height="11" width="11" border="0" alt="" /> ';
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
@@ -538,9 +375,7 @@
|
||||
|
||||
$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($adminroot);
|
||||
@@ -583,18 +418,4 @@ function switch_roles($first, $second) {
|
||||
return $status;
|
||||
}
|
||||
|
||||
// duplicates all the base definitions of a role
|
||||
function role_cap_duplicate($sourcerole, $targetrole) {
|
||||
global $CFG;
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$caps = get_records_sql("SELECT * FROM {$CFG->prefix}role_capabilities
|
||||
WHERE roleid = $sourcerole->id
|
||||
AND contextid = $systemcontext->id");
|
||||
// adding capabilities
|
||||
foreach ($caps as $cap) {
|
||||
unset($cap->id);
|
||||
$cap->roleid = $targetrole;
|
||||
insert_record('role_capabilities', $cap);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
<?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'),'', true);
|
||||
|
||||
$toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allowassign.php', get_string('allowassign', 'role'));
|
||||
|
||||
+23
-36
@@ -5,23 +5,21 @@
|
||||
$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) ?>" />
|
||||
<form name="overrideform" action="override.php" method="post">
|
||||
<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>
|
||||
<th class="name" align="left"><?php print_string('capability','role') ?></th>
|
||||
<th class="inherit"><?php p($strinherit); ?></th>
|
||||
<th class="allow"><?php p($strallow); ?></th>
|
||||
<th class="prevent"><?php p($strprevent); ?></th>
|
||||
<th class="prohibit"><?php p($strprohibit); ?></th>
|
||||
<th class="risk" colspan="5"><?php print_string('risks','role') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -30,16 +28,9 @@
|
||||
$component = '';
|
||||
|
||||
$strrisks = s(get_string('risks', 'role'));
|
||||
// MDL-11687
|
||||
$strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
|
||||
$strcapabilities = 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) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
|
||||
@@ -66,37 +57,32 @@
|
||||
$isprohibit = 0;
|
||||
}
|
||||
|
||||
$isdisabled = $isprohibit;
|
||||
$isdisabled = $isprohibit || islegacy($capability->name);
|
||||
|
||||
$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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">T</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">C</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">X</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">P</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>';
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">S</a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
$riskinfo .= '</td>';
|
||||
@@ -105,33 +91,33 @@
|
||||
?>
|
||||
|
||||
<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="name"><span class="cap-desc"><a 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></label></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 ($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 ($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 ($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 ($localpermission == CAP_PROHIBIT) {echo ' checked="checked"';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
<?php echo $riskinfo; ?>
|
||||
@@ -139,7 +125,8 @@
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
<div class="submit buttons">
|
||||
<br />
|
||||
<div align="center">
|
||||
<input type="submit" value="<?php print_string('savechanges') ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
|
||||
+24
-50
@@ -2,7 +2,7 @@
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$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
|
||||
@@ -12,34 +12,29 @@
|
||||
error('Bad context ID');
|
||||
}
|
||||
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID)) {
|
||||
error('No site ID');
|
||||
}
|
||||
|
||||
if ($context->id == $sitecontext->id) {
|
||||
error('Can not override base role capabilities');
|
||||
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!');
|
||||
}
|
||||
require_capability('moodle/role:override', $context); // Just to make sure
|
||||
|
||||
if ($courseid) {
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Bad course ID');
|
||||
}
|
||||
} else {
|
||||
$course = clone($SITE);
|
||||
$courseid = SITEID;
|
||||
$course = $SITE;
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$baseurl = 'override.php?contextid='.$context->id;
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
if ($courseid != SITEID) {
|
||||
if (!empty($courseid)) {
|
||||
$baseurl .= '&courseid='.$courseid;
|
||||
}
|
||||
|
||||
@@ -47,9 +42,6 @@
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
/// needed for tabs.php
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
@@ -61,7 +53,6 @@
|
||||
$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');
|
||||
@@ -73,27 +64,18 @@
|
||||
$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);
|
||||
$capabilities = fetch_context_capabilities($context); // capabilities applicable in this context
|
||||
|
||||
$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)) {
|
||||
@@ -130,8 +112,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -149,20 +129,12 @@
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
print_header("$course->fullname: $fullname", $course->fullname,
|
||||
print_header("$course->fullname: $fullname", "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$course->id\">$fullname</a> -> $straction", "", "", 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');
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('frontpageroles', $adminroot);
|
||||
admin_externalpage_print_header($adminroot);
|
||||
$currenttab = '';
|
||||
$tabsmode = 'override';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
$currenttab = '';
|
||||
$tabsmode = 'override';
|
||||
@@ -171,14 +143,21 @@
|
||||
|
||||
print_heading_with_help(get_string('overrides', 'role'), 'overrides');
|
||||
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
|
||||
if ($roleid) {
|
||||
/// prints a form to swap roles
|
||||
echo '<div class="selector">';
|
||||
echo $strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
$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>';
|
||||
echo '<form name="rolesform" action="override.php" method="get">';
|
||||
echo '<div align="center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
if ($userid) {
|
||||
echo '<input type="hidden" name="userid" value="'.$userid.'" />';
|
||||
}
|
||||
if ($courseid) {
|
||||
echo '<input type="hidden" name="courseid" value="'.$courseid.'" />';
|
||||
}
|
||||
echo '<input type="hidden" name="contextid" value="'.$context->id.'" />'.$strroletooverride.': ';
|
||||
choose_from_menu ($overridableroles, 'roleid', $roleid, get_string('listallroles', 'role').'...', $script='rolesform.submit()');
|
||||
echo '</div></form>';
|
||||
|
||||
$parentcontexts = get_parent_contexts($context);
|
||||
if (!empty($parentcontexts)) {
|
||||
@@ -195,12 +174,11 @@
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
if (!empty($capabilities)) {
|
||||
// Print the capabilities overrideable in this context
|
||||
// Get the capabilities overrideable in this context
|
||||
if ($capabilities = fetch_context_capabilities($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);
|
||||
@@ -226,10 +204,6 @@
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM or ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID)) {
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
} else {
|
||||
print_footer($course);
|
||||
}
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
|
||||
+22
-46
@@ -1,11 +1,6 @@
|
||||
<?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
|
||||
}
|
||||
|
||||
if ($currenttab != 'update') {
|
||||
switch ($context->contextlevel) {
|
||||
@@ -32,16 +27,11 @@ if ($currenttab != 'update') {
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSE:
|
||||
if ($context->instanceid != SITEID) {
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
|
||||
$course = get_record('course', 'id', $context->instanceid);
|
||||
|
||||
require_login($course);
|
||||
|
||||
print_header($streditcoursesettings, $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $straction");
|
||||
}
|
||||
$course = get_record('course', 'id', $context->instanceid);
|
||||
print_header($streditcoursesettings, "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $straction");
|
||||
break;
|
||||
|
||||
case CONTEXT_GROUP:
|
||||
@@ -62,8 +52,6 @@ if ($currenttab != 'update') {
|
||||
error("The required instance of this module doesn't exist");
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">$instance->name</a> ->";
|
||||
$fullmodulename = get_string("modulename", $module->name);
|
||||
$streditinga = get_string("editinga", "moodle", $fullmodulename);
|
||||
@@ -75,9 +63,10 @@ if ($currenttab != 'update') {
|
||||
$focuscursor = "form.name";
|
||||
}
|
||||
|
||||
$COURSE = $course;
|
||||
print_header_simple($streditinga, '',
|
||||
"<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
|
||||
$strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
|
||||
$strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
|
||||
|
||||
break;
|
||||
|
||||
@@ -90,9 +79,6 @@ if ($currenttab != 'update') {
|
||||
switch ($blockinstance->pagetype) {
|
||||
case 'course-view':
|
||||
if ($course = get_record('course', 'id', $blockinstance->pageid)) {
|
||||
|
||||
require_login($course);
|
||||
|
||||
if ($course->id != SITEID) {
|
||||
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $navigation";
|
||||
}
|
||||
@@ -116,7 +102,7 @@ if ($currenttab != 'update') {
|
||||
break;
|
||||
|
||||
default:
|
||||
error ('This is an unknown context (' . $context->contextlevel . ') in admin/roles/tabs.php!');
|
||||
error ('This is an unknown context!');
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -135,8 +121,16 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex
|
||||
$toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.
|
||||
$context->id, get_string('roles'));
|
||||
|
||||
if (!empty($tabsmode)) {
|
||||
if (isset($tabsmode)) {
|
||||
|
||||
if (!isset($assignableroles)) {
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
}
|
||||
if (!isset($overridableroles)) {
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
}
|
||||
|
||||
$inactive[] = 'roles';
|
||||
if (!empty($assignableroles)) {
|
||||
$secondrow[] = new tabobject('assign',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
|
||||
@@ -153,32 +147,14 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex
|
||||
true);
|
||||
}
|
||||
|
||||
$inactive[] = 'roles';
|
||||
$activetwo = array('roles');
|
||||
$currenttab = $tabsmode;
|
||||
if ($tabsmode == 'override') {
|
||||
$currenttab = 'override';
|
||||
} elseif ($tabsmode == 'assign') {
|
||||
$currenttab = 'assign';
|
||||
}
|
||||
|
||||
} else {
|
||||
$inactive[] = '';
|
||||
$activetwo = array();
|
||||
}
|
||||
|
||||
/// Here other core tabs should go (always calling tabs.php files)
|
||||
/// All the logic to decide what to show must be self-cointained in the tabs file
|
||||
/// ej.:
|
||||
/// 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 mus be one $CFG->dirroot relative file
|
||||
if (file_exists($CFG->dirroot . '/' . $extratab)) {
|
||||
include_once($CFG->dirroot . '/' . $extratab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($secondrow)) {
|
||||
@@ -187,7 +163,7 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex
|
||||
$tabs = array($toprow);
|
||||
}
|
||||
|
||||
print_tabs($tabs, $currenttab, $inactive, $activetwo);
|
||||
print_tabs($tabs, $currenttab, $inactive);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+1
-8
@@ -58,11 +58,9 @@ if ($statusmsg != '') {
|
||||
|
||||
$resultshtml = search_settings_html(admin_get_root(), $query);
|
||||
|
||||
echo '<form action="search.php" method="post" id="adminsettings">';
|
||||
echo '<div>';
|
||||
echo '<form action="search.php" method="post" name="adminsettings" id="adminsettings">';
|
||||
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 != '') {
|
||||
@@ -114,11 +112,6 @@ function search_settings(&$node, $query) {
|
||||
function search_settings_html(&$node, $query) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($query == ''){
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_a($node, 'admin_category')) {
|
||||
$entries = array_keys($node->children);
|
||||
$return = '';
|
||||
|
||||
+22
-82
@@ -87,32 +87,6 @@ if ($data = data_submitted()) {
|
||||
|
||||
/// print header stuff ------------------------------------------------------------
|
||||
// header must be printed after the redirects and require_logout
|
||||
|
||||
if (empty($SITE->fullname)) {
|
||||
print_header();
|
||||
print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
|
||||
|
||||
if ($statusmsg != '') {
|
||||
notify ($statusmsg);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
echo '<form action="settings.php" method="post" id="adminsettings">';
|
||||
echo '<div class="settingsform">';
|
||||
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($root->visiblename);
|
||||
|
||||
echo $root->output_html();
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
if (!empty($SITE->fullname)) {
|
||||
$pageblocks = blocks_setup($PAGE);
|
||||
|
||||
@@ -124,74 +98,40 @@ if (!empty($SITE->fullname)) {
|
||||
$PAGE->print_header();
|
||||
|
||||
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">';
|
||||
if (!empty($THEME->roundcorners)) {
|
||||
echo '<div class="bt"><div></div></div>';
|
||||
echo '<div class="i1"><div class="i2"><div class="i3">';
|
||||
}
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
if (!empty($THEME->roundcorners)) {
|
||||
echo '</div></div></div>';
|
||||
echo '<div class="bb"><div></div></div>';
|
||||
}
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'middle':
|
||||
echo '<td id="middle-column">';
|
||||
if (!empty($THEME->roundcorners)) {
|
||||
echo '<div class="bt"><div></div></div>';
|
||||
echo '<div class="i1"><div class="i2"><div class="i3">';
|
||||
}
|
||||
echo '<a name="startofcontent"></a>';
|
||||
} else {
|
||||
|
||||
if ($statusmsg != '') {
|
||||
notify ($statusmsg);
|
||||
}
|
||||
print_header();
|
||||
print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
echo '<form action="settings.php" method="post" id="adminsettings">';
|
||||
echo '<div class="settingsform">';
|
||||
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($root->visiblename);
|
||||
if ($statusmsg != '') {
|
||||
notify ($statusmsg);
|
||||
}
|
||||
|
||||
echo $root->output_html();
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
|
||||
echo '<form action="settings.php" method="post" name="adminsettings" id="adminsettings">';
|
||||
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($root->visiblename);
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo $root->output_html();
|
||||
|
||||
if (!empty($THEME->roundcorners)) {
|
||||
echo '</div></div></div>';
|
||||
echo '<div class="bb"><div></div></div>';
|
||||
}
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($SITE->fullname)) {
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'right':
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
|
||||
if (!empty($THEME->roundcorners)) {
|
||||
echo '<div class="bt"><div></div></div>';
|
||||
echo '<div class="i1"><div class="i2"><div class="i3">';
|
||||
}
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
if (!empty($THEME->roundcorners)) {
|
||||
echo '</div></div></div>';
|
||||
echo '<div class="bb"><div></div></div>';
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo '</tr></table>';
|
||||
echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</td></tr></table>';
|
||||
}
|
||||
|
||||
if (!empty($CFG->adminusehtmleditor)) {
|
||||
|
||||
@@ -10,20 +10,39 @@ $temp->add(new admin_setting_configcheckbox('allowuserthemes', get_string('allow
|
||||
$temp->add(new admin_setting_configcheckbox('allowcoursethemes', get_string('allowcoursethemes', 'admin'), get_string('configallowcoursethemes', '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_configcheckbox('tabselectedtofront', get_string('tabselectedtofronttext', 'admin'), get_string('tabselectedtofront', 'admin'), 0));
|
||||
$ADMIN->add('themes', $temp);
|
||||
$ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php'));
|
||||
|
||||
# for CALENDAR_TF_12 and CALENDAR_TF_24 ...
|
||||
require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
|
||||
// "frontpage" settingpage
|
||||
$temp = new admin_settingpage('frontpage', get_string('frontpage','admin'));
|
||||
$temp->add(new admin_setting_sitesettext('fullname', get_string('fullsitename'), '', ''));
|
||||
$temp->add(new admin_setting_sitesettext('shortname', get_string('shortsitename'), '', ''));
|
||||
$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));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// calendar
|
||||
$temp = new admin_settingpage('calendar', get_string('calendarsettings','admin'));
|
||||
$temp->add(new admin_setting_special_adminseesall());
|
||||
$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'),
|
||||
CALENDAR_TF_12 => get_string('timeformat_12', 'calendar'),
|
||||
CALENDAR_TF_24 => 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'),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// This file defines settingpages and externalpages under the "courses" category
|
||||
|
||||
|
||||
$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('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on'));
|
||||
|
||||
$ADMIN->add('courses', new admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php'));
|
||||
|
||||
@@ -17,7 +17,7 @@ $ADMIN->add('courses', $temp);
|
||||
|
||||
|
||||
// "backups" settingpage
|
||||
$temp = new admin_settingpage('backups', get_string('backups','admin'),'moodle/site:backup');
|
||||
$temp = new admin_settingpage('backups', get_string('backups','admin'));
|
||||
$temp->add(new admin_setting_backupcheckbox('backup_sche_modules', get_string('includemodules'), get_string('backupincludemoduleshelp'), 0));
|
||||
$temp->add(new admin_setting_backupcheckbox('backup_sche_withuserdata', get_string('includemoduleuserdata'), get_string('backupincludemoduleuserdatahelp'), 0));
|
||||
$temp->add(new admin_setting_backupcheckbox('backup_sche_metacourse', get_string('metacourse'), get_string('backupmetacoursehelp'), 0));
|
||||
|
||||
@@ -1,45 +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);
|
||||
$frontpagecontextid = $frontpagecontext->id;
|
||||
} else {
|
||||
$frontpagecontext = NULL;
|
||||
$frontpagecontextid = 0;
|
||||
}
|
||||
|
||||
// "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'), '', ''));
|
||||
$temp->add(new admin_setting_sitesettext('shortname', get_string('shortsitename'), '', ''));
|
||||
$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));
|
||||
$ADMIN->add('frontpage', $temp);
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpageroles', get_string('frontpageroles', 'admin'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $frontpagecontextid, '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));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('sitefiles', get_string('sitefiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID, 'moodle/course:managefiles', false, $frontpagecontext));
|
||||
|
||||
?>
|
||||
@@ -6,16 +6,13 @@
|
||||
$temp = new admin_settingpage('langsettings', get_string('languagesettings', 'admin'));
|
||||
$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_configtext('langlist', get_string('langlist', 'admin'), get_string('configlanglist', 'admin'), '', PARAM_NOTAGS));
|
||||
$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"));
|
||||
$ADMIN->add('language', new admin_externalpage('langimport', get_string('langpacks', 'admin'), "$CFG->wwwroot/$CFG->admin/langimport.php"));
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ $temp = new admin_settingpage('locationsettings', get_string('locationsettings',
|
||||
$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 = get_list_of_timezones();
|
||||
$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();
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
$temp = new admin_settingpage('experimental', get_string('experimental', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 0));
|
||||
$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));
|
||||
$ADMIN->add('misc', $temp);
|
||||
|
||||
// XMLDB editor
|
||||
@@ -17,6 +16,5 @@ $ADMIN->add('misc', new admin_externalpage('xmldbeditor', get_string('xmldbedito
|
||||
$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)));
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "mnet" category
|
||||
|
||||
$ADMIN->add('mnet', new admin_externalpage('net', get_string('settings', 'mnet'),
|
||||
"$CFG->wwwroot/$CFG->admin/mnet/index.php",
|
||||
'moodle/site:config'));
|
||||
|
||||
$ADMIN->add('mnet', new admin_externalpage('mnetpeers', get_string('mnetpeers', 'mnet'),
|
||||
"$CFG->wwwroot/$CFG->admin/mnet/peers.php",
|
||||
'moodle/site:config'));
|
||||
$ADMIN->add('mnet', new admin_externalpage('ssoaccesscontrol', get_string('ssoaccesscontrol', 'mnet'),
|
||||
"$CFG->wwwroot/$CFG->admin/mnet/access_control.php",
|
||||
'moodle/site:config'));
|
||||
$ADMIN->add('mnet', new admin_externalpage('mnetenrol', get_string('mnetenrol', 'mnet'),
|
||||
"$CFG->wwwroot/$CFG->admin/mnet/enr_hosts.php",
|
||||
'moodle/site:config'));
|
||||
$ADMIN->add('mnet', new admin_externalpage('trustedhosts', get_string('trustedhosts', 'mnet'),
|
||||
"$CFG->wwwroot/$CFG->admin/mnet/trustedhosts.php",
|
||||
'moodle/site:config'));
|
||||
?>
|
||||
@@ -25,7 +25,7 @@ $temp->add(new admin_setting_configselect('fullnamedisplay', get_string('fullnam
|
||||
'lastname firstname' => get_string('lastname') . ' + ' . get_string('firstname'),
|
||||
'firstname' => get_string('firstname'))));
|
||||
$temp->add(new admin_setting_configcheckbox('extendedusernamechars', get_string('extendedusernamechars', 'admin'), get_string('configextendedusernamechars', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('sitepolicy', get_string('sitepolicy', 'admin'), get_string('configsitepolicy', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sitepolicy', get_string('sitepolicy', 'admin'), get_string('configsitepolicy', 'admin'), '', PARAM_URL));
|
||||
$temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', 'admin'), get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'),
|
||||
4 => get_string('siteblogs','blog'),
|
||||
3 => get_string('courseblogs','blog'),
|
||||
@@ -33,12 +33,6 @@ $temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', '
|
||||
1 => get_string('personalblogs','blog'),
|
||||
0 => get_string('disableblogs','blog'))));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('profilesforenrolledusersonly', get_string('profilesforenrolledusersonly','admin'),get_string('configprofilesforenrolledusersonly', 'admin'),'1'));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1));
|
||||
|
||||
$ADMIN->add('security', $temp);
|
||||
|
||||
|
||||
@@ -47,7 +41,7 @@ $ADMIN->add('security', $temp);
|
||||
// "httpsecurity" settingpage
|
||||
$temp = new admin_settingpage('httpsecurity', get_string('httpsecurity', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('loginhttps', get_string('loginhttps', 'admin'), get_string('configloginhttps', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('excludeoldflashclients', get_string('excludeoldflashclients', 'admin'), get_string('configexcludeoldflashclients', 'admin'), '10.0.12', PARAM_TEXT));
|
||||
$temp->add(new admin_setting_configcheckbox('secureforms', get_string('secureforms', 'admin'), get_string('configsecureforms', 'admin'), 0));
|
||||
$ADMIN->add('security', $temp);
|
||||
|
||||
|
||||
|
||||
+13
-40
@@ -17,7 +17,7 @@ $ADMIN->add('server', $temp, 0);
|
||||
|
||||
// "email" settingpage
|
||||
$temp = new admin_settingpage('mail', get_string('mail','admin'));
|
||||
$temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_HOST));
|
||||
$temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configtext('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . $_SERVER['HTTP_HOST'], PARAM_NOTAGS));
|
||||
@@ -47,13 +47,15 @@ $temp->add(new admin_setting_configselect('digestmailtime', get_string('digestma
|
||||
'21' => '21',
|
||||
'22' => '22',
|
||||
'23' => '23')));
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']); // not needed here
|
||||
$options = array();
|
||||
$options['0'] = get_string('none');
|
||||
$options = array_merge($options, $charsets);
|
||||
$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '', $options));
|
||||
$temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0));
|
||||
if (!empty($CFG->unicodedb)) { // These options are only available if running under unicodedb
|
||||
unset($options);
|
||||
unset($charsets);
|
||||
$charsets = get_list_of_charsets();
|
||||
$options['0'] = get_string('none');
|
||||
$options = array_merge($options, $charsets);
|
||||
$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '', $options));
|
||||
$temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0));
|
||||
}
|
||||
$ADMIN->add('server', $temp, 100);
|
||||
|
||||
|
||||
@@ -85,8 +87,6 @@ $ADMIN->add('server', $temp);
|
||||
// "debugging" settingpage
|
||||
$temp = new admin_settingpage('debugging', get_string('debugging', 'admin'));
|
||||
$temp->add(new admin_setting_special_debug());
|
||||
$temp->add(new admin_setting_special_debugdisplay());
|
||||
$temp->add(new admin_setting_configcheckbox('debugsmtp', get_string('debugsmtp', 'admin'), get_string('configdebugsmtp', 'admin'), 0));
|
||||
$temp->add(new admin_setting_special_perfdebug());
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
@@ -127,6 +127,8 @@ $temp->add(new admin_setting_configtext('proxyhost', get_string('proxyhost', 'ad
|
||||
$temp->add(new admin_setting_configtext('proxyport', get_string('proxyport', 'admin'), get_string('configproxyport', 'admin'), 0, PARAM_INT));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('sitefiles', get_string('sitefiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID));
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('maintenancemode', get_string('sitemaintenancemode', 'admin'), "$CFG->wwwroot/$CFG->admin/maintenance.php"));
|
||||
|
||||
|
||||
@@ -155,15 +157,6 @@ $temp->add(new admin_setting_configselect('deleteunconfirmed', get_string('delet
|
||||
6 => get_string('numhours', '', 6),
|
||||
1 => get_string('numhours', '', 1))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('deleteincompleteusers', get_string('deleteincompleteusers', 'admin'), get_string('configdeleteincompleteusers', 'admin'), 0, array(0 => get_string('never'),
|
||||
168 => get_string('numdays', '', 7),
|
||||
144 => get_string('numdays', '', 6),
|
||||
120 => get_string('numdays', '', 5),
|
||||
96 => get_string('numdays', '', 4),
|
||||
72 => get_string('numdays', '', 3),
|
||||
48 => get_string('numdays', '', 2),
|
||||
24 => get_string('numdays', '', 1))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('loglifetime', get_string('loglifetime', 'admin'), get_string('configloglifetime', 'admin'), 0, array(0 => get_string('neverdeletelogs'),
|
||||
1000 => get_string('numdays', '', 1000),
|
||||
365 => get_string('numdays', '', 365),
|
||||
@@ -184,27 +177,7 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), "
|
||||
|
||||
// "performance" settingpage
|
||||
$temp = new admin_settingpage('performance', get_string('performance', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('cachetype', get_string('cachetype', 'admin'),
|
||||
get_string('configcachetype', 'admin'), false,
|
||||
array( '' => 'none',
|
||||
'internal' => 'internal',
|
||||
'memcached' => 'memcached',
|
||||
'eaccelerator' => 'eaccelerator')));
|
||||
// NOTE: $CFG->rcache is forced to bool in lib/setup.php
|
||||
$temp->add(new admin_setting_configselect('rcache', get_string('rcache', 'admin'),
|
||||
get_string('configrcache', 'admin'), false,
|
||||
array( '0' => 'false',
|
||||
'1' => 'true')));
|
||||
$temp->add(new admin_setting_configtext('rcachettl', get_string('rcachettl', 'admin'),
|
||||
get_string('configrcachettl', 'admin'), 10));
|
||||
$temp->add(new admin_setting_configtext('intcachemax', get_string('intcachemax', 'admin'),
|
||||
get_string('configintcachemax', 'admin'), 10));
|
||||
$temp->add(new admin_setting_configtext('memcachedhosts', get_string('memcachedhosts', 'admin'),
|
||||
get_string('configmemcachedhosts', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configselect('memcachedpconn', get_string('memcachedpconn', 'admin'),
|
||||
get_string('configmemcachedpconn', 'admin'), false,
|
||||
array( '0' => 'false',
|
||||
'1' => 'true')));
|
||||
$temp->add(new admin_setting_configcheckbox('enablerecordcache', get_string('enablerecordcache', 'admin'), get_string('configenablerecordcache', 'admin'), 1));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/mysql/frame.php")) {
|
||||
|
||||
@@ -25,14 +25,12 @@ $ADMIN->add('modules', new admin_externalpage('managefilters', get_string('manag
|
||||
|
||||
$ADMIN->add('root', new admin_category('security', get_string('security','admin')));
|
||||
$ADMIN->add('root', new admin_category('appearance', get_string('appearance','admin')));
|
||||
$ADMIN->add('root', new admin_category('frontpage', get_string('frontpage','admin')));
|
||||
$ADMIN->add('root', new admin_category('server', get_string('server','admin')));
|
||||
$ADMIN->add('root', new admin_category('mnet', get_string('net','mnet')));
|
||||
|
||||
$ADMIN->add('root', new admin_category('reports', get_string('reports')));
|
||||
foreach (get_list_of_plugins('admin/report') as $plugin) {
|
||||
/// This snippet is temporary until simpletest can be fixed to use xmldb. See MDL-7377 XXX TODO
|
||||
if ($plugin == 'simpletest' && $CFG->dbfamily != 'mysql' && $CFG->dbfamily != 'postgres') {
|
||||
if ($plugin == 'simpletest' && $CFG->dbtype != 'mysql' && $CFG->dbtype != 'postgres7') {
|
||||
continue;
|
||||
}
|
||||
/// End of removable snippet
|
||||
|
||||
@@ -6,17 +6,11 @@
|
||||
$ADMIN->add('users', new admin_externalpage('userauthentication', get_string('authentication','admin'), "$CFG->wwwroot/$CFG->admin/auth.php"));
|
||||
|
||||
|
||||
if(empty($CFG->loginhttps)) {
|
||||
$securewwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
|
||||
}
|
||||
// stuff under the "accounts" subcategory
|
||||
$ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin')));
|
||||
$ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
|
||||
$ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
|
||||
$ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$CFG->wwwroot/$CFG->admin/user.php?newuser=true", 'moodle/user:create'));
|
||||
$ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers'));
|
||||
$ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config'));
|
||||
|
||||
|
||||
// stuff under the "roles" subcategory
|
||||
@@ -29,7 +23,7 @@ $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglo
|
||||
// "userpolicies" settingpage
|
||||
$temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
if (!$guestrole = get_guest_role()) {
|
||||
$guestrole->id = 0;
|
||||
}
|
||||
@@ -38,45 +32,16 @@ if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW
|
||||
} else {
|
||||
$studentrole->id = 0;
|
||||
}
|
||||
if ($userroles = get_roles_with_capability('moodle/legacy:user', CAP_ALLOW)) {
|
||||
$userrole = array_shift($userroles); /// Take the first one
|
||||
} else {
|
||||
$userrole->id = 0;
|
||||
}
|
||||
if (empty($CFG->creatornewroleid)) {
|
||||
if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, $context)) {
|
||||
$teachereditrole = array_shift($teacherroles);
|
||||
set_config('creatornewroleid', $teachereditrole->id);
|
||||
} else {
|
||||
set_config('creatornewroleid', 0);
|
||||
}
|
||||
}
|
||||
// we must not use assignable roles here:
|
||||
// 1/ unsetting roles as assignable for admin might bork the settings!
|
||||
// 2/ default user role should not be assignable anyway
|
||||
$allroles = array();
|
||||
if ($roles = get_all_roles()) {
|
||||
foreach ($roles as $role) {
|
||||
$allroles[$role->id] = strip_tags(format_string($role->name, true));
|
||||
}
|
||||
}
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
|
||||
$temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
|
||||
get_string('confignotloggedinroleid', 'admin'), $guestrole->id, $allroles ));
|
||||
$temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
|
||||
get_string('configguestroleid', 'admin'), $guestrole->id, $allroles));
|
||||
get_string('confignotloggedinroleid', 'admin'), $guestrole->id, $assignableroles ));
|
||||
$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
|
||||
get_string('configdefaultuserroleid', 'admin'), $userrole->id, $allroles));
|
||||
get_string('configdefaultuserroleid', 'admin'), $guestrole->id, $assignableroles));
|
||||
$temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
|
||||
get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles));
|
||||
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
|
||||
get_string('configcreatornewroleid', 'admin'), $CFG->creatornewroleid, $allroles));
|
||||
get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $assignableroles));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
|
||||
get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles));
|
||||
|
||||
//$temp->add(new admin_setting_configcheckbox('allusersaresitestudents', get_string('allusersaresitestudents', 'admin'), get_string('configallusersaresitestudents','admin'), 1));
|
||||
$temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
|
||||
get_string('confighiddenuserfields', 'admin'), array(),
|
||||
|
||||
@@ -63,16 +63,19 @@
|
||||
}
|
||||
|
||||
|
||||
print_box_start();
|
||||
print_simple_box_start('center');
|
||||
print_heading($strheading);
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/stickyblocks.php?pt=", $options, 'selecttype', $pt, 'choose', '', '', false, 'self', get_string('stickyblockspagetype','admin').': ');
|
||||
echo '<p>'.get_string('stickyblocksduplicatenotice','admin').'</p>';
|
||||
print_box_end();
|
||||
echo '<form method="post" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/stickyblocks.php">'
|
||||
.'<p align="center">'.get_string('stickyblockspagetype','admin').': ';
|
||||
choose_from_menu($options,'pt',$pt,'choose','this.form.submit();');
|
||||
echo '</p></form>';
|
||||
echo get_string('stickyblocksduplicatenotice','admin');
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
if (!empty($pt)) {
|
||||
echo '</td>';
|
||||
echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="right-column">';
|
||||
echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="left-column">';
|
||||
blocks_print_group($PAGE, $blocks, BLOCK_POS_RIGHT);
|
||||
echo '</td>';
|
||||
echo '</tr></table>';
|
||||
|
||||
+2
-2
@@ -33,8 +33,8 @@
|
||||
echo '<center><form action="timezone.php" method="get">';
|
||||
echo "$strusers ($strall): ";
|
||||
choose_from_menu ($timezones, "zone", 99, get_string("serverlocaltime"), "", "99");
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
|
||||
echo "<input type=\"submit\" value=\"$strsavechanges\" />";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
|
||||
echo "<input type=\"submit\" value=\"$strsavechanges\">";
|
||||
echo "</form></center>";
|
||||
|
||||
print_footer();
|
||||
|
||||
+13
-12
@@ -15,6 +15,7 @@
|
||||
|
||||
/// Print headings
|
||||
|
||||
$strcalendarsettings = get_string('calendarsettings', 'admin');
|
||||
$strimporttimezones = get_string('importtimezones', 'admin');
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
@@ -22,16 +23,16 @@
|
||||
print_heading($strimporttimezones);
|
||||
|
||||
if (!$ok or !confirm_sesskey()) {
|
||||
$message = '<br /><br />';
|
||||
$message = '<p>';
|
||||
$message .= $CFG->dataroot.'/temp/olson.txt<br />';
|
||||
$message .= $CFG->dataroot.'/temp/timezone.txt<br />';
|
||||
$message .= '<a href="http://download.moodle.org/timezone/">http://download.moodle.org/timezone/</a><br />';
|
||||
$message .= '<a href="'.$CFG->wwwroot.'/lib/timezone.txt">'.$CFG->dirroot.'/lib/timezone.txt</a><br />';
|
||||
$message .= '<br />';
|
||||
$message .= $CFG->dataroot.'/temp/timezones.txt<br />';
|
||||
$message .= '<a href="http://download.moodle.org/timezones/">http://download.moodle.org/timezones/</a><br />';
|
||||
$message .= '<a href="'.$CFG->wwwroot.'/lib/timezones.txt">'.$CFG->dirroot.'/lib/timezones.txt</a><br />';
|
||||
$message .= '</p>';
|
||||
|
||||
$message = get_string("configintrotimezones", 'admin', $message);
|
||||
|
||||
notice_yesno($message, 'timezoneimport.php?ok=1&sesskey='.sesskey(), 'index.php');
|
||||
notice_yesno($message, 'timezoneimport.php?ok=1&sesskey='.sesskey(), 'index.php');
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
exit;
|
||||
@@ -54,7 +55,7 @@
|
||||
|
||||
/// Next, look for a CSV file locally
|
||||
|
||||
$source = $CFG->dataroot.'/temp/timezone.txt';
|
||||
$source = $CFG->dataroot.'/temp/timezones.txt';
|
||||
if (!$importdone and is_readable($source)) {
|
||||
if ($timezones = get_records_csv($source, 'timezone')) {
|
||||
update_timezone_records($timezones);
|
||||
@@ -64,17 +65,17 @@
|
||||
|
||||
/// Otherwise, let's try moodle.org's copy
|
||||
|
||||
$source = 'http://download.moodle.org/timezone/';
|
||||
$source = 'http://download.moodle.org/timezones/';
|
||||
if (!$importdone and ini_get('allow_url_fopen')) {
|
||||
if (is_readable($source) && $contents = file_get_contents($source)) { // Grab whole page
|
||||
if ($file = fopen($CFG->dataroot.'/temp/timezone.txt', 'w')) { // Make local copy
|
||||
if ($file = fopen($CFG->dataroot.'/temp/timezones.txt', 'w')) { // Make local copy
|
||||
fwrite($file, $contents);
|
||||
fclose($file);
|
||||
if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezone.txt', 'timezone')) { // Parse it
|
||||
if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezones.txt', 'timezone')) { // Parse it
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
unlink($CFG->dataroot.'/temp/timezone.txt');
|
||||
unlink($CFG->dataroot.'/temp/timezones.txt');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +83,7 @@
|
||||
|
||||
/// Final resort, use the copy included in Moodle
|
||||
|
||||
$source = $CFG->dirroot.'/lib/timezone.txt';
|
||||
$source = $CFG->dirroot.'/lib/timezones.txt';
|
||||
if (!$importdone and is_readable($source)) { // Distribution file
|
||||
if ($timezones = get_records_csv($source, 'timezone')) {
|
||||
update_timezone_records($timezones);
|
||||
|
||||
@@ -52,7 +52,11 @@
|
||||
$starttime = time();
|
||||
$sleeptime = 0;
|
||||
|
||||
$LIKE = sql_ilike();
|
||||
if ($CFG->dbtype == "mysql") {
|
||||
$LIKE = "LIKE";
|
||||
} else {
|
||||
$LIKE = "ILIKE";
|
||||
}
|
||||
|
||||
if ($cmcount > 10) {
|
||||
print_simple_box('This process may take a very long time ... please be patient and let it finish.',
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
/// no guest autologin
|
||||
require_login(0, false);
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('upgradesettings', $adminroot); // now hidden page
|
||||
|
||||
@@ -61,12 +58,11 @@ admin_externalpage_print_header($adminroot);
|
||||
|
||||
print_simple_box(get_string('upgradesettingsintro','admin'),'','100%','',5,'generalbox','');
|
||||
|
||||
echo '<form action="upgradesettings.php" method="post" id="adminsettings">';
|
||||
echo '<form action="upgradesettings.php" method="post" name="adminsettings" id="adminsettings">';
|
||||
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
echo '<fieldset>';
|
||||
echo '<div class="clearer"><!-- --></div>';
|
||||
echo $newsettingshtml;
|
||||
echo '</fieldset>';
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
|
||||
echo '</form>';
|
||||
|
||||
|
||||
+29
-23
@@ -62,16 +62,13 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
// that we'll take longer, and that the process should be recycled soon
|
||||
// to free up memory.
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("192M");
|
||||
@raise_memory_limit("128M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
@apache_child_terminate();
|
||||
}
|
||||
|
||||
$text = my_file_get_contents($filename);
|
||||
//trim utf-8 bom
|
||||
$textlib = new textlib();
|
||||
$text = $textlib->trim_utf8_bom($text);
|
||||
//Fix mac/dos newlines
|
||||
$text = my_file_get_contents($filename);
|
||||
$text = preg_replace('!\r\n?!',"\n",$text);
|
||||
$fp = fopen($filename, "w");
|
||||
fwrite($fp,$text);
|
||||
@@ -85,8 +82,7 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
"firstname" => 1,
|
||||
"lastname" => 1,
|
||||
"email" => 1);
|
||||
$optionalDefaults = array("mnethostid" => 1,
|
||||
"institution" => 1,
|
||||
$optionalDefaults = array("institution" => 1,
|
||||
"department" => 1,
|
||||
"city" => 1,
|
||||
"country" => 1,
|
||||
@@ -104,6 +100,8 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
"maildisplay" => 1,
|
||||
"htmleditor" => 1,
|
||||
"autosubscribe" => 1,
|
||||
"idnumber" => 1,
|
||||
"icq" => 1,
|
||||
"course1" => 1,
|
||||
"course2" => 1,
|
||||
"course3" => 1,
|
||||
@@ -132,10 +130,10 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
// check for valid field names
|
||||
foreach ($header as $i => $h) {
|
||||
$h = trim($h); $header[$i] = $h; // remove whitespace
|
||||
if (!(isset($required[$h]) or isset($optionalDefaults[$h]) or isset($optional[$h]))) {
|
||||
if (!($required[$h] or $optionalDefaults[$h] or $optional[$h])) {
|
||||
error(get_string('invalidfieldname', 'error', $h), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
if (isset($required[$h])) {
|
||||
if ($required[$h]) {
|
||||
$required[$h] = 0;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +172,7 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
// add fields to object $user
|
||||
foreach ($record as $name => $value) {
|
||||
// check for required values
|
||||
if (isset($required[$name]) and !$value) {
|
||||
if ($required[$name] and !$value) {
|
||||
error(get_string('missingfield', 'error', $name). " ".
|
||||
get_string('erroronline', 'error', $linenum) .". ".
|
||||
get_string('processingstops', 'error'),
|
||||
@@ -228,11 +226,17 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->username === 'changeme') {
|
||||
notify(get_string('invaliduserchangeme', 'admin'));
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// before insert/update, check whether we should be updating
|
||||
// an old record instead
|
||||
if ($allowrenames && !empty($user->oldusername) ) {
|
||||
$user->oldusername = moodle_strtolower($user->oldusername);
|
||||
if ($olduser = get_record('user', 'username', $user->oldusername, 'mnethostid', $user->mnethostid)) {
|
||||
if ($olduser = get_record('user','username',$user->oldusername)) {
|
||||
if (set_field('user', 'username', $user->username, 'username', $user->oldusername)) {
|
||||
notify(get_string('userrenamed', 'admin') . " : $user->oldusername $user->username");
|
||||
$renames++;
|
||||
@@ -248,7 +252,7 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($olduser = get_record("user", "username", $username, "mnethostid", $user->mnethostid)) {
|
||||
if ($olduser = get_record("user","username",$username)) {
|
||||
if ($updateaccounts) {
|
||||
// Record is being updated
|
||||
$user->id = $olduser->id;
|
||||
@@ -266,6 +270,7 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
//This can be used to obtain a list of userids for existing users
|
||||
notify("$olduser->id ".get_string('usernotaddedregistered', 'error', $username));
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else { // new user
|
||||
@@ -299,8 +304,8 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
if (!$course[$i]) {
|
||||
notify(get_string('coursegroupunknown','error',$addgroup[$i]));
|
||||
} else {
|
||||
if ($gid = groups_get_group_by_name($course[$i]->id, $addgroup[$i])) {
|
||||
$groupid[$i] = $gid;
|
||||
if ($group = get_record("groups","courseid",$course[$i]->id,"name",$addgroup[$i])) {
|
||||
$groupid[$i] = $group->id;
|
||||
} else {
|
||||
notify(get_string('groupunknown','error',$addgroup[$i]));
|
||||
}
|
||||
@@ -374,13 +379,13 @@ print_heading_with_help($struploadusers, 'uploadusers');
|
||||
$noyesoptions = array( get_string('no'), get_string('yes') );
|
||||
|
||||
$maxuploadsize = get_max_upload_file_size();
|
||||
echo '<div style="text-align:center">';
|
||||
echo '<form method="post" enctype="multipart/form-data" action="uploaduser.php"><div>'.
|
||||
$strfile.' <input type="hidden" name="MAX_FILE_SIZE" value="'.$maxuploadsize.'" />'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
|
||||
'<input type="file" name="userfile" size="30" />';
|
||||
echo '<center>';
|
||||
echo '<form method="post" enctype="multipart/form-data" action="uploaduser.php">'.
|
||||
$strfile.' <input type="hidden" name="MAX_FILE_SIZE" value="'.$maxuploadsize.'">'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'">'.
|
||||
'<input type="file" name="userfile" size="30">';
|
||||
print_heading(get_string('settings'));
|
||||
echo '<table style="margin-left:auto;margin-right:auto">';
|
||||
echo '<table>';
|
||||
echo '<tr><td>' . get_string('passwordhandling', 'auth') . '</td><td>';
|
||||
$passwordopts = array( 0 => get_string('infilefield', 'auth'),
|
||||
1 => get_string('createpasswordifneeded', 'auth'),
|
||||
@@ -396,9 +401,9 @@ echo '<tr><td>' . get_string('allowrenames', 'admin') . '</td><td>';
|
||||
choose_from_menu($noyesoptions, 'allowrenames', $allowrenames);
|
||||
echo '</td></tr>';
|
||||
echo '</table><br />';
|
||||
echo '<input type="submit" value="'.$struploadusers.'" />';
|
||||
echo '</div></form><br />';
|
||||
echo '</div>';
|
||||
echo '<input type="submit" value="'.$struploadusers.'">';
|
||||
echo '</form><br />';
|
||||
echo '</center>';
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
@@ -419,3 +424,4 @@ function my_file_get_contents($filename, $use_include_path = 0) {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
+332
-378
@@ -3,6 +3,7 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$newuser = optional_param('newuser', 0, PARAM_BOOL);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$confirm = optional_param('confirm', '', PARAM_ALPHANUM); //md5 confirmation hash
|
||||
$confirmuser = optional_param('confirmuser', 0, PARAM_INT);
|
||||
@@ -13,427 +14,380 @@
|
||||
$search = trim(optional_param('search', '', PARAM_RAW));
|
||||
$lastinitial = optional_param('lastinitial', '', PARAM_CLEAN); // only show students with this last initial
|
||||
$firstinitial = optional_param('firstinitial', '', PARAM_CLEAN); // only show students with this first initial
|
||||
$ru = optional_param('ru', '2', PARAM_INT); // show remote users
|
||||
$lu = optional_param('lu', '2', PARAM_INT); // show local users
|
||||
$acl = optional_param('acl', '0', PARAM_INT); // id of user to tweak mnet ACL (requires $access)
|
||||
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID)) { // Should never happen
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
if (empty($CFG->rolesactive)) { // No admin user yet.
|
||||
|
||||
$user = new object();
|
||||
$user->firstname = get_string('admin');
|
||||
$user->lastname = get_string('user');
|
||||
$user->username = 'admin';
|
||||
$user->password = hash_internal_user_password('admin');
|
||||
$user->email = 'root@localhost';
|
||||
$user->confirmed = 1;
|
||||
$user->lang = $CFG->lang;
|
||||
$user->maildisplay = 1;
|
||||
$user->timemodified = time();
|
||||
|
||||
if (! $user->id = insert_record('user', $user)) {
|
||||
error("SERIOUS ERROR: Could not create admin user record !!!");
|
||||
}
|
||||
|
||||
if (! $user = get_record('user', 'id', $user->id)) { // Double check.
|
||||
error("User ID was incorrect (can't find it)");
|
||||
}
|
||||
|
||||
|
||||
// Assign the default admin role to the new user.
|
||||
if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
|
||||
error('No admin role could be found');
|
||||
}
|
||||
foreach ($adminroles as $adminrole) {
|
||||
role_assign($adminrole->id, $user->id, 0, $sitecontext->id);
|
||||
}
|
||||
set_config('rolesactive', 1);
|
||||
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Could not find site-level course");
|
||||
}
|
||||
|
||||
// Log the user in.
|
||||
$USER = $user;
|
||||
$USER->loggedin = true;
|
||||
$USER->sessionIP = md5(getremoteaddr()); // Store the current IP in the session
|
||||
$USER->site = $CFG->wwwroot;
|
||||
$USER->admin = true;
|
||||
$USER->newadminuser = true;
|
||||
|
||||
sesskey(); // For added security, used to check script parameters
|
||||
|
||||
load_all_capabilities();
|
||||
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id"); // Edit thyself
|
||||
exit;
|
||||
|
||||
} else {
|
||||
if (! $site = get_site()) {
|
||||
error("Could not find site-level course");
|
||||
}
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('editusers', $adminroot);
|
||||
|
||||
// Let's see if we have *any* mnet users. Just ask for a single record
|
||||
$mnet_users = get_records_select('user', " auth='mnet' AND mnethostid != '{$CFG->mnet_localhost_id}' ", '', '*', '0', '1');
|
||||
if(is_array($mnet_users) && count($mnet_users) > 0) {
|
||||
$mnet_auth_users = true;
|
||||
if ($newuser) {
|
||||
admin_externalpage_setup('addnewuser', $adminroot);
|
||||
} else {
|
||||
$mnet_auth_users = false;
|
||||
}
|
||||
|
||||
if($mnet_auth_users) {
|
||||
// Determine which users we are looking at (local, remote, or both). Start with both.
|
||||
if (!isset($_SESSION['admin-user-remoteusers'])) {
|
||||
$_SESSION['admin-user-remoteusers'] = 1;
|
||||
$_SESSION['admin-user-localusers'] = 1;
|
||||
}
|
||||
if ($ru == 0 or $ru == 1) {
|
||||
$_SESSION['admin-user-remoteusers'] = $ru;
|
||||
}
|
||||
if ($lu == 0 or $lu == 1) {
|
||||
$_SESSION['admin-user-localusers'] = $lu;
|
||||
}
|
||||
$remoteusers = $_SESSION['admin-user-remoteusers'];
|
||||
$localusers = $_SESSION['admin-user-localusers'];
|
||||
|
||||
// if neither remote nor local, set to sensible local only
|
||||
if (!$remoteusers and !$localusers) {
|
||||
$_SESSION['admin-user-localusers'] = 1;
|
||||
$localusers = 1;
|
||||
}
|
||||
admin_externalpage_setup('editusers', $adminroot);
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
$site = get_site();
|
||||
|
||||
if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) {
|
||||
error('You do not have the required permission to edit/delete users.');
|
||||
}
|
||||
if ($newuser) { // Create a new user
|
||||
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strdeletecheck = get_string('deletecheck');
|
||||
$strsearch = get_string('search');
|
||||
$strshowallusers = get_string('showallusers');
|
||||
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$securewwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
|
||||
}
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
if ($confirmuser and confirm_sesskey()) {
|
||||
if (!$user = get_record('user', 'id', $confirmuser)) {
|
||||
error("No such user!", '', true);
|
||||
if (!has_capability('moodle/user:create', $sitecontext)) {
|
||||
error('You do not have the required permission to create new users.');
|
||||
}
|
||||
|
||||
$auth = get_auth_plugin($user->auth);
|
||||
if (!$user = get_record('user', 'username', 'changeme')) { // half finished user from another time
|
||||
|
||||
$result = $auth->user_confirm(addslashes($user->username), addslashes($user->secret));
|
||||
$user = new object();
|
||||
$user->auth = 'manual';
|
||||
$user->firstname = '';
|
||||
$user->lastname = '';
|
||||
$user->username = 'changeme';
|
||||
$user->password = '';
|
||||
$user->email = '';
|
||||
$user->lang = $CFG->lang;
|
||||
$user->confirmed = 1;
|
||||
$user->timemodified = time();
|
||||
|
||||
if ($result == AUTH_CONFIRM_OK or $result == AUTH_CONFIRM_ALREADY) {
|
||||
notify(get_string('userconfirmed', '', fullname($user, true)) );
|
||||
} else {
|
||||
notify(get_string('usernotconfirmed', '', fullname($user, true)));
|
||||
if (! $user->id = insert_record('user', $user)) {
|
||||
error('Could not start a new user!');
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
error('You do not have the required permission to delete a user.');
|
||||
} else { // List all users for editing
|
||||
|
||||
if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) {
|
||||
error('You do not have the required permission to edit/delete users.');
|
||||
}
|
||||
|
||||
if (!$user = get_record('user', 'id', $delete)) {
|
||||
error("No such user!", '', true);
|
||||
}
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strdeletecheck = get_string('deletecheck');
|
||||
$strsearch = get_string('search');
|
||||
$strshowallusers = get_string('showallusers');
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
if ($user->id == $primaryadmin->id) {
|
||||
error("You are not allowed to delete the primary admin user!", '', true);
|
||||
}
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
if ($confirm != md5($delete)) {
|
||||
$fullname = fullname($user, true);
|
||||
print_heading(get_string('deleteuser', 'admin'));
|
||||
$optionsyes = array('delete'=>$delete, 'confirm'=>md5($delete), 'sesskey'=>sesskey());
|
||||
notice_yesno(get_string('deletecheckfull', '', "'$fullname'"), 'user.php', 'user.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
die;
|
||||
} else if (data_submitted() and !$user->deleted) {
|
||||
//following code is also used in auth sync scripts
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time()); // Remember it just in case
|
||||
$updateuser->email = md5($user->username); // Store hash of username, useful importing/restoring users
|
||||
$updateuser->idnumber = ''; // Clear this field to free it up
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record('user', $updateuser)) {
|
||||
// Removing a user may have more requirements than just removing their role assignments.
|
||||
// Use 'role_unassign' to make sure that all necessary actions occur.
|
||||
role_unassign(0, $user->id);
|
||||
// remove all context assigned on this user?
|
||||
notify(get_string('deletedactivity', '', fullname($user, true)) );
|
||||
if ($confirmuser and confirm_sesskey()) {
|
||||
if (!$user = get_record('user', 'id', $confirmuser)) {
|
||||
error("No such user!");
|
||||
}
|
||||
|
||||
$confirmeduser = new object();
|
||||
$confirmeduser->id = $confirmuser;
|
||||
$confirmeduser->confirmed = 1;
|
||||
$confirmeduser->timemodified = time();
|
||||
|
||||
if (update_record('user', $confirmeduser)) {
|
||||
notify(get_string('userconfirmed', '', fullname($user, true)) );
|
||||
} else {
|
||||
notify(get_string('deletednot', '', fullname($user, true)));
|
||||
notify(get_string('usernotconfirmed', '', fullname($user, true)));
|
||||
}
|
||||
|
||||
} else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation
|
||||
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
error('You do not have the required permission to delete a user.');
|
||||
}
|
||||
|
||||
if (!$user = get_record('user', 'id', $delete)) {
|
||||
error("No such user!");
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
if ($user->id == $primaryadmin->id) {
|
||||
error("You are not allowed to delete the primary admin user!");
|
||||
}
|
||||
|
||||
if ($confirm != md5($delete)) {
|
||||
$fullname = fullname($user, true);
|
||||
print_heading(get_string('deleteuser', 'admin'));
|
||||
$optionsyes = array('delete'=>$delete, 'confirm'=>md5($delete), 'sesskey'=>sesskey());
|
||||
notice_yesno(get_string('deletecheckfull', '', "'$fullname'"), 'user.php', 'user.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
die;
|
||||
} else if (data_submitted() and !$user->deleted) {
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time()); // Remember it just in case
|
||||
$updateuser->email = ''; // Clear this field to free it up
|
||||
$updateuser->idnumber = ''; // Clear this field to free it up
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record('user', $updateuser)) {
|
||||
// not sure if this is needed. unenrol_student($user->id); // From all courses
|
||||
delete_records('role_assignments', 'userid', $user->id); // unassign all roles
|
||||
// remove all context assigned on this user?
|
||||
notify(get_string('deletedactivity', '', fullname($user, true)) );
|
||||
} else {
|
||||
notify(get_string('deletednot', '', fullname($user, true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($acl and confirm_sesskey()) {
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
// TODO: this should be under a separate capability
|
||||
error('You are not permitted to modify the MNET access control list.');
|
||||
}
|
||||
if (!$user = get_record('user', 'id', $acl)) {
|
||||
error("No such user.", '', true);
|
||||
}
|
||||
if (!is_mnet_remote_user($user)) {
|
||||
error('Users in the MNET access control list must be remote MNET users.');
|
||||
}
|
||||
$accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA));
|
||||
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
|
||||
error('Invalid access parameter.');
|
||||
}
|
||||
$aclrecord = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid);
|
||||
if (empty($aclrecord)) {
|
||||
$aclrecord = new object();
|
||||
$aclrecord->mnet_host_id = $user->mnethostid;
|
||||
$aclrecord->username = $user->username;
|
||||
$aclrecord->accessctrl = $accessctrl;
|
||||
if (!insert_record('mnet_sso_access_control', $aclrecord)) {
|
||||
error("Database error - Couldn't modify the MNET access control list.", '', true);
|
||||
}
|
||||
} else {
|
||||
$aclrecord->accessctrl = $accessctrl;
|
||||
if (!update_record('mnet_sso_access_control', $aclrecord)) {
|
||||
error("Database error - Couldn't modify the MNET access control list.", '', true);
|
||||
}
|
||||
}
|
||||
$mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name');
|
||||
notify("MNET access control list updated: username '$user->username' from host '"
|
||||
. $mnethosts[$user->mnethostid]->name
|
||||
. "' access now set to '$accessctrl'.");
|
||||
}
|
||||
|
||||
// Carry on with the user listing
|
||||
// Carry on with the user listing
|
||||
|
||||
$columns = array("firstname", "lastname", "email", "city", "country", "lastaccess");
|
||||
$columns = array("firstname", "lastname", "email", "city", "country", "lastaccess");
|
||||
|
||||
foreach ($columns as $column) {
|
||||
$string[$column] = get_string("$column");
|
||||
if ($sort != $column) {
|
||||
$columnicon = "";
|
||||
if ($column == "lastaccess") {
|
||||
$columndir = "DESC";
|
||||
foreach ($columns as $column) {
|
||||
$string[$column] = get_string("$column");
|
||||
if ($sort != $column) {
|
||||
$columnicon = "";
|
||||
if ($column == "lastaccess") {
|
||||
$columndir = "DESC";
|
||||
} else {
|
||||
$columndir = "ASC";
|
||||
}
|
||||
} else {
|
||||
$columndir = "ASC";
|
||||
$columndir = $dir == "ASC" ? "DESC":"ASC";
|
||||
if ($column == "lastaccess") {
|
||||
$columnicon = $dir == "ASC" ? "up":"down";
|
||||
} else {
|
||||
$columnicon = $dir == "ASC" ? "down":"up";
|
||||
}
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\" />";
|
||||
|
||||
}
|
||||
$$column = "<a href=\"user.php?sort=$column&dir=$columndir&search=".urlencode(stripslashes($search))."&firstinitial=$firstinitial&lastinitial=$lastinitial\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
|
||||
if ($sort == "name") {
|
||||
$sort = "firstname";
|
||||
}
|
||||
|
||||
$users = get_users_listing($sort, $dir, $page*$perpage, $perpage, $search, $firstinitial, $lastinitial);
|
||||
$usercount = get_users(false);
|
||||
$usersearchcount = get_users(false, $search, true, "", "", $firstinitial, $lastinitial);
|
||||
|
||||
if ($search or $firstinitial or $lastinitial) {
|
||||
print_heading("$usersearchcount / $usercount ".get_string('users'));
|
||||
$usercount = $usersearchcount;
|
||||
} else {
|
||||
$columndir = $dir == "ASC" ? "DESC":"ASC";
|
||||
if ($column == "lastaccess") {
|
||||
$columnicon = $dir == "ASC" ? "up":"down";
|
||||
} else {
|
||||
$columnicon = $dir == "ASC" ? "down":"up";
|
||||
}
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\" />";
|
||||
|
||||
print_heading("$usercount ".get_string('users'));
|
||||
}
|
||||
$$column = "<a href=\"user.php?sort=$column&dir=$columndir&search=".urlencode(stripslashes($search))."&firstinitial=$firstinitial&lastinitial=$lastinitial\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
|
||||
if ($sort == "name") {
|
||||
$sort = "firstname";
|
||||
}
|
||||
|
||||
// tell the query which users we are looking at (local, remote, or both)
|
||||
$remotewhere = '';
|
||||
if($mnet_auth_users && ($localusers XOR $remoteusers)) {
|
||||
if ($localusers) {
|
||||
$remotewhere .= " and mnethostid = {$CFG->mnet_localhost_id} ";
|
||||
} else {
|
||||
$remotewhere .= " and mnethostid <> {$CFG->mnet_localhost_id} ";
|
||||
}
|
||||
}
|
||||
|
||||
$users = get_users_listing($sort, $dir, $page*$perpage, $perpage, $search, $firstinitial, $lastinitial, $remotewhere, false);
|
||||
$usercount = get_users(false);
|
||||
$usersearchcount = get_users(false, $search, true, "", "", $firstinitial, $lastinitial);
|
||||
|
||||
if ($search or $firstinitial or $lastinitial) {
|
||||
print_heading("$usersearchcount / $usercount ".get_string('users'));
|
||||
$usercount = $usersearchcount;
|
||||
} else {
|
||||
print_heading("$usercount ".get_string('users'));
|
||||
}
|
||||
|
||||
$alphabet = explode(',', get_string('alphabet'));
|
||||
$strall = get_string('all');
|
||||
$alphabet = explode(',', get_string('alphabet'));
|
||||
$strall = get_string('all');
|
||||
|
||||
|
||||
/// Bar of first initials
|
||||
/// Bar of first initials
|
||||
|
||||
echo "<p style=\"text-align:center\">";
|
||||
echo get_string("firstname")." : ";
|
||||
if ($firstinitial) {
|
||||
echo " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
foreach ($alphabet as $letter) {
|
||||
if ($letter == $firstinitial) {
|
||||
echo " <b>$letter</b> ";
|
||||
} else {
|
||||
echo " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter</a> ";
|
||||
}
|
||||
}
|
||||
echo "<br />";
|
||||
|
||||
/// Bar of last initials
|
||||
|
||||
echo get_string("lastname")." : ";
|
||||
if ($lastinitial) {
|
||||
echo " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
foreach ($alphabet as $letter) {
|
||||
if ($letter == $lastinitial) {
|
||||
echo " <b>$letter</b> ";
|
||||
} else {
|
||||
echo " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter</a> ";
|
||||
}
|
||||
}
|
||||
echo "</p>";
|
||||
|
||||
print_paging_bar($usercount, $page, $perpage,
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
|
||||
|
||||
flush();
|
||||
|
||||
|
||||
if (!$users) {
|
||||
$match = array();
|
||||
if ($search !== '') {
|
||||
$match[] = s($search);
|
||||
}
|
||||
echo "<center><p align=\"center\">";
|
||||
echo get_string("firstname")." : ";
|
||||
if ($firstinitial) {
|
||||
$match[] = get_string('firstname').": $firstinitial"."___";
|
||||
echo " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
foreach ($alphabet as $letter) {
|
||||
if ($letter == $firstinitial) {
|
||||
echo " <b>$letter</b> ";
|
||||
} else {
|
||||
echo " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter</a> ";
|
||||
}
|
||||
}
|
||||
echo "<br />";
|
||||
|
||||
/// Bar of last initials
|
||||
|
||||
echo get_string("lastname")." : ";
|
||||
if ($lastinitial) {
|
||||
$match[] = get_string('lastname').": $lastinitial"."___";
|
||||
}
|
||||
$matchstring = implode(", ", $match);
|
||||
print_heading(get_string('nousersmatching', '', $matchstring));
|
||||
|
||||
$table = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
$countries = get_list_of_countries();
|
||||
if (empty($mnethosts)) {
|
||||
$mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name');
|
||||
}
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
if (!empty($user->country)) {
|
||||
$users[$key]->country = $countries[$user->country];
|
||||
}
|
||||
}
|
||||
if ($sort == "country") { // Need to resort by full country name, not code
|
||||
foreach ($users as $user) {
|
||||
$susers[$user->id] = $user->country;
|
||||
}
|
||||
asort($susers);
|
||||
foreach ($susers as $key => $value) {
|
||||
$nusers[] = $users[$key];
|
||||
}
|
||||
$users = $nusers;
|
||||
}
|
||||
|
||||
$mainadmin = get_admin();
|
||||
|
||||
$override = new object();
|
||||
$override->firstname = 'firstname';
|
||||
$override->lastname = 'lastname';
|
||||
$fullnamelanguage = get_string('fullnamedisplay', '', $override);
|
||||
if (($CFG->fullnamedisplay == 'firstname lastname') or
|
||||
($CFG->fullnamedisplay == 'firstname') or
|
||||
($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname' )) {
|
||||
$fullnamedisplay = "$firstname / $lastname";
|
||||
} else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname')
|
||||
$fullnamedisplay = "$lastname / $firstname";
|
||||
}
|
||||
$table->head = array ($fullnamedisplay, $email, $city, $country, $lastaccess, "", "", "");
|
||||
$table->align = array ("left", "left", "left", "left", "left", "center", "center", "center");
|
||||
$table->width = "95%";
|
||||
foreach ($users as $user) {
|
||||
if ($user->username == 'guest') {
|
||||
continue; // do not dispaly dummy new user and guest here
|
||||
}
|
||||
|
||||
if ($user->id == $USER->id) {
|
||||
$deletebutton = "";
|
||||
} else {
|
||||
if (has_capability('moodle/user:delete', $sitecontext)) {
|
||||
$deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
} else {
|
||||
$deletebutton ="";
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/user:update', $sitecontext) and ($user->id==$USER->id or $user->id != $mainadmin->id) and !is_mnet_remote_user($user)) {
|
||||
$editbutton = "<a href=\"$securewwwroot/user/editadvanced.php?id=$user->id&course=$site->id\">$stredit</a>";
|
||||
if ($user->confirmed == 0) {
|
||||
$confirmbutton = "<a href=\"user.php?confirmuser=$user->id&sesskey=$USER->sesskey\">" . get_string('confirm') . "</a>";
|
||||
} else {
|
||||
$confirmbutton = "";
|
||||
}
|
||||
} else {
|
||||
$editbutton ="";
|
||||
if ($user->confirmed == 0) {
|
||||
$confirmbutton = "<span class=\"dimmed_text\">".get_string('confirm')."</span>";
|
||||
} else {
|
||||
$confirmbutton = "";
|
||||
}
|
||||
}
|
||||
|
||||
// for remote users, shuffle columns around and display MNET stuff
|
||||
if (is_mnet_remote_user($user)) {
|
||||
$accessctrl = 'allow';
|
||||
if ($acl = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid)) {
|
||||
$accessctrl = $acl->accessctrl;
|
||||
}
|
||||
$changeaccessto = ($accessctrl == 'deny' ? 'allow' : 'deny');
|
||||
// delete button in confirm column - remote users should already be confirmed
|
||||
// TODO: no delete for remote users, for now. new userid, delete flag, unique on username/host...
|
||||
$confirmbutton = "";
|
||||
// ACL in delete column
|
||||
$deletebutton = get_string($accessctrl, 'mnet');
|
||||
if (has_capability('moodle/user:delete', $sitecontext)) {
|
||||
// TODO: this should be under a separate capability
|
||||
$deletebutton .= " (<a href=\"?acl={$user->id}&accessctrl=$changeaccessto&sesskey={$USER->sesskey}\">"
|
||||
. get_string($changeaccessto, 'mnet') . " access</a>)";
|
||||
}
|
||||
// mnet info in edit column
|
||||
if (isset($mnethosts[$user->mnethostid])) {
|
||||
$editbutton = $mnethosts[$user->mnethostid]->name;
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->lastaccess) {
|
||||
$strlastaccess = format_time(time() - $user->lastaccess);
|
||||
} else {
|
||||
$strlastaccess = get_string('never');
|
||||
}
|
||||
$fullname = fullname($user, true);
|
||||
|
||||
$table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
|
||||
"$user->email",
|
||||
"$user->city",
|
||||
"$user->country",
|
||||
$strlastaccess,
|
||||
$editbutton,
|
||||
$deletebutton,
|
||||
$confirmbutton);
|
||||
}
|
||||
}
|
||||
|
||||
if($mnet_auth_users) {
|
||||
echo "<p style=\"text-align:center\">";
|
||||
if ($localusers == 1 && $remoteusers == 1) {
|
||||
echo '<a href="?lu=0">'.get_string('hidelocal','mnet').'</a> | ';
|
||||
} elseif ($localusers == 0) {
|
||||
echo '<a href="?lu=1">'.get_string('showlocal','mnet').'</a> | ';
|
||||
echo " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo get_string('hidelocal','mnet').' | ';
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
if ($localusers == 1 && $remoteusers == 1) {
|
||||
echo '<a href="?ru=0">'.get_string('hideremote','mnet').'</a>';
|
||||
} elseif ($remoteusers == 0) {
|
||||
echo '<a href="?ru=1">'.get_string('showremote','mnet').'</a>';
|
||||
} else {
|
||||
echo get_string('hideremote','mnet');
|
||||
foreach ($alphabet as $letter) {
|
||||
if ($letter == $lastinitial) {
|
||||
echo " <b>$letter</b> ";
|
||||
} else {
|
||||
echo " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter</a> ";
|
||||
}
|
||||
}
|
||||
echo "</p>";
|
||||
}
|
||||
echo "</center>";
|
||||
|
||||
echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>";
|
||||
echo "<form action=\"user.php\" method=\"get\"><fieldset class=\"invisiblefieldset\">";
|
||||
echo "<input type=\"text\" name=\"search\" value=\"".s($search, true)."\" size=\"20\" />";
|
||||
echo "<input type=\"submit\" value=\"$strsearch\" />";
|
||||
if ($search) {
|
||||
echo "<input type=\"button\" onclick=\"document.location='user.php';\" value=\"$strshowallusers\" />";
|
||||
}
|
||||
echo "</fieldset></form>";
|
||||
echo "</td></tr></table>";
|
||||
|
||||
if (has_capability('moodle/user:create', $sitecontext)) {
|
||||
print_heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
|
||||
}
|
||||
if (!empty($table)) {
|
||||
print_table($table);
|
||||
print_paging_bar($usercount, $page, $perpage,
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage".
|
||||
"&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
|
||||
if (has_capability('moodle/user:create', $sitecontext)) {
|
||||
print_heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
|
||||
|
||||
flush();
|
||||
|
||||
|
||||
if (!$users) {
|
||||
$match = array();
|
||||
if ($search !== '') {
|
||||
$match[] = s($search);
|
||||
}
|
||||
if ($firstinitial) {
|
||||
$match[] = get_string('firstname').": $firstinitial"."___";
|
||||
}
|
||||
if ($lastinitial) {
|
||||
$match[] = get_string('lastname').": $lastinitial"."___";
|
||||
}
|
||||
$matchstring = implode(", ", $match);
|
||||
print_heading(get_string('nousersmatching', '', $matchstring));
|
||||
|
||||
$table = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
$countries = get_list_of_countries();
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
if (!empty($user->country)) {
|
||||
$users[$key]->country = $countries[$user->country];
|
||||
}
|
||||
}
|
||||
if ($sort == "country") { // Need to resort by full country name, not code
|
||||
foreach ($users as $user) {
|
||||
$susers[$user->id] = $user->country;
|
||||
}
|
||||
asort($susers);
|
||||
foreach ($susers as $key => $value) {
|
||||
$nusers[] = $users[$key];
|
||||
}
|
||||
$users = $nusers;
|
||||
}
|
||||
|
||||
$table->head = array ("$firstname / $lastname", $email, $city, $country, $lastaccess, "", "", "");
|
||||
$table->align = array ("left", "left", "left", "left", "left", "center", "center", "center");
|
||||
$table->width = "95%";
|
||||
foreach ($users as $user) {
|
||||
if ($user->username == 'changeme' or $user->username == 'guest') {
|
||||
continue; // do not dispaly dummy new user and guest here
|
||||
}
|
||||
|
||||
if ($user->id == $USER->id) {
|
||||
$deletebutton = "";
|
||||
} else {
|
||||
if (has_capability('moodle/user:delete', $sitecontext)) {
|
||||
$deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
} else {
|
||||
$deletebutton ="";
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/user:update', $sitecontext)) {
|
||||
$editbutton = "<a href=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</a>";
|
||||
if ($user->confirmed == 0) {
|
||||
$confirmbutton = "<a href=\"user.php?confirmuser=$user->id&sesskey=$USER->sesskey\">" . get_string('confirm') . "</a>";
|
||||
} else {
|
||||
$confirmbutton = "";
|
||||
}
|
||||
} else {
|
||||
$editbutton ="";
|
||||
if ($user->confirmed == 0) {
|
||||
$confirmbutton = "<span class=\"dimmed_text\">".get_string('confirm')."</span>";
|
||||
} else {
|
||||
$confirmbutton = "";
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->lastaccess) {
|
||||
$strlastaccess = format_time(time() - $user->lastaccess);
|
||||
} else {
|
||||
$strlastaccess = get_string('never');
|
||||
}
|
||||
$fullname = fullname($user, true);
|
||||
|
||||
$table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
|
||||
"$user->email",
|
||||
"$user->city",
|
||||
"$user->country",
|
||||
$strlastaccess,
|
||||
$editbutton,
|
||||
$deletebutton,
|
||||
$confirmbutton);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table class=\"searchbox\" align=\"center\" cellpadding=\"10\"><tr><td>";
|
||||
echo "<form action=\"user.php\" method=\"get\">";
|
||||
echo "<input type=\"text\" name=\"search\" value=\"".s($search, true)."\" size=\"20\" />";
|
||||
echo "<input type=\"submit\" value=\"$strsearch\" />";
|
||||
if ($search) {
|
||||
echo "<input type=\"button\" onclick=\"document.location='user.php';\" value=\"$strshowallusers\" />";
|
||||
}
|
||||
echo "</form>";
|
||||
echo "</td></tr></table>";
|
||||
|
||||
if (has_capability('moodle/user:create', $sitecontext)) {
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string('addnewuser')."</a>");
|
||||
}
|
||||
if (!empty($table)) {
|
||||
print_table($table);
|
||||
print_paging_bar($usercount, $page, $perpage,
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage".
|
||||
"&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
|
||||
if (has_capability('moodle/user:create', $sitecontext)) {
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
if (!isset($form->dbhost)) {
|
||||
$form->dbhost = '';
|
||||
}
|
||||
if (!isset($form->dbname)) {
|
||||
$form->dbname = '';
|
||||
}
|
||||
if (!isset($form->dbuser)) {
|
||||
$form->dbuser = '';
|
||||
}
|
||||
if (!isset($form->dbpass)) {
|
||||
$form->dbpass = '';
|
||||
}
|
||||
if (!isset($form->dbcluster)) {
|
||||
$form->dbcluster = '';
|
||||
}
|
||||
if (!isset($form->pathtopgdump)) {
|
||||
$form->pathtopgdump = '';
|
||||
}
|
||||
if (!isset($form->pathtopsql)) {
|
||||
$form->pathtopsql = '';
|
||||
}
|
||||
?>
|
||||
<form name="migratefrom" action="utfdbmigrate.php" method="POST">
|
||||
<input name="migrate" type="hidden" value="1" />
|
||||
<input name="sesskey" type="hidden" value="<?php echo sesskey() ?>" />
|
||||
<?php if (isset($err["dbconnect"])) formerr($err["dbconnect"]); ?>
|
||||
<?php if (isset($err["pathtopgdump"])) formerr($err["pathtopgdump"]); ?>
|
||||
<?php if (isset($err["pathtopsql"])) formerr($err["pathtopsql"]); ?>
|
||||
<table cellpadding="9" cellspacing="0" width="500">
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("dbhost", "install") ?>:</td>
|
||||
<td><input type="text" name="dbhost" value="<?php p($form->dbhost) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("database", "install") ?>:</td>
|
||||
<td><input type="text" name="dbname" value="<?php p($form->dbname) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("user") ?>:</td>
|
||||
<td><input type="text" name="dbuser" value="<?php p($form->dbuser) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("password") ?>:</td>
|
||||
<td><input type="text" name="dbpass" value="<?php p($form->dbpass) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("pgcluster", "admin") ?>:</td>
|
||||
<td><input type="text" name="dbcluster" value="<?php p($form->dbcluster) ?>" />
|
||||
<td><?php print_string("pgclusterdescription", "admin") ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap="nowrap"><?php print_string("pathtopgdump","admin") ?>:</td>
|
||||
<td><input type="text" name="pathtopgdump" value="<?php p($form->pathtopgdump) ?>" />
|
||||
<td><?php print_string("pathtopgdumpdesc","admin"); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right" nowrap="nowrap"><?php print_string("pathtopsql","admin") ?>:</td>
|
||||
<td><input type="text" name="pathtopsql" value="<?php p($form->pathtopsql) ?>" />
|
||||
<td><?php print_string("pathtopsqldesc","admin"); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<center>
|
||||
<input type="submit" value="<?php print_string('continue') ?>"/>
|
||||
<input type="button" value="<?php print_string('cancel') ?>" onclick="javascript:history.go(-1)" />
|
||||
</center>
|
||||
Executable
+1238
File diff suppressed because it is too large
Load Diff
@@ -47,8 +47,6 @@ class XMLDBAction {
|
||||
|
||||
var $postaction; //Action to execute at the end of the invoke script
|
||||
|
||||
var $sesskey_protected; // Actions must be protected by sesskey mechanishm
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -74,7 +72,6 @@ class XMLDBAction {
|
||||
$this->output = NULL;
|
||||
$this->errormsg = NULL;
|
||||
$this->subaction = NULL;
|
||||
$this->sesskey_protected = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,18 +130,13 @@ class XMLDBAction {
|
||||
}
|
||||
|
||||
/**
|
||||
* main invoke method, it sets the postaction attribute
|
||||
* if possible and checks sesskey_protected if needed
|
||||
* main invoke method, it simply sets the postaction attribute
|
||||
* if possible
|
||||
*/
|
||||
function invoke() {
|
||||
|
||||
global $SESSION;
|
||||
|
||||
/// Sesskey protection
|
||||
if ($this->sesskey_protected) {
|
||||
require_sesskey();
|
||||
}
|
||||
|
||||
/// If we are used any dir, save it in the lastused session object
|
||||
/// Some actions can use it to perform positioning
|
||||
if ($lastused = optional_param ('dir', NULL, PARAM_PATH)) {
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
|
||||
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// This class will compare all the indexes found in the XMLDB definitions
|
||||
/// with the phisical DB implementation, reporting about all the missing
|
||||
/// indexes to be created to be 100% ok.
|
||||
|
||||
class check_indexes extends XMLDBAction {
|
||||
|
||||
/**
|
||||
* Init method, every subclass will have its own
|
||||
*/
|
||||
function init() {
|
||||
parent::init();
|
||||
|
||||
/// Set own core attributes
|
||||
|
||||
/// Set own custom attributes
|
||||
|
||||
/// Get needed strings
|
||||
$this->loadStrings(array(
|
||||
'confirmcheckindexes' => 'xmldb',
|
||||
'ok' => '',
|
||||
'missing' => 'xmldb',
|
||||
'table' => 'xmldb',
|
||||
'key' => 'xmldb',
|
||||
'index' => 'xmldb',
|
||||
'searchresults' => 'xmldb',
|
||||
'missingindexes' => 'xmldb',
|
||||
'completelogbelow' => 'xmldb',
|
||||
'nomissingindexesfound' => 'xmldb',
|
||||
'yesmissingindexesfound' => 'xmldb',
|
||||
'yes' => '',
|
||||
'no' => '',
|
||||
'back' => 'xmldb'
|
||||
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke method, every class will have its own
|
||||
* returns true/false on completion, setting both
|
||||
* errormsg and output as necessary
|
||||
*/
|
||||
function invoke() {
|
||||
parent::invoke();
|
||||
|
||||
$result = true;
|
||||
|
||||
/// Set own core attributes
|
||||
$this->does_generate = ACTION_GENERATE_HTML;
|
||||
|
||||
/// These are always here
|
||||
global $CFG, $XMLDB;
|
||||
|
||||
/// And we nedd some ddl suff
|
||||
require_once ($CFG->libdir . '/ddllib.php');
|
||||
|
||||
/// Here we'll acummulate all the missing indexes found
|
||||
$missing_indexes = array();
|
||||
|
||||
/// Do the job, setting $result as needed
|
||||
|
||||
/// Get the confirmed to decide what to do
|
||||
$confirmed = optional_param('confirmed', false, PARAM_BOOL);
|
||||
|
||||
/// If not confirmed, show confirmation box
|
||||
if (!$confirmed) {
|
||||
$o = '<table class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
|
||||
$o.= ' <tr><td class="generalboxcontent">';
|
||||
$o.= ' <p class="centerpara">' . $this->str['confirmcheckindexes'] . '</p>';
|
||||
$o.= ' <table class="boxaligncenter" cellpadding="20"><tr><td>';
|
||||
$o.= ' <div class="singlebutton">';
|
||||
$o.= ' <form action="index.php?action=check_indexes&sesskey=' . sesskey() . '&confirmed=yes" method="post"><fieldset class="invisiblefieldset">';
|
||||
$o.= ' <input type="submit" value="'. $this->str['yes'] .'" /></fieldset></form></div>';
|
||||
$o.= ' </td><td>';
|
||||
$o.= ' <div class="singlebutton">';
|
||||
$o.= ' <form action="index.php?action=main_view" method="post"><fieldset class="invisiblefieldset">';
|
||||
$o.= ' <input type="submit" value="'. $this->str['no'] .'" /></fieldset></form></div>';
|
||||
$o.= ' </td></tr>';
|
||||
$o.= ' </table>';
|
||||
$o.= ' </td></tr>';
|
||||
$o.= '</table>';
|
||||
|
||||
$this->output = $o;
|
||||
} else {
|
||||
/// The back to edit table button
|
||||
$b = ' <p class="centerpara buttons">';
|
||||
$b .= '<a href="index.php">[' . $this->str['back'] . ']</a>';
|
||||
$b .= '</p>';
|
||||
|
||||
/// Iterate over $XMLDB->dbdirs, loading their XML data to memory
|
||||
if ($XMLDB->dbdirs) {
|
||||
$dbdirs =& $XMLDB->dbdirs;
|
||||
$o='<ul>';
|
||||
foreach ($dbdirs as $dbdir) {
|
||||
/// Only if the directory exists
|
||||
if (!$dbdir->path_exists) {
|
||||
continue;
|
||||
}
|
||||
/// Load the XML file
|
||||
$xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
|
||||
/// Load the needed XMLDB generator
|
||||
$classname = 'XMLDB' . $CFG->dbtype;
|
||||
$generator = new $classname();
|
||||
$generator->setPrefix($CFG->prefix);
|
||||
|
||||
/// Only if the file exists
|
||||
if (!$xmldb_file->fileExists()) {
|
||||
continue;
|
||||
}
|
||||
/// Load the XML contents to structure
|
||||
$loaded = $xmldb_file->loadXMLStructure();
|
||||
if (!$loaded || !$xmldb_file->isLoaded()) {
|
||||
notify('Errors found in XMLDB file: '. $dbdir->path . '/install.xml');
|
||||
continue;
|
||||
}
|
||||
/// Arriving here, everything is ok, get the XMLDB structure
|
||||
$structure = $xmldb_file->getStructure();
|
||||
$o.=' <li>' . str_replace($CFG->dirroot . '/', '', $dbdir->path . '/install.xml');
|
||||
/// Getting tables
|
||||
if ($xmldb_tables = $structure->getTables()) {
|
||||
$o.=' <ul>';
|
||||
/// Foreach table, process its indexes and keys
|
||||
foreach ($xmldb_tables as $xmldb_table) {
|
||||
/// Skip table if not exists
|
||||
if (!table_exists($xmldb_table)) {
|
||||
continue;
|
||||
}
|
||||
$o.=' <li>' . $xmldb_table->getName();
|
||||
/// Keys
|
||||
if ($xmldb_keys = $xmldb_table->getKeys()) {
|
||||
$o.=' <ul>';
|
||||
foreach ($xmldb_keys as $xmldb_key) {
|
||||
$o.=' <li>' . $this->str['key'] . ': ' . $xmldb_key->readableInfo() . ' ';
|
||||
/// Primaries are skipped
|
||||
if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) {
|
||||
$o.='<font color="green">' . $this->str['ok'] . '</font></li>';
|
||||
continue;
|
||||
}
|
||||
/// If we aren't creating the keys or the key is a XMLDB_KEY_FOREIGN (not underlying index generated
|
||||
/// automatically by the RDBMS) create the underlying (created by us) index (if doesn't exists)
|
||||
if (!$generator->getKeySQL($xmldb_table, $xmldb_key) || $xmldb_key->getType() == XMLDB_KEY_FOREIGN) {
|
||||
/// Create the interim index
|
||||
$xmldb_index = new XMLDBIndex('anyname');
|
||||
$xmldb_index->setFields($xmldb_key->getFields());
|
||||
switch ($xmldb_key->getType()) {
|
||||
case XMLDB_KEY_UNIQUE:
|
||||
case XMLDB_KEY_FOREIGN_UNIQUE:
|
||||
$xmldb_index->setUnique(true);
|
||||
break;
|
||||
case XMLDB_KEY_FOREIGN:
|
||||
$xmldb_index->setUnique(false);
|
||||
break;
|
||||
}
|
||||
/// Check if the index exists in DB
|
||||
if (index_exists($xmldb_table, $xmldb_index)) {
|
||||
$o.='<font color="green">' . $this->str['ok'] . '</font>';
|
||||
} else {
|
||||
$o.='<font color="red">' . $this->str['missing'] . '</font>';
|
||||
/// Add the missing index to the list
|
||||
$obj = new object;
|
||||
$obj->table = $xmldb_table;
|
||||
$obj->index = $xmldb_index;
|
||||
$missing_indexes[] = $obj;
|
||||
}
|
||||
}
|
||||
$o.='</li>';
|
||||
}
|
||||
$o.=' </ul>';
|
||||
}
|
||||
/// Indexes
|
||||
if ($xmldb_indexes = $xmldb_table->getIndexes()) {
|
||||
$o.=' <ul>';
|
||||
foreach ($xmldb_indexes as $xmldb_index) {
|
||||
$o.=' <li>' . $this->str['index'] . ': ' . $xmldb_index->readableInfo() . ' ';
|
||||
/// Check if the index exists in DB
|
||||
if (index_exists($xmldb_table, $xmldb_index)) {
|
||||
$o.='<font color="green">' . $this->str['ok'] . '</font>';
|
||||
} else {
|
||||
$o.='<font color="red">' . $this->str['missing'] . '</font>';
|
||||
/// Add the missing index to the list
|
||||
$obj = new object;
|
||||
$obj->table = $xmldb_table;
|
||||
$obj->index = $xmldb_index;
|
||||
$missing_indexes[] = $obj;
|
||||
}
|
||||
$o.='</li>';
|
||||
}
|
||||
$o.=' </ul>';
|
||||
}
|
||||
$o.=' </li>';
|
||||
/// Give the script some more time (resetting to current if exists)
|
||||
if ($currenttl = @ini_get('max_execution_time')) {
|
||||
@ini_set('max_execution_time',$currenttl);
|
||||
}
|
||||
}
|
||||
$o.=' </ul>';
|
||||
}
|
||||
$o.=' </li>';
|
||||
}
|
||||
$o.='</ul>';
|
||||
}
|
||||
|
||||
/// We have finished, let's show the results of the search
|
||||
$s = '';
|
||||
$r = '<table class="generalbox boxaligncenter boxwidthwide" border="0" cellpadding="5" cellspacing="0" id="results">';
|
||||
$r.= ' <tr><td class="generalboxcontent">';
|
||||
$r.= ' <h2 class="main">' . $this->str['searchresults'] . '</h2>';
|
||||
$r.= ' <p class="centerpara">' . $this->str['missingindexes'] . ': ' . count($missing_indexes) . '</p>';
|
||||
$r.= ' </td></tr>';
|
||||
$r.= ' <tr><td class="generalboxcontent">';
|
||||
|
||||
/// If we have found missing indexes inform about them
|
||||
if (count($missing_indexes)) {
|
||||
$r.= ' <p class="centerpara">' . $this->str['yesmissingindexesfound'] . '</p>';
|
||||
$r.= ' <ul>';
|
||||
foreach ($missing_indexes as $obj) {
|
||||
$xmldb_table = $obj->table;
|
||||
$xmldb_index = $obj->index;
|
||||
$sqlarr = $xmldb_table->getAddIndexSQL($CFG->dbtype, $CFG->prefix, $xmldb_index, true);
|
||||
$r.= ' <li>' . $this->str['table'] . ': ' . $xmldb_table->getName() . '. ' .
|
||||
$this->str['index'] . ': ' . $xmldb_index->readableInfo() . '</li>';
|
||||
$s.= '<code>' . str_replace("\n", '<br />', implode('<br />', $sqlarr)) . '</code><br />';
|
||||
|
||||
}
|
||||
$r.= ' </ul>';
|
||||
/// Add the SQL statements (all together)
|
||||
$r.= '<hr />' . $s;
|
||||
} else {
|
||||
$r.= ' <p class="centerpara">' . $this->str['nomissingindexesfound'] . '</p>';
|
||||
}
|
||||
$r.= ' </td></tr>';
|
||||
$r.= ' <tr><td class="generalboxcontent">';
|
||||
/// Add the complete log message
|
||||
$r.= ' <p class="centerpara">' . $this->str['completelogbelow'] . '</p>';
|
||||
$r.= ' </td></tr>';
|
||||
$r.= '</table>';
|
||||
|
||||
$this->output = $b . $r . $o;
|
||||
}
|
||||
|
||||
/// Launch postaction if exists (leave this here!)
|
||||
if ($this->getPostAction() && $result) {
|
||||
return $this->launch($this->getPostAction());
|
||||
}
|
||||
|
||||
/// Return ok if arrived here
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -72,17 +72,17 @@ class delete_field extends XMLDBAction {
|
||||
|
||||
/// If not confirmed, show confirmation box
|
||||
if (!$confirmed) {
|
||||
$o = '<table width="60" class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
|
||||
$o = '<table align="center" width="60" class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
|
||||
$o.= ' <tr><td class="generalboxcontent">';
|
||||
$o.= ' <p class="centerpara">' . $this->str['confirmdeletefield'] . '<br /><br />' . $fieldparam . '</p>';
|
||||
$o.= ' <table class="boxaligncenter" cellpadding="20"><tr><td>';
|
||||
$o.= ' <p align="center">' . $this->str['confirmdeletefield'] . '<br /><br />' . $fieldparam . '</p>';
|
||||
$o.= ' <table align="center" cellpadding="20"><tr><td>';
|
||||
$o.= ' <div class="singlebutton">';
|
||||
$o.= ' <form action="index.php?action=delete_field&sesskey=' . sesskey() . '&confirmed=yes&postaction=edit_table&field=' . $fieldparam . '&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post"><fieldset class="invisiblefieldset">';
|
||||
$o.= ' <input type="submit" value="'. $this->str['yes'] .'" /></fieldset></form></div>';
|
||||
$o.= ' <form action="index.php?action=delete_field&confirmed=yes&postaction=edit_table&field=' . $fieldparam . '&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post">';
|
||||
$o.= ' <input type="submit" value="'. $this->str['yes'] .'" /></form></div>';
|
||||
$o.= ' </td><td>';
|
||||
$o.= ' <div class="singlebutton">';
|
||||
$o.= ' <form action="index.php?action=edit_table&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post"><fieldset class="invisiblefieldset">';
|
||||
$o.= ' <input type="submit" value="'. $this->str['no'] .'" /></div></form></fieldset>';
|
||||
$o.= ' <form action="index.php?action=edit_table&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post">';
|
||||
$o.= ' <input type="submit" value="'. $this->str['no'] .'" /></form></div>';
|
||||
$o.= ' </td></tr>';
|
||||
$o.= ' </table>';
|
||||
$o.= ' </td></tr>';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user