Compare commits
814 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3779604518 | |||
| a331476e41 | |||
| 930c08c352 | |||
| 3cc821f8fe | |||
| 067ce31750 | |||
| 64afd5f7f4 | |||
| d69f04ee5d | |||
| 52de3da486 | |||
| d682f3c9de | |||
| af7d98d028 | |||
| a3a02e99d2 | |||
| 59a4a94d8f | |||
| 751fac4e6e | |||
| 15d37cd080 | |||
| 1e1a7ac3c6 | |||
| 05d24ee32d | |||
| 0002702346 | |||
| 3de575a6b5 | |||
| f32f1338c0 | |||
| 8b66564aa4 | |||
| e8704f463d | |||
| bf043e689c | |||
| ce1eb2484f | |||
| 9d1ff56c6b | |||
| f2da10a89a | |||
| cd71433ca1 | |||
| d7519b5350 | |||
| 91589f2168 | |||
| 996b44d851 | |||
| 8a50e66742 | |||
| 141302854d | |||
| a3bd219a37 | |||
| 7b141f51c9 | |||
| e30fcef7fd | |||
| 602aea1221 | |||
| eea96a893f | |||
| b88317c2e7 | |||
| 0fb4b471ef | |||
| 40ffe0916d | |||
| a377f08b45 | |||
| 884925d4d7 | |||
| dcdfb3680e | |||
| 6a69f3a260 | |||
| 0c38a48c07 | |||
| 19f97a11aa | |||
| b0686d1d07 | |||
| 9b05df5e0a | |||
| 3ce5387d29 | |||
| f21b480d19 | |||
| 65caded8a0 | |||
| cf6be4c7ba | |||
| 71b774398e | |||
| 6ab3069e44 | |||
| f28fd7a6af | |||
| f760a27352 | |||
| c7a3002e4e | |||
| 831fbcf920 | |||
| 87909ae0d6 | |||
| fd495cc1ad | |||
| ad1908146b | |||
| 78e4d1f366 | |||
| 9e4e90132b | |||
| 5e150ed183 | |||
| 12f60822fc | |||
| 3081fefaad | |||
| 20caf128b9 | |||
| 80bdfe86d5 | |||
| c3431d2f52 | |||
| 5fa32737f6 | |||
| 76b268597b | |||
| 9f5b48b33e | |||
| bb8889747b | |||
| 642f1e22ed | |||
| 157d9457f2 | |||
| 52b38b1ae5 | |||
| d8a09929ef | |||
| 63a2da08dc | |||
| da1504234a | |||
| 268f71a656 | |||
| ddeaac7195 | |||
| fd0c975a70 | |||
| 8709af9bea | |||
| 13e3dfb091 | |||
| bc7ba277ec | |||
| 9690e2be10 | |||
| 596728959b | |||
| eda27289aa | |||
| 35b09c6973 | |||
| ded6659cbe | |||
| f7eb2d5336 | |||
| 446f0a5328 | |||
| 1307a14d62 | |||
| 3b28c9003a | |||
| efad7316a9 | |||
| 19032095c0 | |||
| 8d39975ee8 | |||
| 16b0406dd9 | |||
| 014f27e3ab | |||
| 1f08492ac1 | |||
| 2cb9e31052 | |||
| 7231ff0781 | |||
| 5cba81fd45 | |||
| 105dece910 | |||
| a420ef8836 | |||
| 88a5277af1 | |||
| f3f90ac553 | |||
| 6bf83ea6bb | |||
| 4dbc2dfdfd | |||
| 758a8e15c2 | |||
| 5de740d89b | |||
| 53a422c67d | |||
| 2ea8fe3e57 | |||
| 5f09a18471 | |||
| d79506ccd9 | |||
| 77d94a35e3 | |||
| 9e749677e5 | |||
| c4ba56985d | |||
| db054a5c17 | |||
| ad00d9ae5b | |||
| ada76e0ba3 | |||
| 227f33395c | |||
| 4013a66bd9 | |||
| 7b5a73a0c5 | |||
| 3f3e8d9c8d | |||
| 9b71bfd10f | |||
| a54b8ed824 | |||
| d20aa8e36a | |||
| fb549063df | |||
| 6f5f7646ac | |||
| 2538c34519 | |||
| 065aadc0c7 | |||
| 9adb97f8d3 | |||
| 7bd05dc10e | |||
| 9a1101fa6c | |||
| 9be36f580e | |||
| 4edf96511b | |||
| d95767674d | |||
| 0a398d1bb5 | |||
| 33ec1db2cc | |||
| 14717970db | |||
| 7b05c4594e | |||
| a7f3e2f568 | |||
| 561e4b7204 | |||
| 8c2bcbf240 | |||
| df01154cc0 | |||
| 628f32309d | |||
| 1a0c2033be | |||
| 35d97d423c | |||
| a29e76cc88 | |||
| bf09a1d96d | |||
| 4718b038eb | |||
| 4346fb9171 | |||
| 5760c0082a | |||
| 0ded1a2407 | |||
| de20819b90 | |||
| 3dcf9cd573 | |||
| 7873b9bd0f | |||
| c17ae15841 | |||
| 2572eaaaaf | |||
| fa115ec5a2 | |||
| 44b052de61 | |||
| 30060fe892 | |||
| 9a4a7d0040 | |||
| c3155c06af | |||
| 13f26d69a7 | |||
| b8be93026c | |||
| 391d1268bd | |||
| bbb34b78a6 | |||
| ff9a78aa55 | |||
| 0b8d3275d8 | |||
| 440d3cd360 | |||
| 8eca7e454f | |||
| 92a89ca210 | |||
| 01dced7e99 | |||
| 5a5d8c7cf5 | |||
| 50484cd220 | |||
| fb97c774fc | |||
| a97e45be56 | |||
| 01988ca33f | |||
| 4a01c21c53 | |||
| fff09b40c9 | |||
| 41edb82bcd | |||
| 7cf96542da | |||
| 2c09cb2e12 | |||
| 2da759e7cd | |||
| cd8beea5d9 | |||
| da8648b4b5 | |||
| d1f9ad57d5 | |||
| 7e334604be | |||
| ec3a195f56 | |||
| 651a50567a | |||
| 86fb3c83db | |||
| 8fcd89c3ab | |||
| 7839870f41 | |||
| 4893ee397c | |||
| 80ebbb7c08 | |||
| b86e528be4 | |||
| 470dda0aa9 | |||
| 4d1aead12e | |||
| c492f5fe27 | |||
| 5aeaa64aee | |||
| bdebf9a5ae | |||
| 5e36a8315a | |||
| 97152c1b88 | |||
| 0970dd6a48 | |||
| 9c21bcd89b | |||
| 4abde0607d | |||
| a9615e79cc | |||
| 48da6c3c0c | |||
| c8b59fc944 | |||
| 45f15b5c94 | |||
| 6ec5d2c298 | |||
| 04c39c8ded | |||
| 9fba045d1a | |||
| 53eddb7b6e | |||
| d5c9d4bac8 | |||
| ab606712ec | |||
| 7a4df581bf | |||
| ae5eca6313 | |||
| 98e83c1517 | |||
| 54669cd376 | |||
| 3fa6dd59e3 | |||
| 18826234c3 | |||
| 02eb71379e | |||
| d9399f4caf | |||
| 9430b5a322 | |||
| d5cbabd831 | |||
| 8b34bee9c6 | |||
| b9734b5d15 | |||
| a961a2b851 | |||
| 6f454ff99a | |||
| 778f416bd7 | |||
| b9ebeecd11 | |||
| a925263bd3 | |||
| 38a7def0f0 | |||
| 55f21d31e2 | |||
| 7a2596f854 | |||
| 1a0c7e470b | |||
| b442f81966 | |||
| e74d8b7fbc | |||
| 3a4b285549 | |||
| c12ab13b7f | |||
| c110bf9c4a | |||
| c69232269c | |||
| 0df93edd14 | |||
| 61d5adce1e | |||
| 7435a34081 | |||
| 86fad6838a | |||
| 0e2d8f7d99 | |||
| 3a42ca4bf7 | |||
| 68d69eb096 | |||
| 4eebe5eb59 | |||
| fab2f0b23a | |||
| 3729ab341e | |||
| b2a07f418c | |||
| 1cc1fdcd6f | |||
| eaeafbce15 | |||
| a80a5921ca | |||
| fdbadd57eb | |||
| f8731332d5 | |||
| 7e8c56795a | |||
| 9e903136b6 | |||
| 3644b6dca1 | |||
| 61f779597d | |||
| d13e627af5 | |||
| 1e47ecd5d9 | |||
| e3da2769b8 | |||
| ea77aa0617 | |||
| d44af20f37 | |||
| 461a4afe83 | |||
| 9958e237c3 | |||
| c26fdb80fb | |||
| a1c0899be1 | |||
| 8a07a15029 | |||
| d32ae936e4 | |||
| cd47b250c2 | |||
| d94c70cc7b | |||
| 4b8980fc83 | |||
| 609cba70d2 | |||
| 175885e3ff | |||
| 37ac5dfdb1 | |||
| a4f2ce6946 | |||
| 6ddc682c3c | |||
| bce32e1373 | |||
| 0d3a8fa280 | |||
| b55be229e9 | |||
| 96522de058 | |||
| 51cf993598 | |||
| 93f14c02ac | |||
| 18d30cd1d2 | |||
| 00878c64d5 | |||
| db6efd66bd | |||
| ac8d60eae0 | |||
| acc1bff289 | |||
| 4f854e3830 | |||
| cd3565a13c | |||
| c7b29ed094 | |||
| d4b57dfe19 | |||
| 8fcb9ebb39 | |||
| e8f491f249 | |||
| 726f4ca317 | |||
| ff75e0fe8a | |||
| 7380fc552a | |||
| ea9d7e8815 | |||
| ee99d4dd14 | |||
| a12772c292 | |||
| b53f6cbec4 | |||
| 7bf8395be7 | |||
| eca64410fa | |||
| f3f9ab2a5e | |||
| 602c1506e4 | |||
| 3ebf865805 | |||
| bd2c2596c2 | |||
| 0ee95ca7c3 | |||
| ad16b64f1a | |||
| dcb043ddd3 | |||
| b0e5543a31 | |||
| d5e739bc92 | |||
| 7ba2b3a7f4 | |||
| 21b674db66 | |||
| 76cea3d68f | |||
| a95fb63fbe | |||
| 7f9da8a112 | |||
| d9e747e909 | |||
| b81285be22 | |||
| a5b75f54ca | |||
| edd61be0e7 | |||
| a86b324790 | |||
| ecc1076a06 | |||
| edf8528f96 | |||
| f1d7b1301c | |||
| 645ed2b688 | |||
| 6f6109d4ef | |||
| e46a0bc728 | |||
| ffe79bd906 | |||
| f94c9601f0 | |||
| 742960a9c2 | |||
| cc67fc0b5d | |||
| 79a661bd2a | |||
| d6067b0c43 | |||
| 579961aba4 | |||
| c51ffe5107 | |||
| b60003a832 | |||
| 7fc51d17c3 | |||
| 9bd37fa711 | |||
| 9e74ddd633 | |||
| 0551474e63 | |||
| c562717acb | |||
| d52e13002e | |||
| d8d356d4c7 | |||
| 57af827e39 | |||
| 8ba0912440 | |||
| 54b5310062 | |||
| f4f27c0675 | |||
| 796d3c880a | |||
| d6f6091a4b | |||
| fa1c36fb99 | |||
| 5ff5caa58d | |||
| 34990da46d | |||
| e41871f1fb | |||
| af0145e39d | |||
| 40dcb53fc6 | |||
| fbc914dafe | |||
| 412e0bb881 | |||
| c5505d8071 | |||
| 153bd6ec63 | |||
| ebd32e3e38 | |||
| d907cdad93 | |||
| 7747441767 | |||
| f349337d7e | |||
| 00980197b8 | |||
| da11cdfbe4 | |||
| 5dcda7b86f | |||
| 1a8b9564c4 | |||
| e8715b0d9b | |||
| 7092220f99 | |||
| aeb0e7ee1e | |||
| e674aa8ba8 | |||
| 20f961f1e2 | |||
| ed95139596 | |||
| 4cc9465bc7 | |||
| 91bbe51649 | |||
| 4fe3740b36 | |||
| 64f689e0d0 | |||
| b0cbbc56c2 | |||
| 4a69819405 | |||
| dcf2a27a32 | |||
| 83b640f957 | |||
| 07d0fff0f3 | |||
| e5e3f219dd | |||
| 6ee3b260cb | |||
| 35a510d8b6 | |||
| 1a9911452e | |||
| 736db01dc4 | |||
| 1e55f8cfce | |||
| 3eb92f112c | |||
| 20b53a7ba2 | |||
| 4bc418dc6d | |||
| 27974c8587 | |||
| 882a125790 | |||
| ee4fe14631 | |||
| c56d16bb4e | |||
| f7375fe1c3 | |||
| a67dd90008 | |||
| 00c6364cbb | |||
| 176d456ed9 | |||
| 4f64ed9405 | |||
| 27ed82e82f | |||
| 54ce5e46c8 | |||
| a748a0f84d | |||
| ed124087d7 | |||
| 0954d514b8 | |||
| 2d9a666670 | |||
| 291fd04602 | |||
| 2c9f5a3a00 | |||
| f54d5ea5fb | |||
| 2b26825cb2 | |||
| d5640b844b | |||
| 3099dc3e6f | |||
| 1824077052 | |||
| 672610e605 | |||
| 473d3495a5 | |||
| dfcbccbbef | |||
| 55b55d08f9 | |||
| 952d9baf58 | |||
| bccdea508c | |||
| ecea1540da | |||
| 2e989420c9 | |||
| 08bae16463 | |||
| ac63a3f445 | |||
| 58b9565184 | |||
| 4a25390975 | |||
| d177dd7713 | |||
| c30dd54457 | |||
| 229ee13480 | |||
| 4d54248710 | |||
| 9dc9d6b0a8 | |||
| fdce874a70 | |||
| 3db6b58aa4 | |||
| 913f744325 | |||
| c5544714a8 | |||
| dcbe5864f6 | |||
| 028f222c2a | |||
| 8b559dc502 | |||
| 2c13dbe497 | |||
| 92ff33eee8 | |||
| 7c957e6052 | |||
| 2a8d898ae0 | |||
| d7fef4ea06 | |||
| d7b9ae5984 | |||
| 853fdc2076 | |||
| eb1f864d0a | |||
| 9935789477 | |||
| 3d3b104b1b | |||
| ddc2560146 | |||
| 87e1fb0e31 | |||
| 95bd142e85 | |||
| c7d5bd00b8 | |||
| b0fbbd20f6 | |||
| c6ad74fad4 | |||
| 37a192beca | |||
| 13a2015285 | |||
| 215241b0f0 | |||
| e85705799e | |||
| e1f2e71b60 | |||
| 5657bcafcd | |||
| 0f8c7865b1 | |||
| a959544c5b | |||
| 09b1a30d72 | |||
| 9b464d9fb2 | |||
| a8b50ee01e | |||
| 36b1e811e4 | |||
| 719593e839 | |||
| 249c36eaa0 | |||
| 05c2036b1f | |||
| 833b9fd8d5 | |||
| 1721518730 | |||
| bb89f07c23 | |||
| 27b93cf8e5 | |||
| 10604909ea | |||
| 42cc44d560 | |||
| 7b94708be9 | |||
| b93635e369 | |||
| 22bb7196b0 | |||
| 98cda81fcf | |||
| edfa37ae27 | |||
| 9d90abb900 | |||
| 2a135a5f64 | |||
| f85e2d3767 | |||
| b430433c2e | |||
| 8259642b1b | |||
| ed6804bf75 | |||
| af796dc774 | |||
| e39d41ec6b | |||
| 62b9331113 | |||
| 9cc29c562c | |||
| 21ba61c3cf | |||
| 9022e87436 | |||
| 36e62734ec | |||
| d683df8086 | |||
| 30a5ea69f5 | |||
| 0ed0f0298d | |||
| a410c12d23 | |||
| f4df4e9a26 | |||
| 73197ea200 | |||
| 8d3b392d7d | |||
| 1b1779d677 | |||
| ec9111371f | |||
| e30102faed | |||
| e40bd2e541 | |||
| 2dcadca9a6 | |||
| b77f5e7a06 | |||
| c99c3dac32 | |||
| 685a07e8ab | |||
| 357df17cb8 | |||
| 1129e06081 | |||
| be35eacfb3 | |||
| 74845319b5 | |||
| ff377eb66b | |||
| 018d7c657a | |||
| c24313bc8c | |||
| 802766d303 | |||
| db5bf3f55a | |||
| 69a791b831 | |||
| 2003a0d463 | |||
| 62592b861c | |||
| 5fd78134a4 | |||
| b986e3b007 | |||
| 8fcccd5ba8 | |||
| e335cc7193 | |||
| dc9999208b | |||
| 823940bcb3 | |||
| 303eaa286e | |||
| f258f45e31 | |||
| 6d5f3867e9 | |||
| e62064ad43 | |||
| 78a0c06ae6 | |||
| 8c589739b6 | |||
| 8a9d7a93af | |||
| dd26a66841 | |||
| 8a91a43fae | |||
| 7b8ebd2771 | |||
| 146296b733 | |||
| 95c129edfb | |||
| f5650a9675 | |||
| 6b9d8ab22b | |||
| c4b8c0c709 | |||
| f6c70cf3bf | |||
| ebd62fdd86 | |||
| 6cce9458a5 | |||
| 2c241d2a9d | |||
| 8a70716abf | |||
| 1defa4e7be | |||
| 7b3019e3e6 | |||
| 1cca75d257 | |||
| f8ab1daa7c | |||
| 5e56f16030 | |||
| 9b30b693ad | |||
| 50e752d018 | |||
| a187eda73f | |||
| 0afc847f80 | |||
| 198f0fb09b | |||
| 203469c660 | |||
| 5ec9237d2b | |||
| 908b8b9a4f | |||
| 855faed103 | |||
| 69f1e0a3cf | |||
| b8a6ed644b | |||
| 41e783c3cc | |||
| ed6913a320 | |||
| 854e0622c3 | |||
| 7d5e12061e | |||
| 0e468cfc54 | |||
| 7dc26ba47b | |||
| a03a098f63 | |||
| 24fac39fce | |||
| ce31ac9abd | |||
| d7d8758184 | |||
| bef692c32e | |||
| 8d0a452321 | |||
| f80964c99b | |||
| 969da74d8b | |||
| a10b3ade4d | |||
| 06dc71e4e5 | |||
| 7d8e444763 | |||
| 33cfeeb2a5 | |||
| 34f5efca4b | |||
| c16e25ca1d | |||
| 14b03b3507 | |||
| 5efca069cc | |||
| 1b0feaf88a | |||
| 010e8ea172 | |||
| 1ec72ac59b | |||
| fe20798cb6 | |||
| ba9b14e1e8 | |||
| cf0b27037b | |||
| 8915662a32 | |||
| 2b9011efdc | |||
| 00067b0836 | |||
| 527ef6b490 | |||
| a2b8c47446 | |||
| 91e81b7fa4 | |||
| b988c62844 | |||
| b2e0d6b6a2 | |||
| 75c45044bb | |||
| 472b9e478e | |||
| fdcec8bb0c | |||
| e51980345c | |||
| a50ded84ea | |||
| 7c2e85f1bd | |||
| ae18de992f | |||
| cda01a6052 | |||
| c1d0f7d584 | |||
| b495ed2b48 | |||
| 78cb48c712 | |||
| 6154173f51 | |||
| 6472c54bea | |||
| 671daf6e07 | |||
| d5238eaf23 | |||
| e56802dacd | |||
| c62346d190 | |||
| 91202daa84 | |||
| 353a72e0a9 | |||
| f2670b1325 | |||
| 9af5afa62c | |||
| 91b0c4f3e1 | |||
| 2f128ef194 | |||
| 4cde340d52 | |||
| 92b57640a4 | |||
| aa3d9221e2 | |||
| e0f27e8191 | |||
| 93e6edcc16 | |||
| 42e249983d | |||
| c788cafae7 | |||
| 507af9944b | |||
| a57089b02e | |||
| 0644bc9e12 | |||
| 387496c8a6 | |||
| b5cfd0e85f | |||
| fd772c442e | |||
| 2ebaaa5e68 | |||
| e5bd075113 | |||
| 88289032b6 | |||
| 9c0458b046 | |||
| 4ea496519e | |||
| 36d0082229 | |||
| e0a456a3b3 | |||
| 88a70c8436 | |||
| a5b9e4d94e | |||
| 8913dce495 | |||
| de3e4de88d | |||
| d0d1008498 | |||
| 46808f4afc | |||
| 7eda7f6cbd | |||
| 21c500f755 | |||
| dfb203cad6 | |||
| 8ec882c22f | |||
| d31cdc0ee9 | |||
| f547ee52e7 | |||
| 129af65665 | |||
| b2794b6554 | |||
| 04fd313892 | |||
| be037b8039 | |||
| f01c72ee73 | |||
| 2eebac9129 | |||
| a8db8bdc3e | |||
| bee864c912 | |||
| 4a51bb7cca | |||
| 4cbb5d6b4b | |||
| 30bc2fa671 | |||
| 4e65d23fd1 | |||
| 327f0cdf22 | |||
| 5e1eaab52f | |||
| 431c81eefa | |||
| 6908074777 | |||
| 7f446f68b6 | |||
| 6de08a7a4d | |||
| 4172b51f81 | |||
| 52f42b41fc | |||
| 63d9ac4893 | |||
| cc4a7edf6f | |||
| 1afe51e630 | |||
| eb4f1a380a | |||
| 3977f41672 | |||
| bce227c2bd | |||
| 862d076232 | |||
| 7ac53b8334 | |||
| b42451d5c7 | |||
| e706e6bf35 | |||
| 4e3cfbb4d8 | |||
| 7f322bf4f0 | |||
| be50231d4a | |||
| 19425053af | |||
| c0c2ae7637 | |||
| aef7d2ef0b | |||
| f4fbd4d664 | |||
| d5fe509f44 | |||
| 420b3d092c | |||
| 19625783b5 | |||
| c5e704f41b | |||
| fda51b8d69 | |||
| 79424afeb2 | |||
| bcabc1aac6 | |||
| ad13b33c01 | |||
| b50ab1c6ac | |||
| 486e156924 | |||
| 62368bd2a2 | |||
| bbbfb3193b | |||
| c2716331a4 | |||
| a2ce999684 | |||
| 8c8be6622e | |||
| ac75511c40 | |||
| c14abb9990 | |||
| d97903b9ca | |||
| 356f6d69d2 | |||
| d0437b3eab | |||
| 799ce03dff | |||
| b4ad8b3d24 | |||
| e8ef939008 | |||
| ebea2dd039 | |||
| be37cf962d | |||
| c75a34409f | |||
| eb4409277e | |||
| f7311bbe14 | |||
| 04f1308619 | |||
| 48143e5a51 | |||
| 223b5ee619 | |||
| 56fdffcfeb | |||
| eb363f4d99 | |||
| 1a625fd590 | |||
| 7e71e010a7 | |||
| bc213d6e8a | |||
| 19dd3171b1 | |||
| aff55f17a2 | |||
| 42f291c945 | |||
| 64c548ef7a | |||
| 1404a13a33 | |||
| 3e93cbe128 | |||
| dafecdb3d9 | |||
| 56e55d22ec | |||
| ae2b896821 | |||
| 68467fbf94 | |||
| b9f5885b4d | |||
| 9f46966132 | |||
| 6d388d8e29 | |||
| b6162f17e2 | |||
| 9b1f47c6bd | |||
| ba1b26a543 | |||
| 53542fb830 | |||
| d390acad28 | |||
| c27e555d40 | |||
| 1fed924a16 | |||
| 8009ff257a | |||
| b7eccbf37f | |||
| 8428897528 | |||
| 3a5cc3936d | |||
| c0ee89d2dc | |||
| 6365268b3b | |||
| 1e27382ed1 | |||
| e75647df91 | |||
| 19b1bd0bc8 | |||
| 72d8255f7e | |||
| ca27c7f734 | |||
| ebc9be85c7 | |||
| d1dec2d112 | |||
| f54e807d59 | |||
| ab37ddd5d2 | |||
| 6e2c52bad7 | |||
| 7b4bb520ba | |||
| ab55cb4107 | |||
| 785d24f0f6 | |||
| 5d2f527449 | |||
| b36a469ffc | |||
| 1820e4e3f2 | |||
| e55474005b | |||
| 6e82cd4cd3 | |||
| 0b0d2241e3 | |||
| 7d9137d05a | |||
| 97a8cdafd6 | |||
| cc876bc667 | |||
| 5b5302faa8 | |||
| afa051933d | |||
| 1281b0a7df | |||
| 092f22eb7f | |||
| e0f0b7bc2d | |||
| e8df6a8946 | |||
| d00f113675 | |||
| efe91196f3 | |||
| b4d9eecbd0 | |||
| d2049a8b7b | |||
| cbac49ac50 | |||
| ea4dec3080 | |||
| e73ae3f14e | |||
| 4ec1c2a0bd | |||
| 834fc9fd91 | |||
| f3d2d06518 | |||
| 2e32990a63 | |||
| 4b31fcf608 | |||
| dd23e499f3 | |||
| 72fe9309f3 | |||
| 3b905f1aab | |||
| f11d5ccb4f | |||
| 75c180d2e3 | |||
| ae7fb33a55 | |||
| 7a89b30fac | |||
| d9bdf8cb96 | |||
| 1a2e6cfb12 | |||
| df85e55750 | |||
| dba8c2802e | |||
| 67f2fae171 | |||
| bc1ed83f43 | |||
| 2559db73e6 | |||
| 956ad3b8a8 | |||
| 0420e8715d |
+51
-36
@@ -1,36 +1,51 @@
|
||||
README $Id$
|
||||
------
|
||||
|
||||
QUICK INSTALL
|
||||
=============
|
||||
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
a few minutes:
|
||||
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create a single database for Moodle to store all
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
be taken to the install.php script, which will lead
|
||||
you through creating a config.php file and then
|
||||
setting up Moodle, creating an admin account etc.
|
||||
|
||||
4) Set up a cron task to call the file admin/cron.php
|
||||
every five minutes or so.
|
||||
|
||||
|
||||
For more information, see the INSTALL DOCUMENTATION:
|
||||
|
||||
http://docs.moodle.org/en/Installing_Moodle
|
||||
|
||||
A local copy can also be found in
|
||||
|
||||
lang/en_utf8/help/install.html (or your language)
|
||||
|
||||
|
||||
Good luck and have fun!
|
||||
Martin Dougiamas, Lead Developer
|
||||
|
||||
README $Id$
|
||||
------
|
||||
|
||||
If you are installing the first time, then you
|
||||
should read the installation guide which is
|
||||
part of the Moodle documentation (along with
|
||||
information about upgrading etc):
|
||||
|
||||
http://moodle.com/doc/
|
||||
|
||||
There is a copy of all this documentation as part of
|
||||
this Moodle distribution. You can access your local
|
||||
copy of the installation guide here:
|
||||
|
||||
lang/en/docs/install.html
|
||||
|
||||
Once Moodle is installed on your machine, then
|
||||
you can also access a local copy of all this
|
||||
documentation (localised to your language) at:
|
||||
|
||||
http://yourmoodlesite.com/doc/
|
||||
|
||||
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
a few minutes:
|
||||
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create an empty directory somewhere to store
|
||||
uploaded files (NOT accessible via the web).
|
||||
This directory must be writeable by the web server
|
||||
process.
|
||||
|
||||
3) Create a single database for Moodle to store all
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
4) Copy the file config-dist.php to config.php, and
|
||||
edit it with all your own settings.
|
||||
|
||||
5) Visit your new home page with a web browser. Moodle
|
||||
will lead you through the rest of the setup,
|
||||
creating an admin account and so on.
|
||||
|
||||
6) Set up a cron task to call the file admin/cron.php
|
||||
every five minutes or so.
|
||||
|
||||
|
||||
Cheers!
|
||||
Martin Dougiamas
|
||||
|
||||
|
||||
+8
-22
@@ -5,19 +5,11 @@
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = count($admins);
|
||||
$a->items = $strexistingadmins;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
<?php echo count($admins) . " ". $strexistingadmins ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = $usercount;
|
||||
$a->items = $strpotentialadmins;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
<?php echo $usercount . " " . $strpotentialadmins ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -62,23 +54,17 @@
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
} else {
|
||||
if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
|
||||
onFocus ="document.adminform.add.disabled=true;
|
||||
document.adminform.remove.disabled=true;
|
||||
document.adminform.removeselect.selectedIndex=-1;
|
||||
|
||||
+11
-14
@@ -1,10 +1,14 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign administrative rights to users
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
optional_variable($search, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
@@ -44,7 +48,7 @@
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassignadmins",
|
||||
print_header("$site->shortname: $strassignadmins",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strassignadmins", "adminform.searchtext");
|
||||
|
||||
@@ -77,7 +81,7 @@
|
||||
}
|
||||
|
||||
/// Is there a current search?
|
||||
$previoussearch = (!empty($frm->search) or (isset($frm->previoussearch) and $frm->previoussearch == 1)) ;
|
||||
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
|
||||
|
||||
/// Get all existing admins
|
||||
$admins = get_admins();
|
||||
@@ -101,18 +105,11 @@
|
||||
|
||||
/// If no search results then get potential users excluding current admins
|
||||
if (empty($searchusers)) {
|
||||
|
||||
$usercount = get_users(false, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email');
|
||||
|
||||
$users = array();
|
||||
|
||||
if ($usercount <= MAX_USERS_PER_PAGE) {
|
||||
if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email') ) {
|
||||
$users = array();
|
||||
}
|
||||
if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email') ) {
|
||||
$users = array();
|
||||
}
|
||||
$usercount = count($users);
|
||||
}
|
||||
|
||||
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
|
||||
|
||||
+55
-210
@@ -1,10 +1,7 @@
|
||||
<?PHP // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
include("../config.php");
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
@@ -19,8 +16,6 @@
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$focus = '';
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
@@ -28,26 +23,11 @@
|
||||
$config = (array)$config;
|
||||
validate_form($config, $err);
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
if (count($err) == 0) {
|
||||
print_header();
|
||||
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");
|
||||
}
|
||||
if (! set_config($name, $value)) {
|
||||
notify("Problem saving config $name as $value");
|
||||
}
|
||||
}
|
||||
redirect("auth.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
@@ -67,46 +47,39 @@
|
||||
}
|
||||
|
||||
$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 {
|
||||
if (isset($_GET['auth'])) {
|
||||
$auth = $_GET['auth'];
|
||||
} else {
|
||||
$auth = $config->auth;
|
||||
}
|
||||
|
||||
// changepassword link replaced by individual auth setting
|
||||
if (!empty($config->changepassword)) {
|
||||
if (empty($config->{'auth_'.$auth.'_changepasswordurl'})) {
|
||||
$config->{'auth_'.$auth.'_changepasswordurl'} = $config->changepassword;
|
||||
}
|
||||
set_config('changepassword','');
|
||||
}
|
||||
|
||||
$auth = clean_param($auth,PARAM_SAFEDIR);
|
||||
}
|
||||
$auth = clean_filename($auth);
|
||||
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");
|
||||
|
||||
foreach ($user_fields as $user_field) {
|
||||
$user_field = "auth_user_$user_field";
|
||||
if (! isset($config->$user_field)) {
|
||||
$config->$user_field = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
|
||||
@@ -120,116 +93,78 @@
|
||||
$strusers = get_string("users");
|
||||
|
||||
print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strauthenticationoptions", "$focus");
|
||||
"<A HREF=\"index.php\">$stradministration</A> -> <a href=\"users.php\">$strusers</a> -> $strauthenticationoptions", "$focus");
|
||||
|
||||
echo "<center><b>";
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
echo "<CENTER><P><B>";
|
||||
echo "<form TARGET=\"{$CFG->framename}\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
print_string("chooseauthmethod","auth");
|
||||
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
|
||||
echo "</b></center>";
|
||||
|
||||
print_simple_box_start("center", "100%");
|
||||
echo "</B></P></CENTER>";
|
||||
|
||||
print_simple_box_start("center", "100%", "$THEME->cellheading");
|
||||
print_heading($options[$auth]);
|
||||
|
||||
print_simple_box_start("center", "60%", '', 5, 'informationbox');
|
||||
print_simple_box_start("center", "60%", "$THEME->cellcontent");
|
||||
print_string("auth_$auth"."description", "auth");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
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\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
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 ":</p></td>";
|
||||
echo "<td>";
|
||||
echo "<input type=\"text\" name=\"changepassword\" size=40 value=\"$config->changepassword\">";
|
||||
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);
|
||||
print_string("changepasswordhelp","auth");
|
||||
echo "</td></tr>";
|
||||
|
||||
}
|
||||
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\" nowrap=\"nowrap\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
print_string("guestloginbutton", "auth");
|
||||
echo ":</td>";
|
||||
echo "<td>";
|
||||
echo ":</p></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>";
|
||||
}
|
||||
if (function_exists('auth_user_create')){
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
print_string("auth_user_create", "auth");
|
||||
echo ":</p></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>";
|
||||
}
|
||||
|
||||
echo "</table><center><p><input type=\"submit\" value=\"";
|
||||
print_string("savechanges");
|
||||
echo "\"></p></center></form>";
|
||||
|
||||
/// An alternate url for the login form. It means we can use login forms that are integrated
|
||||
/// into non-moodle pages
|
||||
echo '<tr valign="top">';
|
||||
echo '<td algin="right" nowrap="nowrap">';
|
||||
print_string('alternateloginurl', 'auth');
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
echo '<input type="text" size="40" name="alternateloginurl" alt="'.get_string('alternateloginurl', 'auth').'" value="'.$config->alternateloginurl.'" />';
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
print_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot.'/login/index.php'));
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
echo '</table>';
|
||||
echo '<p align="center"><input type="submit" value="'.get_string('savechanges').'"></p>';
|
||||
echo '</form>';
|
||||
|
||||
print_simple_box_end();
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
exit;
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -241,95 +176,5 @@ function validate_form(&$form, &$err) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// 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>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+11
-6
@@ -15,13 +15,17 @@
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
//Initialise error variables
|
||||
$error = false;
|
||||
$sche_destination_error = "";
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (($config = data_submitted()) && confirm_sesskey()) {
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
//First of all we check that everything is correct
|
||||
//Check for trailing slash and backslash in backup_sche_destination
|
||||
@@ -54,6 +58,7 @@
|
||||
$config = (object)$a_config;
|
||||
//weekdays conversions done. Continue
|
||||
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
backup_set_config($name, $value);
|
||||
}
|
||||
@@ -72,7 +77,7 @@
|
||||
}
|
||||
if ($status) {
|
||||
//get courses
|
||||
if ($courses = get_records('course', '', '', '', 'id,shortname')) {
|
||||
if ($courses = get_records("course")) {
|
||||
//For each course, we check (insert, update) the backup_course table
|
||||
//with needed data
|
||||
foreach ($courses as $course) {
|
||||
@@ -110,18 +115,18 @@
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
$strbackup);
|
||||
|
||||
echo "<p align=\"right\"><a href=\"../backup/log.php\">".get_string("logs")."</a></p>";
|
||||
echo "<p align=right><a href=\"../backup/log.php\">".get_string("logs")."</a></p>";
|
||||
|
||||
print_heading($strbackup);
|
||||
|
||||
print_simple_box("<center>".get_string("adminhelpbackup")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
//Check for required functions...
|
||||
if (!function_exists('utf8_encode')) {
|
||||
notify("You need to add XML support to your PHP installation");
|
||||
if(!function_exists('utf8_encode')) {
|
||||
print_simple_box("<font color=\"red\">You need to add XML support to your PHP installation</font>", "center", "70%", "$THEME->cellheading", "20", "noticebox");
|
||||
}
|
||||
include ("$CFG->dirroot/backup/config.html");
|
||||
|
||||
|
||||
+18
-39
@@ -14,54 +14,39 @@
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
|
||||
if(($blockrecord = blocks_get_record($blockid)) === false) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
require_variable($_REQUEST['block']);
|
||||
$blockid = intval($_REQUEST['block']);
|
||||
|
||||
if(($blockrecord = get_record('blocks', 'id', $blockid)) === false) {
|
||||
error('This block does not exist');
|
||||
}
|
||||
|
||||
$block = block_instance($blockrecord->name);
|
||||
$block = block_instance($blockrecord->name, NULL);
|
||||
if($block === false) {
|
||||
error('Problem in instantiating block object');
|
||||
}
|
||||
|
||||
// Define the data we're going to silently include in the instance config form here,
|
||||
// so we can strip them from the submitted data BEFORE handling it.
|
||||
$hiddendata = array(
|
||||
'block' => $blockid,
|
||||
'sesskey' => $USER->sesskey
|
||||
);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
error('This block does not support global configuration');
|
||||
}
|
||||
$remove = array_keys($hiddendata);
|
||||
foreach($remove as $item) {
|
||||
unset($config->$item);
|
||||
}
|
||||
$block->config_save($config);
|
||||
unset($config->block); // This will always be set if we have reached this point
|
||||
$block->handle_config($config);
|
||||
print_header();
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
/// Otherwise print the form.
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'block/' . $block->name() . '/config';
|
||||
|
||||
|
||||
print_header($site->shortname.': '.$strblockname.": $strconfiguration", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
@@ -69,17 +54,11 @@
|
||||
|
||||
print_heading($strblockname);
|
||||
|
||||
print_simple_box('<center>'.get_string('configwarning', 'admin').'</center>', 'center', '50%');
|
||||
print_simple_box('<center>'.get_string('configwarning').'</center>', 'center', '50%');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
echo '<p>';
|
||||
foreach($hiddendata as $name => $val) {
|
||||
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
|
||||
}
|
||||
echo '</p>';
|
||||
$block->config_print();
|
||||
echo '</form>';
|
||||
$block->print_config();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+50
-113
@@ -4,13 +4,12 @@
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
optional_variable($_GET['hide']);
|
||||
optional_variable($_GET['show']);
|
||||
optional_variable($_GET['delete']);
|
||||
optional_variable($_GET['confirm'], 0);
|
||||
$delete = $_GET['delete']; // Dependency remover
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -33,9 +32,8 @@
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
$strsettings = get_string('settings');
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strcourses = get_string('courses');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
|
||||
print_header("$site->shortname: $strmanageblocks", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
@@ -43,63 +41,46 @@
|
||||
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) && confirm_sesskey()) {
|
||||
if (!$block = get_record('block', 'id', $hide)) {
|
||||
if (!empty($_GET['hide']) and confirm_sesskey()) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['hide'])) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('block', 'visible', '0', 'id', $block->id); // Hide block
|
||||
set_field('blocks', 'visible', '0', 'id', $block->id); // Hide block
|
||||
}
|
||||
|
||||
if (!empty($show) && confirm_sesskey() ) {
|
||||
if (!$block = get_record('block', 'id', $show)) {
|
||||
if (!empty($_GET['show']) and confirm_sesskey() ) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['show'])) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('block', 'visible', '1', 'id', $block->id); // Show block
|
||||
set_field('blocks', 'visible', '1', 'id', $block->id); // Show block
|
||||
}
|
||||
|
||||
if (!empty($multiple) && confirm_sesskey()) {
|
||||
if (!$block = blocks_get_record($multiple)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
}
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
if (!$block = get_record('blocks', 'id', $delete)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
|
||||
if (!block_is_compatible($block->name)) {
|
||||
$strblockname = $block->name;
|
||||
}
|
||||
else {
|
||||
$blockobject = block_instance($block->name);
|
||||
$strblockname = $blockobject->get_title();
|
||||
}
|
||||
$blockobject = block_instance($block->name, $site);
|
||||
$strblockname = $blockobject->get_title();
|
||||
|
||||
if (!$confirm) {
|
||||
if (!$_GET['confirm']) {
|
||||
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php');
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// Delete block
|
||||
if (!delete_records('block', 'id', $block->id)) {
|
||||
if (!delete_records('blocks', 'id', $block->id)) {
|
||||
notify("Error occurred while deleting the $strblockname record from blocks table");
|
||||
}
|
||||
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
}
|
||||
blocks_update_every_block_by_id($block->id, 'delete'); // Delete blocks in all courses by id
|
||||
|
||||
// Then the tables themselves
|
||||
|
||||
@@ -124,19 +105,12 @@
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (false === ($blocks = get_records('block'))) {
|
||||
if (false === ($blocks = get_records('blocks'))) {
|
||||
error('No blocks found!'); // Should never happen
|
||||
}
|
||||
|
||||
$incompatible = array();
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
notify('Block '. $block->name .' is not compatible with the current version of Mooodle and needs to be updated by a programmer.');
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
if(($blockobject = block_instance($block->name)) === false) {
|
||||
if(($blockobject = block_instance($block->name, NULL)) === false) {
|
||||
// Failed to load
|
||||
continue;
|
||||
}
|
||||
@@ -152,89 +126,52 @@
|
||||
|
||||
/// Print the table of all blocks
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = '../pix';
|
||||
// [pj] This is not used anywhere, but I'm leaving it in for the future
|
||||
//$modpixpath = '../mod';
|
||||
} else {
|
||||
$pixpath = '../theme/'.$CFG->theme.'/pix';
|
||||
// [pj] This is not used anywhere, but I'm leaving it in for the future
|
||||
//$modpixpath = '../theme/'.$CFG->theme.'/pix/mod';
|
||||
}
|
||||
|
||||
$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.'/admin/blocks.php');
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->setup();
|
||||
$table->head = array ($strname, $strcourses, $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 ($blockbyname as $blockname => $blockid) {
|
||||
|
||||
// [pj] This is not used anywhere, but I'm leaving it in for the future
|
||||
//$icon = "<img src=\"$modpixpath/$block->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
$blockobject = $blockobjects[$blockid];
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if($blockobject->has_config()) {
|
||||
$settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
|
||||
$settings = '<a href="block.php?block='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strsettings.'</a>';
|
||||
}
|
||||
|
||||
$count = count_records('block_instance', 'blockid', $blockid);
|
||||
$count = blocks_get_courses_using_block_by_id($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" height="16" width="16" alt="" /></a>';
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$pixpath.'/i/hide.gif" style="height: 16px; width: 16px;" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" alt="" /></a>';
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
if ($blockobject->instance_allow_multiple()) {
|
||||
if($blocks[$blockid]->multiple) {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('yes').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
else {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('no').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$multiple = '';
|
||||
}
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$blockobject->get_title().'</span>',
|
||||
$count,
|
||||
$blockobject->get_version(),
|
||||
$visible,
|
||||
$multiple,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
$table->data[] = array ('<p'.$class.'>'.$blockobject->get_title().'</p>', $count, $blockobject->get_version(), $visible, $delete, $settings);
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
if(!empty($incompatible)) {
|
||||
print_heading(get_string('incompatibleblocks', 'admin'));
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
$table->define_columns(array('block', 'delete'));
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/admin/blocks.php');
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'incompatible');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
$table->add_data(array(
|
||||
$block->name,
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>',
|
||||
));
|
||||
}
|
||||
$table->print_html();
|
||||
}
|
||||
|
||||
echo '<p>';
|
||||
print_table($table);
|
||||
echo '</p>';
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
|
||||
<form method="post" action="calendar.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<table class="formtable">
|
||||
<tr>
|
||||
<th>adminseesall:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpadminseesall', 'admin'); ?></div>
|
||||
<p>
|
||||
<select name="adminseesallcourses">
|
||||
<option value="0" <?php if(empty($CFG->calendar_adminseesall)) echo "selected='selected'"; ?>><?php print_string('adminseesownevents', 'admin'); ?></option>
|
||||
<option value="1" <?php if(!empty($CFG->calendar_adminseesall)) echo "selected='selected'"; ?>><?php print_string('adminseesallevents', 'admin'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>startwday:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpstartofweek', 'admin'); ?></div>
|
||||
<p><?php choose_from_menu($weekdays, 'startwday', empty($CFG->calendar_startwday) ? 0 : $CFG->calendar_startwday, ''); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>weekenddays:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpweekenddays', 'admin'); ?></div>
|
||||
<p>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="1" id="weekend1" <?php if(CALENDAR_WEEKEND & 2) echo 'checked="checked"'; ?> /> <label for="weekend1"><?php print_string('monday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="2" id="weekend2" <?php if(CALENDAR_WEEKEND & 4) echo 'checked="checked"'; ?> /> <label for="weekend2"><?php print_string('tuesday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="3" id="weekend3" <?php if(CALENDAR_WEEKEND & 8) echo 'checked="checked"'; ?> /> <label for="weekend3"><?php print_string('wednesday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="4" id="weekend4" <?php if(CALENDAR_WEEKEND & 16) echo 'checked="checked"'; ?> /> <label for="weekend4"><?php print_string('thursday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="5" id="weekend5" <?php if(CALENDAR_WEEKEND & 32) echo 'checked="checked"'; ?> /> <label for="weekend5"><?php print_string('friday', 'calendar'); ?></label></span>
|
||||
<br />
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="6" id="weekend6" <?php if(CALENDAR_WEEKEND & 64) echo 'checked="checked"'; ?> /> <label for="weekend6"><?php print_string('saturday', 'calendar'); ?></label></span>
|
||||
<span style="white-space: nowrap;"><input type="checkbox" name="weekend[]" value="0" id="weekend0" <?php if(CALENDAR_WEEKEND & 1) echo 'checked="checked"'; ?> /> <label for="weekend0"><?php print_string('sunday', 'calendar'); ?></label></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>upcoming_lookahead:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpupcominglookahead', 'admin'); ?></div>
|
||||
<p><input type="text" name="lookahead" size="3" value="<?php echo CALENDAR_UPCOMING_DAYS; ?>" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>upcoming_maxevents:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpupcomingmaxevents', 'admin'); ?></div>
|
||||
<p><input type="text" name="maxevents" size="3" value="<?php echo CALENDAR_UPCOMING_MAXEVENTS; ?>" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>timezones:</th>
|
||||
<td>
|
||||
<div><?php print_string('helpforcetimezone', 'admin'); ?></div>
|
||||
<p><?php choose_from_menu($timezones, 'forcetimezone', $CFG->forcetimezone, get_string('timezonenotforced', 'admin'), '', '99'); ?></p>
|
||||
<p><a href="timezoneimport.php"><?php print_string('importtimezones', 'admin'); ?>...</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center">
|
||||
<input type="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
@@ -1,98 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure calendar and date/time stuff
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only administrators can use this page!');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error('Site isn\'t defined!');
|
||||
}
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strcalendarsettings = get_string('calendarsettings', 'admin');
|
||||
|
||||
print_header("$site->shortname: $strcalendarsettings", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strcalendarsettings");
|
||||
|
||||
print_heading($strcalendarsettings);
|
||||
|
||||
/// If data submitted, process and store
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
if(isset($form->adminseesallcourses)) {
|
||||
set_config('calendar_adminseesall', intval($form->adminseesallcourses) != 0);
|
||||
unset($SESSION->cal_courses_shown);
|
||||
}
|
||||
if(isset($form->forcetimezone)) {
|
||||
// To protect from SQL injections ...
|
||||
$form->timezone = clean_param($form->timezone, PARAM_PATH); //not a path, but it looks like it anyway
|
||||
set_config('forcetimezone', $form->forcetimezone);
|
||||
}
|
||||
if(isset($form->startwday)) {
|
||||
$startwday = intval($form->startwday);
|
||||
if($startwday >= 0 && $startwday <= 6) {
|
||||
set_config('calendar_startwday', $startwday);
|
||||
}
|
||||
}
|
||||
if(isset($form->weekend)) {
|
||||
if(is_array($form->weekend)) {
|
||||
// Creating a packed bitfield; look at /calendar/lib.php if you can't figure it out
|
||||
$bitfield = 0;
|
||||
foreach($form->weekend as $day) {
|
||||
$bitfield |= (1 << (intval($day) % 7));
|
||||
}
|
||||
if($bitfield > 0) {
|
||||
set_config('calendar_weekend', $bitfield);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($form->lookahead)) {
|
||||
$lookahead = intval($form->lookahead);
|
||||
if($lookahead > 0) {
|
||||
set_config('calendar_lookahead', $lookahead);
|
||||
}
|
||||
}
|
||||
if(isset($form->maxevents)) {
|
||||
$maxevents = intval($form->maxevents);
|
||||
if($maxevents > 0) {
|
||||
set_config('calendar_maxevents', $maxevents);
|
||||
}
|
||||
}
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
// Include the calendar library AFTER modifying the data, so we read the latest values
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
// Populate some variables we 're going to need in calendar.html
|
||||
$timezones = get_list_of_timezones();
|
||||
|
||||
$weekdays = array(
|
||||
0 => get_string('sunday', 'calendar'),
|
||||
1 => get_string('monday', 'calendar'),
|
||||
2 => get_string('tuesday', 'calendar'),
|
||||
3 => get_string('wednesday', 'calendar'),
|
||||
4 => get_string('thursday', 'calendar'),
|
||||
5 => get_string('friday', 'calendar'),
|
||||
6 => get_string('saturday', 'calendar')
|
||||
);
|
||||
|
||||
// Main display starts here
|
||||
|
||||
print_simple_box_start("center", "80%");
|
||||
include('./calendar.html');
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,619 @@
|
||||
<form method="post" action="config.php" name="form">
|
||||
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><p>lang:</td>
|
||||
<td>
|
||||
<?php choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", ""); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlang") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langmenu:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "langmenu", $config->langmenu, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlangmenu") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langlist:</td>
|
||||
<td>
|
||||
<input name=langlist type=text size=40 value="<?php p($config->langlist) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlanglist") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>locale:</td>
|
||||
<td>
|
||||
<input name=locale type=text size=10 value="<?php p($config->locale) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlocale") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>timezone:</td>
|
||||
<td><?php
|
||||
if (abs($config->timezone) > 13) {
|
||||
$config->timezone = 99;
|
||||
}
|
||||
$timenow = time();
|
||||
$timeformat = get_string('strftimedaytime');
|
||||
|
||||
for ($tz = -26; $tz <= 26; $tz++) {
|
||||
$zone = (float)$tz/2.0;
|
||||
$usertime = $timenow + ($tz * 1800);
|
||||
if ($tz == 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT)";
|
||||
} else if ($tz < 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT$zone)";
|
||||
} else {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT+$zone)";
|
||||
}
|
||||
}
|
||||
|
||||
choose_from_menu ($timezones, "timezone", $config->timezone, get_string("serverlocaltime"), "", "99");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configtimezone") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>country:</td>
|
||||
<td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configcountry") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtphosts:</td>
|
||||
<td>
|
||||
<input name=smtphosts type=text size=30 value="<?php p($config->smtphosts)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsmtphosts") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtpuser:</td>
|
||||
<td>
|
||||
<input name=smtpuser type=text size=10 value="<?php p($config->smtpuser)?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
<?php print_string("configsmtpuser") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtppass:</td>
|
||||
<td>
|
||||
<input name=smtppass type=text size=10 value="<?php p($config->smtppass)?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>noreplyaddress:</td>
|
||||
<td>
|
||||
<input name=noreplyaddress type=text size=30 value="<?php p($config->noreplyaddress)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("confignoreplyaddress") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>gdversion:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("gdnot");
|
||||
$options[1] = get_string("gd1");
|
||||
$options[2] = get_string("gd2");
|
||||
|
||||
$installed = check_gd_version();
|
||||
|
||||
choose_from_menu ($options, "gdversion", $installed, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configgdversion") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxeditingtime:</td>
|
||||
<td>
|
||||
<?php
|
||||
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);
|
||||
|
||||
choose_from_menu ($options, "maxeditingtime", $config->maxeditingtime, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configmaxeditingtime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>longtimenosee:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$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);
|
||||
|
||||
choose_from_menu ($options, "longtimenosee", $config->longtimenosee, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlongtimenosee") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>deleteunconfirmed:</td>
|
||||
<td>
|
||||
<?php
|
||||
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);
|
||||
|
||||
choose_from_menu ($options, "deleteunconfirmed", $config->deleteunconfirmed, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdeleteunconfirmed") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>loglifetime:</td>
|
||||
<td>
|
||||
<?php
|
||||
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);
|
||||
|
||||
choose_from_menu ($options, "loglifetime", $config->loglifetime, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configloglifetime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>displayloginfailures:</p></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[''] = get_string('nobody');
|
||||
$options['admin'] = get_string('administrators');
|
||||
$options['teacher'] = get_string('administratorsandteachers');
|
||||
$options['everybody'] = get_string('everybody');
|
||||
choose_from_menu($options, "displayloginfailures",$config->displayloginfailures,"","","");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdisplayloginfailures") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>notifyloginfailures:</p></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[''] = get_string('nobody');
|
||||
$options['mainadmin'] = get_string('administrator');
|
||||
$options['alladmins'] = get_string('administratorsall');
|
||||
choose_from_menu($options,"notifyloginfailures",$config->notifyloginfailures,"","","");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('confignotifyloginfailures') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>notifyloginthreshold:</p></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
for ($i=1; $i<=100; $i++) {
|
||||
$options[$i] = "$i";
|
||||
}
|
||||
choose_from_menu($options,"notifyloginthreshold",$config->notifyloginthreshold,"","","");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('confignotifyloginthreshold') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessiontimeout:</td>
|
||||
<td>
|
||||
<?php
|
||||
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);
|
||||
|
||||
choose_from_menu ($options, "sessiontimeout", $config->sessiontimeout, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsessiontimeout") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessioncookie:</td>
|
||||
<td>
|
||||
<input name=sessioncookie type=text size=10 value="<?php p($config->sessioncookie)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsessioncookie") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>zip:</td>
|
||||
<td>
|
||||
<input name=zip type=text size=30 value="<?php p($config->zip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configzip") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>unzip:</td>
|
||||
<td>
|
||||
<input name=unzip type=text size=30 value="<?php p($config->unzip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configunzip") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>slasharguments:</td>
|
||||
<td>
|
||||
<?php unset($options);
|
||||
$options[0] = "file.php?file=/pic.jpg";
|
||||
$options[1] = "file.php/pic.jpg";
|
||||
|
||||
choose_from_menu ($options, "slasharguments", $config->slasharguments, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configslasharguments") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyhost:</td>
|
||||
<td>
|
||||
<input name=proxyhost type=text size=30 value="<?php p($config->proxyhost) ?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
<?php print_string("configproxyhost") ?>
|
||||
</td>
|
||||
</TR>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyport:</td>
|
||||
<td>
|
||||
<input name=proxyport type=text size=5 value="<?php p($config->proxyport) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>debug:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[7] = get_string("no");
|
||||
$options[15] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "debug", $config->debug, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdebug") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>framename:</td>
|
||||
<td>
|
||||
<?php
|
||||
if (empty($config->framename)) {
|
||||
$config->framename = "_top";
|
||||
}
|
||||
?>
|
||||
<input name=framename type=text size=15 value="<?php p($config->framename)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configframename") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>secureforms:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "secureforms", $config->secureforms, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsecureforms") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>loginhttps:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "loginhttps", $config->loginhttps, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configloginhttps") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>teacherassignteachers:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "teacherassignteachers", $config->teacherassignteachers, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configteacherassignteachers") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>allusersaresitestudents:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "allusersaresitestudents", $config->allusersaresitestudents, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configallusersaresitestudents") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>showsiteparticipantslist:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("siteteachers");
|
||||
$options[1] = get_string("allteachers");
|
||||
$options[2] = get_string("studentsandteachers");
|
||||
choose_from_menu ($options, "showsiteparticipantslist", $config->showsiteparticipantslist, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configshowsiteparticipantslist") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>allowunenroll:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "allowunenroll", $config->allowunenroll, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configallowunenroll") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxbytes:</td>
|
||||
<td>
|
||||
<?php
|
||||
$options = get_max_upload_sizes();
|
||||
choose_from_menu ($options, "maxbytes", $config->maxbytes, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configmaxbytes") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>fullnamedisplay:</td>
|
||||
<td>
|
||||
<?php
|
||||
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');
|
||||
|
||||
choose_from_menu ($options, "fullnamedisplay", $config->fullnamedisplay, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configfullnamedisplay") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>extendedusernamechars:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "extendedusernamechars", $config->extendedusernamechars, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configextendedusernamechars") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>autologinguests:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "autologinguests", $config->autologinguests, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configautologinguests") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>forcelogin:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "forcelogin", $config->forcelogin, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configforcelogin") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>forceloginforprofiles:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "forceloginforprofiles", $config->forceloginforprofiles, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configforceloginforprofiles") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>opentogoogle:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "opentogoogle", $config->opentogoogle, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configopentogoogle") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>enablerssfeeds:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "enablerssfeeds", $config->enablerssfeeds, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
print_string("configenablerssfeeds");
|
||||
//Check for required functions...
|
||||
if(!function_exists('utf8_encode')) {
|
||||
echo "<font color=\"red\"> You need to add XML support to your PHP installation.</font>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>digestmailtime:</td>
|
||||
<td>
|
||||
<?php
|
||||
$hours = array();
|
||||
for ($i=0; $i<=23; $i++) {
|
||||
$hours[$i] = sprintf("%02d",$i);
|
||||
}
|
||||
choose_from_menu($hours, 'digestmailtime', $config->digestmailtime, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
print_string('configdigestmailtime');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=3 align=center>
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>">
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
+28
-87
@@ -1,27 +1,25 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$focus = '';
|
||||
require_once("../config.php");
|
||||
|
||||
if ($site = get_site()) { // If false then this is a new installation
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error('Only the admin can use this page');
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
}
|
||||
|
||||
/// This is to overcome the "insecure forms paradox"
|
||||
if (isset($secureforms) and $secureforms == 0) {
|
||||
$match = 'nomatch';
|
||||
$match = "nomatch";
|
||||
} else {
|
||||
$match = '';
|
||||
$match = "";
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted($match)) {
|
||||
if ($config = data_submitted($match)) {
|
||||
|
||||
if (!empty($USER->id)) { // Additional identity check
|
||||
if (!confirm_sesskey()) {
|
||||
@@ -32,35 +30,26 @@
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
print_header();
|
||||
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);
|
||||
}
|
||||
$value = eregi_replace("[^a-zA-Z]", "", $value);
|
||||
}
|
||||
unset($conf);
|
||||
$conf->name = $name;
|
||||
$conf->value = $value;
|
||||
if ($current = get_record('config', 'name', $name)) {
|
||||
if ($current = get_record("config", "name", $name)) {
|
||||
$conf->id = $current->id;
|
||||
if (! update_record('config', $conf)) {
|
||||
if (! update_record("config", $conf)) {
|
||||
notify("Could not update $name to $value");
|
||||
}
|
||||
} else {
|
||||
if (! insert_record('config', $conf)) {
|
||||
if (! insert_record("config", $conf)) {
|
||||
notify("Error: could not add new variable $name !");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect('index.php', get_string('changessaved'), 1);
|
||||
redirect("index.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
@@ -68,23 +57,23 @@
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
if (!$config->locale = get_field('config', 'value', 'name', 'locale')) {
|
||||
if (!$config->locale = get_field("config", "value", "name", "locale")) {
|
||||
$config->locale = $CFG->lang;
|
||||
}
|
||||
}
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strconfigvariables = get_string('configvariables', 'admin');
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strconfigvariables = get_string("configvariables");
|
||||
|
||||
if ($site) {
|
||||
print_header("$site->shortname: $strconfigvariables", $site->fullname,
|
||||
@@ -94,64 +83,15 @@
|
||||
} else {
|
||||
print_header();
|
||||
print_heading($strconfigvariables);
|
||||
print_simple_box(get_string('configintro', 'admin'), 'center', "50%");
|
||||
echo '<br />';
|
||||
print_simple_box(get_string("configintro"), "center", "50%");
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
|
||||
/// 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>';
|
||||
|
||||
|
||||
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
/// Lock some options
|
||||
|
||||
@@ -159,7 +99,7 @@
|
||||
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 '<script>'."\n";
|
||||
echo '<!--'."\n";
|
||||
echo "eval('document.form.loginhttps.disabled=true');\n";
|
||||
echo '-->'."\n";
|
||||
@@ -184,4 +124,5 @@ function validate_form(&$form, &$err) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+27
-30
@@ -1,52 +1,49 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only admins can access this page');
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect('index.php');
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
|
||||
print_header("$site->shortname: $stradministration: $strconfiguration", "$site->fullname",
|
||||
'<a href="index.php">'. "$stradministration</a> -> $strconfiguration");
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strconfiguration");
|
||||
|
||||
print_heading($strconfiguration);
|
||||
|
||||
$table->align = array ('right', 'left');
|
||||
$table->align = array ("right", "left");
|
||||
|
||||
$table->data[] = array("<strong><a href=\"config.php\">". get_string('configvariables', 'admin') .'</a></strong>',
|
||||
get_string('adminhelpconfigvariables'));
|
||||
$table->data[] = array("<strong><a href=\"site.php\">". get_string('sitesettings') .'</a></strong>',
|
||||
get_string('adminhelpsitesettings'));
|
||||
$table->data[] = array("<strong><a href=\"../theme/index.php\">". get_string('themes') .'</a></strong>',
|
||||
get_string('adminhelpthemes'));
|
||||
$table->data[] = array("<strong><a href=\"lang.php\">". get_string('language') .'</a></strong>',
|
||||
get_string('adminhelplanguage'));
|
||||
$table->data[] = array("<strong><a href=\"modules.php\">".get_string('managemodules'). ' </a></strong>',
|
||||
get_string('adminhelpmanagemodules'));
|
||||
$table->data[] = array("<strong><a href=\"blocks.php\">". get_string('manageblocks') .'</a></strong>',
|
||||
get_string('adminhelpmanageblocks'));
|
||||
$table->data[] = array("<strong><a href=\"filters.php\">". get_string('managefilters') .'</a></strong>',
|
||||
get_string('adminhelpmanagefilters'));
|
||||
$table->data[] = array("<b><a href=\"config.php\">".get_string("configvariables")."</a></b>",
|
||||
get_string("adminhelpconfigvariables"));
|
||||
$table->data[] = array("<b><a href=\"site.php\">".get_string("sitesettings")."</a></b>",
|
||||
get_string("adminhelpsitesettings"));
|
||||
$table->data[] = array("<b><a href=\"../theme/index.php\">".get_string("themes")."</a></b>",
|
||||
get_string("adminhelpthemes"));
|
||||
$table->data[] = array("<b><a href=\"lang.php\">".get_string("language")."</a></b>",
|
||||
get_string("adminhelplanguage"));
|
||||
$table->data[] = array("<b><a href=\"modules.php\">".get_string("managemodules")."</a></b>",
|
||||
get_string("adminhelpmanagemodules"));
|
||||
$table->data[] = array("<b><a href=\"blocks.php\">".get_string("manageblocks")."</a></b>",
|
||||
get_string("adminhelpmanageblocks"));
|
||||
$table->data[] = array("<b><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a></b>",
|
||||
get_string("adminhelpmanagefilters"));
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$table->data[] = array("<strong><a href=\"backup.php\">".get_string("backup")."</a></strong>",
|
||||
get_string('adminhelpbackup'));
|
||||
$table->data[] = array("<b><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a></b>",
|
||||
get_string("adminhelpbackup"));
|
||||
}
|
||||
|
||||
$table->data[]= array("<strong><a href=\"editor.php\">". get_string('editorsettings') ."</a></strong>",
|
||||
get_string('adminhelpeditorsettings'));
|
||||
$table->data[]= array("<strong><a href=\"calendar.php\">". get_string('calendarsettings', 'admin') ."</a></strong>",
|
||||
get_string('helpcalendarsettings', 'admin'));
|
||||
$table->data[]= array("<strong><a href=\"maintenance.php\">". get_string('sitemaintenancemode', 'admin') ."</a></strong>",
|
||||
get_string('helpsitemaintenance', 'admin'));
|
||||
$table->data[]= array("<b><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a></b>",
|
||||
get_string("adminhelpeditorsettings"));
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
@@ -1,651 +0,0 @@
|
||||
<?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[7] = $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=/pic.jpg";
|
||||
$options[1] = "file.php/pic.jpg";
|
||||
|
||||
$operatingsystem['slasharguments'] = new configvar (get_string('configslasharguments', 'admin'),
|
||||
choose_from_menu ($options, 'slasharguments', $config->slasharguments, '', '', '', true) );
|
||||
|
||||
/// proxyhost
|
||||
$operatingsystem['proxyhost'] = new configvar (get_string('configproxyhost', 'admin'),
|
||||
'<input name="proxyhost" type="text" size="30" value="'.s($config->proxyhost).'" alt="proxyhost" />' );
|
||||
|
||||
/// proxyport
|
||||
$operatingsystem['proxyport'] = new configvar ('',
|
||||
'<input name="proxyport" type="text" size="5" value="'.s($config->proxyport).'" alt="proxyport" />' );
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// PERMISSIONS config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$permissions = array();
|
||||
|
||||
/// teacherassignteachers
|
||||
$permissions['teacherassignteachers'] = new configvar (get_string('configteacherassignteachers', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'teacherassignteachers', $config->teacherassignteachers, '', '', '', true) );
|
||||
|
||||
/// allowunenroll
|
||||
$permissions['allowunenroll'] = new configvar (get_string('configallowunenroll', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowunenroll', $config->allowunenroll, '', '', '', true) );
|
||||
|
||||
/// allusersaresitestudents
|
||||
$permissions['allusersaresitestudents'] = new configvar (get_string('configallusersaresitestudents', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allusersaresitestudents', $config->allusersaresitestudents, '', '', '', true) );
|
||||
|
||||
/// showsiteparticipantslist
|
||||
unset($options);
|
||||
$options[0] = get_string('siteteachers');
|
||||
$options[1] = get_string('allteachers');
|
||||
$options[2] = get_string('studentsandteachers');
|
||||
|
||||
$permissions['showsiteparticipantslist'] = new configvar (get_string('configshowsiteparticipantslist', 'admin'),
|
||||
choose_from_menu ($options, 'showsiteparticipantslist', $config->showsiteparticipantslist, '', '', '', true) );
|
||||
|
||||
/// forcelogin
|
||||
$permissions['forcelogin'] = new configvar (get_string('configforcelogin', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'forcelogin', $config->forcelogin, '', '', '', true) );
|
||||
|
||||
/// forceloginforprofiles
|
||||
$permissions['forceloginforprofiles'] = new configvar (get_string('configforceloginforprofiles', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'forceloginforprofiles', $config->forceloginforprofiles, '', '', '', true) );
|
||||
|
||||
/// opentogoogle
|
||||
$permissions['opentogoogle'] = new configvar (get_string('configopentogoogle', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'opentogoogle', $config->opentogoogle, '', '', '', true) );
|
||||
|
||||
/// maxbytes
|
||||
$options = get_max_upload_sizes();
|
||||
|
||||
$permissions['maxbytes'] = new configvar (get_string('configmaxbytes', 'admin'),
|
||||
choose_from_menu ($options, 'maxbytes', $config->maxbytes, '', '', 0, true) );
|
||||
|
||||
/// messaging
|
||||
$permissions['messaging'] = new configvar (get_string('configmessaging', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'messaging', $config->messaging, '', '', '', true) );
|
||||
|
||||
/// allowobjectembed
|
||||
$permissions['allowobjectembed'] = new configvar (get_string('configallowobjectembed', 'admin'),
|
||||
choose_from_menu ($noyesoptions, 'allowobjectembed', $config->allowobjectembed, '', '', '', true) );
|
||||
|
||||
|
||||
unset($options);
|
||||
$options['none'] = 'No courses';
|
||||
$options['all'] = 'All courses';
|
||||
$options['requested'] = 'Requested courses';
|
||||
|
||||
$permissions['restrictmodulesfor'] = new configvar (get_string('configrestrictmodulesfor','admin'),
|
||||
' <script language="JavaScript">
|
||||
function togglemodules(index) {
|
||||
if (index == 0) {
|
||||
document.getElementById(\'allowedmodules\').disabled=true;
|
||||
}
|
||||
else {
|
||||
document.getElementById(\'allowedmodules\').disabled=false;
|
||||
}
|
||||
}
|
||||
</script>'.
|
||||
choose_from_menu($options,'restrictmodulesfor',$config->restrictmodulesfor,'','togglemodules(this.selectedIndex);','',true) );
|
||||
|
||||
$permissions['restrictbydefault'] = new configvar (get_string('configrestrictbydefault','admin'),
|
||||
choose_from_menu($noyesoptions, 'restrictbydefault',$config->restrictbydefault,'','','',true) );
|
||||
|
||||
$allowstr = '<select name="defaultallowedmodules[]" id="allowedmodules" multiple="multiple" size="10"'.((empty($config->restrictmodulesfor)) ? "disabled=\"disabled\"" : "").'>';
|
||||
|
||||
$allowedmodules = array();
|
||||
if (!empty($config->defaultallowedmodules)) {
|
||||
$allowedmodules = explode(',',$config->defaultallowedmodules);
|
||||
}
|
||||
|
||||
// On a fresh install of Moodle, this could be empty; prevent a warning on the following loop.
|
||||
if (!$mods = get_records("modules")) {
|
||||
$mods = array();
|
||||
}
|
||||
$s = "selected=\"selected\"";
|
||||
$allowstr .= '<option value="0" '.((empty($allowedmodules)) ? $s : '').'>'.get_string('allownone').'</option>'."\n";
|
||||
foreach ($mods as $mod) {
|
||||
$selected = "";
|
||||
if (in_array($mod->id,$allowedmodules))
|
||||
$selected = $s;
|
||||
$allowstr .= '<option '.$selected.' value="'.$mod->id.'">'.$mod->name.'</option>'."\n";
|
||||
}
|
||||
$allowstr .= '</select>';
|
||||
|
||||
$permissions['defaultallowedmodules'] = new configvar (get_string('configdefaultallowedmodules','admin'),$allowstr);
|
||||
|
||||
|
||||
/// course requests
|
||||
$reqcourse['enablecourserequests'] = new configvar (get_string('configenablecourserequests', 'admin'),
|
||||
choose_from_menu ($noyesoptions,'enablecourserequests',$config->enablecourserequests,'','','',true) );
|
||||
|
||||
/// default category for course requests
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
$reqcourse['defaultrequestedcategory'] = new configvar (get_string('configdefaultrequestedcategory', 'admin'),
|
||||
choose_from_menu (make_categories_options(), 'defaultrequestedcategory',$config->defaultrequestedcategory,'','','',true) );
|
||||
|
||||
$reqcourse['requestedteachername'] = new configvar (get_string('configrequestedteachername','admin'),
|
||||
'<input type="text" name="requestedteachername" size="20" maxlength="100" value="'.s($config->requestedteachername).'" />');
|
||||
|
||||
$reqcourse['requestedteachersname'] = new configvar (get_string('configrequestedteachersname','admin'),
|
||||
'<input type="text" name="requestedteachersname" size="20" maxlength="100" value="'.s($config->requestedteachersname).'" />');
|
||||
|
||||
$reqcourse['requestedstudentname'] = new configvar (get_string('configrequestedstudentname','admin'),
|
||||
'<input type="text" name="requestedstudentname" size="20" maxlength="100" value="'.s($config->requestedstudentname).'" />');
|
||||
|
||||
$reqcourse['requestedstudentsname'] = new configvar (get_string('configrequestedstudentsname','admin'),
|
||||
'<input type="text" name="requestedstudentsname" size="20" maxlength="100" value="'.s($config->requestedstudentsname).'" />');
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// INTERFACE config variables
|
||||
////////////////////////////////////////////////////////////////////
|
||||
$interface = array();
|
||||
|
||||
/// language settings
|
||||
$interface['lang'] = new configvar ( get_string('configlang', 'admin'),
|
||||
choose_from_menu(get_list_of_languages(), 'lang', $config->lang, '', '', '', true) );
|
||||
|
||||
/// language menu
|
||||
$interface['langmenu'] = new configvar ( get_string('configlangmenu', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'langmenu', $config->langmenu, '', '', '', true) );
|
||||
|
||||
/// language list
|
||||
$interface['langlist'] = new configvar ( get_string('configlanglist', 'admin'),
|
||||
'<input name="langlist" type="text" size="60" value="'.s($config->langlist).'" alt="langlist" />' );
|
||||
|
||||
/// language menu
|
||||
$interface['langcache'] = new configvar ( get_string('configlangcache', 'admin'),
|
||||
choose_from_menu($noyesoptions, 'langcache', $config->langcache, '', '', '', true) );
|
||||
|
||||
/// locale
|
||||
$interface['locale'] = new configvar ( get_string('configlocale', 'admin'),
|
||||
'<input name="locale" type="text" size="10" 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" />' );
|
||||
|
||||
/// 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
|
||||
$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;
|
||||
$configvars['stats'] = $stats;
|
||||
|
||||
?>
|
||||
+4
-12
@@ -5,19 +5,11 @@
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = count($creators);
|
||||
$a->items = $strexistingcreators;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
<?php echo count($creators) . " ". $strexistingcreators ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$a->count = $usercount;
|
||||
$a->items = $strpotentialcreators;
|
||||
print_string('counteditems', '', $a);
|
||||
?>
|
||||
<?php echo $usercount . " " . $strpotentialcreators ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -64,10 +56,10 @@
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
function
|
||||
</script>
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext) ?>"
|
||||
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
|
||||
onFocus ="document.creatorsform.add.disabled=true;
|
||||
document.creatorsform.remove.disabled=true;
|
||||
document.creatorsform.removeselect.selectedIndex=-1;
|
||||
|
||||
+7
-4
@@ -1,10 +1,14 @@
|
||||
<?PHP // $Id$
|
||||
// Admin only script to assign course creator rights to users
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
optional_variable($search, "");
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
@@ -38,7 +42,7 @@
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassigncreators",
|
||||
print_header("$site->shortname: $strassigncreators",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
|
||||
$strassigncreators", "creatorsform.searchtext");
|
||||
@@ -46,7 +50,6 @@
|
||||
|
||||
if (!$frm = data_submitted()) {
|
||||
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
|
||||
$frm = new object();
|
||||
|
||||
/// A form was submitted so process the input
|
||||
|
||||
@@ -70,7 +73,7 @@
|
||||
}
|
||||
|
||||
/// Is there a current search?
|
||||
$previoussearch = (!empty($frm->search) or (isset($frm->previoussearch) && $frm->previoussearch == 1)) ;
|
||||
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
|
||||
|
||||
|
||||
/// Get all existing creators
|
||||
|
||||
+23
-156
@@ -26,8 +26,7 @@
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot.'/lib/adminlib.php');
|
||||
require_once("../config.php");
|
||||
|
||||
if (!$alreadyadmin = isadmin()) {
|
||||
unset($_SESSION['USER']);
|
||||
@@ -35,13 +34,8 @@
|
||||
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, '/');
|
||||
|
||||
/// Start output log
|
||||
|
||||
$timenow = time();
|
||||
@@ -72,37 +66,6 @@
|
||||
}
|
||||
mtrace("Finished activity modules");
|
||||
|
||||
mtrace("Starting blocks");
|
||||
if ($blocks = get_records_select("block", "cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
// we will need the base class.
|
||||
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
|
||||
foreach ($blocks as $block) {
|
||||
$blockfile = $CFG->dirroot.'/blocks/'.$block->name.'/block_'.$block->name.'.php';
|
||||
if (file_exists($blockfile)) {
|
||||
require_once($blockfile);
|
||||
$classname = 'block_'.$block->name;
|
||||
$blockobj = new $classname;
|
||||
if (method_exists($blockobj,'cron')) {
|
||||
mtrace("Processing cron function for ".$block->name.'....','');
|
||||
if ($blockobj->cron()) {
|
||||
if (!set_field('block','lastcron',$timenow,'id',$block->id)) {
|
||||
mtrace('Error: could not update timestamp for '.$block->name);
|
||||
}
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mtrace("Finished blocks");
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages();
|
||||
}
|
||||
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
/// to randomly choose the percentage of times we should run these jobs.
|
||||
@@ -132,28 +95,12 @@
|
||||
$oneweek = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
if ($users = get_users_unconfirmed($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
if (delete_records("user", "id", $user->id)) {
|
||||
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
/// Delete users who haven't completed profile within required period
|
||||
|
||||
$oneweek = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
if ($users = get_users_not_fully_set_up($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted not fully setup user $user->username ($user->id)");
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
/// Delete old logs to save space (this might need a timer to slow it down...)
|
||||
|
||||
@@ -166,8 +113,8 @@
|
||||
/// Delete old cached texts
|
||||
|
||||
if (!empty($CFG->cachetext)) { // Defined in config.php
|
||||
$cachelifetime = time() - $CFG->cachetext - 60; // Add an extra minute to allow for really heavy sites
|
||||
delete_records_select('cache_text', "timemodified < '$cachelifetime'");
|
||||
$cachelifetime = time() - $CFG->cachetext;
|
||||
delete_records_select("cache_text", "timemodified < '$cachelifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
@@ -176,47 +123,18 @@
|
||||
}
|
||||
flush();
|
||||
|
||||
sync_metacourses();
|
||||
|
||||
//
|
||||
// generate new password emails for users
|
||||
//
|
||||
mtrace('checking for create_password');
|
||||
if (count_records('user_preferences', 'name', 'create_password', 'value', '1')) {
|
||||
mtrace('creating passwords for new users');
|
||||
$newusers = get_records_sql("SELECT u.id as id, u.email, u.firstname,
|
||||
u.lastname, u.username,
|
||||
p.id as prefid
|
||||
FROM {$CFG->prefix}user u
|
||||
JOIN {$CFG->prefix}user_preferences p ON u.id=p.userid
|
||||
WHERE p.name='create_password' AND p.value=1 AND u.email !='' ");
|
||||
|
||||
foreach ($newusers as $newuserid => $newuser) {
|
||||
$newuser->emailstop = 0; // send email regardless
|
||||
// email user
|
||||
if (setnew_password_and_mail($newuser)) {
|
||||
// remove user pref
|
||||
delete_records('user_preferences', 'id', $newuser->prefid);
|
||||
} else {
|
||||
trigger_error("Could not create and mail new user password!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of occasional clean-up tasks
|
||||
|
||||
if (file_exists("$CFG->dataroot/cronextra.php")) {
|
||||
mtrace("Running extra commands in $CFG->dataroot/cronextra.php ...");
|
||||
include("$CFG->dataroot/cronextra.php");
|
||||
}
|
||||
|
||||
if (!isset($CFG->disablescheduledbackups)) { // Defined in config.php
|
||||
//Execute backup's cron
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("128M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
// if we are running from Apache, give httpd a hint that
|
||||
// it can recycle the process after it's done. Apache's
|
||||
// memory management is truly awful but we can help it.
|
||||
@apache_child_terminate();
|
||||
}
|
||||
raise_memory_limit("128M");
|
||||
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
|
||||
file_exists("$CFG->dirroot/backup/backuplib.php") and
|
||||
file_exists("$CFG->dirroot/backup/lib.php") and
|
||||
@@ -228,7 +146,7 @@
|
||||
mtrace("Running backups if required...");
|
||||
|
||||
if (! schedule_backup_cron()) {
|
||||
mtrace("ERROR: Something went wrong while performing backup tasks!!!");
|
||||
mtrace("ERORR: Something went wrong while performing backup tasks!!!");
|
||||
} else {
|
||||
mtrace("Backup tasks finished.");
|
||||
}
|
||||
@@ -236,75 +154,24 @@
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablerssfeeds)) { //Defined in admin/variables page
|
||||
include_once("$CFG->libdir/rsslib.php");
|
||||
mtrace("Running rssfeeds if required...");
|
||||
if (file_exists("$CFG->dirroot/rss/rsslib.php")) {
|
||||
include_once("$CFG->dirroot/rss/rsslib.php");
|
||||
mtrace("Running rssfeeds if required...");
|
||||
|
||||
if ( ! cron_rss_feeds()) {
|
||||
mtrace("Something went wrong while generating rssfeeds!!!");
|
||||
} else {
|
||||
mtrace("Rssfeeds finished");
|
||||
if ( ! cron_rss_feeds()) {
|
||||
mtrace("Something went wrong while generating rssfeeds!!!");
|
||||
} else {
|
||||
mtrace("Rssfeeds finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the enrolment cron, if any
|
||||
if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
|
||||
$plugins = array($CFG->enrol);
|
||||
}
|
||||
require_once($CFG->dirroot .'/enrol/enrol.class.php');
|
||||
foreach ($plugins as $p) {
|
||||
$enrol = enrolment_factory::factory($p);
|
||||
if (method_exists($enrol, 'cron')) {
|
||||
$enrol->cron();
|
||||
}
|
||||
if (!empty($enrol->log)) {
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
unset($enrol);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
|
||||
// check we're not before our runtime
|
||||
$timetocheck = strtotime("$CFG->statsruntimestarthour:$CFG->statsruntimestartminute today");
|
||||
|
||||
if (time() > $timetocheck) {
|
||||
$time = 60*60*20; // set it to 20 here for first run... (overridden by $CFG)
|
||||
$clobber = true;
|
||||
if (!empty($CFG->statsmaxruntime)) {
|
||||
$time = $CFG->statsmaxruntime+(60*30); // add on half an hour just to make sure (it could take that long to break out of the loop)
|
||||
}
|
||||
if (!get_field_sql('SELECT id FROM '.$CFG->prefix.'stats_daily LIMIT 1')) {
|
||||
// first run, set another lock. we'll check for this in subsequent runs to set the timeout to later for the normal lock.
|
||||
set_cron_lock('statsfirstrunlock',true,$time,true);
|
||||
$firsttime = true;
|
||||
}
|
||||
$time = 60*60*2; // this time set to 2.. (overridden by $CFG)
|
||||
if (!empty($CFG->statsmaxruntime)) {
|
||||
$time = $CFG->statsmaxruntime+(60*30); // add on half an hour to make sure (it could take that long to break out of the loop)
|
||||
}
|
||||
if ($config = get_record('config','name','statsfirstrunlock')) {
|
||||
if (!empty($config->value)) {
|
||||
$clobber = false; // if we're on the first run, just don't clobber it.
|
||||
}
|
||||
}
|
||||
if (set_cron_lock('statsrunning',true,$time, $clobber)) {
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
$return = stats_cron_daily();
|
||||
if (stats_check_runtime() && $return == STATS_RUN_COMPLETE) {
|
||||
stats_cron_weekly();
|
||||
}
|
||||
if (stats_check_runtime() && $return == STATS_RUN_COMPLETE) {
|
||||
$return = $return && stats_cron_monthly();
|
||||
}
|
||||
if (stats_check_runtime() && $return == STATS_RUN_COMPLETE) {
|
||||
stats_clean_old();
|
||||
}
|
||||
set_cron_lock('statsrunning',false);
|
||||
if (!empty($firsttime)) {
|
||||
set_cron_lock('statsfirstrunlock',false);
|
||||
}
|
||||
}
|
||||
}
|
||||
require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
|
||||
$enrol = new enrolment_plugin();
|
||||
$enrol->cron();
|
||||
if (!empty($enrol->log)) {
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
|
||||
//Unset session variables and destroy it
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
<?PHP // $Id$
|
||||
// dbperformance.php - shows latest ADOdb stats for the current server
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$topframe = optional_param('topframe', 0, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', 0, PARAM_BOOL);
|
||||
$do = optional_param('do', '', PARAM_ALPHA);
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -17,13 +13,13 @@
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
if (!empty($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
|
||||
if (isset($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> Database performance");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($bottomframe) or !empty($do)) {
|
||||
if (isset($bottomframe) or isset($_GET['do'])) {
|
||||
$perf =&NewPerfMonitor($db);
|
||||
$perf->UI($pollsecs=5);
|
||||
exit;
|
||||
|
||||
+17
-24
@@ -3,38 +3,31 @@
|
||||
// Deletes the moodledata directory, COMPLETELY!!
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
$sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
$reallysure = optional_param('reallysure', 0, PARAM_BOOL);
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be admin to use this script!');
|
||||
error("You must be admin to use this script!");
|
||||
}
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
if (empty($sure)) {
|
||||
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 'delete.php?sure=yes&sesskey='.sesskey(), 'index.php');
|
||||
if (!$sure) {
|
||||
notice_yesno ("Are you completely sure you want to delete everything inside the directory $deletedir ?", "delete.php?sure=yes", "index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($reallysure)) {
|
||||
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?', 'delete.php?sure=yes&reallysure=yes&sesskey='.sesskey(), 'index.php');
|
||||
if (!$reallysure) {
|
||||
notice_yesno ("Are you REALLY REALLY completely sure you want to delete everything inside the directory $deletedir (this includes all user images, and any other course files that have been created) ?", "delete.php?sure=yes&reallysure=yes", "index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error('This script was called wrongly');
|
||||
}
|
||||
|
||||
/// OK, here goes ...
|
||||
|
||||
delete_subdirectories($deletedir);
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
echo "<H1 align=center>Done!</H1>";
|
||||
print_continue($CFG->wwwroot);
|
||||
exit;
|
||||
|
||||
@@ -44,22 +37,22 @@ function delete_subdirectories($rootdir) {
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
if (filetype($fullfile) == 'dir') {
|
||||
if ($file != "." and $file != "..") {
|
||||
$fullfile = "$rootdir/$file";
|
||||
if (filetype($fullfile) == "dir") {
|
||||
delete_subdirectories($fullfile);
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
echo "Deleting $fullfile ... ";
|
||||
if (rmdir($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
echo "Done.<BR>";
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
echo "FAILED.<BR>";
|
||||
}
|
||||
} else {
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (unlink($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
echo "Deleting $fullfile ... ";
|
||||
if (unlink("$fullfile")) {
|
||||
echo "Done.<BR>";
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
echo "FAILED.<BR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-262
@@ -1,10 +1,9 @@
|
||||
<form method="post" action="editor.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="tab" value="<?php p($currentpage) ?>" />
|
||||
<form method="post" action="<?php print($GLOBALS['ME']);?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table border="0" cellpadding="4" cellspacing="2">
|
||||
<tr>
|
||||
<td align="right" valign="top">htmleditor:</td>
|
||||
<td valign="top">
|
||||
<tr valign=top>
|
||||
<td align=right><p>htmleditor:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("allownot");
|
||||
@@ -13,23 +12,22 @@
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('confightmleditor', 'admin') ?>
|
||||
<?php print_string("confightmleditor") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $currenttab == 'htmlarea' ) { ?>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorbackgroundcolor:</td>
|
||||
<td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>" /></td>
|
||||
<td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>"></td>
|
||||
<td valign="top"><?php print_string("edhelpbgcolor");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorfontfamily:</td>
|
||||
<td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>" /></td>
|
||||
<td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>"></td>
|
||||
<td valign="top"><?php print_string("edhelpfontfamily");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorfontsize:</td>
|
||||
<td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>" /></td>
|
||||
<td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>"></td>
|
||||
<td valign="top"><?php print_string("edhelpfontsize");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -40,14 +38,9 @@
|
||||
</select></td>
|
||||
<td valign="top"><?php print_string("edhelpcleanword");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">aspellpath:</td>
|
||||
<td valign="top"><input onchange="change_state()" id="aspellpath" type="text" name="aspellpath" size="25" value="<?php print($CFG->aspellpath);?>" /></td>
|
||||
<td valign="top"><?php print_string("edhelpaspellpath");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorspelling:</td>
|
||||
<td valign="top"><select onchange="change_state()" id="spelling" name="spelling"<?php
|
||||
<td valign="top"><select name="spelling"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editorspelling = false;
|
||||
@@ -55,28 +48,7 @@
|
||||
?>>
|
||||
<option value="1"<?php print(!$CFG->editorspelling)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
|
||||
<option value="0"<?php print(!$CFG->editorspelling)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
|
||||
</select>
|
||||
<select id="dictionary" name="dictionary"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editordictionary = false;
|
||||
}
|
||||
?>>
|
||||
<?php
|
||||
if (is_array($dicts)) {
|
||||
foreach ($dicts as $dict) {
|
||||
echo "<option value=\"$dict\"";
|
||||
if (!empty($CFG->editordictionary)) {
|
||||
print ($CFG->editordictionary != $dict) ? "" : " selected=\"selected\"";
|
||||
}
|
||||
echo ">$dict</option>\n";
|
||||
}
|
||||
} else if (is_string($dicts)) {
|
||||
echo '<option value="">'. $dicts .'</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</select></td>
|
||||
<td valign="top"><?php print_string("edhelpenablespelling");?></td>
|
||||
</tr>
|
||||
<tr><td colspan="3"><br /><?php print_string("edhelpfontlist");?></td></tr>
|
||||
@@ -87,7 +59,7 @@
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>">
|
||||
<input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>" /></td>
|
||||
<input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>"></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
@@ -95,237 +67,19 @@
|
||||
?>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="" />
|
||||
<input type="text" name="fontnamevalue[]" size="30" value="" /></td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="">
|
||||
<input type="text" name="fontnamevalue[]" size="30" value=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right">editorhidebuttons:</td>
|
||||
<td colspan="2">
|
||||
<?php
|
||||
$buttons = array();
|
||||
if (!empty($CFG->editorhidebuttons)) {
|
||||
$buttons = explode(chr(32), $CFG->editorhidebuttons);
|
||||
}
|
||||
?>
|
||||
<table border="0" cellpadding="2" cellspacing="1">
|
||||
<tr>
|
||||
<td colspan="12"><input type="checkbox" name="buttons[fontname]"<?php print(in_array("fontname", $buttons)) ? " checked=\"checked\"": "";?> /> <?php print_string("fontname","editor");?>
|
||||
<input type="checkbox" name="buttons[fontsize]"<?php print(in_array("fontsize", $buttons)) ? " checked=\"checked\"": "";?> /> <?php print_string("fontsize","editor");?>
|
||||
<input type="checkbox" name="buttons[formatblock]"<?php print(in_array("formatblock", $buttons)) ? " checked=\"checked\"": "";?> /> <?php print_string("formatblock","editor");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_bold.gif" width="18" height="18" alt="<?php print_string("bold","editor");?>" title="<?php print_string("bold","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_italic.gif" width="18" height="18" alt="<?php print_string("italic","editor");?>" title="<?php print_string("italic","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_underline.gif" width="18" height="18" alt="<?php print_string("underline","editor");?>" title="<?php print_string("underline","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_strike.gif" width="18" height="18" alt="<?php print_string("strikethrough","editor");?>" title="<?php print_string("strikethrough","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_sub.gif" width="18" height="18" alt="<?php print_string("subscript","editor");?>" title="<?php print_string("subscript","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_format_sup.gif" width="18" height="18" alt="<?php print_string("superscript","editor");?>" title="<?php print_string("superscript","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_copy.gif" width="18" height="18" alt="<?php print_string("copy","editor");?>" title="<?php print_string("copy","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_cut.gif" width="18" height="18" alt="<?php print_string("cut","editor");?>" title="<?php print_string("cut","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_paste.gif" width="18" height="18" alt="<?php print_string("paste","editor");?>" title="<?php print_string("paste","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_wordclean.gif" width="18" height="18" alt="<?php print_string("wordclean","editor");?>" title="<?php print_string("wordclean","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_undo.gif" width="18" height="18" alt="<?php print_string("undo","editor");?>" title="<?php print_string("undo","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_redo.gif" width="18" height="18" alt="<?php print_string("redo","editor");?>" title="<?php print_string("redo","editor");?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[bold]"<?php print(in_array("bold", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[italic]"<?php print(in_array("italic", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[underline]"<?php print(in_array("underline", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[strikethrough]"<?php print(in_array("strikethrough", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[subscript]"<?php print(in_array("subscript", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[superscript]"<?php print(in_array("superscript", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[copy]"<?php print(in_array("copy", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[cut]"<?php print(in_array("cut", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[paste]"<?php print(in_array("paste", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[clean]"<?php print(in_array("clean", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[undo]"<?php print(in_array("undo", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[redo]"<?php print(in_array("redo", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_left.gif" width="18" height="18" alt="<?php print_string("justifyleft","editor");?>" title="<?php print_string("justifyleft","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_center.gif" width="18" height="18" alt="<?php print_string("justifycenter","editor");?>" title="<?php print_string("justifycenter","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_right.gif" width="18" height="18" alt="<?php print_string("justifyright","editor");?>" title="<?php print_string("justifyright","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_align_justify.gif" width="18" height="18" alt="<?php print_string("justifyfull","editor");?>" title="<?php print_string("justifyfull","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_left_to_right.gif" width="18" height="18" alt="<?php print_string("lefttoright","editor");?>" title="<?php print_string("lefttoright","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_right_to_left.gif" width="18" height="18" alt="<?php print_string("righttoleft","editor");?>" title="<?php print_string("righttoleft","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_list_num.gif" width="18" height="18" alt="<?php print_string("orderedlist","editor");?>" title="<?php print_string("orderedlist","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_list_bullet.gif" width="18" height="18" alt="<?php print_string("unorderedlist","editor");?>" title="<?php print_string("unorderedlist","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_indent_less.gif" width="18" height="18" alt="<?php print_string("outdent","editor");?>" title="<?php print_string("outdent","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_indent_more.gif" width="18" height="18" alt="<?php print_string("indent","editor");?>" title="<?php print_string("indent","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_color_fg.gif" width="18" height="18" alt="<?php print_string("forecolor","editor");?>" title="<?php print_string("forecolor","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_color_bg.gif" width="18" height="18" alt="<?php print_string("hilitecolor","editor");?>" title="<?php print_string("hilitecolor","editor");?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[justifyleft]"<?php print(in_array("justifyleft", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[justifycenter]"<?php print(in_array("justifycenter", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[justifyright]"<?php print(in_array("justifyright", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[justifyfull]"<?php print(in_array("justifyfull", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[lefttoright]"<?php print(in_array("lefttoright", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[righttoleft]"<?php print(in_array("righttoleft", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertorderedlist]"<?php print(in_array("insertorderedlist", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertunorderedlist]"<?php print(in_array("insertunorderedlist", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[outdent]"<?php print(in_array("outdent", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[indent]"<?php print(in_array("indent", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[forecolor]"<?php print(in_array("forecolor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[hilitecolor]"<?php print(in_array("hilitecolor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_hr.gif" width="18" height="18" alt="<?php print_string("horizontalrule","editor");?>" title="<?php print_string("horizontalrule","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_anchor.gif" width="18" height="18" alt="<?php print_string("createanchor","editor");?>" title="<?php print_string("createanchor","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_link.gif" width="18" height="18" alt="<?php print_string("insertlink","editor");?>" title="<?php print_string("insertlink","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_unlink.gif" width="18" height="18" alt="<?php print_string("removelink","editor");?>" title="<?php print_string("removelink","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_image.gif" width="18" height="18" alt="<?php print_string("insertimage","editor");?>" title="<?php print_string("insertimage","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/insert_table.gif" width="18" height="18" alt="<?php print_string("inserttable","editor");?>" title="<?php print_string("inserttable","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/em.icon.smile.gif" width="18" height="18" alt="<?php print_string("insertsmile","editor");?>" title="<?php print_string("insertsmile","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/icon_ins_char.gif" width="18" height="18" alt="<?php print_string("insertchar","editor");?>" title="<?php print_string("insertchar","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/spell-check.gif" width="18" height="18" alt="<?php print_string("spellcheck","editor");?>" title="<?php print_string("spellcheck","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_html.gif" width="18" height="18" alt="<?php print_string("htmlmode","editor");?>" title="<?php print_string("htmlmode","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/fullscreen_maximize.gif" width="18" height="18" alt="<?php print_string("popupeditor","editor");?>" title="<?php print_string("popupeditor","editor");?>" /></td>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_replace.gif" width="18" height="18" alt="<?php print_string("popupeditor","editor");?>" title="<?php print_string("searchandreplace","editor");?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[inserthorizontalrule]"<?php print(in_array("inserthorizontalrule", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[createanchor]"<?php print(in_array("createanchor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[createlink]"<?php print(in_array("createlink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[unlink]"<?php print(in_array("unlink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertimage]"<?php print(in_array("insertimage", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[inserttable]"<?php print(in_array("inserttable", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertsmile]"<?php print(in_array("insertsmile", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[insertchar]"<?php print(in_array("insertchar", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[spellcheck]"<?php print(in_array("spellcheck", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[htmlmode]"<?php print(in_array("htmlmode", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[popupeditor]"<?php print(in_array("popupeditor", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td><input type="checkbox" name="buttons[search_replace]"<?php print(in_array("search_replace", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/ed_nolink.gif" width="18" height="18" alt="<?php print_string("horizontalrule","editor");?>" title="<?php print_string("nolink","editor");?>" /></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="buttons[nolink]"<?php print(in_array("nolink", $buttons)) ? " checked=\"checked\"" : "" ;?> /></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
else if ( $currenttab == 'tinymce' ) {
|
||||
?>
|
||||
<tr>
|
||||
<td>tinymcetheme:</td>
|
||||
<td><?php
|
||||
$options = array('advanced' => 'Advanced','simple' => 'Simple');
|
||||
choose_from_menu ($options, "tinymcetheme", $CFG->tinymcetheme, "", "", "");
|
||||
?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">tinymceplugins:</td>
|
||||
<td nowrap="nowrap"><?php
|
||||
$pluginsdir = $CFG->libdir .'/editor/tinymce/jscripts/tiny_mce/plugins';
|
||||
$plugins = editor_get_tiny_plugins();
|
||||
$pluginsinuse = explode(",", $CFG->tinymceplugins);
|
||||
|
||||
sort($plugins);
|
||||
$cnt = 0;
|
||||
echo '<table border="0" cellpadding="2">';
|
||||
foreach ( $plugins as $plugin ) {
|
||||
$num = ($cnt % 2);
|
||||
if ( $num < 1 ) {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<td><input type="checkbox" name="tinymceplugins[]" value="'. s($plugin) .'"';
|
||||
if ( in_array($plugin, $pluginsinuse) ) {
|
||||
echo ' checked="checked"';
|
||||
}
|
||||
echo ' /> '. $plugin .'</td>'."\n";
|
||||
|
||||
if ( $num > 0 ) {
|
||||
echo '</tr>';
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
echo '</table>';
|
||||
?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tinymcecontentcss:</td>
|
||||
<td><input type="text" name="tinymcecontentcss" value="<?php
|
||||
!empty($CFG->tinymcecontentcss) ? p($CFG->tinymcecontentcss) : ''; ?>" size="40" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tinymcepopupcss:</td>
|
||||
<td><input type="text" name="tinymcepopupcss" value="<?php
|
||||
!empty($CFG->tinymcepopupcss) ? p($CFG->tinymcepopupcss) : ''; ?>" size="40" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tinymceeditorcss:</td>
|
||||
<td><input type="text" name="tinymceeditorcss" value="<?php
|
||||
!empty($CFG->tinymceeditorcss) ? p($CFG->tinymceeditorcss) : ''; ?>" size="40" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>" /></td>
|
||||
<td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<form method="post" action="<?php print($GLOBALS['ME']);?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="tab" value="<?php p($currentpage) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<center>
|
||||
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
|
||||
</center>
|
||||
</form>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
|
||||
function change_state () {
|
||||
|
||||
var choice = document.forms[0].spelling;
|
||||
var speller = choice.options[choice.selectedIndex].value;
|
||||
var spellpath = document.forms[0].aspellpath.value;
|
||||
|
||||
if (spellpath == '') {
|
||||
document.forms[0].spelling.disabled = true;
|
||||
} else {
|
||||
document.forms[0].spelling.disabled = false;
|
||||
}
|
||||
|
||||
if (speller != 1) {
|
||||
document.forms[0].dictionary.disabled = true;
|
||||
} else {
|
||||
document.forms[0].dictionary.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
document.onload = change_state();
|
||||
-->
|
||||
</script>
|
||||
|
||||
+25
-191
@@ -1,54 +1,36 @@
|
||||
<?php // $Id$
|
||||
/// configuration routines for HTMLArea editor
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$currentpage = optional_param('tab', 1, PARAM_INT);
|
||||
|
||||
require_once("../config.php");
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (($data = data_submitted()) && confirm_sesskey()) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if ($data = data_submitted()) {
|
||||
|
||||
// do we want default values?
|
||||
if (isset($data->resettodefaults)) {
|
||||
if (!(reset_to_defaults($currentpage))) {
|
||||
if(!(reset_to_defaults())) {
|
||||
error("Editor settings could not be restored!");
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!(editor_update_config($data, $currentpage))) {
|
||||
if(!(editor_update_config($data))) {
|
||||
error("Editor settings could not be updated!");
|
||||
}
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/editor.php?tab=$currentpage", get_string("changessaved"), 1);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/editor.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
|
||||
} else {
|
||||
// Generate edit form
|
||||
|
||||
$inactive = array();
|
||||
switch ( $currentpage ) {
|
||||
case 1:
|
||||
$currenttab = 'htmlarea';
|
||||
break;
|
||||
case 2:
|
||||
$currenttab = 'tinymce';
|
||||
break;
|
||||
default:
|
||||
error("Unknown currentpage: $currentpage");
|
||||
}
|
||||
|
||||
//$url = 'editor.php?tab=';
|
||||
//$tabrow = array();
|
||||
//$tabrow[] = new tabobject('htmlarea',$url . '1', 'HTMLArea');
|
||||
//$tabrow[] = new tabobject('tinymce',$url . '2', 'TinyMCE');
|
||||
//$tabs = array($tabrow);
|
||||
|
||||
$fontlist = editor_convert_to_array($CFG->editorfontlist);
|
||||
$dicts = editor_get_dictionaries();
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
@@ -58,12 +40,9 @@
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $streditorsettings");
|
||||
print_heading($streditorsettings);
|
||||
|
||||
print_simple_box("<center>$streditorsettingshelp</center>","center","50%");
|
||||
print("<br />\n");
|
||||
//print_tabs($tabs, $currenttab, $inactive);
|
||||
|
||||
print_simple_box_start("center");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("editor.html");
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
@@ -75,14 +54,14 @@
|
||||
function editor_convert_to_array ($string) {
|
||||
/// Converts $CFG->editorfontlist to array
|
||||
|
||||
if (empty($string) || !is_string($string)) {
|
||||
if(empty($string) || !is_string($string)) {
|
||||
return false;
|
||||
}
|
||||
$fonts = array();
|
||||
|
||||
$lines = explode(";", $string);
|
||||
foreach ($lines as $line) {
|
||||
if (!empty($line)) {
|
||||
foreach($lines as $line) {
|
||||
if(!empty($line)) {
|
||||
list($fontkey, $fontvalue) = explode(":", $line);
|
||||
$fonts[$fontkey] = $fontvalue;
|
||||
}
|
||||
@@ -91,16 +70,13 @@ function editor_convert_to_array ($string) {
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
function editor_update_config ($data, $editor) {
|
||||
|
||||
function editor_update_config ($data) {
|
||||
/// Updates the editor config values.
|
||||
|
||||
if (!is_object($data)) {
|
||||
if(!is_object($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch($editor) {
|
||||
case 1: // HTMLArea.
|
||||
// Make array for unwanted characters.
|
||||
$nochars = array(chr(33),chr(34),chr(35),chr(36),chr(37),
|
||||
chr(38),chr(39),chr(40),chr(41),chr(42),
|
||||
@@ -112,9 +88,8 @@ function editor_update_config ($data, $editor) {
|
||||
$fontlist = '';
|
||||
|
||||
// make font string
|
||||
$cnt = count($data->fontname);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if (!empty($data->fontname[$i])) {
|
||||
for($i = 0; $i < count($data->fontname); $i++) {
|
||||
if(!empty($data->fontname[$i])) {
|
||||
$fontlist .= str_replace($nochars, "", $data->fontname[$i]) .":";
|
||||
$fontlist .= str_replace($nochars, "", $data->fontnamevalue[$i]) .";";
|
||||
}
|
||||
@@ -124,50 +99,16 @@ function editor_update_config ($data, $editor) {
|
||||
|
||||
// make array of values to update
|
||||
$updatedata = array();
|
||||
$updatedata['htmleditor'] = !empty($data->htmleditor) ? $data->htmleditor : 0;
|
||||
$updatedata['htmleditor'] = $data->htmleditor;
|
||||
$updatedata['editorbackgroundcolor'] = !empty($data->backgroundcolor) ? $data->backgroundcolor : "#ffffff";
|
||||
$updatedata['editorfontfamily'] = !empty($data->fontfamily) ? str_replace($nochars,"",$data->fontfamily) : "Times New Roman, Times";
|
||||
$updatedata['editorfontsize'] = !empty($data->fontsize) ? $data->fontsize : "";
|
||||
$updatedata['editorkillword'] = !empty($data->killword) ? $data->killword : 0;
|
||||
$updatedata['editorkillword'] = !empty($data->killword) ? $data->killword : "true";
|
||||
$updatedata['editorspelling'] = !empty($data->spelling) ? $data->spelling : 0;
|
||||
$updatedata['editorfontlist'] = $fontlist;
|
||||
$updatedata['editordictionary'] = !empty($data->dictionary) ? $data->dictionary : '';
|
||||
$updatedata['aspellpath'] = !empty($data->aspellpath) ? $data->aspellpath : '';
|
||||
|
||||
$hidebuttons = '';
|
||||
if (!empty($data->buttons) && is_array($data->buttons)) {
|
||||
foreach ($data->buttons as $key => $value) {
|
||||
$hidebuttons .= $key . " ";
|
||||
}
|
||||
}
|
||||
$updatedata['editorhidebuttons'] = trim($hidebuttons);
|
||||
break;
|
||||
|
||||
case 2: // TinyMCE.
|
||||
$updatedata = array();
|
||||
$updatedata['htmleditor'] = !empty($data->htmleditor) ? $data->htmleditor : 0;
|
||||
|
||||
// Process plugins
|
||||
if ( !empty($data->tinymceplugins) ) {
|
||||
foreach ( $data->tinymceplugins as $key => $value ) {
|
||||
$value = stripslashes(clean_param($value, PARAM_ALPHA));
|
||||
$data->tinymceplugins[$key] = addslashes($value);
|
||||
}
|
||||
}
|
||||
$updatedata['tinymceplugins'] = !empty($data->tinymceplugins) ? implode(",", $data->tinymceplugins) : '';
|
||||
$updatedata['tinymcetheme'] = !empty($data->tinymcetheme) ?
|
||||
clean_param($data->tinymcetheme, PARAM_ALPHA) : '';
|
||||
$updatedata['tinymcecontentcss'] = !empty($data->tinymcecontentcss) ?
|
||||
clean_param($data->tinymcecontentcss, PARAM_URL) : '';
|
||||
$updatedata['tinymcepopupcss'] = !empty($data->tinymcepopupcss) ?
|
||||
clean_param($data->tinymcepopupcss, PARAM_URL) : '';
|
||||
$updatedata['tinymceeditorcss'] = !empty($data->tinymceeditorcss) ?
|
||||
clean_param($data->tinymceeditorcss, PARAM_URL) : '';
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($updatedata as $name => $value) {
|
||||
if (!(set_config($name, $value))) {
|
||||
foreach($updatedata as $name => $value) {
|
||||
if(!(set_config($name, $value))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -175,132 +116,25 @@ function editor_update_config ($data, $editor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset_to_defaults ($editor) {
|
||||
/// Reset the values to default
|
||||
|
||||
function reset_to_defaults () {
|
||||
global $CFG;
|
||||
include_once($CFG->dirroot .'/lib/defaults.php');
|
||||
|
||||
$updatedata = array();
|
||||
|
||||
switch ( $editor ) {
|
||||
case 1: // HTMLArea.
|
||||
$updatedata['htmleditor'] = $defaults['htmleditor'];
|
||||
$updatedata['editorbackgroundcolor'] = $defaults['editorbackgroundcolor'];
|
||||
$updatedata['editorfontfamily'] = $defaults['editorfontfamily'];
|
||||
$updatedata['editorfontsize'] = $defaults['editorfontsize'];
|
||||
$updatedata['editorkillword'] = $defaults['editorkillword'];
|
||||
$updatedata['editorspelling'] = $defaults['editorspelling'];
|
||||
$updatedata['editorfontlist'] = $defaults['editorfontlist'];
|
||||
$updatedata['editorhidebuttons'] = $defaults['editorhidebuttons'];
|
||||
$updatedata['editordictionary'] = '';
|
||||
break;
|
||||
|
||||
case 2: // TinyMCE.
|
||||
$updatedata['tinymceplugins'] = $defaults['tinymceplugins'];
|
||||
$updatedata['tinymcetheme'] = $defaults['tinymcetheme'];
|
||||
$updatedata['tinymcecontentcss'] = $defaults['tinymcecontentcss'];
|
||||
$updatedata['tinymcepopupcss'] = $defaults['tinymcepopupcss'];
|
||||
$updatedata['tinymceeditorcss'] = $defaults['tinymceeditorcss'];
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($updatedata as $name => $value) {
|
||||
if (!(set_config($name, $value))) {
|
||||
foreach($updatedata as $name => $value) {
|
||||
if(!(set_config($name, $value))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function editor_get_dictionaries () {
|
||||
/// Get all installed dictionaries in the system
|
||||
|
||||
global $CFG;
|
||||
|
||||
error_reporting(E_ALL); // for debug, final version shouldn't have this...
|
||||
clearstatcache();
|
||||
|
||||
$strerror = '';
|
||||
|
||||
// If aspellpath isn't set don't even bother ;-)
|
||||
if (empty($CFG->aspellpath)) {
|
||||
return $strerror = 'Empty aspell path!';
|
||||
}
|
||||
|
||||
// Do we have access to popen function?
|
||||
if (!function_exists('popen')) {
|
||||
return $strerror = "Popen function disabled!";
|
||||
exit;
|
||||
}
|
||||
|
||||
global $CFG;
|
||||
|
||||
$cmd = $CFG->aspellpath;
|
||||
$output = '';
|
||||
$dictionaries = array();
|
||||
$dicts = array();
|
||||
|
||||
if(!($handle = @popen(escapeshellarg($cmd) .' dump dicts', 'r'))) {
|
||||
return $strerror = "Couldn't create handle!";
|
||||
exit;
|
||||
}
|
||||
|
||||
while(!feof($handle)) {
|
||||
$output .= fread($handle, 1024);
|
||||
}
|
||||
@pclose($handle);
|
||||
|
||||
$dictionaries = explode(chr(10), $output);
|
||||
|
||||
// Get rid of possible empty values
|
||||
if (is_array($dictionaries)) {
|
||||
|
||||
$cnt = count($dictionaries);
|
||||
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if (!empty($dictionaries[$i])) {
|
||||
$dicts[] = $dictionaries[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($dicts) >= 1) {
|
||||
return $dicts;
|
||||
}
|
||||
|
||||
$strerror = "Error! Check your aspell installation!";
|
||||
return $strerror;
|
||||
|
||||
}
|
||||
|
||||
function editor_get_tiny_plugins() {
|
||||
global $CFG;
|
||||
|
||||
$plugins = array();
|
||||
$plugindir = $CFG->libdir .'/editor/tinymce/jscripts/tiny_mce/plugins';
|
||||
|
||||
if ( !$fp = opendir($plugindir) ) {
|
||||
return $plugins;
|
||||
exit;
|
||||
}
|
||||
|
||||
while ( ($file = readdir($fp)) !== false ) {
|
||||
|
||||
if ( preg_match("/^\.+/", $file) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_dir($plugindir .'/'. $file) ) {
|
||||
array_push($plugins, $file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $fp ) {
|
||||
closedir($fp);
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
+43
-65
@@ -2,11 +2,10 @@
|
||||
// enrol.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once('../config.php');
|
||||
include("../config.php");
|
||||
|
||||
$enrol = optional_param('enrol', $CFG->enrol);
|
||||
|
||||
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
|
||||
$CFG->pagepath = 'enrol';
|
||||
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
@@ -21,91 +20,70 @@
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrol = clean_filename($enrol);
|
||||
require_once("$CFG->dirroot/enrol/$enrol/enrol.php"); /// Open the class
|
||||
|
||||
/// Save settings
|
||||
$enrolment = new enrolment_plugin();
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if (empty($frm->enable)) {
|
||||
$frm->enable = array();
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($enrolment->process_config($frm)) {
|
||||
set_config('enrol', $frm->enrol);
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
if (empty($frm->default)) {
|
||||
$frm->default = '';
|
||||
}
|
||||
if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) {
|
||||
$frm->enable[] = $frm->default;
|
||||
}
|
||||
asort($frm->enable);
|
||||
$frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first
|
||||
set_config('enrol_plugins_enabled', implode(',', $frm->enable));
|
||||
set_config('enrol', $frm->default);
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
} else {
|
||||
$frm = $CFG;
|
||||
}
|
||||
|
||||
/// Print the form
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
|
||||
|
||||
print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
|
||||
"<a href=\"index.php\">$str->administration</a> ->
|
||||
<a href=\"users.php\">$str->users</a> -> $str->enrolmentplugins");
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$options = array();
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
|
||||
print_header("$site->shortname: $str->enrolments", "$site->fullname",
|
||||
"<a href=\"index.php\">$str->administration</a> ->
|
||||
<a href=\"users.php\">$str->users</a> -> $str->enrolments");
|
||||
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
echo "<div align=\"center\"><p><b>";
|
||||
|
||||
$table = new stdClass();
|
||||
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
|
||||
$table->align = array('left', 'center', 'center', 'center');
|
||||
$table->size = array('60%', '', '', '15%');
|
||||
$table->width = '700';
|
||||
$table->data = array();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
/// Choose an enrolment method
|
||||
echo get_string('chooseenrolmethod').': ';
|
||||
choose_from_menu ($options, "enrol", $enrol, "",
|
||||
"document.location='enrol.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
|
||||
|
||||
// skip if directory is empty
|
||||
if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
|
||||
continue;
|
||||
}
|
||||
echo "</b></p></div>";
|
||||
|
||||
/// Print current enrolment type description
|
||||
print_simple_box_start("center", "80%", "$THEME->cellheading");
|
||||
print_heading($options[$enrol]);
|
||||
|
||||
$name = get_string("enrolname", "enrol_$module");
|
||||
$plugin = enrolment_factory::factory($module);
|
||||
$enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
|
||||
if (stristr($CFG->enrol_plugins_enabled, $module) !== false) {
|
||||
$enable .= ' checked="checked"';
|
||||
}
|
||||
if ($module == 'manual') {
|
||||
$enable .= ' disabled="disabled"';
|
||||
}
|
||||
$enable .= ' />';
|
||||
if (method_exists($plugin, 'print_entry')) {
|
||||
$default = '<input type="radio" name="default" value="'.$module.'"';
|
||||
if ($CFG->enrol == $module) {
|
||||
$default .= ' checked="checked"';
|
||||
}
|
||||
$default .= ' />';
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
$table->data[$name] = array($name, $enable, $default,
|
||||
'<a href="enrol_config.php?sesskey='.$USER->sesskey.'&enrol='.$module.'">'.$str->edit.'</a>');
|
||||
}
|
||||
asort($table->data);
|
||||
print_simple_box_start("center", "60%", "$THEME->cellcontent");
|
||||
print_string("description", "enrol_$enrol");
|
||||
print_simple_box_end();
|
||||
|
||||
print_table($table);
|
||||
echo "<hr>";
|
||||
// print_heading($str->settings);
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
|
||||
echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
exit;
|
||||
?>
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
$enrol = required_param('enrol', PARAM_ALPHA);
|
||||
$CFG->pagepath = 'enrol/' . $enrol;
|
||||
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory($enrol);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($enrolment->process_config($frm)) {
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
} else {
|
||||
$frm = $CFG;
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
|
||||
"<a href=\"index.php\">$str->administration</a> ->
|
||||
<a href=\"users.php\">$str->users</a> ->
|
||||
<a href=\"enrol.php?sesskey=$USER->sesskey\">$str->enrolmentplugins</a> ->
|
||||
$str->configuration");
|
||||
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
echo "<div align=\"center\"><p><b>";
|
||||
|
||||
|
||||
/// Choose an enrolment method
|
||||
echo get_string('chooseenrolmethod').': ';
|
||||
choose_from_menu ($options, "enrol", $enrol, "",
|
||||
"document.location='enrol_config.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
|
||||
|
||||
echo "</b></p></div>";
|
||||
|
||||
/// Print current enrolment type description
|
||||
print_simple_box_start("center", "80%");
|
||||
print_heading($options[$enrol]);
|
||||
|
||||
print_simple_box_start("center", "60%", '', 5, 'informationbox');
|
||||
print_string("description", "enrol_$enrol");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
@@ -1,149 +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 file is the admin frontend to execute all the checks available
|
||||
// in the environment.xml file. It includes database, php and
|
||||
// php_extensions. Also, it's possible to update the xml file
|
||||
// from moodle.org be able to check more and more versions.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
|
||||
/// Parameters
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
|
||||
/// Security checks
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You need to be admin to use this page');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
/// Get some strings
|
||||
$stradmin = get_string('administration');
|
||||
$stradminhelpenvironment = get_string("adminhelpenvironment");
|
||||
$strenvironment = get_string('environment', 'admin');
|
||||
$strerror = get_string('error');
|
||||
$strmoodleversion = get_string('moodleversion');
|
||||
$strupdate = get_string('updatecomponent', 'admin');
|
||||
$strupwards = get_string('upwards', 'admin');
|
||||
|
||||
/// Print the header stuff
|
||||
print_header("$SITE->shortname: $strenvironment", $SITE->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".$strenvironment);
|
||||
|
||||
/// Print the component download link
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.$USER->sesskey.'">'.$strupdate.'</a></div>';
|
||||
|
||||
print_heading($strenvironment);
|
||||
|
||||
/// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
/// Create component installer and execute it
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest= $CFG->dataroot.'/';
|
||||
print_simple_box(get_string($cd->get_error(), 'error', $a), 'center', '', '', 5, 'errorbox');
|
||||
} else {
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center', '', '', 5, 'errorbox');
|
||||
}
|
||||
break;
|
||||
case UPTODATE:
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center');
|
||||
break;
|
||||
case INSTALLED:
|
||||
print_simple_box(get_string('componentinstalled', 'admin'), 'center');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start of main box
|
||||
print_simple_box_start('center');
|
||||
|
||||
echo "<center>".$stradminhelpenvironment."</center><br />";
|
||||
|
||||
/// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
|
||||
/// Calculate list of versions
|
||||
$versions = array();
|
||||
if ($contents = load_environment_xml()) {
|
||||
if ($env_versions = get_list_of_environment_versions($contents)) {
|
||||
/// Set the current version at the beginning
|
||||
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
||||
$versions[$env_version] = $current_version;
|
||||
/// If no version has been previously selected, default to $current_version
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
///Iterate over each version, adding bigged than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
}
|
||||
}
|
||||
/// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.$strupwards;
|
||||
} else {
|
||||
$versions = array('error' => $strerror);
|
||||
}
|
||||
}
|
||||
|
||||
/// Print form and popup menu
|
||||
echo '<center><form method="post" action="environment.php">';
|
||||
echo $strmoodleversion.' ';
|
||||
choose_from_menu ($versions, 'version', $version, null, 'this.form.submit();' );
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '</form></center>';
|
||||
/// End of main box
|
||||
print_simple_box_end();
|
||||
|
||||
/// Gather and show results
|
||||
$status = check_moodle_environment($version, $environment_results);
|
||||
|
||||
/// Other links
|
||||
echo '<div align="center">';
|
||||
print_single_button('phpinfo.php', NULL, get_string('phpinfo'));
|
||||
echo '</div>';
|
||||
|
||||
/// Print footer
|
||||
print_footer();
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<COMPATIBILITY_MATRIX>
|
||||
<MOODLE version="1.5">
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="3.23" />
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
</DATABASE>
|
||||
<PHP version="4.1.0" level="required" />
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="mbstring" level="optional" />
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.6">
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required" />
|
||||
<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_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.7">
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="8.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required" />
|
||||
<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_EXTENSIONS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php // $Id$
|
||||
// filter.php
|
||||
// Edit text filter settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// check for allowed access
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error( 'Only administrators can use the filters administration page' );
|
||||
}
|
||||
if (!$site = get_site()) {
|
||||
error( 'Site is not defined in filters administration page' );
|
||||
}
|
||||
|
||||
// get parameters
|
||||
$param = new Object;
|
||||
|
||||
$param->filter = required_param('filter', PARAM_PATH);
|
||||
$param->submit = optional_param('submit', 0, PARAM_BOOL);
|
||||
$param->reset = optional_param('reset', 0, PARAM_BOOL);
|
||||
|
||||
$filtername = substr($param->filter, strpos( $param->filter, '/' )+1 ) ;
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'filter/' . $filtername . '/config';
|
||||
|
||||
// get translated strings for use on page
|
||||
$txt = new Object;
|
||||
$txt->managefilters = get_string( 'managefilters' );
|
||||
$txt->administration = get_string( 'administration' );
|
||||
$txt->configuration = get_string( 'configuration' );
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
// if reset pressed let filter config page handle it
|
||||
$forcereset = false;
|
||||
if (!empty($param->reset)) {
|
||||
$forcereset = true;
|
||||
}
|
||||
else
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
// check session key
|
||||
if (!confirm_sesskey()) {
|
||||
error( get_string('confirmsesskeybad', 'error' ) );
|
||||
}
|
||||
|
||||
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
|
||||
if (file_exists($configpath)) {
|
||||
require_once($configpath);
|
||||
$functionname = $filtername.'_process_config';
|
||||
if (function_exists($functionname)) {
|
||||
$functionname($config);
|
||||
$saved = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($saved)) {
|
||||
// run through submitted data
|
||||
// reject if does not start with filter_
|
||||
foreach ($config as $name => $value) {
|
||||
set_config( $name,$value );
|
||||
}
|
||||
}
|
||||
redirect( "$CFG->wwwroot/$CFG->admin/filters.php", get_string('changessaved'), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
$filtername = ucfirst($filtername);
|
||||
print_header( "$site->shortname: $txt->managefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
|
||||
"-> <a href=\"filters.php\">$txt->managefilters</a> -> $filtername" );
|
||||
|
||||
print_heading( $txt->managefilters );
|
||||
|
||||
print_simple_box("<center>".get_string("configwarning", "admin")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center",'');
|
||||
|
||||
?>
|
||||
<form action="filter.php?filter=<?php echo urlencode($param->filter); ?>" method="post">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
|
||||
<?php include "$CFG->dirroot/$param->filter/filterconfig.html"; ?>
|
||||
|
||||
<center>
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
<input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
|
||||
</center>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="filters" id="filters" method="post" action="filters.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><div align="right">
|
||||
<br />
|
||||
<input name="up" type="submit" id="up" value="↑" />
|
||||
<br />
|
||||
<input name="down" type="submit" id="down" value="↓" />
|
||||
<br />
|
||||
</div></td>
|
||||
<td valign="top">
|
||||
<?php p($stractive) ?>
|
||||
<br />
|
||||
|
||||
<select name="iselect" size="20" id="iselect"
|
||||
onclick="document.filters.add.disabled=true;
|
||||
document.filters.remove.disabled=false;
|
||||
document.filters.uselect.selectedIndex=-1;">
|
||||
<?php
|
||||
$runscript = "";
|
||||
foreach ($installedfilters as $filter) {
|
||||
if ($selectedfilter == $filter) {
|
||||
$selected = " selected ";
|
||||
$runscript = "eval(\"document.filters.add.disabled=true\");
|
||||
eval(\"document.filters.remove.disabled=false\");
|
||||
eval(\"document.filters.uselect.selectedIndex=-1\");";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
|
||||
}
|
||||
?>
|
||||
</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">
|
||||
<?php p($strinactive) ?>
|
||||
<br />
|
||||
<select name="uselect" size="20" id="select"
|
||||
onclick="document.filters.add.disabled=false;
|
||||
document.filters.remove.disabled=true;
|
||||
document.filters.iselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($uninstalledfilters as $filter) {
|
||||
if ($selectedfilter == $filter) {
|
||||
$selected = " selected ";
|
||||
$runscript = "eval(\"document.filters.add.disabled=false\");
|
||||
eval(\"document.filters.remove.disabled=true\");
|
||||
eval(\"document.filters.iselect.selectedIndex=-1\");";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script language="Javascript">
|
||||
<!--
|
||||
<?php echo $runscript ?>
|
||||
|
||||
-->
|
||||
</script>
|
||||
<?php print_simple_box_end(); ?>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="options" id="options" method="post" action="filters.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<input type="hidden" name="options" value="1">
|
||||
<table cellpadding="20">
|
||||
<tr valign=top>
|
||||
<td nowrap="nowrap" align="right"><?php p($strcachetext) ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[10800] = get_string('numhours', '', 3);
|
||||
$options[7200] = get_string('numhours', '', 2);
|
||||
$options[3600] = get_string('numhours', '', 1);
|
||||
$options[2700] = get_string('numminutes', '', 45);
|
||||
$options[1800] = get_string('numminutes', '', 30);
|
||||
$options[900] = get_string('numminutes', '', 15);
|
||||
$options[600] = get_string('numminutes', '', 10);
|
||||
$options[540] = get_string('numminutes', '', 9);
|
||||
$options[480] = get_string('numminutes', '', 8);
|
||||
$options[420] = get_string('numminutes', '', 7);
|
||||
$options[360] = get_string('numminutes', '', 6);
|
||||
$options[300] = get_string('numminutes', '', 5);
|
||||
$options[240] = get_string('numminutes', '', 4);
|
||||
$options[180] = get_string('numminutes', '', 3);
|
||||
$options[120] = get_string('numminutes', '', 2);
|
||||
$options[60] = get_string('numminutes', '', 1);
|
||||
$options[30] = get_string('numseconds', '', 30);
|
||||
$options[0] = get_string('no');
|
||||
|
||||
choose_from_menu ($options, "cachetext", $CFG->cachetext, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php p($strconfigcachetext) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td nowrap="nowrap" align="right"><?php p($strfilteruploadedfiles) ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "filteruploadedfiles", $CFG->filteruploadedfiles, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php p($strconfigfilteruploadedfiles) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php print_simple_box_end(); ?>
|
||||
+137
-297
@@ -1,333 +1,173 @@
|
||||
<?php // $Id$
|
||||
// filters.php
|
||||
// Edit list of available text filters
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
require_once("../config.php");
|
||||
|
||||
// defines
|
||||
define('FILTER_TABLE','filter_administration_table');
|
||||
optional_variable($iselect);
|
||||
optional_variable($uselect);
|
||||
optional_variable($add);
|
||||
optional_variable($remove);
|
||||
optional_variable($up);
|
||||
optional_variable($down);
|
||||
|
||||
// check for allowed access
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only administrators can use the filters administration page');
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error('Site is not defined in filters administration page');
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
// get values from page
|
||||
$params = new object();
|
||||
$params->action = optional_param('action', '', PARAM_ACTION);
|
||||
$params->filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
$params->cachetext = optional_param('cachetext', 0, PARAM_INT);
|
||||
$params->filterall = optional_param('filterall', 0, PARAM_BOOL);
|
||||
$params->filteruploadedfiles = optional_param('filteruploadedfiles', 0, PARAM_INT);
|
||||
$params->filtermatchoneperpage = optional_param('filtermatchoneperpage', 0, PARAM_BOOL);
|
||||
$params->filtermatchonepertext = optional_param('filtermatchonepertext', 0, PARAM_BOOL);
|
||||
/// Print headings
|
||||
|
||||
// some basic information
|
||||
$url = 'filters.php';
|
||||
$myurl = "$url?sesskey=" . sesskey();
|
||||
$img = "$CFG->pixpath/t";
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagefilters = get_string("managefilters");
|
||||
$strversion = get_string("version");
|
||||
$strsettings = get_string("settings");
|
||||
$strup = get_string("up");
|
||||
$strdown = get_string("down");
|
||||
$stractive = get_string("active");
|
||||
$strinactive = get_string("inactive");
|
||||
$strcachetext = get_string("cachetext", "admin");
|
||||
$strconfigcachetext = get_string("configcachetext");
|
||||
$strfilteruploadedfiles = get_string("filteruploadedfiles", "admin");
|
||||
$strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles");
|
||||
|
||||
// get translated strings for use on page
|
||||
$txt = new object();
|
||||
$txt->managefilters = get_string('managefilters');
|
||||
$txt->administration = get_string('administration');
|
||||
$txt->configuration = get_string('configuration');
|
||||
$txt->name = get_string('name');
|
||||
$txt->hide = get_string('hide');
|
||||
$txt->show = get_string('show');
|
||||
$txt->hideshow = "$txt->hide/$txt->show";
|
||||
$txt->settings = get_string('settings');
|
||||
$txt->up = get_string('up');
|
||||
$txt->down = get_string('down');
|
||||
$txt->updown = "$txt->up/$txt->down";
|
||||
$txt->cachetext = get_string('cachetext', 'admin');
|
||||
$txt->configcachetext = get_string('configcachetext', 'admin');
|
||||
$txt->filteruploadedfiles = get_string('filteruploadedfiles','admin');
|
||||
$txt->configfilteruploadedfiles = get_string('configfilteruploadedfiles','admin');
|
||||
$txt->filterall = get_string('filterall','admin');
|
||||
$txt->filtermatchoneperpage = get_string('filtermatchoneperpage','admin');
|
||||
$txt->filtermatchonepertext = get_string('filtermatchonepertext','admin');
|
||||
$txt->configfilterall = get_string('configfilterall','admin');
|
||||
$txt->configfiltermatchoneperpage = get_string('configfiltermatchoneperpage','admin');
|
||||
$txt->configfiltermatchonepertext = get_string('configfiltermatchonepertext','admin');
|
||||
$txt->cachecontrols = get_string('cachecontrols');
|
||||
$txt->yes = get_string('yes');
|
||||
$txt->no = get_string('no');
|
||||
$txt->none = get_string('none');
|
||||
$txt->allfiles = get_string('allfiles');
|
||||
$txt->htmlfilesonly = get_string('htmlfilesonly');
|
||||
print_header("$site->shortname: $strmanagefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanagefilters");
|
||||
|
||||
print_heading($strmanagefilters);
|
||||
|
||||
|
||||
/// Make a list of all available filters and the best names for them we can find
|
||||
$allfilters = array();
|
||||
|
||||
$filterlocations = array("mod", "filter");
|
||||
|
||||
// get a list of possible filters (and translate name if possible)
|
||||
// note filters can be in the dedicated filters area OR in their
|
||||
// associated modules
|
||||
$installedfilters = array();
|
||||
$filtersettings = array();
|
||||
$filterlocations = array('mod','filter');
|
||||
foreach ($filterlocations as $filterlocation) {
|
||||
$plugins = get_list_of_plugins($filterlocation);
|
||||
foreach ($plugins as $plugin) {
|
||||
$pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php";
|
||||
$settingspath = "$CFG->dirroot/$filterlocation/$plugin/filterconfig.html";
|
||||
if (is_readable($pluginpath)) {
|
||||
foreach ($plugins as $key => $plugin) {
|
||||
if (is_readable("$CFG->dirroot/$filterlocation/$plugin/filter.php")) {
|
||||
$name = trim(get_string("filtername", $plugin));
|
||||
if (empty($name) or ($name == '[[filtername]]')) {
|
||||
$name = ucfirst($plugin);
|
||||
}
|
||||
$installedfilters["$filterlocation/$plugin"] = $name;
|
||||
if (is_readable($settingspath)) {
|
||||
$filtersettings[] = "$filterlocation/$plugin";
|
||||
if (empty($name) or $name == "[[filtername]]") {
|
||||
$name = $plugin;
|
||||
}
|
||||
$allfilters["$filterlocation/$plugin"] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all the currently selected filters
|
||||
|
||||
/// Make an array of all the currently installed filters
|
||||
|
||||
$installedfilters = array();
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$oldactivefilters = explode(',', $CFG->textfilters);
|
||||
$oldactivefilters = array_unique($oldactivefilters);
|
||||
} else {
|
||||
$oldactivefilters = array();
|
||||
}
|
||||
$installedfilters = explode(',',$CFG->textfilters);
|
||||
|
||||
// take this opportunity to clean up filters
|
||||
$activefilters = array();
|
||||
foreach ($oldactivefilters as $oldactivefilter) {
|
||||
if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) {
|
||||
$activefilters[] = $oldactivefilter;
|
||||
}
|
||||
}
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
if ($params->action=="") {
|
||||
// store cleaned active filers in db
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
} elseif (($params->action=="hide") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
// ignore it - doubleclick??
|
||||
} else {
|
||||
// just delete it
|
||||
unset($activefilters[$key]);
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="show") and confirm_sesskey()) {
|
||||
// check filterpath is valid
|
||||
if (!array_key_exists($params->filterpath, $installedfilters)) {
|
||||
error("Filter $params->filterpath is not currently installed", $url);
|
||||
} elseif (array_search($params->filterpath,$activefilters)) {
|
||||
// filterpath is already active - doubleclick??
|
||||
} else {
|
||||
// add it to installed filters
|
||||
$activefilters[] = $params->filterpath;
|
||||
$activefilters = array_unique($activefilters);
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="down") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $params->filterpath is not currently active", $url);
|
||||
} elseif ($key>=(count($activefilters)-1)) {
|
||||
// cannot be moved any further down - doubleclick??
|
||||
} else {
|
||||
// swap with $key+1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key+1];
|
||||
$activefilters[$key+1] = $fsave;
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="up") and confirm_sesskey()) {
|
||||
$key=array_search($params->filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $params->filterpath is not currently active", $url);
|
||||
} elseif ($key<1) {
|
||||
//cannot be moved any further up - doubleclick??
|
||||
} else {
|
||||
// swap with $key-1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key-1];
|
||||
$activefilters[$key-1] = $fsave;
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
}
|
||||
} elseif (($params->action=="config") and confirm_sesskey()) {
|
||||
set_config('cachetext', $params->cachetext);
|
||||
set_config('filteruploadedfiles', $params->filteruploadedfiles);
|
||||
set_config('filterall', $params->filterall);
|
||||
set_config('filtermatchoneperpage', $params->filtermatchoneperpage);
|
||||
set_config('filtermatchonepertext', $params->filtermatchonepertext);
|
||||
}
|
||||
|
||||
//======================
|
||||
// Build Display Objects
|
||||
//======================
|
||||
|
||||
// construct the display array with installed filters
|
||||
// at the top in the right order
|
||||
$displayfilters = array();
|
||||
foreach ($activefilters as $activefilter) {
|
||||
$name = $installedfilters[$activefilter];
|
||||
$displayfilters[$activefilter] = $name;
|
||||
}
|
||||
foreach ($installedfilters as $key => $filter) {
|
||||
if (!array_key_exists($key, $displayfilters)) {
|
||||
$displayfilters[$key] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(FILTER_TABLE);
|
||||
$table->define_columns(array('name', 'hideshow', 'order', 'settings'));
|
||||
$table->column_style('hideshow', 'text-align', 'center');
|
||||
$table->column_style('order', 'text-align', 'center');
|
||||
$table->column_style('settings', 'text-align', 'center');
|
||||
$table->define_headers(array($txt->name, $txt->hideshow, $txt->updown, $txt->settings));
|
||||
$table->define_baseurl("$CFG->wwwroot/admin/filters.php");
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'flexible generaltable generalbox');
|
||||
$table->set_attribute('style', 'margin:auto;');
|
||||
$table->set_attribute('cellpadding', '5');
|
||||
$table->setup();
|
||||
|
||||
// iterate through filters adding to display table
|
||||
$updowncount = 1;
|
||||
$activefilterscount = count($activefilters);
|
||||
foreach ($displayfilters as $path => $name) {
|
||||
$upath = urlencode($path);
|
||||
// get hide/show link
|
||||
if (in_array($path, $activefilters)) {
|
||||
$hideshow = "<a href=\"$myurl&action=hide&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" height=\"16\" width=\"16\" alt=\"hide\" /></a>";
|
||||
$hidden = false;
|
||||
$displayname = "<span>$name</span>";
|
||||
}
|
||||
else {
|
||||
$hideshow = "<a href=\"$myurl&action=show&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" height=\"16\" width=\"16\" alt=\"show\" /></a>";
|
||||
$hidden = true;
|
||||
$displayname = "<span class=\"dimmed_text\">$name</span>";
|
||||
}
|
||||
|
||||
// get up/down link (only if not hidden)
|
||||
$updown = '';
|
||||
if (!$hidden) {
|
||||
if ($updowncount>1) {
|
||||
$updown .= "<a href=\"$myurl&action=up&filterpath=$upath\">";
|
||||
$updown .= "<img src=\"$img/up.gif\" alt=\"up\" /></a> ";
|
||||
// Do a little cleanup for robustness
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if (empty($installedfilter)) {
|
||||
unset($installedfilters[$key]);
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" height=\"16\" width=\"16\" alt=\"\" /> ";
|
||||
}
|
||||
if ($updowncount<$activefilterscount) {
|
||||
$updown .= "<a href=\"$myurl&action=down&filterpath=$upath\">";
|
||||
$updown .= "<img src=\"$img/down.gif\" alt=\"down\" /></a>";
|
||||
}
|
||||
else {
|
||||
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" height=\"16\" width=\"16\" alt=\"\" />";
|
||||
}
|
||||
++$updowncount;
|
||||
}
|
||||
|
||||
// settings link (if defined)
|
||||
$settings = '';
|
||||
if (in_array($path, $filtersettings)) {
|
||||
$settings = "<a href=\"filter.php?filter=" . urlencode($path) . "\">";
|
||||
$settings .= "{$txt->settings}</a>";
|
||||
}
|
||||
|
||||
// write data into the table object
|
||||
$table->add_data(array($displayname, $hideshow, $updown, $settings));
|
||||
}
|
||||
|
||||
// build options list for cache lifetime
|
||||
$seconds = array(604800,86400,43200,10800,7200,3600,2700,1800,900,600,540,480,420,360,300,240,180,120,60,30,0);
|
||||
unset($lifetimeoptions);
|
||||
foreach ($seconds as $second) {
|
||||
if ($second>=86400) {
|
||||
$options[$second] = get_string('numdays','',$second/86400);
|
||||
}
|
||||
elseif ($second>=3600) {
|
||||
$options[$second] = get_string('numhours','',$second/3600);
|
||||
}
|
||||
elseif ($second>=60) {
|
||||
$options[$second] = get_string('numminutes','',$second/60);
|
||||
}
|
||||
elseif ($second>=1) {
|
||||
$options[$second] = get_string('numseconds','',$second);
|
||||
}
|
||||
else {
|
||||
$options[$second] = get_string('no');
|
||||
}
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
$selectedfilter = "none";
|
||||
|
||||
print_header("$site->shortname: $txt->managefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
|
||||
"-> $txt->managefilters");
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
print_heading_with_help($txt->managefilters, 'filters');
|
||||
if (!empty($options)) {
|
||||
if ($config = data_submitted()) {
|
||||
unset($config->options);
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// print the table of all the filters
|
||||
$table->print_html();
|
||||
if (!empty($add) and !empty($uselect)) {
|
||||
$selectedfilter = $uselect;
|
||||
if (!in_array($selectedfilter, $installedfilters)) {
|
||||
$installedfilters[] = $selectedfilter;
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
}
|
||||
|
||||
// print the table for the cache controls
|
||||
print_heading($txt->cachecontrols);
|
||||
print_simple_box_start('center');
|
||||
?>
|
||||
} else if (!empty($remove) and !empty($iselect)) {
|
||||
$selectedfilter = $iselect;
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if ($installedfilter == $selectedfilter) {
|
||||
unset($installedfilters[$key]);
|
||||
}
|
||||
}
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
|
||||
<form name="options" id="options" method="post" action="<?php echo $url; ?>" >
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<input type="hidden" name="action" value="config" />
|
||||
<table cellpadding="20">
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->cachetext; ?></td>
|
||||
<td><?php choose_from_menu($options, "cachetext", $CFG->cachetext, "", "", ""); ?></td>
|
||||
<td><?php echo $txt->configcachetext; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filteruploadedfiles; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->none,$txt->allfiles,$txt->htmlfilesonly),
|
||||
"filteruploadedfiles", $CFG->filteruploadedfiles,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfilteruploadedfiles; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filtermatchoneperpage; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->no,$txt->yes), "filtermatchoneperpage", $CFG->filtermatchoneperpage,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfiltermatchoneperpage; ?></td>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filtermatchonepertext; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->no,$txt->yes), "filtermatchonepertext", $CFG->filtermatchonepertext,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfiltermatchonepertext; ?></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td nowrap="nowrap" align="right"><?php echo $txt->filterall; ?></td>
|
||||
<td><?php choose_from_menu(array($txt->no,$txt->yes), "filterall", $CFG->filterall,"","",""); ?></td>
|
||||
<td><?php echo $txt->configfilterall; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td> </td>
|
||||
<td><input type="submit" value="<?php print_string('savechanges'); ?>" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
} else if ((!empty($up) or !empty($down)) and !empty($iselect)) {
|
||||
|
||||
if (!empty($up)) {
|
||||
if ($allfilters[$iselect]) {
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if ($installedfilter == $iselect) {
|
||||
$movefilter = $key;
|
||||
break;
|
||||
}
|
||||
$swapfilter = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($down)) {
|
||||
if ($allfilters[$iselect]) {
|
||||
$choosenext = false;
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if ($choosenext) {
|
||||
$swapfilter = $key;
|
||||
break;
|
||||
}
|
||||
if ($installedfilter == $iselect) {
|
||||
$movefilter = $key;
|
||||
$choosenext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($swapfilter) and isset($movefilter)) {
|
||||
$tempfilter = $installedfilters[$swapfilter];
|
||||
$installedfilters[$swapfilter] = $installedfilters[$movefilter];
|
||||
$installedfilters[$movefilter] = $tempfilter;
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
}
|
||||
$selectedfilter = $iselect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Make an array of all the currently uninstalled filters
|
||||
|
||||
$uninstalledfilters = array();
|
||||
foreach ($allfilters as $filter => $name) {
|
||||
$installed = false;
|
||||
foreach ($installedfilters as $installedfilter) {
|
||||
if ($installedfilter == $filter) {
|
||||
$installed = true;
|
||||
}
|
||||
}
|
||||
if (!$installed) {
|
||||
$uninstalledfilters[] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the current form
|
||||
|
||||
include("filters.html");
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
<?php // $Id$
|
||||
/** This expects the output from a command like
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
|
||||
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
|
||||
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
|
||||
*/
|
||||
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$FULLME='cron';
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
|
||||
|
||||
$site = get_site();
|
||||
|
||||
while(!feof($fd)) {
|
||||
$entry = fgets($fd);
|
||||
if (strlen(trim($entry)) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!$file = validate_line($entry)) {
|
||||
continue;
|
||||
}
|
||||
$bits = explode('/',$file);
|
||||
$a->filename = $bits[count($bits)-1];
|
||||
|
||||
if (!$log = get_record("log","module","upload","info",$file,"action","upload")) {
|
||||
$a->action = clam_handle_infected_file($file,0,false);
|
||||
clam_replace_infected_file($file);
|
||||
notify_admins_unknown($file,$a);
|
||||
continue;
|
||||
}
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
$user = get_record("user","id",$log->userid);
|
||||
$course = get_record("course","id",$log->course);
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
$a->course = $course->fullname;
|
||||
$a->user = fullname($user);
|
||||
|
||||
notify_user($user,$subject,$a);
|
||||
notify_admins($user,$subject,$a);
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
|
||||
function notify_user($user,$subject,$a) {
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
$body = get_string('virusfoundlater','moodle',$a);
|
||||
email_to_user($user,get_admin(),$subject,$body);
|
||||
}
|
||||
|
||||
|
||||
function notify_admins($user,$subject,$a) {
|
||||
|
||||
$admins = get_admins();
|
||||
|
||||
$body = get_string('virusfoundlateradmin','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function notify_admins_unknown($file,$a) {
|
||||
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_line($line) {
|
||||
global $CFG;
|
||||
if (strpos($line,"FOUND") === false) {
|
||||
return false;
|
||||
}
|
||||
$index = strpos($line,":");
|
||||
$file = substr($line,0,$index);
|
||||
if (!(strpos($file,$CFG->dataroot) === false)) {
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($file{0} == "/") {
|
||||
$file = $CFG->dataroot.$file;
|
||||
}
|
||||
else {
|
||||
$file = $CFG->dataroot."/".$file;
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// clean up
|
||||
$file = preg_replace('/\.\//','/',$file);
|
||||
$file = preg_replace('/\/\//','/',$file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,541 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
define('SEVERITY_NOTICE', 'notice');
|
||||
define('SEVERITY_ANNOYANCE', 'annoyance');
|
||||
define('SEVERITY_SIGNIFICANT', 'significant');
|
||||
define('SEVERITY_CRITICAL', 'critical');
|
||||
|
||||
$resetsesserrorcounter = optional_param('resetsesserrorcounter', 0, PARAM_BOOL);
|
||||
$solution = optional_param('solution', 0, PARAM_SAFEDIR); //in fact it is class name alhanumeric and _
|
||||
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error('Only the admin can use this page');
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$stradmin = get_string('administration');
|
||||
$strhealthcenter = get_string('healthcenter');
|
||||
|
||||
print_header($site->shortname.': '.$strhealthcenter, $site->fullname,
|
||||
'<a href="index.php">'.$stradmin.'</a> -> '.$strhealthcenter);
|
||||
|
||||
echo <<<STYLES
|
||||
<style type="text/css">
|
||||
div#healthnoproblemsfound {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
padding: 1em;
|
||||
border: 1px black solid;
|
||||
-moz-border-radius: 6px;
|
||||
}
|
||||
dl.healthissues {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
}
|
||||
dl.critical dt, dl.critical dd {
|
||||
background-color: #a71501;
|
||||
}
|
||||
dl.significant dt, dl.significant dd {
|
||||
background-color: #d36707;
|
||||
}
|
||||
dl.annoyance dt, dl.annoyance dd {
|
||||
background-color: #dba707;
|
||||
}
|
||||
dl.notice dt, dl.notice dd {
|
||||
background-color: #e5db36;
|
||||
}
|
||||
dt.solution, dd.solution, div#healthnoproblemsfound {
|
||||
background-color: #5BB83E !important;
|
||||
}
|
||||
dl.healthissues dt, dl.healthissues dd {
|
||||
margin: 0px;
|
||||
padding: 1em;
|
||||
border: 1px black solid;
|
||||
}
|
||||
dl.healthissues dt {
|
||||
font-weight: bold;
|
||||
border-bottom: none;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
dl.healthissues dd {
|
||||
border-top: none;
|
||||
padding-top: 0.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
dl.healthissues dd form {
|
||||
margin-top: 0.5em;
|
||||
text-align: right;
|
||||
}
|
||||
form#healthformreturn {
|
||||
text-align: center;
|
||||
margin: 2em;
|
||||
}
|
||||
dd.solution p {
|
||||
padding: 0px;
|
||||
margin: 1em 0px;
|
||||
}
|
||||
dd.solution li {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
STYLES;
|
||||
|
||||
if(strpos($solution, 'problem_') === 0 && class_exists($solution)) {
|
||||
health_print_solution($solution);
|
||||
}
|
||||
else {
|
||||
health_find_problems();
|
||||
}
|
||||
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
function health_find_problems() {
|
||||
|
||||
print_heading(get_string('healthcenter'));
|
||||
|
||||
$issues = array(
|
||||
SEVERITY_CRITICAL => array(),
|
||||
SEVERITY_SIGNIFICANT => array(),
|
||||
SEVERITY_ANNOYANCE => array(),
|
||||
SEVERITY_NOTICE => array(),
|
||||
);
|
||||
$problems = 0;
|
||||
|
||||
for($i = 1; $i < 1000000; ++$i) {
|
||||
$classname = sprintf('problem_%06d', $i);
|
||||
if(!class_exists($classname)) {
|
||||
break;
|
||||
}
|
||||
$problem = new $classname;
|
||||
if($problem->exists()) {
|
||||
$severity = $problem->severity();
|
||||
$issues[$severity][$classname] = array(
|
||||
'severity' => $severity,
|
||||
'description' => $problem->description(),
|
||||
'title' => $problem->title()
|
||||
);
|
||||
++$problems;
|
||||
}
|
||||
unset($problem);
|
||||
}
|
||||
|
||||
if($problems == 0) {
|
||||
echo '<div id="healthnoproblemsfound">';
|
||||
echo get_string('healthnoproblemsfound');
|
||||
echo '</div>';
|
||||
}
|
||||
else {
|
||||
print_heading(get_string('healthproblemsdetected'));
|
||||
$severities = array(SEVERITY_CRITICAL, SEVERITY_SIGNIFICANT, SEVERITY_ANNOYANCE, SEVERITY_NOTICE);
|
||||
foreach($severities as $severity) {
|
||||
if(!empty($issues[$severity])) {
|
||||
echo '<dl class="healthissues '.$severity.'">';
|
||||
foreach($issues[$severity] as $classname => $data) {
|
||||
echo '<dt id="'.$classname.'">'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'];
|
||||
echo '<form action="health.php#solution" method="get">';
|
||||
echo '<input type="hidden" name="solution" value="'.$classname.'" /><input type="submit" value="'.get_string('viewsolution').'" />';
|
||||
echo '</form></dd>';
|
||||
}
|
||||
echo '</dl>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function health_print_solution($classname) {
|
||||
$problem = new $classname;
|
||||
$data = array(
|
||||
'title' => $problem->title(),
|
||||
'severity' => $problem->severity(),
|
||||
'description' => $problem->description(),
|
||||
'solution' => $problem->solution()
|
||||
);
|
||||
|
||||
print_heading(get_string('healthcenter'));
|
||||
print_heading(get_string('healthproblemsolution'));
|
||||
echo '<dl class="healthissues '.$data['severity'].'">';
|
||||
echo '<dt>'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'].'</dd>';
|
||||
echo '<dt id="solution" class="solution">'.get_string('healthsolution').'</dt>';
|
||||
echo '<dd class="solution">'.$data['solution'].'</dd></dl>';
|
||||
echo '<form id="healthformreturn" action="health.php#'.$classname.'" method="get">';
|
||||
echo '<input type="submit" value="'.get_string('healthreturntomain').'" />';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
class problem_base {
|
||||
function exists() {
|
||||
return false;
|
||||
}
|
||||
function title() {
|
||||
return '???';
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_NOTICE;
|
||||
}
|
||||
function description() {
|
||||
return '';
|
||||
}
|
||||
function solution() {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000001 extends problem_base {
|
||||
function title() {
|
||||
return 'Invalid value for $CFG->dirroot';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
if (!empty($dirroot) && $dirroot != $CFG->dirroot) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> file contains the setting <strong>$CFG->dirroot = "'.$CFG->dirroot.'"</strong>, which is incorrect. Unless you correct this problem, Moodle will not function correctly, if at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
return 'You need to edit your <strong>config.php</strong> file. Find the line which reads <pre>$CFG->dirroot = \''.$CFG->dirroot.'\';</pre> and change it to read <pre>$CFG->dirroot = \''.$dirroot.'\'</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000002 extends problem_base {
|
||||
function title() {
|
||||
return 'Extra characters at the end of config.php';
|
||||
}
|
||||
function exists() {
|
||||
// [pj] When the requirements are raised to PHP 4.3.0 this will be file_get_contents()
|
||||
if($fp = @fopen('../config.php', 'r')) {
|
||||
$contents = fread($fp, 16384); // 16K should be enough
|
||||
$ending = substr($contents, -2);
|
||||
unset($contents);
|
||||
if($ending == '?>') {
|
||||
return false;
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your Moodle configuration file, config.php, contains some characters after the closing PHP tag (?>). This could cause Moodle to exhibit several kinds of problems and should be fixed.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'You need to edit <strong>'.$CFG->dirroot.'/config.php</strong> and remove all characters (including spaces and returns) after the ending ?> tag. These two characters should be the very last in that file.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000003 extends problem_base {
|
||||
function title() {
|
||||
return '$CFG->dataroot does not exist or does not have write permissions';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
if(!is_dir($CFG->dataroot) || !is_writable($CFG->dataroot)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> says that your "data root" directory is <strong>'.$CFG->dataroot.'</strong>. However, this directory either does not exist or cannot be written to by Moodle. This means that a variety of problems will be present, such as users not being able to log in and not being able to upload any files. It is imperative that you address this problem for Moodle to work correctly.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'First of all, make sure that the directory <strong>'.$CFG->dataroot.'</strong> exists. If the directory does exist, then you must make sure that Moodle is able to write to it. Contact your web server administrator and request that he gives write permissions for that directory to the user that the web server process is running as.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000004 extends problem_base {
|
||||
function title() {
|
||||
return 'cron.php is not set up to run automatically';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM '.$CFG->prefix.'modules');
|
||||
return (time() - $lastcron > 3600 * 24);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'The cron.php mainenance script has not been run in the past 24 hours. This probably means that your server is not configured to automatically run this script in regular time intervals. If this is the case, then Moodle will mostly work as it should but some operations (notably sending email to users) will not be carried out at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'For detailed instructions on how to enable cron, see <a href="'.$CFG->wwwroot.'/doc/?file=install.html#cron">this section</a> of the installation manual.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000005 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: session.auto_start is enabled';
|
||||
}
|
||||
function exists() {
|
||||
return ini_get_bool('session.auto_start');
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes an enabled setting, session.auto_start, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include fatal errors and/or blank pages when trying to log in.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>session.auto_start = 1</pre> and change it to <pre>session.auto_start = 0</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value session.auto_start "0"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000006 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: magic_quotes_runtime is enabled';
|
||||
}
|
||||
function exists() {
|
||||
return (ini_get_bool('magic_quotes_runtime'));
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes an enabled setting, magic_quotes_runtime, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include strange display errors whenever a text field that includes single or double quotes is processed.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>magic_quotes_runtime = On</pre> and change it to <pre>magic_quotes_runtime = Off</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value magic_quotes_runtime "Off"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000007 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: file_uploads is disabled';
|
||||
}
|
||||
function exists() {
|
||||
return !ini_get_bool('file_uploads');
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes a disabled setting, file_uploads, that <strong>must be enabled</strong> to let Moodle offer its full functionality. Until this setting is enabled, it will not be possible to upload any files into Moodle. This includes, for example, course content and user pictures.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>file_uploads = Off</pre> and change it to <pre>file_uploads = On</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value file_uploads "On"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000008 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: memory_limit cannot be controlled by Moodle';
|
||||
}
|
||||
function exists() {
|
||||
$memlimit = @ini_get('memory_limit');
|
||||
if(empty($memlimit)) {
|
||||
// PHP not compiled with memory limits, this means that it's
|
||||
// probably limited to 8M so we have a problem...
|
||||
return true;
|
||||
}
|
||||
// Otherwise, raise_memory_limit in setup.php will do the trick
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return 'The settings for PHP on your server do not allow a script to request more memory during its execution. This means that most likely there is a hard limit of 8MB for each script. It is possible that certain operations within Moodle will require more than this amount in order to complete successfully, especially if there are lots of data to be processed. Therefore, it is recommended that you contact your server administrator to address this issue.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'We need a good solution here. Enabling memory limit control means recompiling PHP... maybe this should be SEVERITY_NOTICE instead of SEVERITY_ANNOYANCE?';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000009 extends problem_base {
|
||||
function title() {
|
||||
return 'SQL: using account without password';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return empty($CFG->dbpass);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'The user account your are connecting to the database server with is set up without a password. This is a very big security risk and is only somewhat lessened if your database is configured to not accept connections from any hosts other than the server Moodle is running on. Unless you use a strong password to connect to the database, you risk unauthorized access to and manipulation of your data.'.($CFG->dbuser != 'root'?'':' <strong>This is especially alarming because such access to the database would be as the superuser (root)!</strong>');
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'You should change the password of the user <strong>'.$CFG->dbuser.'</strong> both in your database and in your Moodle <strong>config.php</strong> immediately!'.($CFG->dbuser != 'root'?'':' It would also be a good idea to change the user account from root to something else, because this would lessen the impact in the event that your database is compromised anyway.');
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000010 extends problem_base {
|
||||
function title() {
|
||||
return 'Uploaded files: slasharguments disabled or not working';
|
||||
}
|
||||
function exists() {
|
||||
if (!$this->is_enabled()) {
|
||||
return true;
|
||||
}
|
||||
if ($this->status() < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
if ($this->is_enabled() and $this->status() == 0) {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
} else {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
$desc = 'Slasharguments are needed for relative linking in uploaded resources:<ul>';
|
||||
if (!$this->is_enabled()) {
|
||||
$desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
|
||||
}
|
||||
if ($this->status() == -1) {
|
||||
$desc .= '<li>can not run automatic test, you can verify it <a href="'.$CFG->wwwroot.'/file.php/testslasharguments" target="_blank">here</a></li>';
|
||||
} else if ($this->status() == 0) {
|
||||
$desc .= '<li>slashargument test <strong>failed</strong>, please check server configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slashargument test passed</li>';
|
||||
}
|
||||
$desc .= '</ul>';
|
||||
return $desc;
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$enabled = $this->is_enabled();
|
||||
$status = $this->status();
|
||||
$solution = '';
|
||||
if ($enabled and ($status == 0)) {
|
||||
$solution .= 'Slasharguments are enabled, but the test failed. Please disable slasharguments in Moodle configuration or fix the server configuration.<hr />';
|
||||
} else if ((!$enabled) and ($status == 0)) {
|
||||
$solution .= 'Slasharguments are disabled and the test failed. You may try to fix the server configuration.<hr />';
|
||||
} else if ($enabled and ($status == -1)) {
|
||||
$solution .= 'Slasharguments are enabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
|
||||
} else if ((!$enabled) and ($status == -1)) {
|
||||
$solution .= 'Slasharguments are disabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
|
||||
} else if ((!$enabled) and ($status > 0)) {
|
||||
$solution .= 'Slasharguments are disabled though the iternal test is OK. You should enable slasharguments in Moodle configuration.';
|
||||
} else if ($enabled and ($status > 0)) {
|
||||
$solution .= 'Congratulations - everything seems OK now :-D';
|
||||
}
|
||||
if ($status < 1) {
|
||||
$solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>';
|
||||
$solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
|
||||
$solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
|
||||
}
|
||||
return $solution;
|
||||
}
|
||||
function is_enabled() {
|
||||
global $CFG;
|
||||
return !empty($CFG->slasharguments);
|
||||
}
|
||||
function status() {
|
||||
global $CFG;
|
||||
$handle = @fopen($CFG->wwwroot.'/file.php?file=/testslasharguments', "r");
|
||||
$contents = trim(@fread($handle, 7));
|
||||
@fclose($handle);
|
||||
if ($contents != 'test -1') {
|
||||
return -1;
|
||||
}
|
||||
$handle = @fopen($CFG->wwwroot.'/file.php/testslasharguments', "r");
|
||||
$contents = trim(@fread($handle, 6));
|
||||
@fclose($handle);
|
||||
switch ($contents) {
|
||||
case 'test 1': return 1;
|
||||
case 'test 2': return 2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000011 extends problem_base {
|
||||
function title() {
|
||||
return 'Session errors detected';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return isset($CFG->session_error_counter);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
if (isset($CFG->session_error_counter)) {
|
||||
return 'Session problems were detected. Total count: '.$CFG->session_error_counter;
|
||||
} else {
|
||||
return 'No session errors detected.';
|
||||
}
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
if (!empty($resetsesserrorcounter)) {
|
||||
if (get_field('config', 'name', 'name', 'session_error_counter')) {
|
||||
delete_records('config', 'name', 'session_error_counter');
|
||||
}
|
||||
return 'Error counter was cleared.';
|
||||
} else {
|
||||
return '<p>Session errors can be caused by:<ul><li>unresolved problem in server software (aka random switching of users),</li><li>blocked or modified cookies,</li><li>deleting of active session files.</li></ul></p><p><a href="'.me().'&resetsesserrorcounter=1">Reset counter.</a></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class problem_00000x extends problem_base {
|
||||
function title() {
|
||||
return '';
|
||||
}
|
||||
function exists() {
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return '';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
||||
session.save_path -- it doesn't really matter because we are already IN a session, right?
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
+154
-265
@@ -1,29 +1,27 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
/// Check that config.php exists, if not then call the install script
|
||||
if (!file_exists('../config.php')) {
|
||||
if (!file_exists("../config.php")) {
|
||||
header('Location: ../install.php');
|
||||
die;
|
||||
}
|
||||
|
||||
require_once('../config.php');
|
||||
include_once($CFG->dirroot.'/lib/adminlib.php'); // Contains various admin-only functions
|
||||
|
||||
$id = optional_param('id', '', PARAM_ALPHANUM);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
$agreelicence = optional_param('agreelicence',0, PARAM_BOOL);
|
||||
require_once("../config.php");
|
||||
include_once("$CFG->dirroot/lib/adminlib.php"); // Contains various admin-only functions
|
||||
|
||||
|
||||
/// Check that PHP is of a sufficient version
|
||||
|
||||
if (!check_php_version("4.1.0")) { //TODO: should we bump it up to 4.3.0??
|
||||
$phpversion = phpversion();
|
||||
print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $phpversion)");
|
||||
if (!check_php_version("4.1.0")) {
|
||||
$version = phpversion();
|
||||
print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)");
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/// Check some PHP server settings
|
||||
|
||||
$documentationlink = "please read the <a href=\"../doc/?frame=install.html&sub=webserver\">install documentation</a>";
|
||||
$documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>";
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
|
||||
@@ -41,7 +39,7 @@
|
||||
/// Check that config.php has been edited
|
||||
|
||||
if ($CFG->wwwroot == "http://example.com/moodle") {
|
||||
error("Moodle has not been configured yet. You need to edit config.php first.");
|
||||
error("Moodle has not been configured yet. You need to to edit config.php first.");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +48,10 @@
|
||||
$dirroot = dirname(realpath("../index.php"));
|
||||
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
|
||||
error("Please fix your settings in config.php:
|
||||
<p>You have:
|
||||
<p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
|
||||
<p>but it should be:
|
||||
<p>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
|
||||
<P>You have:
|
||||
<P>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
|
||||
<P>but it should be:
|
||||
<P>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
|
||||
"./");
|
||||
}
|
||||
|
||||
@@ -68,12 +66,9 @@
|
||||
$CFG->version = "";
|
||||
}
|
||||
|
||||
/// Turn off time limits and try to flush everything all the time, sometimes upgrades can be slow.
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
@ob_end_flush();
|
||||
|
||||
|
||||
/// Check if the main tables have been installed yet or not.
|
||||
|
||||
@@ -82,11 +77,11 @@
|
||||
|
||||
} else { // Check for missing main tables
|
||||
$maintables = true;
|
||||
$mtables = array("config", "course", "course_categories", "course_modules",
|
||||
"course_sections", "log", "log_display", "modules",
|
||||
$mtables = array("config", "course", "course_categories", "course_modules",
|
||||
"course_sections", "log", "log_display", "modules",
|
||||
"user", "user_admins", "user_students", "user_teachers");
|
||||
foreach ($mtables as $mtable) {
|
||||
if (!in_array($CFG->prefix.$mtable, $tables)) {
|
||||
if (!in_array($CFG->prefix.$mtable, $tables)) {
|
||||
$maintables = false;
|
||||
break;
|
||||
}
|
||||
@@ -97,14 +92,14 @@
|
||||
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("<A HREF=\"http://moodle.org\">Moodle</A> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_heading(get_string("copyrightnotice"));
|
||||
print_simple_box_start('center');
|
||||
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?agreelicence=true",
|
||||
"http://docs.moodle.org/en/License");
|
||||
notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
|
||||
"http://moodle.org/doc/?frame=licence.html");
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -128,58 +123,68 @@
|
||||
}
|
||||
|
||||
|
||||
/// Insert default values for any important configuration variables
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php");
|
||||
}
|
||||
|
||||
|
||||
/// Check version of Moodle code on disk compared with database
|
||||
/// and upgrade if possible.
|
||||
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
if ($CFG->version) {
|
||||
if ($CFG->version) {
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$a->oldversion = $CFG->version;
|
||||
$a->newversion = $version;
|
||||
$strdatabasechecking = get_string("databasechecking", "", $a);
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
|
||||
exit;
|
||||
|
||||
} else {
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
if (main_upgrade($CFG->version)) {
|
||||
$db->debug=false;
|
||||
if (set_config("version", $version)) {
|
||||
remove_dir($CFG->dataroot . '/cache', true); // flush cache
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("index.php");
|
||||
exit;
|
||||
} else {
|
||||
notify("Upgrade failed! (Could not update version in config table)");
|
||||
}
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
if (main_upgrade($CFG->version)) {
|
||||
$db->debug=false;
|
||||
if (set_config("version", $version)) {
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("index.php");
|
||||
die;
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrade failed! See /version.php");
|
||||
notify("Upgrade failed! (Could not update version in config table)");
|
||||
}
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrade failed! See /version.php");
|
||||
}
|
||||
} else if ($version < $CFG->version) {
|
||||
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$strcurrentversion = get_string("currentversion");
|
||||
print_header($strcurrentversion, $stradministration, $strcurrentversion,
|
||||
print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
if (!set_config("version", $version)) {
|
||||
if (set_config("version", $version)) {
|
||||
print_heading("You are currently using Moodle version $version (Release $release)");
|
||||
print_continue("index.php");
|
||||
die;
|
||||
} else {
|
||||
$db->debug=true;
|
||||
if (main_upgrade(0)) {
|
||||
print_continue("index.php");
|
||||
@@ -199,37 +204,14 @@
|
||||
if (!set_config("release", $release)) {
|
||||
notify("ERROR: Could not update release version in database!!");
|
||||
}
|
||||
notice(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'index.php');
|
||||
print_continue("index.php");
|
||||
print_simple_box_start("CENTER");
|
||||
include("$CFG->dirroot/lang/en/docs/release.html");
|
||||
print_simple_box_end();
|
||||
print_continue("index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Insert default values for any important configuration variables
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Send $CFG->unicodedb to DB to have it available for next requests
|
||||
set_config('unicodedb', $CFG->unicodedb);
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php");
|
||||
}
|
||||
|
||||
/// Find and check all main modules and load them up or upgrade them if necessary
|
||||
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all questiontype plugins and upgrade if necessary
|
||||
// It is important that this is done AFTER the quiz module has been upgraded
|
||||
upgrade_plugins('qtype', 'question/type', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Upgrade backup/restore system if necessary
|
||||
require_once("$CFG->dirroot/backup/lib.php");
|
||||
@@ -243,11 +225,11 @@
|
||||
upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all enrolment plugins and upgrade if necessary
|
||||
upgrade_plugins('enrol', 'enrol', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
upgrade_enrol_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Find and check all main modules and load them up or upgrade them if necessary
|
||||
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check for local database customisations
|
||||
require_once("$CFG->dirroot/lib/locallib.php");
|
||||
upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
|
||||
/// Set up the overall site name etc.
|
||||
@@ -255,29 +237,6 @@
|
||||
redirect("site.php");
|
||||
}
|
||||
|
||||
/// Define the unique site ID code if it isn't already
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32));
|
||||
}
|
||||
|
||||
/// Check if the guest user exists. If not, create one.
|
||||
if (! record_exists("user", "username", "guest")) {
|
||||
$guest->auth = "manual";
|
||||
$guest->username = "guest";
|
||||
$guest->password = md5("guest");
|
||||
$guest->firstname = addslashes(get_string("guestuser"));
|
||||
$guest->lastname = " ";
|
||||
$guest->email = "root@localhost";
|
||||
$guest->description = addslashes(get_string("guestuserinfo"));
|
||||
$guest->confirmed = 1;
|
||||
$guest->lang = $CFG->lang;
|
||||
$guest->timemodified= time();
|
||||
|
||||
if (! $guest->id = insert_record("user", $guest)) {
|
||||
notify("Could not create guest user record !!!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Set up the admin user
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
redirect("user.php");
|
||||
@@ -290,193 +249,123 @@
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
/// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
|
||||
|
||||
if (!empty($id)) {
|
||||
if ($id == $CFG->siteidentifier) {
|
||||
set_config('registered', time());
|
||||
}
|
||||
}
|
||||
|
||||
/// At this point everything is set up and the user is an admin, so print menu
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
print_header("$site->shortname: $stradministration","$site->fullname", "$stradministration");
|
||||
print_simple_box_start('center', '100%', '', 20);
|
||||
print_simple_box_start("center", "100%", "$THEME->cellcontent2", 20);
|
||||
print_heading($stradministration);
|
||||
|
||||
/// Deprecated database! Warning!!
|
||||
if (!empty($CFG->migrated_to_new_db)) {
|
||||
print_simple_box_start('center','60%');
|
||||
print_string('dbmigrationdeprecateddb','admin');
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
if (!empty($CFG->upgrade)) { // Print notice about extra upgrading that needs to be done
|
||||
print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
|
||||
"$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center", '60%');
|
||||
print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
|
||||
"$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center");
|
||||
print_spacer(10,10);
|
||||
}
|
||||
|
||||
if (ini_get_bool('register_globals') && !ini_get_bool('magic_quotes_gpc')) {
|
||||
print_simple_box(get_string('globalsquoteswarning', 'admin'), 'center', '60%');
|
||||
}
|
||||
|
||||
|
||||
/// 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_simple_box(get_string('cronwarning', 'admin')." ".$helpbutton, 'center', '60%');
|
||||
print_simple_box(get_string('cronwarning', 'admin') , 'center');
|
||||
}
|
||||
|
||||
/// Alert if we are currently in maintenance mode
|
||||
if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
|
||||
print_simple_box(get_string('sitemaintenancewarning', 'admin') , 'center', '60%');
|
||||
}
|
||||
|
||||
/// Alert if we are currently in maintenance mode
|
||||
if (empty($CFG->unicodedb)) {
|
||||
print_simple_box(get_string('unicodeupgradenotice', 'admin') , 'center', '60%');
|
||||
}
|
||||
|
||||
/// Print slightly annoying registration button every six months ;-)
|
||||
/// You can set the "registered" variable to something far in the future
|
||||
/// if you really want to prevent this. eg 9999999999
|
||||
if (!isset($CFG->registered) || $CFG->registered < (time() - 3600*24*30*6)) {
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<div align="center">';
|
||||
print_string('pleaseregister', 'admin');
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
$table->tablealign = "center";
|
||||
$table->tablealign = "right";
|
||||
$table->align = array ("right", "left");
|
||||
$table->wrap = array ("nowrap", "nowrap");
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '40%';
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 3;
|
||||
$table->width = "40%";
|
||||
|
||||
$configdata = '<div class="adminlink"><a href="config.php">'.get_string('configvariables', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpconfigvariables').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="site.php">'.get_string('sitesettings').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpsitesettings').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="../theme/index.php">'.get_string('themes').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpthemes').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="lang.php">'.get_string('language').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelplanguage').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="modules.php">'.get_string('managemodules').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagemodules').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="blocks.php">'.get_string('manageblocks').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanageblocks').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="filters.php">'.get_string('managefilters').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagefilters').'</span></div>';
|
||||
$configdata = "<font size=+1> </font><a href=\"config.php\">".get_string("configvariables")."</a> - <font size=1>".
|
||||
get_string("adminhelpconfigvariables")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"site.php\">".get_string("sitesettings")."</a> - <font size=1>".
|
||||
get_string("adminhelpsitesettings")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"../theme/index.php\">".get_string("themes")."</a> - <font size=1>".
|
||||
get_string("adminhelpthemes")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"lang.php\">".get_string("language")."</a> - <font size=1>".
|
||||
get_string("adminhelplanguage")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"modules.php\">".get_string("managemodules")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagemodules")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"blocks.php\">".get_string("manageblocks")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanageblocks")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagefilters")."</font><br />";
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$configdata .= '<div class="adminlink"><a href="backup.php">'.get_string('backup').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpbackup').'</span></div>';
|
||||
$configdata .= "<font size=+1> </font><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a> - <font size=1>".
|
||||
get_string("adminhelpbackup")."</font><br />";
|
||||
}
|
||||
$configdata .= '<div class="adminlink"><a href="editor.php">'.get_string('editorsettings').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpeditorsettings').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="calendar.php">'.get_string('calendarsettings', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('helpcalendarsettings', 'admin').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="maintenance.php">'.get_string('sitemaintenancemode', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('helpsitemaintenance', 'admin').'</span></div>';
|
||||
$configdata .= "<font size=+1> </font><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a> - <font size=1>".
|
||||
get_string("adminhelpeditorsettings")."</font><br />";
|
||||
|
||||
$table->data[] = array('<strong><a href="configure.php">'.get_string('configuration').'</a></strong>', $configdata);
|
||||
$table->data[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>",
|
||||
$configdata);
|
||||
|
||||
|
||||
$userdata = '<div class="adminlink"><a href="auth.php?sesskey='.$USER->sesskey.'">'.get_string("authentication").
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpauthentication').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="user.php">'.get_string('edituser').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpedituser').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/user.php?newuser=true&sesskey='.$USER->sesskey.'">'.
|
||||
get_string('addnewuser').'</a> - <span class="explanation">'.get_string('adminhelpaddnewuser').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/uploaduser.php?sesskey='.$USER->sesskey.'">'.
|
||||
get_string('uploadusers').'</a> - <span class="explanation">'.get_string('adminhelpuploadusers').'</span></div>';
|
||||
$userdata = "<font size=+1> </font><a href=\"auth.php?sesskey=$USER->sesskey\">".get_string("authentication")."</a> - <font size=1>".
|
||||
get_string("adminhelpauthentication")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"user.php\">".get_string("edituser")."</a> - <font size=1>".
|
||||
get_string("adminhelpedituser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".
|
||||
get_string("addnewuser")."</a> - <font size=1>".
|
||||
get_string("adminhelpaddnewuser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".
|
||||
get_string("uploadusers")."</a> - <font size=1>".
|
||||
get_string("adminhelpuploadusers")."</font><br />";
|
||||
|
||||
$userdata .= '<hr /><div class="adminlink"><a href="enrol.php?sesskey='.$USER->sesskey.'">'.get_string('enrolmentplugins').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpenrolments').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="../course/index.php?edit=off&sesskey='.$USER->sesskey.'">'.
|
||||
get_string('assignstudents').'</a> - <span class="explanation">'.get_string('adminhelpassignstudents').'</span></div>';
|
||||
$userdata .= "<hr><font size=+1> </font><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a> - <font size=1>".
|
||||
get_string("adminhelpenrolments")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignstudents")."</font><br />";
|
||||
|
||||
$userdata .= '<div class="adminlink"><a href="../course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.
|
||||
get_string('assignteachers').'</a> - <span class="explanation">'.get_string('adminhelpassignteachers').
|
||||
' <img src="../pix/t/user.gif" height="11" width="11" alt="" /></span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="creators.php?sesskey='.$USER->sesskey.'">'.get_string('assigncreators').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpassigncreators').'</span></div>';
|
||||
$userdata .= '<div class="adminlink"><a href="admin.php?sesskey='.$USER->sesskey.'">'.get_string('assignadmins').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpassignadmins').'</span></div>';
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignteachers").
|
||||
" <img src=\"../pix/t/user.gif\" height=11 width=11></font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a> - <font size=1>".
|
||||
get_string("adminhelpassigncreators")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignadmins")."</font><br />";
|
||||
|
||||
$table->data[] = array('<strong><a href="users.php">'.get_string('users').'</a></strong>', $userdata);
|
||||
$table->data[] = array("<font size=+1><b><a href=\"users.php\">".get_string("users")."</a></b>", $userdata);
|
||||
|
||||
$table->data[] = array('<strong><a href="../course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.get_string('courses').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelpcourses').'</div>');
|
||||
$table->data[] = array('<strong><a href="../files/index.php?id='.$site->id.'">'.get_string('sitefiles').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelpsitefiles').'</div>');
|
||||
$table->data[] = array('<strong><a href="stickyblocks.php">'.get_string('stickyblocks','admin').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelpstickyblocks').'</div>');
|
||||
$table->data[] = array('<strong><a href="report.php">'.get_string('reports').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelpreports').'</div>');
|
||||
$table->data[] = array('<strong><a href="environment.php">'.get_string('environment','admin').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelpenvironment').'</div>');
|
||||
|
||||
/// Optional stuff
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("courses")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpcourses"));
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/log.php?id=$site->id\">".get_string("logs")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelplogs"));
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../files/index.php?id=$site->id\">".get_string("sitefiles")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpsitefiles"));
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
|
||||
$table->data[] = array("<strong><a href=\"$CFG->dbtype/frame.php\">".get_string('managedatabase').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelpmanagedatabase').'</div>');
|
||||
$table->data[] = array("<font size=+1><b><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpmanagedatabase"));
|
||||
}
|
||||
|
||||
/// Hooks for Matt Oquists contrib code for repositories and portfolio.
|
||||
/// The eventual official versions may not look like this
|
||||
if (isset($CFG->portfolio) && file_exists("$CFG->dirroot/$CFG->portfolio")) {
|
||||
$table->data[] = array("<strong><a href=\"../portfolio/\">".get_string('portfolio','portfolio').'</a></
|
||||
trong>',
|
||||
'<div class="explanation">'.get_string('adminhelpportfolio','portfolio').'</div>');
|
||||
}
|
||||
|
||||
if (isset($CFG->repo) && file_exists("$CFG->dirroot/$CFG->repo")) {
|
||||
$table->data[] = array("<strong><a href=\"../repository/?repoid=1&action=list\">".get_string('repository','
|
||||
epository').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelprepository','repository').'</div>');
|
||||
}
|
||||
|
||||
|
||||
|
||||
print_table($table);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO REMOVE OR MODIFY THE COPYRIGHT NOTICE BELOW ////
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/en/Release">'.$CFG->release.'</a> ('.$CFG->version.')<br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
|
||||
echo '<p class="copyright">'.$copyrighttext.'</p>';
|
||||
$copyrighttext = "<a href=\"http://moodle.org/\">Moodle</a> ".
|
||||
"<a href=\"../doc/?frame=release.html\">$CFG->release</a> ($CFG->version)<br />".
|
||||
"Copyright © 1999-2004 Martin Dougiamas<br />".
|
||||
"<a href=\"../doc/?frame=licence.html\">GNU Public License</a>";
|
||||
echo "<center><p><font size=1>$copyrighttext</font></p></center>";
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
echo '<div align="center">';
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
echo '</div>';
|
||||
echo "<table border=0 align=center width=100%><tr>";
|
||||
echo "<td align=center width=33%>";
|
||||
print_single_button("$CFG->wwwroot/doc", NULL, get_string("documentation"));
|
||||
echo "</td>";
|
||||
|
||||
echo "<td align=center width=33%>";
|
||||
print_single_button("phpinfo.php", NULL, get_string("phpinfo"));
|
||||
echo "</td>";
|
||||
|
||||
echo "<td align=center width=33%>";
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_single_button("register.php", $options, get_string("registration"));
|
||||
echo "</td>";
|
||||
echo "<tr></table>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
if (optional_param('dbmigrate')) { // ??? Is this actually used?
|
||||
print_simple_box_start('center','60%');
|
||||
require_once($CFG->dirroot.'/admin/utfdbmigrate.php');
|
||||
db_migrate2utf8();
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Admin only');
|
||||
}
|
||||
|
||||
print_header("Convert all tables from MYISAM to InnoDB", "Convert all tables from MYISAM to InnoDB",
|
||||
"Convert all tables from MYISAM to InnoDB");
|
||||
|
||||
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
|
||||
print_heading("Please be patient and wait for this to complete...");
|
||||
|
||||
if ($tables = $db->MetaTables()) {
|
||||
$db->debug = true;
|
||||
foreach ($tables as $table) {
|
||||
execute_sql("ALTER TABLE $table TYPE=INNODB; ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notice_yesno("Are you sure you want convert all your tables to the InnoDB format?",
|
||||
"innodb.php?confirm=1&sesskey=".sesskey(), "index.php");
|
||||
}
|
||||
|
||||
?>
|
||||
+63
-110
@@ -1,9 +1,9 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
$mode = optional_param('mode', '', PARAM_ALPHA);
|
||||
$currentfile = optional_param('currentfile', 'moodle.php', PARAM_FILE);
|
||||
optional_variable($mode, "");
|
||||
optional_variable($currentfile, "moodle.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -20,23 +20,24 @@
|
||||
$strlanguage = get_string("language");
|
||||
$strcurrentlanguage = get_string("currentlanguage");
|
||||
$strmissingstrings = get_string("missingstrings");
|
||||
$streditstrings = get_string("editstrings", 'admin');
|
||||
$stredithelpdocs = get_string("edithelpdocs", 'admin');
|
||||
$strcomparelanguage = get_string("comparelanguage");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
|
||||
switch ($mode) {
|
||||
case "missing":
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $strmissingstrings";
|
||||
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strmissingstrings";
|
||||
$title = $strmissingstrings;
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="submit" value="'.$streditstrings.'" /></form>';
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
|
||||
'<input type="submit" value="'.$strcomparelanguage.'" /></form>';
|
||||
break;
|
||||
case "compare":
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $streditstrings";
|
||||
$title = $streditstrings;
|
||||
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strcomparelanguage";
|
||||
$title = $strcomparelanguage;
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="missing" />'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></form>';
|
||||
break;
|
||||
default:
|
||||
@@ -54,75 +55,59 @@
|
||||
'', '', true, $button);
|
||||
|
||||
if (!$mode) {
|
||||
print_simple_box_start('center','80%');
|
||||
echo '<table align="center" width="100%"><tr><td width="50%" align="center">';
|
||||
print_string('managelang','admin');
|
||||
echo '</td><td align="center" width="50%">';
|
||||
print_string('editlang','admin');
|
||||
echo '</td></tr><tr><td>';
|
||||
print_string('lang16notify','admin');
|
||||
echo '<p /><a href="langimport.php">'.get_string('langimport','admin').'</a>';
|
||||
echo '</td><td>';
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
echo "<table align=\"center\"><tr><td align=\"right\">";
|
||||
echo "<table align=center><tr><td align=\"right\">";
|
||||
echo "<b>$strcurrentlanguage:</b>";
|
||||
echo "</td><td>";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
echo '</td></tr><tr><td colspan="2">';
|
||||
$options["lang"] = $currentlang;
|
||||
//print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||
echo "</td></tr></table>";
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare\">$streditstrings</a>");
|
||||
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
|
||||
echo '</td></tr></table>';
|
||||
print_simple_box_end();
|
||||
print_heading("<a href=\"lang.php?mode=missing&sesskey=$USER->sesskey\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare&sesskey=$USER->sesskey\">$strcomparelanguage</a>");
|
||||
echo "<center><hr noshade size=1>";
|
||||
$options["lang"] = $currentlang;
|
||||
print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||
echo "</center>";
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get a list of all the root files in the English directory
|
||||
|
||||
$langdir = "$CFG->dataroot/lang/$currentlang";
|
||||
$enlangdir = "$CFG->dirroot/lang/en_utf8";
|
||||
$langdir = "$CFG->dirroot/lang/$currentlang";
|
||||
$enlangdir = "$CFG->dirroot/lang/en";
|
||||
|
||||
if (! $stringfiles = get_directory_list($enlangdir, "", false)) {
|
||||
error("Could not find English language pack!");
|
||||
}
|
||||
|
||||
foreach ($stringfiles as $key => $file) {
|
||||
if (substr($file, -4) != ".php") { //Avoid non php files to be showed
|
||||
unset($stringfiles[$key]);
|
||||
}
|
||||
if ($file == "langconfig.php") { //Avoid langconfig.php to be showed
|
||||
if (substr($file, -4) != ".php") {
|
||||
unset($stringfiles[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "missing") {
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
|
||||
if ($mode == "missing" and confirm_sesskey()) {
|
||||
// For each file, check that a counterpart exists, then check all the strings
|
||||
|
||||
foreach ($stringfiles as $file) {
|
||||
if (!file_exists("$langdir/$file")) {
|
||||
if (!touch("$langdir/$file")) {
|
||||
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$file")."</font></p>";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
unset($string);
|
||||
include("$enlangdir/$file");
|
||||
$enstring = $string;
|
||||
|
||||
|
||||
unset($string);
|
||||
|
||||
if (file_exists("$langdir/$file")) {
|
||||
include("$langdir/$file");
|
||||
} else {
|
||||
notify(get_string("filemissing", "", "$langdir/$file"));
|
||||
$string = array();
|
||||
}
|
||||
include("$langdir/$file");
|
||||
|
||||
$first = true;
|
||||
foreach ($enstring as $key => $value) {
|
||||
if (empty($string[$key]) and $string[$key] != "0") { //bug fix 4735 mits
|
||||
if (!isset($string[$key]) or $string[$key] == "") {
|
||||
$value = htmlspecialchars($value);
|
||||
$value = str_replace("$"."a", "\\$"."a", $value);
|
||||
$value = str_replace("%%","%",$value);
|
||||
@@ -139,24 +124,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
if (!file_exists("$langdir/help/$file")) {
|
||||
echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/help/$file")."</font></p>";
|
||||
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/help/$file")."</font></p>";
|
||||
$somethingfound = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en/docs", "CVS")) {
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
foreach ($files as $filekey => $file) { // check all the docs files.
|
||||
if (!file_exists("$langdir/docs/$file")) {
|
||||
echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/docs/$file")."</font></p>";
|
||||
echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/docs/$file")."</FONT></P>";
|
||||
$somethingfound = true;
|
||||
continue;
|
||||
}
|
||||
@@ -168,34 +153,19 @@
|
||||
notice(get_string("languagegood"), "lang.php");
|
||||
}
|
||||
|
||||
} else if ($mode == "compare") {
|
||||
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
|
||||
} else if ($mode == "compare" and confirm_sesskey()) {
|
||||
|
||||
if (isset($_POST['currentfile'])){ // Save a file
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$newstrings = array();
|
||||
|
||||
foreach ($_POST as $postkey => $postval) {
|
||||
$stringkey = lang_file_string_key($postkey);
|
||||
$newstrings[$stringkey] = $postval;
|
||||
}
|
||||
|
||||
$newstrings = $_POST;
|
||||
unset($newstrings['currentfile']);
|
||||
if (lang_save_file($langdir, $currentfile, $newstrings)) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "lang.php?mode=compare&currentfile=$currentfile");
|
||||
error("Could not save the file '$currentfile'!", "lang.php?mode=compare¤tfile=$currentfile&sesskey=$USER->sesskey");
|
||||
}
|
||||
}
|
||||
|
||||
print_heading_with_help($streditstrings, "langedit");
|
||||
print_heading_with_help($strcomparelanguage, "langedit");
|
||||
|
||||
print_simple_box_start("center", "80%");
|
||||
echo '<center><font size="2">';
|
||||
@@ -203,7 +173,7 @@
|
||||
if ($file == $currentfile) {
|
||||
echo "<b>$file</b> ";
|
||||
} else {
|
||||
echo "<a href=\"lang.php?mode=compare&currentfile=$file\">$file</a> ";
|
||||
echo "<a href=\"lang.php?mode=compare¤tfile=$file&sesskey=$USER->sesskey\">$file</a> ";
|
||||
}
|
||||
}
|
||||
echo '</font></center>';
|
||||
@@ -214,21 +184,19 @@
|
||||
|
||||
if (!file_exists("$langdir/$currentfile")) {
|
||||
if (!touch("$langdir/$currentfile")) {
|
||||
echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/$currentfile")."</font></p>";
|
||||
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$currentfile")."</font></p>";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
error_reporting(0);
|
||||
if ($f = fopen("$langdir/$currentfile","r+") && ($currentlang != "en_utf8")) {
|
||||
if ($f = fopen("$langdir/$currentfile","r+")) {
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
} else {
|
||||
$editable = false;
|
||||
echo "<p><font size=\"1\">".get_string("makeeditable", "", "$langdir/$currentfile")."</font></p>";
|
||||
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")."</font></p>";
|
||||
}
|
||||
///added code here to prevent en_utf8 being edited
|
||||
|
||||
error_reporting(7);
|
||||
|
||||
|
||||
@@ -248,17 +216,18 @@
|
||||
|
||||
if ($editable) {
|
||||
echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
}
|
||||
echo "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"3\" border=\"0\" class=\"generalbox\">";
|
||||
echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>";
|
||||
foreach ($enstring as $key => $envalue) {
|
||||
$envalue = nl2br(htmlspecialchars($envalue));
|
||||
$envalue = preg_replace('/(\$a\-\>[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
|
||||
$envalue = str_replace("%%","%",$envalue);
|
||||
$envalue = str_replace("\\","",$envalue); // Delete all slashes
|
||||
|
||||
echo "\n\n".'<tr>';
|
||||
echo '<td dir="ltr" lang="en" width="20%" nowrap="nowrap" valign="top">'.$key.'</td>'."\n";
|
||||
echo '<td dir="ltr" lang="en" width="40%" valign="top">'.$envalue.'</td>'."\n";
|
||||
echo "\n\n<tr>";
|
||||
echo "<td dir=ltr lang=en width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>\n";
|
||||
echo "<td dir=ltr lang=en width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>\n";
|
||||
|
||||
$value = $string[$key];
|
||||
$value = str_replace("\r","",$value); // Bad character caused by Windows
|
||||
@@ -270,10 +239,10 @@
|
||||
$value = str_replace(">",">",$value);
|
||||
$value = str_replace('"',""",$value);
|
||||
|
||||
$cellcolour = $value ? '': 'class="highlight"';
|
||||
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
|
||||
|
||||
if ($editable) {
|
||||
echo '<td width="40%" '.$cellcolour.' valign="top">'."\n";
|
||||
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>\n";
|
||||
if (isset($string[$key])) {
|
||||
$valuelen = strlen($value);
|
||||
} else {
|
||||
@@ -282,29 +251,28 @@
|
||||
$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";
|
||||
echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>\n";
|
||||
} else {
|
||||
if ($valuelen) {
|
||||
$cols = $valuelen + 2;
|
||||
}
|
||||
echo '<input type="text" name="stringXXX'.lang_form_string_key($key).'" value="'.$value.'" size="'.$cols.'" />';
|
||||
echo "<input type=\"text\" name=\"string-$key\" value=\"$value\" size=\"$cols\"></td>";
|
||||
}
|
||||
echo '</td>';
|
||||
echo "</TD>\n";
|
||||
|
||||
} else {
|
||||
echo '<td width="40%" bgcolor="'.$cellcolour.'" valign="top">'.$value.'</td>';
|
||||
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>\n";
|
||||
}
|
||||
}
|
||||
if ($editable) {
|
||||
echo '<tr><td colspan="2"> <td><br />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo ' <input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
echo ' <input type="hidden" name="mode" value="compare" />';
|
||||
echo ' <input type="submit" name="update" value="'.get_string('savechanges').': '.$currentfile.'" />';
|
||||
echo '</td></tr>';
|
||||
echo "<tr><td colspan=2> <td><br />";
|
||||
echo " <input type=\"hidden\" name=\"currentfile\" value=\"$currentfile\">";
|
||||
echo " <input type=\"hidden\" name=\"mode\" value=\"compare\">";
|
||||
echo " <input type=\"submit\" name=\"update\" value=\"".get_string("savechanges").": $currentfile\">";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo '</table>';
|
||||
echo '</form>';
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
|
||||
@@ -335,7 +303,7 @@ function lang_save_file($path, $file, $strings) {
|
||||
ksort($strings);
|
||||
|
||||
foreach ($strings as $key => $value) {
|
||||
list($id, $stringname) = explode('XXX',$key);
|
||||
list($id, $stringname) = explode("-",$key);
|
||||
if ($CFG->lang != "zh_hk" and $CFG->lang != "zh_tw") { // Some MB languages include backslash bytes
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
}
|
||||
@@ -353,19 +321,4 @@ function lang_save_file($path, $file, $strings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Following functions are required because '.' in form input names
|
||||
/// get replaced by '_' by PHP.
|
||||
|
||||
function lang_form_string_key($keyfromfile) {
|
||||
return str_replace('.', '##46#', $keyfromfile); /// Derived from ., the ascii value for a period.
|
||||
}
|
||||
|
||||
|
||||
function lang_file_string_key($keyfromform) {
|
||||
return str_replace('##46#', '.', $keyfromform);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
This script enables Moodle translators to edit /docs and /help language
|
||||
files directly via WWW interface.
|
||||
|
||||
Author: mudrd8mz@uxit.pedf.cuni.cz (http://moodle.cz)
|
||||
Based on: lang.php in 1.4.3+ release
|
||||
Thanks: Jaime Villate for important bug fixing, koen roggemans for his job and all moodlers
|
||||
for intensive testing of this my first contribution
|
||||
*/
|
||||
require_once('../config.php');
|
||||
|
||||
//
|
||||
// Some local configuration
|
||||
//
|
||||
$fileeditorrows = 12; // number of textareas' rows
|
||||
$fileeditorcols = 100; // dtto cols
|
||||
$fileeditorinline = 1; // shall be textareas put in one row?
|
||||
$filemissingmark = ' (***)'; // mark to add to non-existing filenames in selection form
|
||||
$fileoldmark = ' (old?)'; // mark to add to filenames in selection form id english version is newer
|
||||
// or to filenames with filesize() == 0
|
||||
$filetemplate = ''; // template for new files, i.e. '$Id$';
|
||||
|
||||
$currentfile = optional_param('currentfile', 'docs/README.txt', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You need to be admin to edit this page");
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Site not defined!");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strlanguage = get_string("language");
|
||||
$strcurrentlanguage = get_string("currentlanguage");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$stredithelpdocs = get_string('edithelpdocs', 'admin');
|
||||
|
||||
print_header("$site->shortname: $stredithelpdocs: $currentfile", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> ->
|
||||
<a href=\"lang.php\">$strlanguage</a> -> $stredithelpdocs",
|
||||
'choosefile.popup', '', true);
|
||||
|
||||
$currentlang = current_language();
|
||||
$langdir = "$CFG->dataroot/lang/$currentlang";
|
||||
$enlangdir = "$CFG->dirroot/lang/en_utf8";
|
||||
|
||||
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
// Shall I save POSTed data?
|
||||
|
||||
if (isset($_POST['currentfile'])) {
|
||||
if (confirm_sesskey()) {
|
||||
if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_reporting(0); // Error reporting turned off due to non-existing files
|
||||
|
||||
// Generate selection for all help and documentation files
|
||||
|
||||
// Get all files from /docs directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the docs files.
|
||||
$options["docs/$file"] = "docs/$file";
|
||||
// add mark if file doesn't exist or is empty
|
||||
if (( !file_exists("$langdir/docs/$file")) || (filesize("$langdir/docs/$file") == 0)) {
|
||||
$options["docs/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/docs/$file") < filemtime("$CFG->dirroot/lang/en_utf8/docs/$file")) {
|
||||
$options["docs/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all files from /help directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
$options["help/$file"] = "help/$file";
|
||||
if (( !file_exists("$langdir/help/$file")) || (filesize("$CFG->dirroot/lang/en_utf8/help/$file") == 0)) {
|
||||
$options["help/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/help/$file") < filemtime("$langdir/help/$file")) {
|
||||
$options["help/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr><td align=\"center\">";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=", $options, "choosefile", $currentfile, "", "", "", true);
|
||||
echo "</td></tr></table>";
|
||||
|
||||
// Generate textareas
|
||||
|
||||
if (!empty($currentfile)) {
|
||||
|
||||
if (!file_exists("$langdir/$currentfile")) {
|
||||
//check if directory exist
|
||||
$pathparts = explode('/',$currentfile);
|
||||
$checkpath = $langdir;
|
||||
for ($a=0; $a < count($pathparts)-1 ; $a++) {
|
||||
$checkpath .= "/".$pathparts[$a];
|
||||
if(!file_exists($checkpath)){
|
||||
if(!mkdir($checkpath)){
|
||||
echo ("Cannot create directory: $checkpath");
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// file doesn't exist - let's check webserver's permission to create it
|
||||
//
|
||||
if (!touch("$langdir/$currentfile")) {
|
||||
//
|
||||
// webserver is unable to create new file
|
||||
//
|
||||
echo "<p align=\"center\"><font color=red>".get_string("filemissing", "", "
|
||||
$langdir/$currentfile")."</font></p>";
|
||||
$editable = false;
|
||||
} else {
|
||||
//
|
||||
// webserver can create new file - we can delete it now and let
|
||||
// the langdoc_save_file() create it again if its filesize() > 0
|
||||
//
|
||||
$editable = true;
|
||||
unlink("$langdir/$currentfile");
|
||||
}
|
||||
} elseif ($f = fopen("$langdir/$currentfile","r+")) {
|
||||
//
|
||||
// file exists and is writeable - good for you, translator ;-)
|
||||
//
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
} else {
|
||||
//
|
||||
// file exists but it is not writeable by web server process :-(
|
||||
//
|
||||
$editable = false;
|
||||
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")
|
||||
."</font></p>";
|
||||
}
|
||||
|
||||
//en_utf8 in dataroot is not editable
|
||||
if ($currentlang == 'en_utf8') {
|
||||
$editable = false;
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr valign=\"center\"><td align=\"center\">\n";
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"\">\n";
|
||||
echo htmlspecialchars(file_get_contents("$enlangdir/$currentfile"));
|
||||
echo "</textarea>\n";
|
||||
//link_to_popup_window("/lang/en_utf8/$currentfile", "popup", get_string("preview"));
|
||||
link_to_popup_window(help_preview_url($currentfile).'&forcelang=en_utf8', 'popup', get_string('preview'));
|
||||
echo "</td>\n";
|
||||
if ($fileeditorinline == 1) {
|
||||
echo "</tr>\n<tr valign=\"center\">\n";
|
||||
}
|
||||
echo "<td align=\"center\">\n";
|
||||
|
||||
if ($editable) {
|
||||
echo "<form name=\"$currentfile\" action=\"langdoc.php\" method=\"post\">";
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
}
|
||||
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"filedata\">\n";
|
||||
if (file_exists("$langdir/$currentfile")) {
|
||||
echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
|
||||
} else {
|
||||
echo ($filetemplate);
|
||||
}
|
||||
echo "</textarea>\n";
|
||||
link_to_popup_window(help_preview_url($currentfile), 'popup', get_string('preview'));
|
||||
echo "</td>\n</tr>\n</table>";
|
||||
|
||||
if ($editable) {
|
||||
echo '<div align="center"><input type="submit" value="'.get_string('savechanges').': lang/'.$currentlang.'/'.$currentfile.'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
function langdoc_save_file($path, $file, $content) {
|
||||
|
||||
// $path is a full pathname to the file
|
||||
// $file is the file to overwrite.
|
||||
// $content are data to write
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
if (!$f = fopen("$path/$file","w")) {
|
||||
error_reporting($CFG->debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
$content = str_replace("\r", "",$content); // Remove linefeed characters
|
||||
$content = preg_replace("/\n{3,}/", "\n\n", $content); // Collapse runs of blank lines
|
||||
$content = trim($content); // Delete leading/trailing whitespace
|
||||
|
||||
fwrite($f, stripslashes($content));
|
||||
|
||||
fclose($f);
|
||||
|
||||
// Remove file if its empty
|
||||
|
||||
if (filesize("$path/$file") == 0) {
|
||||
unlink("$path/$file");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function help_preview_url($currentfile) {
|
||||
if (substr($currentfile, 0, 5) == 'help/') {
|
||||
$currentfile = substr($currentfile, 5);
|
||||
}
|
||||
$currentpathexp = explode('/', $currentfile);
|
||||
if (count($currentpathexp) > 1) {
|
||||
$url = '/help.php?module='.$currentpathexp[0].'&file='.$currentpathexp[1];
|
||||
} else {
|
||||
$url = '/help.php?module=moodle&file='.$currentfile;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,424 +0,0 @@
|
||||
<?php //$Id$
|
||||
///This file only manages the installation of 1.6 lang packs.
|
||||
///in downloads.moodle.org, they are store in separate directory /lang16
|
||||
///in local server, they are stored in $CFG->dataroot/lang
|
||||
///This helps to avoid confusion.
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$mode = optional_param('mode', 0, PARAM_INT); //phase
|
||||
$pack = optional_param('pack', '', PARAM_FILE); //pack to install
|
||||
$displaylang = $pack;
|
||||
$uninstalllang = optional_param('uninstalllang', '', PARAM_FILE);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$sitelang = optional_param('sitelangconfig', '', PARAM_FILE);
|
||||
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('CHANGE_SITE_LANG', 3);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be an admin');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site not defined!");
|
||||
}
|
||||
|
||||
$strlang = get_string('langimport','admin');
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strlanguage = get_string("language");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$title = $strlang;
|
||||
|
||||
print_header("$site->shortname: $title", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"lang.php\">$strlanguage</a> -> $strlang",
|
||||
'', '', true, '');
|
||||
|
||||
print_heading('');
|
||||
|
||||
switch ($mode){
|
||||
|
||||
case INSTALLATION_OF_SELECTED_LANG: ///installation of selected language pack
|
||||
|
||||
if (confirm_sesskey()) {
|
||||
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
error(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
break;
|
||||
|
||||
case INSTALLED:
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack));
|
||||
break;
|
||||
|
||||
case UPTODATE:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
notify('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CHANGE_SITE_LANG: //change site language
|
||||
|
||||
if (confirm_sesskey()) {
|
||||
$langconfig = get_record('config','name','lang');
|
||||
$langconfig->value = $sitelang;
|
||||
if (!empty($sitelang) && update_record('config',$langconfig)){
|
||||
redirect('langimport.php', get_string('sitelangchanged','admin'));
|
||||
} else {
|
||||
error('Could not update the default site language!');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
|
||||
|
||||
if (!$confirm && confirm_sesskey()) {
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode=4&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
'langimport.php');
|
||||
} else if (confirm_sesskey()) {
|
||||
if ($uninstalllang == 'en_utf8') {
|
||||
error ('en_utf8 can not be uninstalled!');
|
||||
}
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$uninstalllang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$uninstalllang;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)){
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
//delete the direcotries
|
||||
if ($rm1 or $rm2) {
|
||||
redirect('langimport.php', get_string('langpackremoved','admin'));
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
error('An error has occurred, language pack is not completely uninstalled, please check file permissions');
|
||||
}
|
||||
}
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
break;
|
||||
|
||||
case UPDATE_ALL_LANG: //1 click update for all updatable language packs
|
||||
|
||||
//0th pull a list from download.moodle.org,
|
||||
//key = langname, value = md5
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$md5array = array();
|
||||
$updated = 0; //any packs updated?
|
||||
unset($CFG->langlist); // ignore admin's langlist
|
||||
$alllangs = array_keys(get_list_of_languages());
|
||||
$lang16 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
|
||||
$packs = array(); //all the packs that needs updating
|
||||
|
||||
|
||||
if (!$availablelangs = proxy_url($source)) {
|
||||
error ('can not read from course');
|
||||
}
|
||||
|
||||
//and build an associative array
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
//filtering out non-16 packs
|
||||
foreach ($alllangs as $clang) {
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||
|
||||
if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
|
||||
$lang16[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
//then filter out packs that have the same md5 key
|
||||
foreach ($lang16 as $clang) {
|
||||
if (!is_installed_lang($clang, $md5array[$clang])){
|
||||
$packs[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
@mkdir ($CFG->dataroot.'/temp/');
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
foreach ($packs as $pack){ //for each of the remaining in the list, we
|
||||
if ($pack == 'en_utf8') { // no update for en_utf8
|
||||
continue;
|
||||
}
|
||||
//1. delete old director(ies)
|
||||
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$pack;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)) {
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)) {
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
if (!($rm1 || $rm2)) {
|
||||
error ('could not delete old directory, update failed');
|
||||
}
|
||||
|
||||
//2. copy & unzip into new
|
||||
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
error(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
break;
|
||||
case UPTODATE:
|
||||
//Print error string or whatever you want to do
|
||||
break;
|
||||
case INSTALLED:
|
||||
notify(get_string('langpackupdated','admin',$pack), 'notifysuccess');
|
||||
$updated = true;
|
||||
//Print/do whatever you want
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php');
|
||||
} else {
|
||||
notice(get_string('nolangupdateneeded','admin'), 'langimport.php');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default: //display choice mode
|
||||
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$remote = 0; //flag for reading from remote or local
|
||||
|
||||
if ($availablelangs = proxy_url($source)) {
|
||||
$remote = 1;
|
||||
} else {
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
/*
|
||||
if ($fp = fopen($source, 'r')){ /// attempt to get the list from Moodle.org.
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
$remote = 1; //can read from download.moodle.org
|
||||
} else { /// fopen failed, we find local copy of list.
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
*/
|
||||
if (!$remote) {
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<div align="center">';
|
||||
print_string('remotelangnotavailable','admin',$CFG->dataroot.'/lang/');
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
print_simple_box_start('center','60%');
|
||||
echo '<table width="100%"><tr><td align="center">';
|
||||
echo get_string('installedlangs','admin');
|
||||
echo '</td><td align="center">';
|
||||
echo get_string('availablelangs','admin');
|
||||
echo '</td></tr>';
|
||||
echo '<tr><td align="center" valign="top">';
|
||||
echo '<form name="uninstallform" action="langimport.php?mode=4" method="POST">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
unset($CFG->langlist); // ignore admin's langlist
|
||||
$installedlangs = get_list_of_languages();
|
||||
|
||||
/// display installed langs here
|
||||
|
||||
echo '<select name="uninstalllang" size="15">';
|
||||
foreach ($installedlangs as $clang =>$ilang){
|
||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.get_string('uninstall','admin').'" />';
|
||||
echo '</form>';
|
||||
echo '<form name="updateform" action="langimport.php?mode=5" method="POST">';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</form>';
|
||||
echo '<p />';
|
||||
|
||||
/// Display option to change site language
|
||||
|
||||
print_string('changesitelang','admin');
|
||||
$sitelanguage = get_record('config','name','lang');
|
||||
echo '<form name="changelangform" action="langimport.php?mode=3" method="POST">';
|
||||
echo '<select name="sitelangconfig">';
|
||||
|
||||
foreach ($installedlangs as $clang =>$ilang) {
|
||||
if ($clang == $sitelanguage->value){
|
||||
echo '<option value="'.$clang.'" selected="selected">'.$ilang.'</option>';
|
||||
} else {
|
||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||
}
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="submit" value="'.get_string('change','admin').'" />';
|
||||
echo '</form>';
|
||||
|
||||
/// display to be installed langs here
|
||||
|
||||
echo '</td><td align="center" valign="top">';
|
||||
echo '<table><tr><td valign="top" align="center">'; //availabe langs table
|
||||
$empty = 1; //something to pring
|
||||
|
||||
/// if this language pack is not already installed, then we allow installation
|
||||
|
||||
echo '<form name="installform" method="POST" action="langimport.php?mode=2">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
if ($remote) {
|
||||
echo '<select name="pack" size="15">';
|
||||
}
|
||||
|
||||
foreach ($availablelangs as $alang) {
|
||||
if (trim($alang[0]) != "en_utf8") {
|
||||
if ($remote){
|
||||
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
|
||||
$shortlang = substr($alang[0], 0, -5);
|
||||
} else {
|
||||
$shortlang = $alang[0];
|
||||
}
|
||||
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
||||
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$shortlang.')</option>';
|
||||
}
|
||||
} else { //print list in local format, and instruction to install
|
||||
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang16/'.$alang[0].'.zip">'.get_string('download','admin').'</a>';
|
||||
}
|
||||
$empty = 0;
|
||||
}
|
||||
}
|
||||
if ($remote) {
|
||||
echo '</select>';
|
||||
echo '<br/ ><input type="submit" value="<-- '.get_string('install','admin').'">';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
if ($empty) {
|
||||
echo '<tr><td align="center">';
|
||||
print_string('nolanguagetodownload','admin');
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
echo '</td><tr></table>'; //close available langs table
|
||||
echo '<form>';
|
||||
echo '</td></tr></table>';
|
||||
print_simple_box_end();
|
||||
|
||||
break;
|
||||
|
||||
} //close of main switch
|
||||
|
||||
print_footer();
|
||||
|
||||
/* returns a list of available language packs from a
|
||||
* local copy shipped with standard moodle distro
|
||||
* this is for site that can't perform fopen
|
||||
* @return array
|
||||
*/
|
||||
function get_local_list_of_languages() {
|
||||
global $CFG;
|
||||
$source = $CFG->wwwroot.'/lib/languages.md5';
|
||||
$availablelangs = array();
|
||||
if ($fp = fopen($source, 'r')){
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
}
|
||||
|
||||
/* checks the md5 of the zip file, grabbed from download.moodle.org,
|
||||
* against the md5 of the local language file from last update
|
||||
* @param string $lang
|
||||
* @param string $md5check
|
||||
* @return bool
|
||||
*/
|
||||
function is_installed_lang($lang, $md5check) {
|
||||
global $CFG;
|
||||
$md5file = $CFG->dataroot.'/lang/'.$lang.'/'.$lang.'.md5';
|
||||
if (file_exists($md5file)){
|
||||
return (file_get_contents($md5file) == $md5check);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//returns an array of languages, or false if can not read from source
|
||||
//uses a socket if proxy is set as a config variable
|
||||
function proxy_url($url) {
|
||||
global $CFG;
|
||||
|
||||
if ($CFG->proxyhost && $CFG->proxyport) {
|
||||
|
||||
$proxy_fp = fsockopen($CFG->proxyhost, $CFG->proxyport);
|
||||
if (!$proxy_fp) {
|
||||
return false; //failed
|
||||
}
|
||||
fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
|
||||
$i = 0;
|
||||
while(!feof($proxy_fp)) {
|
||||
$string = fgets($proxy_fp, 1024);
|
||||
if ($i > 11) { //12 lines of info skipped
|
||||
$availablelangs[] = split(',', $string);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
fclose($proxy_fp);
|
||||
|
||||
} else { //proxy not in use
|
||||
if ($fp = fopen($url, 'r')){ /// attempt to get the list from Moodle.org.
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
} else { /// fopen failed, return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
}
|
||||
?>
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Enables/disables maintenance mode
|
||||
|
||||
require('../config.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You need to be admin to use this page');
|
||||
}
|
||||
|
||||
//Check folder exists
|
||||
if (! make_upload_directory(SITEID)) { // Site folder
|
||||
error("Could not create site folder. The site administrator needs to fix the file permissions");
|
||||
}
|
||||
|
||||
$filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($form->action == "disable") {
|
||||
unlink($filename);
|
||||
redirect('index.php', get_string('sitemaintenanceoff','admin'));
|
||||
} else {
|
||||
$file = fopen($filename, 'w');
|
||||
fwrite($file, stripslashes($form->text));
|
||||
fclose($file);
|
||||
redirect('index.php', get_string('sitemaintenanceon', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the header stuff
|
||||
|
||||
$strmaintenance = get_string('sitemaintenancemode', 'admin');
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
|
||||
print_header("$SITE->shortname: $strmaintenance", $SITE->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmaintenance");
|
||||
|
||||
print_heading($strmaintenance);
|
||||
|
||||
/// Print the appropriate form
|
||||
|
||||
if (file_exists($filename)) { // We are in maintenance mode
|
||||
echo '<center>';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<input type="hidden" name="action" value="disable">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
|
||||
echo '<p><input type="submit" value="'.get_string('disable').'"></p>';
|
||||
echo '</form>';
|
||||
echo '</center>';
|
||||
} else { // We are not in maintenance mode
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
echo '<center>';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<input type="hidden" name="action" value="enable">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
|
||||
echo '<p><input type="submit" value="'.get_string('enable').'"></p>';
|
||||
echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
|
||||
echo '<table><tr><td>';
|
||||
print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
|
||||
echo '</td></tr></table>';
|
||||
echo '</form>';
|
||||
echo '</center>';
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
}
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
+19
-39
@@ -1,7 +1,7 @@
|
||||
<?PHP // $Id$
|
||||
// module.php - allows admin to edit all local configuration variables for a module
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -13,54 +13,34 @@
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
$module = optional_param('module', '', PARAM_SAFEDIR);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
// if the config.html contains a hidden form field giving
|
||||
// the module name then the form does not have to prefix all
|
||||
// its variable names, we will do it here.
|
||||
$moduleprefix = $module.'_';
|
||||
// let the module process the form data if it has to,
|
||||
// $config is passed to this function by reference
|
||||
$moduleconfig = $module.'_process_options';
|
||||
if (function_exists($moduleconfig)) {
|
||||
$moduleconfig($config);
|
||||
}
|
||||
} else {
|
||||
$moduleprefix = '';
|
||||
}
|
||||
|
||||
unset($config->sesskey);
|
||||
unset($config->module);
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($moduleprefix.$name, $value);
|
||||
set_config($name, $value);
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
$module = required_param('module', PARAM_SAFEDIR);
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
require_variable($module);
|
||||
|
||||
$module = clean_filename($module);
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagemodules = get_string("managemodules");
|
||||
$strmodulename = get_string("modulename", $module);
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'mod/' . $module . '/config';
|
||||
|
||||
|
||||
print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
@@ -68,11 +48,11 @@
|
||||
|
||||
print_heading($strmodulename);
|
||||
|
||||
print_simple_box("<center>".get_string("configwarning", 'admin')."</center>", "center", "60%");
|
||||
print_simple_box("<center>".get_string("configwarning")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
include("$CFG->dirroot/mod/$module/config.html");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("$CFG->dirroot/mod/$module/config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
+34
-41
@@ -1,13 +1,13 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to manage activity modules
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once("../config.php");
|
||||
require_once("../course/lib.php");
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
optional_variable($disable);
|
||||
optional_variable($enable);
|
||||
optional_variable($delete);
|
||||
optional_variable($confirm);
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
$coursesaffected = false;
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
@@ -48,29 +46,25 @@
|
||||
if (!$module = get_record("modules", "name", $hide)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
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;
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
set_field("course_modules", "visible", "0", "module", $module->id); // Hide all related activity modules
|
||||
}
|
||||
|
||||
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.
|
||||
$coursesaffected = true;
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field("course_modules", "visible", "1", "module", $module->id); // Show all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
|
||||
$strmodulename = get_string("modulename", "$delete");
|
||||
|
||||
if (!$confirm) {
|
||||
if (empty($confirm)) {
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
"modules.php?delete=$delete&confirm=$delete&sesskey=$USER->sesskey",
|
||||
"modules.php");
|
||||
print_footer();
|
||||
exit;
|
||||
@@ -127,19 +121,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
//rebuild_course_cache(); // Because things have changed
|
||||
$coursesaffected = true;
|
||||
rebuild_course_cache(); // Because things have changed
|
||||
|
||||
|
||||
$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
|
||||
|
||||
@@ -149,30 +138,34 @@
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$strmodulename = get_string("modulename", "$module->name");
|
||||
// Deal with modules which are lacking the language string
|
||||
if ($strmodulename == '[[modulename]]') {
|
||||
$strmodulename = $module->name;
|
||||
}
|
||||
$modulebyname[$strmodulename] = $module;
|
||||
}
|
||||
ksort($modulebyname);
|
||||
|
||||
/// Print the table of all modules
|
||||
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = "../pix";
|
||||
$modpixpath = "../mod";
|
||||
} else {
|
||||
$pixpath = "../theme/$CFG->theme/pix";
|
||||
$modpixpath = "../theme/$CFG->theme/pix/mod";
|
||||
}
|
||||
|
||||
$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->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) {
|
||||
|
||||
$icon = "<img src=\"$CFG->modpixpath/$module->name/icon.gif\" hspace=\"10\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" />";
|
||||
$icon = "<img src=\"$modpixpath/$module->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
|
||||
$settings = "<a href=\"module.php?module=$module->name\">$strsettings</a>";
|
||||
$settings = "<a href=\"module.php?module=$module->name&sesskey=$USER->sesskey\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
@@ -180,12 +173,12 @@
|
||||
$count = count_records("$module->name");
|
||||
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$pixpath/i/hide.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$pixpath/i/show.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
@@ -193,7 +186,7 @@
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$table->data[] = array ("<span $class>$icon $modulename</span>", $count, $module->version, $visible, $delete, $settings);
|
||||
$table->data[] = array ("<p $class>$icon $modulename</p>", $count, $module->version, $visible, $delete, $settings);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
if (!isset($CFG)) {
|
||||
|
||||
require('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be an admin to use this script');
|
||||
exit;
|
||||
}
|
||||
|
||||
print_header_simple('Online Assignment Cleanup','Online Assignment Cleanup', 'Admin');
|
||||
|
||||
online_assignment_cleanup(true);
|
||||
|
||||
print_footer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function online_assignment_cleanup($output=false) {
|
||||
global $CFG;
|
||||
|
||||
if ($output) {
|
||||
print_heading('Online Assignment Cleanup');
|
||||
echo '<center>';
|
||||
}
|
||||
|
||||
|
||||
/// We don't want to run this code if we are doing an upgrade from an assignment
|
||||
/// version earlier than 2005041400
|
||||
/// because the assignment type field will not exist
|
||||
$amv = get_field('modules', 'version', 'name', 'assignment');
|
||||
if ((int)$amv < 2005041400) {
|
||||
if ($output) {
|
||||
echo '</center>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/// get the module id for assignments from db
|
||||
$arecord = get_record('modules', 'name', 'assignment');
|
||||
$aid = $arecord->id;
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
$courses = get_courses();
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$fullname = empty($course->fullname) ? 'Course: '.$course->id : $course->fullname;
|
||||
if ($output) print_heading($fullname);
|
||||
|
||||
/// retrieve a list of sections beyond what is currently being shown
|
||||
$sql = 'SELECT * FROM '.$CFG->prefix.'course_sections WHERE course='.$course->id.' AND section>'.$course->numsections.' ORDER BY section ASC';
|
||||
if (!($xsections = get_records_sql($sql))) {
|
||||
if ($output) echo 'No extra sections<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// cycle through each of the xtra sections
|
||||
foreach ($xsections as $xsection) {
|
||||
|
||||
if ($output) echo 'Checking Section: '.$xsection->section.'<br />';
|
||||
|
||||
/// grab any module instances from the sequence field
|
||||
if (!empty($xsection->sequence)) {
|
||||
$instances = explode(',', $xsection->sequence);
|
||||
|
||||
/// cycle through the instances
|
||||
foreach ($instances as $instance) {
|
||||
/// is this an instance of an online assignment
|
||||
$sql = "SELECT a.id
|
||||
FROM {$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}assignment a
|
||||
WHERE cm.id = '$instance' AND
|
||||
cm.module = '$aid' AND
|
||||
cm.instance = a.id AND
|
||||
a.assignmenttype = 'online'";
|
||||
|
||||
|
||||
/// if record exists then we need to move instance to it's correct section
|
||||
if (record_exists_sql($sql)) {
|
||||
|
||||
/// check the new section id
|
||||
/// the journal update erroneously stored it in course_sections->section
|
||||
$newsection = $xsection->section;
|
||||
/// double check the new section
|
||||
if ($newsection > $course->numsections) {
|
||||
/// get the record for section 0 for this course
|
||||
if (!($zerosection = get_record('course_sections', 'course', $course->id, 'section', '0'))) {
|
||||
continue;
|
||||
}
|
||||
$newsection = $zerosection->id;
|
||||
}
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = get_record('course_sections', 'id', $newsection))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '.$course->fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// add instance to correct section
|
||||
array_push($sequence, $instance);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
/// now we need to remove the instance from the old sequence
|
||||
|
||||
/// grab the old section record
|
||||
if (!($section = get_record('course_sections', 'id', $xsection->id))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$course->fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// remove the old value from the array
|
||||
$key = array_search($instance, $sequence);
|
||||
unset($sequence[$key]);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
|
||||
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// if the summary and sequence are empty then remove this section
|
||||
if (empty($xsection->summary) and empty($xsection->sequence)) {
|
||||
delete_records('course_sections', 'id', $xsection->id);
|
||||
if ($output) echo 'Deleting empty section '.$xsection->section.'<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
?>
|
||||
+15
-20
@@ -3,37 +3,32 @@
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
$topframe = optional_param('topframe', false, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', false, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!$topframe && !$bottomframe) {
|
||||
?>
|
||||
|
||||
<head>
|
||||
<title>PHP info</title>
|
||||
</head>
|
||||
|
||||
<frameset rows="80,*">
|
||||
<frame src="phpinfo.php?topframe=true&sesskey=<?php echo $USER->sesskey ?>">
|
||||
<frame src="phpinfo.php?bottomframe=true&sesskey=<?php echo $USER->sesskey ?>">
|
||||
</frameset>
|
||||
|
||||
<?php
|
||||
} else if ($topframe && confirm_sesskey()) {
|
||||
if (isset($topframe)) {
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
print_header("$site->shortname: phpinfo", "$site->fullname",
|
||||
|
||||
print_header("$site->shortname: phpinfo", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> PHP info");
|
||||
exit;
|
||||
} else if ($bottomframe && confirm_sesskey()) {
|
||||
}
|
||||
|
||||
if (isset($bottomframe)) {
|
||||
phpinfo();
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<head>
|
||||
<title>PHP info</title>
|
||||
</head>
|
||||
|
||||
<frameset rows="80,*">
|
||||
<frame src="phpinfo.php?topframe=true">
|
||||
<frame src="phpinfo.php?bottomframe=true">
|
||||
</frameset>
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/usr/bin/php -f
|
||||
<?php // $Id$
|
||||
define('FULLME','cron'); // prevent warnings
|
||||
//error_reporting(0);
|
||||
//ini_set('display_errors',0);
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
$tmp = explode('@',$_ENV['RECIPIENT']);
|
||||
$address = $tmp[0];
|
||||
|
||||
// BOUNCE EMAILS TO NOREPLY
|
||||
if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
|
||||
$user->email = $_ENV['SENDER'];
|
||||
|
||||
if (!validate_email($user->email)) {
|
||||
die();
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$subject = get_string('noreplybouncesubject','moodle',$site->fullname);
|
||||
$body = get_string('noreplybouncemessage','moodle',$site->fullname)."\n\n";
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if ($fd) {
|
||||
while(!feof($fd)) {
|
||||
$body .= fgets($fd);
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
$user->id = 0; // to prevent anything annoying happening
|
||||
|
||||
$from->firstname = null;
|
||||
$from->lastname = null;
|
||||
$from->email = '<>';
|
||||
$from->maildisplay = true;
|
||||
|
||||
email_to_user($user,$from,$subject,$body);
|
||||
die ();
|
||||
}
|
||||
/// ALL OTHER PROCESSING
|
||||
// we need to split up the address
|
||||
$prefix = substr($address,0,4);
|
||||
$mod = substr($address,4,2);
|
||||
$modargs = substr($address,6,-16);
|
||||
$hash = substr($address,-16);
|
||||
|
||||
if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) {
|
||||
die("HASH DIDN'T MATCH!\n");
|
||||
}
|
||||
list(,$modid) = unpack('C',base64_decode($mod.'=='));
|
||||
|
||||
if ($modid == '0') { // special
|
||||
$modname = 'moodle';
|
||||
}
|
||||
else {
|
||||
$modname = get_field("modules","name","id",$modid);
|
||||
require_once('mod/'.$modname.'/lib.php');
|
||||
}
|
||||
$function = $modname.'_process_email';
|
||||
|
||||
if (!function_exists($function)) {
|
||||
die();
|
||||
}
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
while(!feof($fd)) {
|
||||
$body .= fgets($fd);
|
||||
}
|
||||
|
||||
$function($modargs,$body);
|
||||
|
||||
fclose($handle);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,171 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to manage questiontypes
|
||||
// This page is adapted from modules.php
|
||||
|
||||
// This page is not yet in service, the whole plug-in architecture
|
||||
// for question types is still under construction.
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strdelete = get_string("delete");
|
||||
$strversion = get_string("version");
|
||||
$strhide = get_string("hide");
|
||||
$strshow = get_string("show");
|
||||
$strsettings = get_string("settings");
|
||||
$strquestions = get_string("questions");
|
||||
$strquestiontype = get_string("questiontype", 'quiz');
|
||||
|
||||
print_header("$site->shortname: $strquestions", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strquestions");
|
||||
|
||||
print_heading($strquestions);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
if (!$qtype = get_record("question_types", "name", $hide)) {
|
||||
error("Question type doesn't exist!");
|
||||
}
|
||||
set_field("question_types", "visible", "0", "id", $qtype->id); // Hide question type
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
if (!$qtype = get_record("question_types", "name", $show)) {
|
||||
error("Question type doesn't exist!");
|
||||
}
|
||||
set_field("question_types", "visible", "1", "id", $qtype->id); // Show question type
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
|
||||
$strqtypename = get_string("qtypename", "qtype_$delete");
|
||||
|
||||
if (!$confirm) {
|
||||
notice_yesno(get_string("qtypedeleteconfirm", "admin", $strqtypename),
|
||||
"questiontypes.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
"questiontypes.php");
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "random") {
|
||||
error("You can not delete the random question type!!");
|
||||
}
|
||||
|
||||
if (!$qtype = get_record("question_types", "name", $delete)) {
|
||||
error("Question type doesn't exist!");
|
||||
}
|
||||
|
||||
// OK, first delete all the questions
|
||||
if ($questions = get_records("quiz_questions", "qtype", $qtype->id)) {
|
||||
foreach ($questions as $question) {
|
||||
if (! quiz_delete_question($coursemod->id, $coursemod->section)) {
|
||||
notify("Could not delete the $strqtypename with id = $question->id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// And the qtype entry itself
|
||||
if (!delete_records("question_types", "name", $qtype->name)) {
|
||||
notify("Error occurred while deleting the $strqtypename record from question_types table");
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$qtype->name;
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table, $prefix) === 0) {
|
||||
if (!execute_sql("DROP TABLE $table", false)) {
|
||||
notify("ERROR: while trying to drop table $table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$a->qtype = $strqtypename;
|
||||
$a->directory = "$CFG->dirroot/qtype/$delete";
|
||||
notice(get_string("qtypedeletefiles", "", $a), "questiontypes.php");
|
||||
}
|
||||
}
|
||||
|
||||
/// Get and sort the existing questiontypes
|
||||
|
||||
if (!$qtypes = get_records("question_types")) {
|
||||
error("No question types found!!"); // Should never happen
|
||||
}
|
||||
|
||||
foreach ($qtypes as $qtype) {
|
||||
$strqtypename = get_string("qtypename", "qtype_$qtype->name");
|
||||
$qtypebyname[$strqtypename] = $qtype;
|
||||
}
|
||||
ksort($qtypebyname);
|
||||
|
||||
/// Print the table of all questiontypes
|
||||
|
||||
$table->head = array ($strquestiontype, $strquestions, $strversion, "$strhide/$strshow", $strdelete, $strsettings);
|
||||
$table->align = array ("left", "right", "left", "center", "center", "center");
|
||||
$table->wrap = array ("nowrap", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
|
||||
foreach ($qtypebyname as $qtypename => $qtype) {
|
||||
|
||||
$icon = "<img src=\"$CFG->dirroot/mod/quiz/questiontypes/$qtype->name/icon.gif\" hspace=\"10\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" />";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/quiz/questiontypes/$qtype->name/config.html")) {
|
||||
$settings = "<a href=\"questiontype.php?qtype=$qtype->name\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
|
||||
$count = count_records('quiz_questions', 'qtype', $qtype->id);
|
||||
|
||||
$delete = $count ? '' : "<a href=\"questiontypes.php?delete=$qtype->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
|
||||
if ($qtype->visible) {
|
||||
$visible = "<a href=\"questiontypes.php?hide=$qtype->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"questiontypes.php?show=$qtype->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
if ($qtype->name == "random") {
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$table->data[] = array ("<span $class>$icon $qtypename</span>", $count, $qtype->version, $visible, $delete, $settings);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
echo "<br /><br />";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+35
-92
@@ -1,7 +1,7 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// register.php - allows admin to register their site on moodle.org
|
||||
|
||||
require_once('../config.php');
|
||||
include("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
$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);
|
||||
@@ -47,17 +47,14 @@
|
||||
|
||||
/// Print the form
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
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 "<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=\"right\">Moodle URL:</td>\n";
|
||||
echo "<td>$CFG->wwwroot</td>\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>Moodle URL:</td>\n";
|
||||
echo "<td><p>$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";
|
||||
@@ -68,28 +65,28 @@
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("currentversion").":</td>\n";
|
||||
echo "<td>$CFG->release ($CFG->version)</td>\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("currentversion").":</td>\n";
|
||||
echo "<td><p>$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 "<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 valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("fullsitename").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"sitename\" value=\"$site->fullname\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\">".get_string("country").":</td>\n";
|
||||
echo "<td>";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("country").":</td>\n";
|
||||
echo "<td><p>";
|
||||
choose_from_menu (get_list_of_countries(), "country", $admin->country, get_string("selectacountry")."...", "", "");
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
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>";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p><a href=\"http://moodle.org/sites\" title=\"See the current list of sites\" target=_blank>".get_string("publicdirectory")."</a>:</td>\n";
|
||||
echo "<td><p>";
|
||||
$options[0] = get_string("publicdirectory0");
|
||||
$options[1] = get_string("publicdirectory1");
|
||||
$options[2] = get_string("publicdirectory2");
|
||||
@@ -98,77 +95,23 @@
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
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 "</td>\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td colspan=2><hr size=1 noshade>\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 '<br />';
|
||||
|
||||
$count = count_records('user')-1;
|
||||
echo get_string("users").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"users\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('user_students');
|
||||
echo get_string("enrolments").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"enrolments\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('user_teachers');
|
||||
echo get_string("teachers").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"teachers\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('forum_posts');
|
||||
echo get_string("posts", 'forum').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"posts\" value=\"$count\">\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('question');
|
||||
echo get_string("questions", 'quiz').": ".$count;
|
||||
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 '<br />';
|
||||
|
||||
echo "</td>\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("administrator").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"adminname\" value=\"".fullname($admin, true)."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"center\" colspan=\"2\"><hr size=\"1\" noshade>".get_string("administrator")."</td>\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("email").":</td>\n";
|
||||
echo "<td><p><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("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";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("registrationemail")."</a>:</td>\n";
|
||||
echo "<td><p>\n";
|
||||
$options[0] = get_string("registrationno");
|
||||
$options[1] = get_string("registrationyes");
|
||||
choose_from_menu ($options, "mailme", "1", "", "", "");
|
||||
@@ -176,9 +119,9 @@
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\"> </td>\n";
|
||||
echo "<td><input type=\"submit\" value=\"".get_string("registrationsend")."\"></td>\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right> </td>\n";
|
||||
echo "<td><p><input type=\"submit\" value=\"".get_string("registrationsend")."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php /// $Id$
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$search = optional_param('search', '', PARAM_RAW);
|
||||
$replace = optional_param('replace', '', PARAM_RAW);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Admins only");
|
||||
}
|
||||
|
||||
###################################################################
|
||||
print_header('Search and replace throughout the whole database', 'Replace text within the whole database');
|
||||
|
||||
|
||||
if (!$search or !$replace or !confirm_sesskey()) { /// Print a form
|
||||
|
||||
print_simple_box_start('center');
|
||||
echo '<div align="center">';
|
||||
echo '<form action="replace.php">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'">';
|
||||
echo 'Search whole database for: <input type="text" name="search"><br />';
|
||||
echo 'Replace with this string: <input type="text" name="replace"><br /></br />';
|
||||
echo '<input type="submit" value="Yes, do it now"><br />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
if (!$tables = $db->Metatables() ) { // No tables yet at all.
|
||||
error("no tables");
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
foreach ($tables as $table) {
|
||||
if (in_array($table, array($CFG->prefix.'config'))) { // Don't process these
|
||||
continue;
|
||||
}
|
||||
if ($columns = $db->MetaColumns($table, false)) {
|
||||
foreach ($columns as $column => $data) {
|
||||
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
|
||||
$db->debug = true;
|
||||
execute_sql("UPDATE $table SET $column = REPLACE($column, '$search', '$replace');");
|
||||
$db->debug = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
?>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Display all the reports available in admin/report
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You are not allowed to look at this page");
|
||||
}
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strreports = get_string('reports');
|
||||
|
||||
print_header($strreports, $strreports,
|
||||
'<a href="index.php">'.$stradmin.'</a> -> '.$strreports);
|
||||
|
||||
$directories = get_list_of_plugins('admin/report');
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
echo '<div class="plugin '.$directory.'">';
|
||||
include_once($CFG->dirroot.'/admin/report/'.$directory.'/mod.php'); // Fragment for listing
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("This page is for admins only");
|
||||
}
|
||||
|
||||
$course = get_site();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
$strreports = get_string('reports');
|
||||
$strcourseoverview = get_string('courseoverview');
|
||||
|
||||
$strnav = '<a href="'.$CFG->wwwroot.'/admin/index.php">'.get_string('administration').'</a> -> <a href="'.$CFG->wwwroot.'/admin/report.php">'.$strreports.'</a> -> '.$strcourseoverview;
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
if (empty($timeoptions)) {
|
||||
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
print_header($strcourseoverview, $strcourseoverview, $strnav,'','',true,' ');
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n";
|
||||
|
||||
$table->width = '*';
|
||||
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($report) && !empty($time)) {
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= ".$param->timeafter
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby
|
||||
." LIMIT ".$numcourses;
|
||||
|
||||
$courses = get_records_sql($sql);
|
||||
|
||||
if (empty($courses)) {
|
||||
error(get_string('statsnodata'),$CFG->wwwroot.'/admin/report/courseoverview/index.php');
|
||||
}
|
||||
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/admin/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></center>';
|
||||
|
||||
$table = new object();
|
||||
$table->align = array('left','center','center','center');
|
||||
$table->head = array(get_string('course'),$param->line1);
|
||||
if (!empty($param->line2)) {
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
if (!empty($param->line3)) {
|
||||
$table->head[] = $param->line3;
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$a = array();
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
|
||||
|
||||
$a[] = $c->line1;
|
||||
if (isset($c->line2)) {
|
||||
$a[] = $c->line2;
|
||||
}
|
||||
if (isset($c->line3)) {
|
||||
$a[] = $c->line3;
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
|
||||
$strreports = get_string('reports');
|
||||
$strcourseoverview = get_string('courseoverview');
|
||||
|
||||
print_heading("$strcourseoverview:");
|
||||
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
$course = get_site();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
$table->width = '*';
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
echo '<form action="report/courseoverview/index.php" method="post">'."\n";
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/lib/graphlib.php');
|
||||
|
||||
$report = required_param('report', PARAM_INT);
|
||||
$time = required_param('time', PARAM_INT);
|
||||
$numcourses = required_param('numcourses', PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an admin to use this page");
|
||||
}
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= ".$param->timeafter
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby
|
||||
." LIMIT ".$numcourses;
|
||||
|
||||
$courses = get_records_sql($sql);
|
||||
|
||||
if (empty($courses)) {
|
||||
error(get_string('statsnodata'),$CFG->wwwroot.'/admin/report/course/index.php');
|
||||
}
|
||||
|
||||
|
||||
$graph = new graph(750,400);
|
||||
|
||||
$graph->parameter['legend'] = 'outside-right';
|
||||
$graph->parameter['legend_size'] = 10;
|
||||
$graph->parameter['x_axis_angle'] = 90;
|
||||
$graph->parameter['title'] = false; // moodle will do a nicer job.
|
||||
if ($report != STATS_REPORT_ACTIVE_COURSES) {
|
||||
$graph->parameter['y_decimal_left'] = 2;
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$graph->x_data[] = get_field('course','shortname','id',$c->courseid);
|
||||
$graph->y_data['bar1'][] = $c->{$param->graphline};
|
||||
}
|
||||
$graph->y_order = array('bar1');
|
||||
$graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
|
||||
|
||||
$graph->draw_stack();
|
||||
|
||||
?>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/course/report/log/lib.php');
|
||||
|
||||
$course = get_site();
|
||||
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_log_selector_form($course);
|
||||
|
||||
echo '<br />';
|
||||
print_heading(get_string('chooselivelogs') .':');
|
||||
|
||||
echo '<center><h3>';
|
||||
link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800);
|
||||
echo '</h3></center>';
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
if (!$user = get_record('user','id',$userid)) {
|
||||
error("That's an invalid user id");
|
||||
}
|
||||
}
|
||||
|
||||
require_login();
|
||||
if (!isteacher($course->id)) {
|
||||
error("You need to be a teacher to use this page");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$menu = report_stats_mode_menu($course, $mode, $time);
|
||||
|
||||
|
||||
$crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
<a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
|
||||
$strstats";
|
||||
|
||||
print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
$crumb, '', '', true, ' ', $menu);
|
||||
|
||||
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<p style="text-align:center;">';
|
||||
echo '<a href="'.$CFG->wwwroot.'/admin/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
|
||||
echo '</p>';
|
||||
}
|
||||
?>
|
||||
+55
-70
@@ -1,19 +1,20 @@
|
||||
<form method="post" action="site.php" name="form">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("fullsitename") ?>:</td>
|
||||
<td><input type="text" name="fullname" size="50" maxlength="254" value="<?php p($form->fullname) ?>" alt="<?php print_string("fullsitename") ?>" />
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("fullsitename") ?>:</td>
|
||||
<td><input type="text" name="fullname" size="50" maxlength="254" value="<?php p($form->fullname) ?>">
|
||||
<?php if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("shortsitename") ?>:</td>
|
||||
<td><input type="text" name="shortname" size="15" maxlength="15" value="<?php p($form->shortname) ?>" alt="<?php print_string("shortsitename") ?>" />
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("shortsitename") ?>:</td>
|
||||
<td><input type="text" name="shortname" size="15" maxlength="15" value="<?php p($form->shortname) ?>">
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("frontpagedescription") ?>:<br /><br />
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("frontpagedescription") ?>:</P><br />
|
||||
<font size=1>
|
||||
<?PHP
|
||||
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
|
||||
echo "<br />";
|
||||
@@ -21,58 +22,32 @@
|
||||
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
|
||||
} else {
|
||||
helpbutton("html", get_string("helphtml"), "moodle", true, true);
|
||||
}
|
||||
echo "<br />";
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
</font>
|
||||
</td>
|
||||
<td><?php print_textarea($usehtmleditor, 20, 50, 600, 400, "summary", $form->summary); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("frontpageformat") ?>:</td>
|
||||
<td>
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<?php
|
||||
$options = array(FRONTPAGENEWS => get_string("frontpagenews"),
|
||||
FRONTPAGECOURSELIST => get_string("frontpagecourselist"),
|
||||
FRONTPAGECATEGORYNAMES => get_string("frontpagecategorynames"),
|
||||
);
|
||||
$values = array(get_string('hide'), get_string('order1', 'admin'), get_string('order2', 'admin'));
|
||||
$seq = array_flip(explode(',',$form->frontpage));
|
||||
foreach ($seq as $k => $s) {
|
||||
$seq[$k]++;
|
||||
}
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("frontpageformat") ?>:</td>
|
||||
<td><?php
|
||||
$options = array("0" => get_string("frontpagenews"),
|
||||
"1" => get_string("frontpagecourselist"),
|
||||
"2" => get_string("frontpagecategorynames"));
|
||||
if (count_records("course") > 200) {
|
||||
unset($options[FRONTPAGECOURSELIST]);
|
||||
if (isset($seq[FRONTPAGECOURSELIST])) {
|
||||
unset($options[1]);
|
||||
if ($form->frontpage == 1) {
|
||||
$form->frontpage = 2;
|
||||
}
|
||||
} else {
|
||||
$values[] = get_string('order3', 'admin');
|
||||
}
|
||||
foreach ($options as $key => $option) {
|
||||
echo "<td>$option<br />";
|
||||
choose_from_menu ($values, "frontpage[$key]", isset($seq[$key])?$seq[$key]:0, "");
|
||||
echo '</td>';
|
||||
}
|
||||
choose_from_menu ($options, "frontpage", "$form->frontpage", "");
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("sitesection") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
$choices["1"] = get_string("yes");
|
||||
choose_from_menu ($choices, "numsections", $form->numsections, "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("newsitemsnumber") ?>:</td>
|
||||
<td><?php
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("newsitemsnumber") ?>:</td>
|
||||
<td><?php
|
||||
$newsitem = get_string("newsitem");
|
||||
$newsitems = get_string("newsitems");
|
||||
$options = array("0" => "0 $newsitems",
|
||||
@@ -90,41 +65,51 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" maxlength="100" size="25" value="<?php p($form->teacher) ?>" alt="<?php print_string("wordforteacher") ?>" />
|
||||
(<?php print_string("wordforteachereg") ?>)
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("sitesection") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
$choices["1"] = get_string("yes");
|
||||
choose_from_menu ($choices, "numsections", $form->numsections, "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" maxlength="100" size="25" value="<?php p($form->teacher) ?>">
|
||||
(<?php print_string("wordforteachereg") ?>)
|
||||
<?php if (isset($err["teacher"])) formerr($err["teacher"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" maxlength="100" size="25" value="<?php p($form->teachers) ?>" alt="<?php print_string("wordforteachers") ?>" />
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" maxlength="100" size="25" value="<?php p($form->teachers) ?>">
|
||||
(<?php print_string("wordforteacherseg") ?>)
|
||||
<?php if (isset($err["teachers"])) formerr($err["teachers"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" maxlength="100" size="25" value="<?php p($form->student) ?>" alt="<?php print_string("wordforstudent") ?>" />
|
||||
(<?php print_string("wordforstudenteg") ?>)
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" maxlength="100" size="25" value="<?php p($form->student) ?>">
|
||||
(<?php print_string("wordforstudenteg") ?>)
|
||||
<?php if (isset($err["student"])) formerr($err["student"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" maxlength="100" size="25" value="<?php p($form->students) ?>" alt="<?php print_string("wordforstudents") ?>" />
|
||||
(<?php print_string("wordforstudentseg") ?>)
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" maxlength="100" size="25" value="<?php p($form->students) ?>">
|
||||
(<?php print_string("wordforstudentseg") ?>)
|
||||
<?php if (isset($err["students"])) formerr($err["students"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="id" value="<?php p($form->id) ?>" />
|
||||
<input type="hidden" name="category" value="<?php p($form->category) ?>" />
|
||||
<input type="hidden" name="format" value="<?php p($form->format) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
|
||||
<input type="hidden" name="id" value="<?php p($form->id) ?>">
|
||||
<input type="hidden" name="category" value="<?php p($form->category) ?>">
|
||||
<input type="hidden" name="format" value="<?php p($form->format) ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>">
|
||||
</form>
|
||||
|
||||
+21
-27
@@ -1,7 +1,6 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once("../config.php");
|
||||
|
||||
if ($site = get_site()) {
|
||||
require_login();
|
||||
@@ -11,11 +10,9 @@
|
||||
$site->format = "social"; // override
|
||||
}
|
||||
|
||||
$focus = "form.fullname";
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if (!empty($USER->id)) { // Additional identity check
|
||||
if (!confirm_sesskey()) {
|
||||
@@ -27,15 +24,7 @@
|
||||
|
||||
if (count($err) == 0) {
|
||||
|
||||
$form->frontpage = array_flip($form->frontpage);
|
||||
unset($form->frontpage[0]);
|
||||
$form->frontpage = array_flip($form->frontpage);
|
||||
asort($form->frontpage);
|
||||
$form->frontpage = implode(',',array_flip($form->frontpage));
|
||||
set_config("frontpage", $form->frontpage);
|
||||
if ($form->frontpage == '') {
|
||||
$form->numsections = 1; // Force the topic display for this format
|
||||
}
|
||||
|
||||
$form->timemodified = time();
|
||||
|
||||
@@ -46,17 +35,14 @@
|
||||
error("Serious Error! Could not update the site record! (id = $form->id)");
|
||||
}
|
||||
} else {
|
||||
// We are about to create the site "course"
|
||||
// [pj] We are about to create the site, so let's add some blocks...
|
||||
// calendar_month is included as a Moodle feature advertisement ;-)
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
$form->blockinfo = blocks_get_default_blocks(NULL, BLOCKS_DEFAULT_SITE);
|
||||
|
||||
if ($newid = insert_record('course', $form)) {
|
||||
|
||||
// Site created, add blocks for it
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $newid);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
|
||||
$cat->name = get_string('miscellaneous');
|
||||
if (insert_record('course_categories', $cat)) {
|
||||
if ($newid = insert_record("course", $form)) {
|
||||
$cat->name = get_string("miscellaneous");
|
||||
if (insert_record("course_categories", $cat)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
|
||||
} else {
|
||||
error("Serious Error! Could not set up a default course category!");
|
||||
@@ -88,7 +74,7 @@
|
||||
$form->numsections = 0;
|
||||
$form->id = "";
|
||||
$form->category = 0;
|
||||
$form->format = 'site'; // Only for this course
|
||||
$form->format = "social";
|
||||
$form->teacher = get_string("defaultcourseteacher");
|
||||
$form->teachers = get_string("defaultcourseteachers");
|
||||
$form->student = get_string("defaultcoursestudent");
|
||||
@@ -100,10 +86,18 @@
|
||||
$form->frontpage = $CFG->frontpage;
|
||||
|
||||
} else {
|
||||
$form->frontpage = FRONTPAGECOURSELIST; // Show course list by default
|
||||
if ($form->newsitems > 0) {
|
||||
$form->frontpage = 0;
|
||||
} else {
|
||||
$form->frontpage = 1;
|
||||
}
|
||||
set_config("frontpage", $form->frontpage);
|
||||
}
|
||||
|
||||
if (empty($focus)) {
|
||||
$focus = "form.fullname";
|
||||
}
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strsitesettings = get_string("sitesettings");
|
||||
@@ -111,7 +105,7 @@
|
||||
if ($firsttime) {
|
||||
print_header();
|
||||
print_heading($strsitesettings);
|
||||
print_simple_box(get_string("configintrosite", 'admin'), "center", "50%");
|
||||
print_simple_box(get_string("configintrosite"), "center", "50%");
|
||||
echo "<br />";
|
||||
} else {
|
||||
print_header("$site->shortname: $strsitesettings", "$site->fullname",
|
||||
@@ -129,7 +123,7 @@
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
$defaultformat = FORMAT_HTML;
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("site.html");
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/my/pagelib.php');
|
||||
require_once($CFG->dirroot.'/lib/pagelib.php');
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
|
||||
$pt = optional_param('pt', null, PARAM_SAFEDIR); //alhanumeric and -
|
||||
|
||||
$pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE,
|
||||
'lib' => '/my/pagelib.php',
|
||||
'name' => get_string('stickyblocksmymoodle','admin')),
|
||||
PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW,
|
||||
'lib' => '/lib/pagelib.php',
|
||||
'name' => get_string('stickyblockscourseview','admin'))
|
||||
// ... more?
|
||||
);
|
||||
|
||||
// for choose_from_menu
|
||||
$options = array();
|
||||
foreach ($pagetypes as $p) {
|
||||
$options[$p['id']] = $p['name'];
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
// first thing to do is print the dropdown menu
|
||||
|
||||
$strtitle = get_string('stickyblocks','admin');
|
||||
$strheading = get_string('adminhelpstickyblocks');
|
||||
|
||||
print_header($strtitle,$strtitle,'<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.
|
||||
get_string('admin').'</a> -> '.$strtitle);
|
||||
|
||||
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
|
||||
echo '<tr valign="top">';
|
||||
|
||||
|
||||
if (!empty($pt)) {
|
||||
require_once($CFG->dirroot.$pagetypes[$pt]['lib']);
|
||||
|
||||
define('ADMIN_STICKYBLOCKS',$pt);
|
||||
|
||||
$PAGE = page_create_object($pt);
|
||||
|
||||
$blocks = blocks_setup($PAGE,BLOCKS_PINNED_TRUE);
|
||||
|
||||
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
|
||||
echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
|
||||
|
||||
blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
|
||||
} else {
|
||||
echo '<td style="vertical-align: top;" id="left-column">';
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
|
||||
echo '<td valign="top" width="*" id="middle-column">';
|
||||
print_simple_box_start('center');
|
||||
print_heading($strheading);
|
||||
echo '<form method="post" action="'.$CFG->wwwroot.'/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();
|
||||
echo '</td>';
|
||||
|
||||
|
||||
if (!empty($pt)) {
|
||||
echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
|
||||
blocks_print_group($PAGE, $blocks, BLOCK_POS_RIGHT);
|
||||
}
|
||||
echo '<td style="vertical-align: top;" id="left-column">';
|
||||
echo '</td>';
|
||||
|
||||
echo '</tr></table>';
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
?>
|
||||
+22
-7
@@ -1,8 +1,6 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$zone = optional_param('zone', '', PARAM_PATH); //not a path, but it looks like it anyway
|
||||
include("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -19,7 +17,7 @@
|
||||
|
||||
print_heading("");
|
||||
|
||||
if (!empty($zone) and confirm_sesskey()) {
|
||||
if (isset($zone) and confirm_sesskey()) {
|
||||
$db->debug = true;
|
||||
echo "<center>";
|
||||
execute_sql("UPDATE {$CFG->prefix}user SET timezone = '$zone'");
|
||||
@@ -29,12 +27,29 @@
|
||||
$USER->timezone = $zone;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
$timezones = get_list_of_timezones();
|
||||
$user = $USER;
|
||||
|
||||
if (abs($user->timezone) > 13) {
|
||||
$user->timezone = 99;
|
||||
}
|
||||
$timenow = time();
|
||||
$timeformat = get_string('strftimedaytime');
|
||||
|
||||
for ($tz = -26; $tz <= 26; $tz++) {
|
||||
$zone = (float)$tz/2.0;
|
||||
$usertime = $timenow + ($tz * 1800);
|
||||
if ($tz == 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT)";
|
||||
} else if ($tz < 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT$zone)";
|
||||
} else {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT+$zone)";
|
||||
}
|
||||
}
|
||||
|
||||
echo '<center><form action="timezone.php" method="get">';
|
||||
echo "$strusers ($strall): ";
|
||||
choose_from_menu ($timezones, "zone", 99, get_string("serverlocaltime"), "", "99");
|
||||
choose_from_menu ($timezones, "zone", $user->timezone, get_string("serverlocaltime"), "", "99");
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
|
||||
echo "<input type=\"submit\" value=\"$strsavechanges\">";
|
||||
echo "</form></center>";
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Automatic update of Timezones from a new source
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/olson.php');
|
||||
|
||||
$ok = optional_param('ok', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error('Only administrators can use this page!');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error('Site isn\'t defined!');
|
||||
}
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strcalendarsettings = get_string('calendarsettings', 'admin');
|
||||
$strimporttimezones = get_string('importtimezones', 'admin');
|
||||
|
||||
print_header("$site->shortname: $strcalendarsettings", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"calendar.php\">$strcalendarsettings</a> -> $strimporttimezones");
|
||||
|
||||
print_heading($strimporttimezones);
|
||||
|
||||
if (!$ok or !confirm_sesskey()) {
|
||||
$message = '<p>';
|
||||
$message .= $CFG->dataroot.'/temp/olson.txt<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(), 'calendar.php');
|
||||
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/// Try to find a source of timezones to import from
|
||||
|
||||
$importdone = false;
|
||||
|
||||
/// First, look for an Olson file locally
|
||||
|
||||
$source = $CFG->dataroot.'/temp/olson.txt';
|
||||
if (!$importdone and is_readable($source)) {
|
||||
if ($timezones = olson_to_timezones($source)) {
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
}
|
||||
|
||||
/// Next, look for a CSV file locally
|
||||
|
||||
$source = $CFG->dataroot.'/temp/timezones.txt';
|
||||
if (!$importdone and is_readable($source)) {
|
||||
if ($timezones = get_records_csv($source, 'timezone')) {
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise, let's try moodle.org's copy
|
||||
|
||||
$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/timezones.txt', 'w')) { // Make local copy
|
||||
fwrite($file, $contents);
|
||||
fclose($file);
|
||||
if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezones.txt', 'timezone')) { // Parse it
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
unlink($CFG->dataroot.'/temp/timezones.txt');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Final resort, use the copy included in Moodle
|
||||
|
||||
$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);
|
||||
$importdone = $source;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// That's it!
|
||||
|
||||
if ($importdone) {
|
||||
$a = null;
|
||||
$a->count = count($timezones);
|
||||
$a->source = $importdone;
|
||||
print_heading(get_string('importtimezonescount', 'admin', $a), '', 3);
|
||||
|
||||
print_continue('calendar.php');
|
||||
|
||||
$timezonelist = array();
|
||||
foreach ($timezones as $timezone) {
|
||||
if (isset($timezonelist[$timezone->name])) {
|
||||
$timezonelist[$timezone->name]++;
|
||||
} else {
|
||||
$timezonelist[$timezone->name] = 1;
|
||||
}
|
||||
}
|
||||
ksort($timezonelist);
|
||||
|
||||
echo "<br />";
|
||||
print_simple_box_start('center');
|
||||
foreach ($timezonelist as $name => $count) {
|
||||
echo "$name ($count)<br />";
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
} else {
|
||||
print_heading(get_string('importtimezonesfailed', 'admin'), '', 3);
|
||||
print_continue('calendar.php');
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,118 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an admin to use this script");
|
||||
}
|
||||
|
||||
if ($CFG->version < 2005042300) {
|
||||
error("This script does not work with this old version of Moodle");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
|
||||
/// Print header
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strupgradingdata = get_string("upgradingdata", "admin");
|
||||
|
||||
print_header("$site->shortname: $stradministration: $strupgradingdata", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strupgradingdata");
|
||||
|
||||
if (empty($confirm)) {
|
||||
notice_yesno(get_string("upgradeforumreadinfo", "admin"),
|
||||
"upgradeforumread.php?confirm=true&sesskey=$USER->sesskey",
|
||||
"index.php");
|
||||
print_footer();
|
||||
exit;
|
||||
} else if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
@ob_end_flush();
|
||||
|
||||
execute_sql('TRUNCATE TABLE '.$CFG->prefix.'forum_read;', false); // Trash all old entries
|
||||
|
||||
/// Enter initial read records for all posts older than 1 day.
|
||||
|
||||
/// Timestamp for old posts (and therefore considered read).
|
||||
$dateafter = time() - ($CFG->forum_oldpostdays*24*60*60);
|
||||
|
||||
/// Timestamp for one day ago.
|
||||
$onedayago = time() - (24*60*60);
|
||||
|
||||
|
||||
/// Get all discussions that have had posts since the old post date.
|
||||
if ($discussions = get_records_select('forum_discussions', 'timemodified > '.$dateafter,
|
||||
'course', 'id,course,forum,groupid,userid')) {
|
||||
$dtotal = count($discussions);
|
||||
print_heading('Updating forum post read/unread records for '.$dtotal.' discussions...'.
|
||||
'Please keep this window open until it completes', '', 3);
|
||||
|
||||
$groups = array();
|
||||
|
||||
$currcourse = 0;
|
||||
$users = 0;
|
||||
$count = 0;
|
||||
$dcount = 0;
|
||||
|
||||
foreach ($discussions as $discussion) {
|
||||
$dcount++;
|
||||
print_progress($dcount, $dtotal);
|
||||
|
||||
if ($discussion->course != $currcourse) {
|
||||
/// Discussions are ordered by course, so we only need to get any course's users once.
|
||||
$currcourse = $discussion->course;
|
||||
$users = get_course_users($currcourse, '', '', 'u.id,u.confirmed');
|
||||
}
|
||||
/// If this course has users, and posts more than a day old, mark them for each user.
|
||||
if ($users &&
|
||||
($posts = get_records_select('forum_posts', 'discussion = '.$discussion->id.
|
||||
' AND '.$dateafter.' < modified AND modified < '.$onedayago,
|
||||
'', 'id,discussion,modified'))) {
|
||||
foreach ($users as $user) {
|
||||
/// If its a group discussion, make sure the user is in the group.
|
||||
if ($discussion->groupid) {
|
||||
if (!isset($groups[$discussion->groupid][$user->id])) {
|
||||
$groups[$discussion->groupid][$user->id] = ismember($discussion->groupid, $user->id);
|
||||
}
|
||||
}
|
||||
if (!$discussion->groupid || !empty($groups[$discussion->groupid][$user->id])) {
|
||||
foreach ($posts as $post) {
|
||||
print_progress($dcount, $dtotal);
|
||||
forum_tp_mark_post_read($user->id, $post, $discussion->forum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print_progress($dcount, $dtotal, 0);
|
||||
}
|
||||
|
||||
|
||||
delete_records('config', 'name', 'upgrade', 'value', 'forumread');
|
||||
|
||||
notify('Log upgrading was successful!', 'notifysuccess');
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,8 +1,8 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require("../config.php");
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
optional_variable($confirm);
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
print_header("$site->shortname: $stradministration: $strupgradinglogs", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strupgradinglogs");
|
||||
|
||||
if (empty($confirm)) {
|
||||
if (empty($_GET['confirm'])) {
|
||||
notice_yesno(get_string("upgradelogsinfo", "admin"),
|
||||
"upgradelogs.php?confirm=true&sesskey=$USER->sesskey",
|
||||
"index.php");
|
||||
|
||||
+253
-374
@@ -1,404 +1,283 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
/// Bulk user registration script from a comma separated file
|
||||
/// Returns list of users with their user ids
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/uploadlib.php');
|
||||
require_once("../config.php");
|
||||
|
||||
$createpassword = optional_param('createpassword', 0, PARAM_BOOL);
|
||||
$updateaccounts = optional_param('updateaccounts', 0, PARAM_BOOL);
|
||||
$allowrenames = optional_param('allowrenames', 0, PARAM_BOOL);
|
||||
optional_variable($numusers, 0);
|
||||
|
||||
require_login();
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to edit users this way.");
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Could not find site-level course");
|
||||
}
|
||||
|
||||
if (!$adminuser = get_admin()) {
|
||||
error("Could not find site admin");
|
||||
}
|
||||
|
||||
$streditmyprofile = get_string("editmyprofile");
|
||||
$stradministration = get_string("administration");
|
||||
$strfile = get_string("file");
|
||||
$struser = get_string("user");
|
||||
$strusers = get_string("users");
|
||||
$strusersnew = get_string("usersnew");
|
||||
$strusersupdated = get_string("usersupdated");
|
||||
$struploadusers = get_string("uploadusers");
|
||||
$straddnewuser = get_string("importuser");
|
||||
|
||||
$csv_encode = '/\&\#44/';
|
||||
if (isset($CFG->CSV_DELIMITER)) {
|
||||
$csv_delimiter = '\\' . $CFG->CSV_DELIMITER;
|
||||
$csv_delimiter2 = $CFG->CSV_DELIMITER;
|
||||
|
||||
if (isset($CFG->CSV_ENCODE)) {
|
||||
$csv_encode = '/\&\#' . $CFG->CSV_ENCODE . '/';
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to edit users this way.");
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Could not find site-level course");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$adminuser = get_admin()) {
|
||||
error("Could not find site admin");
|
||||
}
|
||||
|
||||
$streditmyprofile = get_string("editmyprofile");
|
||||
$stradministration = get_string("administration");
|
||||
$strchoose = get_string("choose");
|
||||
$struser = get_string("user");
|
||||
$strusers = get_string("users");
|
||||
$strusersnew = get_string("usersnew");
|
||||
$struploadusers = get_string("uploadusers");
|
||||
$straddnewuser = get_string("importuser");
|
||||
|
||||
$csv_encode = '/\&\#44/';
|
||||
if (isset($CFG->CSV_DELIMITER)) {
|
||||
$csv_delimiter = '\\' . $CFG->CSV_DELIMITER;
|
||||
$csv_delimiter2 = $CFG->CSV_DELIMITER;
|
||||
|
||||
if (isset($CFG->CSV_ENCODE)) {
|
||||
$csv_encode = '/\&\#' . $CFG->CSV_ENCODE . '/';
|
||||
}
|
||||
} else {
|
||||
$csv_delimiter = "\,";
|
||||
$csv_delimiter2 = ",";
|
||||
}
|
||||
} else {
|
||||
$csv_delimiter = "\,";
|
||||
$csv_delimiter2 = ",";
|
||||
}
|
||||
|
||||
/// Print the header
|
||||
|
||||
print_header("$site->shortname: $struploadusers", $site->fullname,
|
||||
"<a href=\"index.php\">$stradministration</a> ->
|
||||
<a href=\"users.php\">$strusers</a> -> $struploadusers");
|
||||
print_header("$site->shortname: $struploadusers", $site->fullname,
|
||||
"<a href=\"index.php\">$stradministration</a> ->
|
||||
<a href=\"users.php\">$strusers</a> -> $struploadusers");
|
||||
|
||||
|
||||
/// If a file has been uploaded, then process it
|
||||
|
||||
if ($filename = valid_uploaded_file($_FILES['userfile'])) {
|
||||
|
||||
$um = new upload_manager('userfile',false,false,null,false,0);
|
||||
//Fix mac/dos newlines
|
||||
$text = my_file_get_contents($filename);
|
||||
$text = preg_replace('!\r\n?!',"\n",$text);
|
||||
$fp = fopen($filename, "w");
|
||||
fwrite($fp,$text);
|
||||
fclose($fp);
|
||||
|
||||
if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
$filename = $um->files['userfile']['tmp_name'];
|
||||
$fp = fopen($filename, "r");
|
||||
|
||||
// Large files are likely to take their time and memory. Let PHP know
|
||||
// that we'll take longer, and that the process should be recycled soon
|
||||
// to free up memory.
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("128M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
@apache_child_terminate();
|
||||
// make arrays of valid fields for error checking
|
||||
$required = array("username" => 1,
|
||||
"password" => 1,
|
||||
"firstname" => 1,
|
||||
"lastname" => 1,
|
||||
"email" => 1);
|
||||
$optionalDefaults = array("institution" => 1,
|
||||
"department" => 1,
|
||||
"city" => 1,
|
||||
"country" => 1,
|
||||
"lang" => 1,
|
||||
"timezone" => 1);
|
||||
$optional = array("idnumber" => 1,
|
||||
"icq" => 1,
|
||||
"phone1" => 1,
|
||||
"phone2" => 1,
|
||||
"address" => 1,
|
||||
"url" => 1,
|
||||
"description" => 1,
|
||||
"mailformat" => 1,
|
||||
"maildisplay" => 1,
|
||||
"htmleditor" => 1,
|
||||
"autosubscribe" => 1,
|
||||
"idnumber" => 1,
|
||||
"icq" => 1,
|
||||
"course1" => 1,
|
||||
"course2" => 1,
|
||||
"course3" => 1,
|
||||
"course4" => 1,
|
||||
"course5" => 1,
|
||||
"group1" => 1,
|
||||
"group2" => 1,
|
||||
"group3" => 1,
|
||||
"group4" => 1,
|
||||
"group5" =>1);
|
||||
|
||||
// --- get header (field names) ---
|
||||
$header = split($csv_delimiter, fgets($fp,1024));
|
||||
// check for valid field names
|
||||
foreach ($header as $i => $h) {
|
||||
$h = trim($h); $header[$i] = $h; // remove whitespace
|
||||
if (!($required[$h] or $optionalDefaults[$h] or $optional[$h])) {
|
||||
error(get_string('invalidfieldname', 'error', $h), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
if ($required[$h]) {
|
||||
$required[$h] = 2;
|
||||
}
|
||||
}
|
||||
// check for required fields
|
||||
foreach ($required as $key => $value) {
|
||||
if ($value < 2) {
|
||||
error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
}
|
||||
$linenum = 2; // since header is line 1
|
||||
|
||||
while (!feof ($fp)) {
|
||||
foreach ($optionalDefaults as $key => $value) {
|
||||
$user->$key = addslashes($adminuser->$key);
|
||||
}
|
||||
//Note: commas within a field should be encoded as , (for comma separated csv files)
|
||||
//Note: semicolon within a field should be encoded as ; (for semicolon separated csv files)
|
||||
$line = split($csv_delimiter, fgets($fp,1024));
|
||||
foreach ($line as $key => $value) {
|
||||
//decode encoded commas
|
||||
$record[$header[$key]] = preg_replace($csv_encode,$csv_delimiter2,trim($value));
|
||||
}
|
||||
if ($record[$header[0]]) {
|
||||
// add a new user to the database
|
||||
optional_variable($newuser, "");
|
||||
|
||||
// add fields to object $user
|
||||
foreach ($record as $name => $value) {
|
||||
// check for required values
|
||||
if ($required[$name] and !$value) {
|
||||
error(get_string('missingfield', 'error', $name). " ".
|
||||
get_string('erroronline', 'error', $linenum) .". ".
|
||||
get_string('processingstops', 'error'),
|
||||
'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
// password needs to be encrypted
|
||||
else if ($name == "password") {
|
||||
$user->password = md5($value);
|
||||
}
|
||||
else if ($name == "username") {
|
||||
$user->username = addslashes(moodle_strtolower($value));
|
||||
}
|
||||
// normal entry
|
||||
else {
|
||||
$user->{$name} = addslashes($value);
|
||||
}
|
||||
}
|
||||
$user->auth = 'manual';
|
||||
$user->confirmed = 1;
|
||||
$user->timemodified = time();
|
||||
$linenum++;
|
||||
$username = $user->username;
|
||||
$addcourse[0] = $user->course1;
|
||||
$addcourse[1] = $user->course2;
|
||||
$addcourse[2] = $user->course3;
|
||||
$addcourse[3] = $user->course4;
|
||||
$addcourse[4] = $user->course5;
|
||||
$addgroup[0] = $user->group1;
|
||||
$addgroup[1] = $user->group2;
|
||||
$addgroup[2] = $user->group3;
|
||||
$addgroup[3] = $user->group4;
|
||||
$addgroup[4] = $user->group5;
|
||||
$courses = get_courses("all",'c.sortorder','c.id,c.shortname,c.fullname,c.sortorder');
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$courseid[$i]=0;
|
||||
}
|
||||
foreach ($courses as $course) {
|
||||
for ($i=0; $i<5; $i++) {
|
||||
if ($course->shortname == $addcourse[$i]) {
|
||||
$courseid[$i] = $course->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (get_record("user","username",$username) || !($user->id = insert_record("user", $user))) {
|
||||
if (!$user = get_record("user", "username", "changeme")) { // half finished user from another time
|
||||
//Record not added - probably because user is already registered
|
||||
//In this case, output userid from previous registration
|
||||
//This can be used to obtain a list of userids for existing users
|
||||
if ($user = get_record("user","username",$username)) {
|
||||
notify("$user->id ".get_string('usernotaddedregistered', 'error', $username));
|
||||
} else {
|
||||
notify(get_string('usernotaddederror', 'error', $username));
|
||||
}
|
||||
}
|
||||
} else if ($user->username != "changeme") {
|
||||
notify("$struser: $user->id = $user->username");
|
||||
$numusers++;
|
||||
}
|
||||
for ($i=0; $i<5; $i++) {
|
||||
if ($addcourse[$i] && !$courseid[$i]) {
|
||||
notify(get_string('unknowncourse', 'error', $addcourse[$i]));
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$groupid[$i] = 0;
|
||||
if ($addgroup[$i]) {
|
||||
if (!$courseid[$i]) {
|
||||
notify(get_string('coursegroupunknown','error',$addgroup[$i]));
|
||||
} else {
|
||||
if ($group = get_record("groups","courseid",$courseid[$i],"name",$addgroup[$i])) {
|
||||
$groupid[$i] = $group->id;
|
||||
} else {
|
||||
notify(get_string('groupunknown','error',$addgroup[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) {
|
||||
if ($courseid[$i]) {
|
||||
if (enrol_student($user->id, $courseid[$i])) {
|
||||
notify('-->'. get_string('enrolledincourse', '', $addcourse[$i]));
|
||||
} else {
|
||||
notify('-->'.get_string('enrolledincoursenot', '', $addcourse[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) {
|
||||
if ($courseid[$i] && $groupid[$i]) {
|
||||
if (record_exists("user_students","userid",$user->id,"course",$courseid[$i])) {
|
||||
$usergroup = user_group($courseid[$i],$user->id);
|
||||
if ($usergroup) {
|
||||
notify('-->' . get_string('groupalready','error',$usergroup->name));
|
||||
} else {
|
||||
$group_member->groupid = $groupid[$i];
|
||||
$group_member->userid = $user->id;
|
||||
$group_member->timeadded = time();
|
||||
if (insert_record("groups_members",$group_member)) {
|
||||
notify('-->' . get_string('addedtogroup','',$addgroup[$i]));
|
||||
} else {
|
||||
notify('-->' . get_string('addedtogroupnot','',$addgroup[$i]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notify('-->' . get_string('addedtogroupnotenrolled','',$addgroup[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset ($user);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
notify("$strusersnew: $numusers");
|
||||
|
||||
echo '<hr />';
|
||||
}
|
||||
|
||||
//Fix mac/dos newlines
|
||||
$text = my_file_get_contents($filename);
|
||||
$text = preg_replace('!\r\n?!',"\n",$text);
|
||||
$fp = fopen($filename, "w");
|
||||
fwrite($fp,$text);
|
||||
fclose($fp);
|
||||
|
||||
$fp = fopen($filename, "r");
|
||||
|
||||
// make arrays of valid fields for error checking
|
||||
$required = array("username" => 1,
|
||||
"password" => !$createpassword,
|
||||
"firstname" => 1,
|
||||
"lastname" => 1,
|
||||
"email" => 1);
|
||||
$optionalDefaults = array("institution" => 1,
|
||||
"department" => 1,
|
||||
"city" => 1,
|
||||
"country" => 1,
|
||||
"lang" => 1,
|
||||
"auth" => 1,
|
||||
"timezone" => 1);
|
||||
$optional = array("idnumber" => 1,
|
||||
"icq" => 1,
|
||||
"phone1" => 1,
|
||||
"phone2" => 1,
|
||||
"address" => 1,
|
||||
"url" => 1,
|
||||
"description" => 1,
|
||||
"mailformat" => 1,
|
||||
"maildisplay" => 1,
|
||||
"htmleditor" => 1,
|
||||
"autosubscribe" => 1,
|
||||
"idnumber" => 1,
|
||||
"icq" => 1,
|
||||
"course1" => 1,
|
||||
"course2" => 1,
|
||||
"course3" => 1,
|
||||
"course4" => 1,
|
||||
"course5" => 1,
|
||||
"group1" => 1,
|
||||
"group2" => 1,
|
||||
"group3" => 1,
|
||||
"group4" => 1,
|
||||
"group5" => 1,
|
||||
"type1" => 1,
|
||||
"type2" => 1,
|
||||
"type3" => 1,
|
||||
"type4" => 1,
|
||||
"type5" => 1,
|
||||
"password" => $createpassword,
|
||||
"oldusername" => $allowrenames);
|
||||
|
||||
// --- get header (field names) ---
|
||||
$header = split($csv_delimiter, fgets($fp,1024));
|
||||
// check for valid field names
|
||||
foreach ($header as $i => $h) {
|
||||
$h = trim($h); $header[$i] = $h; // remove whitespace
|
||||
if (!($required[$h] or $optionalDefaults[$h] or $optional[$h])) {
|
||||
error(get_string('invalidfieldname', 'error', $h), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
if ($required[$h]) {
|
||||
$required[$h] = 0;
|
||||
}
|
||||
}
|
||||
// check for required fields
|
||||
foreach ($required as $key => $value) {
|
||||
if ($value) { //required field missing
|
||||
error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
}
|
||||
$linenum = 2; // since header is line 1
|
||||
|
||||
$usersnew = 0;
|
||||
$usersupdated = 0;
|
||||
$userserrors = 0;
|
||||
$renames = 0;
|
||||
$renameerrors = 0;
|
||||
|
||||
// Will use this course array a lot
|
||||
// so fetch it early and keep it in memory
|
||||
$courses = get_courses('all','c.sortorder','c.id,c.shortname,c.fullname,c.sortorder,c.teacher');
|
||||
|
||||
while (!feof ($fp)) {
|
||||
foreach ($optionalDefaults as $key => $value) {
|
||||
$user->$key = addslashes($adminuser->$key);
|
||||
}
|
||||
//Note: commas within a field should be encoded as , (for comma separated csv files)
|
||||
//Note: semicolon within a field should be encoded as ; (for semicolon separated csv files)
|
||||
$line = split($csv_delimiter, fgets($fp,1024));
|
||||
foreach ($line as $key => $value) {
|
||||
//decode encoded commas
|
||||
$record[$header[$key]] = preg_replace($csv_encode,$csv_delimiter2,trim($value));
|
||||
}
|
||||
if ($record[$header[0]]) {
|
||||
// add a new user to the database
|
||||
|
||||
// add fields to object $user
|
||||
foreach ($record as $name => $value) {
|
||||
// check for required values
|
||||
if ($required[$name] and !$value) {
|
||||
error(get_string('missingfield', 'error', $name). " ".
|
||||
get_string('erroronline', 'error', $linenum) .". ".
|
||||
get_string('processingstops', 'error'),
|
||||
'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
// password needs to be encrypted
|
||||
else if ($name == "password" && !empty($value)) {
|
||||
$user->password = hash_internal_user_password($value);
|
||||
}
|
||||
else if ($name == "username") {
|
||||
$user->username = addslashes(moodle_strtolower($value));
|
||||
}
|
||||
// normal entry
|
||||
else {
|
||||
$user->{$name} = addslashes($value);
|
||||
}
|
||||
}
|
||||
$user->confirmed = 1;
|
||||
$user->timemodified = time();
|
||||
$linenum++;
|
||||
$username = $user->username;
|
||||
$addcourse[0] = $user->course1;
|
||||
$addcourse[1] = $user->course2;
|
||||
$addcourse[2] = $user->course3;
|
||||
$addcourse[3] = $user->course4;
|
||||
$addcourse[4] = $user->course5;
|
||||
$addgroup[0] = $user->group1;
|
||||
$addgroup[1] = $user->group2;
|
||||
$addgroup[2] = $user->group3;
|
||||
$addgroup[3] = $user->group4;
|
||||
$addgroup[4] = $user->group5;
|
||||
$addtype[0] = $user->type1;
|
||||
$addtype[1] = $user->type2;
|
||||
$addtype[2] = $user->type3;
|
||||
$addtype[3] = $user->type4;
|
||||
$addtype[4] = $user->type5;
|
||||
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$course[$i]=NULL;
|
||||
}
|
||||
foreach ($courses as $eachcourse) {
|
||||
for ($i=0; $i<5; $i++) {
|
||||
if ($eachcourse->shortname == $addcourse[$i]) {
|
||||
$course[$i] = $eachcourse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
if (set_field('user', 'username', $user->username, 'username', $user->oldusername)) {
|
||||
notify(get_string('userrenamed', 'admin') . " : $user->oldusername $user->username");
|
||||
$renames++;
|
||||
} else {
|
||||
notify(get_string('usernotrenamedexists', 'error') . " : $user->oldusername $user->username");
|
||||
$renameerrors++;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
notify(get_string('usernotrenamedmissing', 'error') . " : $user->oldusername $user->username");
|
||||
$renameerrors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($olduser = get_record("user","username",$username)) {
|
||||
if ($updateaccounts) {
|
||||
// Record is being updated
|
||||
$user->id = $olduser->id;
|
||||
if (update_record('user', $user)) {
|
||||
notify("$user->id , $user->username ".get_string('useraccountupdated', 'admin'));
|
||||
$usersupdated++;
|
||||
} else {
|
||||
notify(get_string('usernotupdatederror', 'error', $username));
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
//Record not added - user is already registered
|
||||
//In this case, output userid from previous registration
|
||||
//This can be used to obtain a list of userids for existing users
|
||||
notify("$user->id ".get_string('usernotaddedregistered', 'error', $username));
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else { // new user
|
||||
if ($user->id = insert_record("user", $user)) {
|
||||
notify("$struser: $user->id = $user->username");
|
||||
$usersnew++;
|
||||
if (empty($user->password) && $createpassword) {
|
||||
// passwords will be created and sent out on cron
|
||||
insert_record('user_preferences', array( userid => $user->id,
|
||||
name => 'create_password',
|
||||
value => 1));
|
||||
insert_record('user_preferences', array( userid => $user->id,
|
||||
name => 'auth_forcepasswordchange',
|
||||
value => 1));
|
||||
}
|
||||
} else {
|
||||
// Record not added -- possibly some other error
|
||||
notify(get_string('usernotaddederror', 'error', $username));
|
||||
$userserrors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) {
|
||||
if ($addcourse[$i] && !$course[$i]) {
|
||||
notify(get_string('unknowncourse', 'error', $addcourse[$i]));
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$groupid[$i] = 0;
|
||||
if ($addgroup[$i]) {
|
||||
if (!$course[$i]) {
|
||||
notify(get_string('coursegroupunknown','error',$addgroup[$i]));
|
||||
} else {
|
||||
if ($group = get_record("groups","courseid",$course[$i]->id,"name",$addgroup[$i])) {
|
||||
$groupid[$i] = $group->id;
|
||||
} else {
|
||||
notify(get_string('groupunknown','error',$addgroup[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) { /// Enrol into courses if necessary
|
||||
if ($course[$i]) {
|
||||
if (isset($addtype[$i])) {
|
||||
switch ($addtype[$i]) {
|
||||
case 2: // teacher
|
||||
$ret = add_teacher($user->id, $course[$i]->id, 1);
|
||||
break;
|
||||
|
||||
case 3: // non-editing teacher
|
||||
$ret = add_teacher($user->id, $course[$i]->id, 0);
|
||||
break;
|
||||
|
||||
default: // student
|
||||
$ret = enrol_student($user->id, $course[$i]->id);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$ret = enrol_student($user->id, $course[$i]->id);
|
||||
}
|
||||
if ($ret) { // OK
|
||||
notify('-->'. get_string('enrolledincourse', '', $addcourse[$i]));
|
||||
} else {
|
||||
notify('-->'.get_string('enrolledincoursenot', '', $addcourse[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($i=0; $i<5; $i++) { // Add user to groups if necessary
|
||||
if ($course[$i] && $groupid[$i]) {
|
||||
if (record_exists('user_students','userid',$user->id,'course',$course[$i]->id) ||
|
||||
record_exists('user_teachers','userid',$user->id,'course',$course[$i]->id)) {
|
||||
if (add_user_to_group($groupid[$i], $user->id)) {
|
||||
notify('-->' . get_string('addedtogroup','',$addgroup[$i]));
|
||||
} else {
|
||||
notify('-->' . get_string('addedtogroupnot','',$addgroup[$i]));
|
||||
}
|
||||
} else {
|
||||
notify('-->' . get_string('addedtogroupnotenrolled','',$addgroup[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset ($user);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
notify("$strusersnew: $usersnew");
|
||||
notify(get_string('usersupdated', 'admin') . ": $usersupdated");
|
||||
notify(get_string('errors', 'admin') . ": $userserrors");
|
||||
if ($allowrenames) {
|
||||
notify(get_string('usersrenamed', 'admin') . ": $renames");
|
||||
notify(get_string('renameerrors', 'admin') . ": $renameerrors");
|
||||
}
|
||||
echo '<hr />';
|
||||
}
|
||||
|
||||
/// Print the form
|
||||
print_heading_with_help($struploadusers, 'uploadusers');
|
||||
print_heading_with_help($struploadusers, 'uploadusers');
|
||||
|
||||
$noyesoptions = array( get_string('no'), get_string('yes') );
|
||||
$maxuploadsize = get_max_upload_file_size();
|
||||
echo '<center>';
|
||||
echo '<form method="post" enctype="multipart/form-data" action="uploaduser.php">'.
|
||||
$strchoose.':<input type="hidden" name="MAX_FILE_SIZE" value="'.$maxuploadsize.'">'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'">'.
|
||||
'<input type="file" name="userfile" size=30>'.
|
||||
'<input type="submit" value="'.$struploadusers.'">'.
|
||||
'</form></br>';
|
||||
echo '</center>';
|
||||
|
||||
$maxuploadsize = get_max_upload_file_size();
|
||||
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>';
|
||||
echo '<tr><td>' . get_string('passwordhandling', 'auth') . '</td><td>';
|
||||
$passwordopts = array( 0 => get_string('infilefield', 'auth'),
|
||||
1 => get_string('createpasswordifneeded', 'auth'),
|
||||
);
|
||||
choose_from_menu($passwordopts, 'createpassword', $createpassword);
|
||||
echo '</td></tr>';
|
||||
|
||||
echo '<tr><td>' . get_string('updateaccounts', 'admin') . '</td><td>';
|
||||
choose_from_menu($noyesoptions, 'updateaccounts', $updateaccounts);
|
||||
echo '</td></tr>';
|
||||
|
||||
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 '</form><br />';
|
||||
echo '</center>';
|
||||
|
||||
print_footer($course);
|
||||
print_footer($course);
|
||||
|
||||
|
||||
|
||||
function my_file_get_contents($filename, $use_include_path = 0) {
|
||||
/// Returns the file as one big long string
|
||||
/// Returns the file as one big long string
|
||||
|
||||
$data = "";
|
||||
$file = @fopen($filename, "rb", $use_include_path);
|
||||
|
||||
+81
-78
@@ -1,35 +1,38 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.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);
|
||||
$sort = optional_param('sort', 'name', PARAM_ALPHA);
|
||||
$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$perpage = optional_param('perpage', 30, PARAM_INT); // how many per page
|
||||
$search = 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
|
||||
optional_variable($newuser, "");
|
||||
optional_variable($delete, "");
|
||||
optional_variable($confirm, "");
|
||||
optional_variable($confirmuser, "");
|
||||
optional_variable($sort, "name");
|
||||
optional_variable($dir, "ASC");
|
||||
optional_variable($page, 0);
|
||||
optional_variable($search, "");
|
||||
if (!empty($search)) {
|
||||
$search=trim($search);
|
||||
}
|
||||
optional_variable($lastinitial, ""); // only show students with this last initial
|
||||
optional_variable($firstinitial, ""); // only show students with this first initial
|
||||
optional_variable($perpage, "30"); // how many per page
|
||||
|
||||
unset($user);
|
||||
unset($admin);
|
||||
unset($teacher);
|
||||
|
||||
$search = trim($search);
|
||||
|
||||
$user = new object();
|
||||
$admin = new object();
|
||||
$teacher = new object();
|
||||
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
|
||||
$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->firstname = get_string("admin");
|
||||
$user->lastname = get_string("user");
|
||||
$user->username = "admin";
|
||||
$user->password = md5("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)) {
|
||||
@@ -59,14 +62,13 @@
|
||||
|
||||
$USER = $user;
|
||||
$USER->loggedin = true;
|
||||
$USER->sessionIP = md5(getremoteaddr()); // Store the current IP in the session
|
||||
$USER->site = $CFG->wwwroot;
|
||||
$USER->admin = true;
|
||||
$USER->teacher["$site->id"] = true;
|
||||
$USER->newadminuser = true;
|
||||
sesskey(); // for added security, used to check script parameters
|
||||
set_user_sesskey(); // for added security, used to check script parameters
|
||||
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
exit;
|
||||
|
||||
} else {
|
||||
@@ -82,14 +84,14 @@
|
||||
}
|
||||
|
||||
if ($newuser and confirm_sesskey()) { // Create a new user
|
||||
$user->auth = "manual";
|
||||
$user->firstname = "";
|
||||
$user->lastname = "";
|
||||
$user->username = "changeme";
|
||||
$user->password = "";
|
||||
$user->email = "";
|
||||
$user->lang = $CFG->lang;
|
||||
$user->confirmed = 1;
|
||||
$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 (! $user->id = insert_record("user", $user)) {
|
||||
@@ -98,8 +100,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
|
||||
} else { // List all users for editing
|
||||
|
||||
$stredituser = get_string("edituser");
|
||||
@@ -112,12 +114,12 @@
|
||||
$strshowallusers = get_string("showallusers");
|
||||
|
||||
if ($firstinitial or $lastinitial or $search or $page) {
|
||||
print_header("$site->shortname: $stredituser", $site->fullname,
|
||||
print_header("$site->shortname: $stredituser", $site->fullname,
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"users.php\">$strusers</a> -> ".
|
||||
"<a href=\"user.php\">$stredituser</a>");
|
||||
} else {
|
||||
print_header("$site->shortname: $stredituser", $site->fullname,
|
||||
print_header("$site->shortname: $stredituser", $site->fullname,
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"users.php\">$strusers</a> -> $stredituser");
|
||||
}
|
||||
@@ -127,7 +129,7 @@
|
||||
error("No such user!");
|
||||
}
|
||||
|
||||
$confirmeduser = new object();
|
||||
unset($confirmeduser);
|
||||
$confirmeduser->id = $confirmuser;
|
||||
$confirmeduser->confirmed = 1;
|
||||
$confirmeduser->timemodified = time();
|
||||
@@ -151,16 +153,15 @@
|
||||
if ($confirm != md5($delete)) {
|
||||
$fullname = fullname($user, true);
|
||||
notice_yesno(get_string("deletecheckfull", "", "'$fullname'"),
|
||||
"user.php?delete=$delete&confirm=".md5($delete)."&sesskey=$USER->sesskey", "user.php");
|
||||
"user.php?delete=$delete&confirm=".md5($delete)."&sesskey=$USER->sesskey", "user.php");
|
||||
|
||||
exit;
|
||||
} else if (!$user->deleted) {
|
||||
$updateuser = new object();
|
||||
unset($updateuser);
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = "1";
|
||||
$updateuser->username = "$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)) {
|
||||
unenrol_student($user->id); // From all courses
|
||||
@@ -193,10 +194,10 @@
|
||||
} else {
|
||||
$columnicon = $dir == "ASC" ? "down":"up";
|
||||
}
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\" />";
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" />";
|
||||
|
||||
}
|
||||
$$column = "<a href=\"user.php?sort=$column&dir=$columndir&search=".urlencode(stripslashes($search))."&firstinitial=$firstinitial&lastinitial=$lastinitial\">".$string[$column]."</a>$columnicon";
|
||||
$$column = "<a href=\"user.php?sort=$column&dir=$columndir&search=$search&firstinitial=$firstinitial&lastinitial=$lastinitial\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
|
||||
if ($sort == "name") {
|
||||
@@ -223,8 +224,8 @@
|
||||
echo "<center><p align=\"center\">";
|
||||
echo get_string("firstname")." : ";
|
||||
if ($firstinitial) {
|
||||
echo " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial\">$strall</a> ";
|
||||
echo " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
@@ -232,8 +233,8 @@
|
||||
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 " <a href=\"user.php?sort=firstname&dir=ASC&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter</a> ";
|
||||
}
|
||||
}
|
||||
echo "<br />";
|
||||
@@ -242,8 +243,8 @@
|
||||
|
||||
echo get_string("lastname")." : ";
|
||||
if ($lastinitial) {
|
||||
echo " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial\">$strall</a> ";
|
||||
echo " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
@@ -251,23 +252,23 @@
|
||||
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 " <a href=\"user.php?sort=lastname&dir=ASC&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter</a> ";
|
||||
}
|
||||
}
|
||||
echo "</p>";
|
||||
echo "</center>";
|
||||
|
||||
print_paging_bar($usercount, $page, $perpage,
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&search=$search&");
|
||||
|
||||
flush();
|
||||
|
||||
|
||||
if (!$users) {
|
||||
$match = array();
|
||||
if ($search !== '') {
|
||||
$match[] = s($search);
|
||||
if ($search) {
|
||||
$match[] = $search;
|
||||
}
|
||||
if ($firstinitial) {
|
||||
$match[] = get_string("firstname").": $firstinitial"."___";
|
||||
@@ -278,8 +279,6 @@
|
||||
$matchstring = implode(", ", $match);
|
||||
print_heading(get_string("nousersmatching", "", $matchstring));
|
||||
|
||||
$table = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
$countries = get_list_of_countries();
|
||||
@@ -307,7 +306,7 @@
|
||||
if ($user->id == $USER->id or $user->username == "changeme") {
|
||||
$deletebutton = "";
|
||||
} else {
|
||||
$deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
$deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
}
|
||||
if ($user->lastaccess) {
|
||||
$strlastaccess = format_time(time() - $user->lastaccess);
|
||||
@@ -315,41 +314,45 @@
|
||||
$strlastaccess = get_string("never");
|
||||
}
|
||||
if ($user->confirmed == 0) {
|
||||
$confirmbutton = "<a href=\"user.php?confirmuser=$user->id&sesskey=$USER->sesskey\">" . get_string("confirm") . "</a>";
|
||||
$confirmbutton = "<a href=\"user.php?confirmuser=$user->id&sesskey=$USER->sesskey\">" . get_string("confirm") . "</a>";
|
||||
} else {
|
||||
$confirmbutton = "";
|
||||
}
|
||||
$fullname = fullname($user, true);
|
||||
$table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
|
||||
$table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
|
||||
"$user->email",
|
||||
"$user->city",
|
||||
"$user->country",
|
||||
$strlastaccess,
|
||||
"<a href=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</a>",
|
||||
"<a href=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</a>",
|
||||
$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>";
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
|
||||
echo "<table align=center cellpadding=10><tr><td>";
|
||||
echo "<form action=user.php method=post>";
|
||||
echo "<input type=text name=search value=\"$search\" 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 (is_internal_auth()){
|
||||
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))."&");
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
|
||||
"user.php?sort=$sort&dir=$dir&perpage=$perpage".
|
||||
"&firstinitial=$firstinitial&lastinitial=$lastinitial&search=$search&");
|
||||
|
||||
}
|
||||
|
||||
if (is_internal_auth()){
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
|
||||
}
|
||||
|
||||
print_footer();
|
||||
}
|
||||
|
||||
+10
-8
@@ -1,6 +1,6 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -27,17 +27,19 @@
|
||||
|
||||
$table->data[] = array("<b><a href=\"user.php\">".get_string("edituser")."</a></b>",
|
||||
get_string("adminhelpedituser"));
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a></b>",
|
||||
if (is_internal_auth()) {
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a></b>",
|
||||
get_string("adminhelpaddnewuser"));
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".get_string("uploadusers")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".get_string("uploadusers")."</a></b>",
|
||||
get_string("adminhelpuploadusers"));
|
||||
}
|
||||
$table->data[] = array('', '<hr />');
|
||||
$table->data[] = array("<b><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolmentplugins")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a></b>",
|
||||
get_string("adminhelpenrolments"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a></b>",
|
||||
get_string("adminhelpassignstudents"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a></b>",
|
||||
get_string("adminhelpassignteachers")." <img src=\"../pix/t/user.gif\" height=\"11\" width=\"11\" alt=\"\" />");
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a></b>",
|
||||
get_string("adminhelpassignteachers")." <img src=\"../pix/t/user.gif\" height=11 width=11>");
|
||||
$table->data[] = array("<b><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a></b>",
|
||||
get_string("adminhelpassigncreators"));
|
||||
$table->data[] = array("<b><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a></b>",
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?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>
|
||||
File diff suppressed because it is too large
Load Diff
-106
@@ -82,109 +82,3 @@ db - Uses an external database to check username/password
|
||||
- if correct, user is logged in
|
||||
- if the username doesn't already exist then
|
||||
a new Moodle account is created
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
Authentication API
|
||||
|
||||
This file describes Moodle interface functions to authentication modules.
|
||||
|
||||
Most of functions are from ldap-authentication module and are not implemented (yet?)
|
||||
on other modules. Please feel free to extend other modules to support same features
|
||||
or roll your own module.
|
||||
|
||||
Some of new function are still tested and are not documented here yet.
|
||||
|
||||
|
||||
|
||||
AUTHENTICATION
|
||||
Basic fuctions to authenticate users with external db
|
||||
|
||||
Mandatory:
|
||||
|
||||
auth_user_login ($username, $password)
|
||||
|
||||
Authenticate username, password with userdatabase.
|
||||
|
||||
Returns:
|
||||
true if the username and password work
|
||||
and false if they don't
|
||||
|
||||
Optional:
|
||||
|
||||
auth_get_userinfo($username)
|
||||
|
||||
Query other userinformation from database.
|
||||
|
||||
Returns:
|
||||
Userinformation in array ( name => value, ....
|
||||
or false in case of error
|
||||
|
||||
COURSE CREATING
|
||||
|
||||
auth_iscreator($username)
|
||||
|
||||
should user have rights to create courses
|
||||
|
||||
Returns:
|
||||
True if user have rights to crete cources otherwise false
|
||||
|
||||
|
||||
USER CREATION
|
||||
|
||||
Functions that enable usercreation, activation and deactivation
|
||||
from moodle to external database
|
||||
|
||||
|
||||
auth_user_exists ($username)
|
||||
|
||||
Checks if given username exist on external db
|
||||
|
||||
Returns:
|
||||
true if given usernname exist or false
|
||||
|
||||
auth_user_create ($userobject,$plainpass)
|
||||
|
||||
Creates new user to external db. User should be created
|
||||
in inactive stage until confirmed by email.
|
||||
|
||||
Returns:
|
||||
True on success otherwise false
|
||||
|
||||
|
||||
auth_user_activate ($username)
|
||||
|
||||
activate new user after email-address is confirmed
|
||||
|
||||
Returns:
|
||||
True on success otherwise false
|
||||
|
||||
|
||||
auth_user_disable ($username) {
|
||||
|
||||
deactivate user in external db.
|
||||
|
||||
Returns:
|
||||
True on success otherwise false
|
||||
|
||||
|
||||
|
||||
USER INFORMATION AND SYNCRONIZATION
|
||||
|
||||
auth_get_userlist ()
|
||||
|
||||
Get list of usernames in external db.
|
||||
|
||||
Returns:
|
||||
All usernames in array or false on error.
|
||||
|
||||
|
||||
auth_get_users($filter='*')
|
||||
|
||||
Get ALL USEROBJECTS FROM EXTERNAL DB.
|
||||
|
||||
Returns:
|
||||
Array of all users as objects from external db
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
CAS-module README
|
||||
|
||||
Please read comments from lib.php for auth/cas module
|
||||
The auth/cas module is using part of the /auth/ldap module. The /auth/ldap directory should exist.
|
||||
The auth/cas use the PHPCAS project from http://esup-phpcas.sourceforge.net
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/** auth_ldap_sync_users.php
|
||||
* Modified for cas Module
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* backend in those setups where the LDAP backend acts as 'master'.
|
||||
*
|
||||
* Recommended cron entry:
|
||||
* # 5 minutes past 4am
|
||||
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
|
||||
*
|
||||
* Notes:
|
||||
* - If you have a large number of users, you may want to raise the memory limits
|
||||
* by passing -d momory_limit=256M
|
||||
* - For debugging & better logging, you are encouraged to use in the command line:
|
||||
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
|
||||
*
|
||||
* Performance notes:
|
||||
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if(!empty($_SERVER['GATEWAY_INTERFACE'])){
|
||||
error_log("should not be called from apache!");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/auth/cas/lib.php'); //cas specific
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
$CFG->debug=10;
|
||||
auth_sync_users(1000, true );
|
||||
|
||||
?>
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
require_once('languages.php');
|
||||
// Initialize vars
|
||||
if (!isset ($config->cas_hostname)) {
|
||||
$config->cas_hostname = "";
|
||||
}
|
||||
if (!isset ($config->cas_port)) {
|
||||
$config->cas_port = "";
|
||||
}
|
||||
if (!isset ($config->cas_version)) {
|
||||
$config->cas_version = "";
|
||||
}
|
||||
if (!isset ($config->cas_baseuri)) {
|
||||
$config->cas_baseuri = "";
|
||||
}
|
||||
if (!isset ($config->cas_language)) {
|
||||
$config->cas_language = "";
|
||||
}
|
||||
if (!isset ($config->cas_use_cas)) {
|
||||
$config->cas_use_cas = "";
|
||||
}
|
||||
if (!isset ($config->cas_create_user)) {
|
||||
$config->cas_create_user = "0";
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("auth_cas_server_settings", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_enabled:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "cas_enabled", $config->cas_enabled, get_string("no"),"","");?>
|
||||
</td><td>
|
||||
<?php print_string("auth_cas_enabled","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_hostname:</td>
|
||||
<td>
|
||||
<input name="cas_hostname" type="text" size="30" value="<?php echo $config->cas_hostname?>" />
|
||||
<?php if (isset($err["cas_hostname"])) formerr($err["cas_hostname"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_cas_hostname","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_baseuri:</td>
|
||||
<td>
|
||||
<input name="cas_baseuri" type="text" size="30" value="<?php echo $config->cas_baseuri?>" />
|
||||
<?php if (isset($err["cas_baseuri"])) formerr($err["cas_baseuri"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_cas_baseuri","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_port:</td>
|
||||
<td>
|
||||
<input name="cas_port" type="text" size="30" value="<?php echo $config->cas_port?>" />
|
||||
<?php if (isset($err["cas_port"])) formerr($err["cas_port"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_cas_port","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_version:</td>
|
||||
<td>
|
||||
<input name="cas_version" type="text" size="30" value="<?php echo $config->cas_version?>" />
|
||||
<?php if (isset($err["cas_version"])) formerr($err["cas_version"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_cas_version","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_language:</td>
|
||||
<td>
|
||||
<?php choose_from_menu ($CASLANGUAGES, "cas_language", $config->cas_language, "");?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_cas_language","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">cas_create_user:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "cas_create_user", $config->cas_create_user, "");?>
|
||||
</td><td>
|
||||
<?php print_string("auth_cas_create_user","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
include($CFG->dirroot.'/auth/ldap/config.html');
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<table width="90%" border="0" cellspacing="10" cellpadding="5" align="center" style="font-size: small">
|
||||
<tr>
|
||||
<td width="50%" class="required" class="headingblock">
|
||||
<p align="center"><b><font size="3"><?php formerr($errormsg) ?></font></b></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
// version $Id$
|
||||
// Page for forbidden access from CAS
|
||||
require("../../config.php");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("No site found!");
|
||||
}
|
||||
|
||||
$loginsite = get_string("loginsite");
|
||||
$errormsg = get_string("auth_cas_invalidcaslogin", "auth");
|
||||
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite);
|
||||
include("forbidden.html");
|
||||
print_footer();
|
||||
exit;
|
||||
?>
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<table width="90%" border="0" cellspacing="10" cellpadding="5" align="center">
|
||||
<tr>
|
||||
<?php if ($show_instructions) { ?>
|
||||
<td width="50%" class="headingblock">
|
||||
<p align="center"><b><font size="3"><?php print_string("returningtosite") ?></font></b></p>
|
||||
</td>
|
||||
<td width="50%" class="headingblock">
|
||||
<p align="center"><b><font size="3"><?php print_string("firsttime") ?></font></b></p>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%" align="center" valign="top" class="generalbox">
|
||||
<p><?php print_string("loginusing") ?>:<br />
|
||||
(<?php print_string("cookiesenabled");?>)
|
||||
<?php helpbutton("cookies", get_string("cookiesenabled"))?><br /><?php formerr($errormsg) ?>
|
||||
</p>
|
||||
<form action="index.php" method="post" name="login" id="login">
|
||||
<table border="0" align="center" style="font-size: small">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<input type="hidden" name="username" value="cas" />
|
||||
<input type="hidden" name="password" value="cas" />
|
||||
<input type="submit" value="<?php print_string("auth_cas_logincas", "auth") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php if ($CFG->guestloginbutton) { ?>
|
||||
<hr width="80%" />
|
||||
<p><?php print_string("someallowguest") ?>:</p>
|
||||
<form action="index.php" method="post" name="guestlogin">
|
||||
<input type="hidden" name="username" value="guest" />
|
||||
<input type="hidden" name="password" value="guest" />
|
||||
<input type="submit" value="<?php print_string("loginguest") ?>" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (is_internal_auth() ) {
|
||||
$changepassword = "forgot_password.php";
|
||||
$changebuttonname = get_string("senddetails");
|
||||
?>
|
||||
<hr width="80%" />
|
||||
<p><?php print_string("forgotten") ?></p>
|
||||
<form action="<?php p($changepassword) ?>" method="get" name="changepassword">
|
||||
<input type="submit" value="<?php p($changebuttonname) ?>" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
|
||||
<?php if ($show_instructions) { ?>
|
||||
<td width="50%" valign="top" class="generalbox">
|
||||
<?php switch ($CFG->auth) {
|
||||
case "email":
|
||||
print_string("loginsteps", "", "signup.php");
|
||||
?>
|
||||
<div align="center">
|
||||
<form action="signup.php" method="get" name="signup">
|
||||
<input type="submit" value="<?php print_string("startsignup") ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php break;
|
||||
case "none":
|
||||
print_string("loginstepsnone");
|
||||
break;
|
||||
default:
|
||||
echo format_text($CFG->auth_instructions);
|
||||
if (!function_exists('auth_user_login')) {
|
||||
require_once("../auth/$CFG->auth/lib.php");
|
||||
}
|
||||
if (!empty($CFG->auth_user_create) and function_exists('auth_user_create') ){
|
||||
?>
|
||||
|
||||
<div align="center">
|
||||
<form action="signup.php" method="get" name="signup">
|
||||
<input type="submit" value="<?php print_string("startsignup") ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
</td></tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?PHP
|
||||
// version $Id$
|
||||
// List of CAS langages.
|
||||
// You can add langages in /CAS/langage.
|
||||
// Please send them to http://esup-phpcas.sourceforge.net
|
||||
$CASLANGUAGES = array (
|
||||
"greek" => "Modern Greek",
|
||||
"english" => "English",
|
||||
"french" => "French");
|
||||
?>
|
||||
@@ -1,171 +0,0 @@
|
||||
<?PHP
|
||||
// $Id$
|
||||
// author: romuald Lorthioir
|
||||
//CHANGELOG:
|
||||
//16/03/2005 Use of LDAP Module
|
||||
//05.02.2005 Added CAS module
|
||||
|
||||
/* README!
|
||||
CAS Module
|
||||
This Module can be turn ON/OFF on admin screen.
|
||||
The /login/index.php module is intercepted and replace with the login.php.
|
||||
This Module is using the /auth/cas/index_form.html.
|
||||
This module is using the LDAP Module so you need the /auth/ldap directory.
|
||||
You can see /auth/ldap/lib.php for the other functions.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
|
||||
define('AUTH_LDAP_NAME', 'cas'); // for ldap module
|
||||
require_once($CFG->dirroot.'/config.php');
|
||||
require_once($CFG->dirroot.'/auth/ldap/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/cas/CAS.php');
|
||||
$cas_validate=false;
|
||||
|
||||
/**
|
||||
* replace the ldap auth_user_login function
|
||||
* authenticates user againt CAS with ldap
|
||||
* Returns true if the username and password work
|
||||
* and false if they don't
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*
|
||||
*/
|
||||
function cas_ldap_auth_user_login ($username, $password) {
|
||||
/// Returns true if the username and password work
|
||||
/// and false if they don't
|
||||
|
||||
global $CFG;
|
||||
if (!$username or !$password) { // Don't allow blank usernames or passwords
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($CFG->auth == "cas" && !empty($CFG->cas_enabled)){ //cas specific
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (record_exists('user', 'username', $username)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$ldap_connection = auth_ldap_connect();
|
||||
|
||||
if ($ldap_connection) {
|
||||
$ldap_user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
//if ldap_user_dn is empty, user does not exist
|
||||
if(!$ldap_user_dn){
|
||||
ldap_close($ldap_connection);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to bind with current username and password
|
||||
$ldap_login = ldap_bind($ldap_connection, $ldap_user_dn, $password);
|
||||
ldap_close($ldap_connection);
|
||||
if ($ldap_login) {
|
||||
if ($CFG->cas_create_user=="0"){ //cas specific
|
||||
if (record_exists('user', 'username', $username)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ldap_close($ldap_connection);
|
||||
error("LDAP part of CAS-module cannot connect to server: $CFG->ldap_host_url");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* authenticates user against CAS from screen login
|
||||
* the user doesn't have a CAS Ticket yet.
|
||||
*
|
||||
* Returns an object user if the username and password work
|
||||
* and nothing if they don't
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*
|
||||
*/
|
||||
function cas_authenticate_user_login ($username, $password) {
|
||||
|
||||
global $CFG;
|
||||
// FIX ME: $cas_validate is not global
|
||||
$cas_validate=true;
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(int)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
phpCAS::setLang($CFG->cas_language);
|
||||
phpCAS::forceAuthentication();
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (record_exists('user', 'username', phpCAS::getUser())) {
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}else{
|
||||
//login as guest if CAS but not Moodle and not automatic creation
|
||||
if ($CFG->guestloginbutton){
|
||||
$user = authenticate_user_login('guest', 'guest');
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* authenticates user against CAS when first call of Moodle
|
||||
* if already in CAS (cookie with the CAS ticket), don't have to log again (SSO)
|
||||
*
|
||||
* Returns an object user if the username and password work
|
||||
* and nothing if they don't
|
||||
*
|
||||
* @param object $user
|
||||
*
|
||||
*/
|
||||
function cas_automatic_authenticate ($user="") {
|
||||
global $CFG;
|
||||
// FIX ME: $cas_validate is not global, but it works anyway ;-)
|
||||
if (!$cas_validate){
|
||||
$cas_validate=true;
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(int)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
phpCAS::setLang($CFG->cas_language);
|
||||
$cas_user_exist=phpCAS::checkAuthentication();
|
||||
if (!$cas_user_exist && !$CFG->guestloginbutton){
|
||||
$cas_user_exist=phpCAS::forceAuthentication();
|
||||
}
|
||||
if ($cas_user_exist){
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (record_exists('user', 'username', phpCAS::getUser())) {
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}else{
|
||||
//login as guest if CAS but not Moodle and not automatic creation
|
||||
if ($CFG->guestloginbutton){
|
||||
$user = authenticate_user_login('guest', 'guest');
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
return $user;
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
}else{
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,316 +0,0 @@
|
||||
<?php
|
||||
// $Id$
|
||||
// author: romualdLorthioir $
|
||||
//CHANGELOG:
|
||||
//05.03.2005 replace /login/index.php
|
||||
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
|
||||
//Define variables used in page
|
||||
if (!$site = get_site()) {
|
||||
error("No site found!");
|
||||
}
|
||||
|
||||
if (empty($CFG->langmenu)) {
|
||||
$langmenu = "";
|
||||
} else {
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http:','https:',$CFG->wwwroot);
|
||||
}
|
||||
$langmenu = popup_form ("$wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
|
||||
$loginsite = get_string("loginsite");
|
||||
|
||||
|
||||
$frm = false;
|
||||
$user = false;
|
||||
if ((!empty($SESSION->wantsurl) and strstr($SESSION->wantsurl,'username=guest')) or $loginguest) {
|
||||
/// Log in as guest automatically (idea from Zbigniew Fiedorowicz)
|
||||
$frm->username = 'guest';
|
||||
$frm->password = 'guest';
|
||||
} else if (!empty($SESSION->wantsurl) && file_exists($CFG->dirroot.'/login/weblinkauth.php')) {
|
||||
// Handles the case of another Moodle site linking into a page on this site
|
||||
include($CFG->dirroot.'/login/weblinkauth.php');
|
||||
if (function_exists(weblink_auth)) {
|
||||
$user = weblink_auth($SESSION->wantsurl);
|
||||
}
|
||||
if ($user) {
|
||||
$frm->username = $user->username;
|
||||
} else {
|
||||
$frm = data_submitted();
|
||||
}
|
||||
} else {
|
||||
$frm = data_submitted();
|
||||
}
|
||||
|
||||
if ($frm and (get_moodle_cookie() == '')) { // Login without cookie
|
||||
|
||||
$errormsg = get_string("cookiesnotenabled");
|
||||
|
||||
} else if ($frm) { // Login WITH cookies
|
||||
|
||||
$frm->username = trim(moodle_strtolower($frm->username));
|
||||
|
||||
if (($frm->username == 'guest') and empty($CFG->guestloginbutton)) {
|
||||
$user = false; /// Can't log in as guest if guest button is disabled
|
||||
$frm = false;
|
||||
} else if (!$user) {
|
||||
if ($CFG->auth == "cas" && $frm->username != 'guest'){ /// Cas SSO case
|
||||
require_once($CFG->dirroot.'/auth/cas/lib.php');
|
||||
$user = cas_authenticate_user_login($frm->username, $frm->password);
|
||||
}else{
|
||||
$user = authenticate_user_login($frm->username, $frm->password);
|
||||
}
|
||||
}
|
||||
update_login_count();
|
||||
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$USER = $user;
|
||||
if (!empty($USER->description)) {
|
||||
$USER->description = true; // No need to cart all of it around
|
||||
}
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
|
||||
sesskey(); // for added security, used to check script parameters
|
||||
|
||||
if ($USER->username == "guest") {
|
||||
$USER->lang = $CFG->lang; // Guest language always same as site
|
||||
$USER->firstname = get_string("guestuser"); // Name always in current language
|
||||
$USER->lastname = " ";
|
||||
}
|
||||
|
||||
if (!update_user_login_times()) {
|
||||
error("Wierd error: could not update login records");
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
// Restore the calendar filters, if saved
|
||||
if(intval(get_user_preferences('calendar_persistflt', 0))) {
|
||||
include_once($CFG->dirroot.'/calendar/lib.php');
|
||||
calendar_set_filters_status(get_user_preferences('calendar_savedflt', 0xff));
|
||||
}
|
||||
|
||||
//Select password change url
|
||||
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
}
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)){
|
||||
if (isset($passwordchangeurl)) {
|
||||
redirect($passwordchangeurl);
|
||||
} else {
|
||||
error("You cannot proceed without changing your password.
|
||||
However there is no available page for changing it.
|
||||
Please contact your Moodle Administrator.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.SITEID;
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
} else {
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
// check if user password has expired
|
||||
// Currently supported only for ldap-authentication module
|
||||
if (isset($CFG->ldap_expiration) && $CFG->ldap_expiration == 1 ) {
|
||||
if (function_exists('auth_password_expire')){
|
||||
$days2expire = auth_password_expire($USER->username);
|
||||
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
} elseif (intval($days2expire) < 0 ) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
|
||||
redirect($urltogo);
|
||||
|
||||
exit;
|
||||
|
||||
} else {
|
||||
if ($CFG->auth == "cas" ){ /// CAS error login
|
||||
require_once($CFG->dirroot.'/auth/cas/lib.php');
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
|
||||
}else{
|
||||
$errormsg = get_string("invalidlogin");
|
||||
}
|
||||
}
|
||||
}
|
||||
require_once($CFG->dirroot.'/auth/cas/lib.php');
|
||||
$user=cas_automatic_authenticate($user);
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$USER = $user;
|
||||
if (!empty($USER->description)) {
|
||||
$USER->description = true; // No need to cart all of it around
|
||||
}
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
|
||||
sesskey(); // for added security, used to check script parameters
|
||||
|
||||
if ($USER->username == "guest") {
|
||||
$USER->lang = $CFG->lang; // Guest language always same as site
|
||||
$USER->firstname = get_string("guestuser"); // Name always in current language
|
||||
$USER->lastname = " ";
|
||||
}
|
||||
|
||||
if (!update_user_login_times()) {
|
||||
error("Wierd error: could not update login records");
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
// Restore the calendar filters, if saved
|
||||
if(intval(get_user_preferences('calendar_persistflt', 0))) {
|
||||
include_once($CFG->dirroot.'/calendar/lib.php');
|
||||
calendar_set_filters_status(get_user_preferences('calendar_savedflt', 0xff));
|
||||
}
|
||||
|
||||
//Select password change url
|
||||
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
}
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)){
|
||||
if (isset($passwordchangeurl)) {
|
||||
redirect($passwordchangeurl);
|
||||
} else {
|
||||
error("You cannot proceed without changing your password.
|
||||
However there is no available page for changing it.
|
||||
Please contact your Moodle Administrator.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.SITEID;
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
} else {
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
// check if user password has expired
|
||||
// Currently supported only for ldap-authentication module
|
||||
if (isset($CFG->ldap_expiration) && $CFG->ldap_expiration == 1 ) {
|
||||
if (function_exists('auth_password_expire')){
|
||||
$days2expire = auth_password_expire($USER->username);
|
||||
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
} elseif (intval($days2expire) < 0 ) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
|
||||
redirect($urltogo);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
if(!$CFG->guestloginbutton){
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errormsg)) {
|
||||
$errormsg = "";
|
||||
}
|
||||
|
||||
if (empty($SESSION->wantsurl)) {
|
||||
$SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot;
|
||||
}
|
||||
|
||||
if (get_moodle_cookie() == '') {
|
||||
set_moodle_cookie('nobody'); // To help search for cookies
|
||||
}
|
||||
|
||||
if (empty($frm->username)) {
|
||||
$frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
|
||||
$frm->password = "";
|
||||
}
|
||||
|
||||
if (!empty($frm->username)) {
|
||||
$focus = "login.password";
|
||||
} else {
|
||||
$focus = "login.username";
|
||||
}
|
||||
|
||||
if ($CFG->auth == "email" or $CFG->auth == "none" or chop($CFG->auth_instructions) <> "" ) {
|
||||
$show_instructions = true;
|
||||
} else {
|
||||
$show_instructions = false;
|
||||
}
|
||||
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
include($CFG->dirroot.'/auth/cas/index_form.html');
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
|
||||
// No footer on this page
|
||||
|
||||
?>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
// $Id$
|
||||
// logout the user from CAS server (destroy the ticket)
|
||||
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
|
||||
global $CFG;
|
||||
if ($CFG->cas_logout){
|
||||
require_once($CFG->dirroot.'/config.php');
|
||||
include_once($CFG->dirroot.'/lib/cas/CAS.php');
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(int)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
$backurl = $CFG->wwwroot;
|
||||
phpCAS::logout($backurl);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/** auth_db_sync_users.php
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* backend in those setups where the LDAP backend acts as 'master'.
|
||||
*
|
||||
* Recommended cron entry:
|
||||
* # 5 minutes past 4am
|
||||
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/db/auth_db_sync_users.php
|
||||
*
|
||||
* Notes:
|
||||
* - If you have a large number of users, you may want to raise the memory limits
|
||||
* by passing -d memory_limit=256M
|
||||
* - For debugging & better logging, you are encouraged to use in the command line:
|
||||
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
|
||||
*
|
||||
* Performance notes:
|
||||
* + The code is simpler, but not as optimized as its LDAP counterpart.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if(!empty($_SERVER['GATEWAY_INTERFACE'])){
|
||||
error_log("should not be called from apache!");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/auth/db/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
$CFG->debug=10;
|
||||
auth_sync_users(true );
|
||||
|
||||
?>
|
||||
+169
-88
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?PHP
|
||||
if (!isset($config->auth_dbhost)) {
|
||||
$config->auth_dbhost = "localhost";
|
||||
}
|
||||
@@ -26,24 +26,21 @@
|
||||
if (!isset($config->auth_dbpasstype)) {
|
||||
$config->auth_dbpasstype = "plaintext";
|
||||
}
|
||||
|
||||
$pluginconfig = get_config('auth/db');
|
||||
?>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbhost:</td>
|
||||
<td>
|
||||
<input name="auth_dbhost" type="text" size="30" value="<?php echo $config->auth_dbhost?>" />
|
||||
<?php if (isset($err["auth_dbhost"])) formerr($err["auth_dbhost"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbhost:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_dbhost TYPE=text SIZE=30 VALUE="<?php echo $config->auth_dbhost?>">
|
||||
<?php if (isset($err["auth_dbhost"])) formerr($err["auth_dbhost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbhost","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbtype:</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbtype:</TD>
|
||||
<TD>
|
||||
<?php $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
|
||||
foreach ($dbtypes as $dbtype) {
|
||||
$dboptions[$dbtype] = $dbtype;
|
||||
@@ -51,104 +48,188 @@
|
||||
choose_from_menu($dboptions, "auth_dbtype", $config->auth_dbtype, "");
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbtype","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbname:</td>
|
||||
<td>
|
||||
<input name="auth_dbname" type="text" size="30" value="<?php echo $config->auth_dbname?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbname:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_dbname TYPE=text SIZE=30 VALUE="<?php echo $config->auth_dbname?>">
|
||||
<?php if (isset($err["auth_dbname"]))formerr($err["auth_dbname"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbname","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbuser:</td>
|
||||
<td>
|
||||
<input name="auth_dbuser" type="text" size="30" value="<?php echo $config->auth_dbuser?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbuser:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_dbuser TYPE=text SIZE=30 VALUE="<?php echo $config->auth_dbuser?>">
|
||||
<?php if (isset($err["auth_dbuser"])) formerr($err["auth_dbuser"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbuser","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbpass:</td>
|
||||
<td>
|
||||
<input name="auth_dbpass" type="text" size="30" value="<?php echo $config->auth_dbpass?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbpass:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbpass" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_dbpass?>">
|
||||
<?php if (isset($err["auth_dbpass"])) formerr($err["auth_dbpass"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbpass","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbtable:</td>
|
||||
<td>
|
||||
<input name="auth_dbtable" type="text" size="30" value="<?php echo $config->auth_dbtable?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbtable:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbtable" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_dbtable?>">
|
||||
<?php if (isset($err["auth_dbtable"])) formerr($err["auth_dbtable"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbtable","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbfielduser:</td>
|
||||
<td>
|
||||
<input name="auth_dbfielduser" type="text" size="30" value="<?php echo $config->auth_dbfielduser?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbfielduser:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbfielduser" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_dbfielduser?>">
|
||||
<?php if (isset($err["auth_dbfielduser"])) formerr($err["auth_dbfielduser"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbfielduser","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbfieldpass:</td>
|
||||
<td>
|
||||
<input name="auth_dbfieldpass" type="text" size="30" value="<?php echo $config->auth_dbfieldpass?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbfieldpass:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbfieldpass" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_dbfieldpass?>">
|
||||
<?php if (isset($err["auth_dbfieldpass"])) formerr($err["auth_dbfieldpass"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbfieldpass","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_dbpasstype:</td>
|
||||
<td>
|
||||
<?php
|
||||
$passtype["plaintext"] = get_string("plaintext", "auth");
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbpasstype:</TD>
|
||||
<TD>
|
||||
<?php $passtype["plaintext"] = get_string("plaintext", "auth");
|
||||
$passtype["md5"] = get_string("md5", "auth");
|
||||
$passtype["internal"] = get_string("internal", "auth");
|
||||
|
||||
choose_from_menu($passtype, "auth_dbpasstype", $config->auth_dbpasstype, "");
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_dbpasstype","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string("auth_dbextrafields","auth"), true, false); ?>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("firstname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_firstname?>">
|
||||
</TD>
|
||||
<TD rowspan=12 VALIGN=CENTER>
|
||||
<?php print_string("auth_dbextrafields","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("lastname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lastname?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("email") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_email?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 1:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone1?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 2:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone2?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("department") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_department?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("address") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_address?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("city") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_city?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("country") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_country?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("description") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_description?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("idnumber") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_idnumber?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("language") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lang?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
+23
-356
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up an external database table
|
||||
|
||||
|
||||
@@ -12,68 +12,34 @@ function auth_user_login ($username, $password) {
|
||||
// two databases of the same kind ... it seems to get confused when trying to access
|
||||
// the first database again, after having accessed the second.
|
||||
// The following hack will make the database explicit which keeps it happy
|
||||
// This seems to broke postgesql so ..
|
||||
|
||||
$prefix = $CFG->prefix.''; // Remember it. The '' is to prevent PHP5 reference.. see bug 3223
|
||||
|
||||
if ($CFG->dbtype != 'postgres7') {
|
||||
$CFG->prefix = $CFG->dbname.$CFG->prefix;
|
||||
}
|
||||
$CFG->prefix = "$CFG->dbname.$CFG->prefix";
|
||||
}
|
||||
|
||||
// Connect to the external database
|
||||
$authdb = &ADONewConnection($CFG->auth_dbtype);
|
||||
$authdb = &ADONewConnection($CFG->auth_dbtype);
|
||||
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
|
||||
|
||||
if ($CFG->auth_dbpasstype === 'internal') {
|
||||
// lookup username externally, but resolve
|
||||
// password locally -- to support backend that
|
||||
// don't track passwords
|
||||
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username' ");
|
||||
$authdb->Close();
|
||||
|
||||
if (!$rs) {
|
||||
notify("Could not connect to the specified authentication database...");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
// user exists exterally
|
||||
// check username/password internally
|
||||
if ($user = get_record('user', 'username', $username)) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
}
|
||||
} else {
|
||||
// user does not exist externally
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
// normal case: use external db for passwords
|
||||
|
||||
if ($CFG->auth_dbpasstype === 'md5') { // Re-format password accordingly
|
||||
switch ($CFG->auth_dbpasstype) { // Re-format password accordingly
|
||||
case "md5":
|
||||
$password = md5($password);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
|
||||
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username'
|
||||
AND $CFG->auth_dbfieldpass = '$password' ");
|
||||
$authdb->Close();
|
||||
|
||||
$CFG->prefix = $prefix;
|
||||
|
||||
if (!$rs) {
|
||||
notify("Could not connect to the specified authentication database...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$authdb->Close();
|
||||
|
||||
if (!$rs) {
|
||||
notify("Could not connect to the specified authentication database...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +52,6 @@ function auth_get_userinfo($username){
|
||||
|
||||
$config = (array) $CFG;
|
||||
|
||||
$pcfg = get_config('auth/db');
|
||||
$pcfg = (array) $pcfg;
|
||||
|
||||
ADOLoadCode($CFG->auth_dbtype);
|
||||
$authdb = &ADONewConnection();
|
||||
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
|
||||
@@ -100,15 +63,11 @@ function auth_get_userinfo($username){
|
||||
$result = array();
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ($pcfg["field_map_$field"]) {
|
||||
if ($rs = $authdb->Execute("SELECT ".$pcfg["field_map_$field"]." FROM $CFG->auth_dbtable
|
||||
if ($config["auth_user_$field"]) {
|
||||
if ($rs = $authdb->Execute("SELECT ".$config["auth_user_$field"]." FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username'")) {
|
||||
if ( $rs->RecordCount() == 1 ) {
|
||||
if (!empty($CFG->unicodedb)) {
|
||||
$result["$field"] = addslashes(stripslashes($rs->fields[0]));
|
||||
} else {
|
||||
$result["$field"] = addslashes(stripslashes(utf8_decode($rs->fields[0])));
|
||||
}
|
||||
$result["$field"] = $rs->fields[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,296 +76,4 @@ function auth_get_userinfo($username){
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* syncronizes user fron external db to moodle user table
|
||||
*
|
||||
* Sync shouid be done by using idnumber attribute, not username.
|
||||
* You need to pass firstsync parameter to function to fill in
|
||||
* idnumbers if they dont exists in moodle user table.
|
||||
*
|
||||
* Syncing users removes (disables) users that dont exists anymore in external db.
|
||||
* Creates new users and updates coursecreator status of users.
|
||||
*
|
||||
* @param bool $do_updates Optional: set to true to force an update of existing accounts
|
||||
*
|
||||
* This implementation is simpler but less scalable than the one found in the LDAP module.
|
||||
*
|
||||
*/
|
||||
function auth_sync_users ($do_updates=0) {
|
||||
|
||||
global $CFG;
|
||||
$pcfg = get_config('auth/db');
|
||||
|
||||
///
|
||||
/// list external users
|
||||
///
|
||||
$userlist = auth_get_userlist();
|
||||
$quoteduserlist = implode("', '", $userlist);
|
||||
$quoteduserlist = "'$quoteduserlist'";
|
||||
|
||||
///
|
||||
/// delete obsolete internal users
|
||||
///
|
||||
|
||||
// find obsolete users
|
||||
if (count($userlist)) {
|
||||
$sql = 'SELECT u.id, u.username
|
||||
FROM ' . $CFG->prefix .'user u
|
||||
WHERE u.auth=\'db\' AND u.deleted=\'0\' AND u.username NOT IN (' . $quoteduserlist . ')';
|
||||
} else {
|
||||
$sql = 'SELECT u.id, u.username
|
||||
FROM ' . $CFG->prefix .'user u
|
||||
WHERE u.auth=\'db\' AND u.deleted=\'0\' ';
|
||||
}
|
||||
$remove_users = get_records_sql($sql);
|
||||
|
||||
if (!empty($remove_users)){
|
||||
print "User entries to remove: ". count($remove_users) . "\n";
|
||||
|
||||
begin_sql();
|
||||
foreach ($remove_users as $user) {
|
||||
//following is copy pasted from admin/user.php
|
||||
//maybe this should moved to function in lib/datalib.php
|
||||
unset($updateuser);
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = "1";
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record("user", $updateuser)) {
|
||||
unenrol_student($user->id); // From all courses
|
||||
remove_teacher($user->id); // From all courses
|
||||
remove_admin($user->id);
|
||||
notify(get_string("deletedactivity", "", fullname($user, true)) );
|
||||
} else {
|
||||
notify(get_string("deletednot", "", fullname($user, true)));
|
||||
}
|
||||
//copy pasted part ends
|
||||
}
|
||||
commit_sql();
|
||||
}
|
||||
unset($remove_users); // free mem!
|
||||
|
||||
if (!count($userlist)) {
|
||||
// exit right here
|
||||
// nothing else to do
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
/// update existing accounts
|
||||
///
|
||||
if ($do_updates) {
|
||||
// narrow down what fields we need to update
|
||||
$all_keys = array_keys(get_object_vars($pcfg));
|
||||
$updatekeys = array();
|
||||
foreach ($all_keys as $key) {
|
||||
if (preg_match('/^field_updatelocal_(.+)$/',$key, $match)) {
|
||||
if ($pcfg->{$match[0]}) { // if it has a true value
|
||||
array_push($updatekeys, $match[1]); // the actual key name
|
||||
}
|
||||
}
|
||||
}
|
||||
// print_r($all_keys); print_r($updatekeys);
|
||||
unset($all_keys); unset($key);
|
||||
|
||||
// only go ahead if we actually
|
||||
// have fields to update locally
|
||||
if (!empty($updatekeys)) {
|
||||
$sql = 'SELECT u.id, u.username
|
||||
FROM ' . $CFG->prefix .'user u
|
||||
WHERE u.auth=\'db\' AND u.deleted=\'0\' AND u.username IN (' . $quoteduserlist . ')';
|
||||
$update_users = get_records_sql($sql);
|
||||
|
||||
foreach ($update_users as $user) {
|
||||
auth_db_update_user_record($user->username, $updatekeys);
|
||||
}
|
||||
unset($update_users); // free memory
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// create missing accounts
|
||||
///
|
||||
// NOTE: this is very memory intensive
|
||||
// and generally inefficient
|
||||
$sql = 'SELECT u.id, u.username
|
||||
FROM ' . $CFG->prefix .'user u
|
||||
WHERE u.auth=\'db\' AND u.deleted=\'0\'';
|
||||
|
||||
$users = get_records_sql($sql);
|
||||
|
||||
// simplify down to usernames
|
||||
$usernames = array();
|
||||
foreach ($users as $user) {
|
||||
array_push($usernames, $user->username);
|
||||
}
|
||||
unset($users);
|
||||
|
||||
$add_users = array_diff($userlist, $usernames);
|
||||
unset($usernames);
|
||||
|
||||
if(!empty($add_users)){
|
||||
print "User entries to add: ". count($add_users). "\n";
|
||||
begin_sql();
|
||||
foreach($add_users as $user){
|
||||
$username = $user;
|
||||
$user = auth_get_userinfo_asobj($user);
|
||||
|
||||
// prep a few params
|
||||
$user->username = $username;
|
||||
$user->modified = time();
|
||||
$user->confirmed = 1;
|
||||
$user->auth = 'db';
|
||||
|
||||
// insert it
|
||||
$old_debug=$CFG->debug;
|
||||
$CFG->debug=10;
|
||||
|
||||
// maybe the user has been deleted before
|
||||
if ($old_user = get_record('user', 'username', $user->username, 'deleted', 1)) {
|
||||
$user->id = $old_user->id;
|
||||
set_field('user', 'deleted', 0, 'username', $user->username);
|
||||
echo "Revived user $user->username id $user->id\n";
|
||||
} elseif ($id=insert_record ('user',$user)) { // it is truly a new user
|
||||
echo "inserted user $user->username id $id\n";
|
||||
$user->id = $id;
|
||||
// if relevant, tag for password generation
|
||||
if ($CFG->auth_dbpasstype === 'internal') {
|
||||
set_user_preference('auth_forcepasswordchange', 1, $id);
|
||||
set_user_preference('create_password', 1, $id);
|
||||
}
|
||||
} else {
|
||||
echo "error inserting user $user->username \n";
|
||||
}
|
||||
$CFG->debug=$old_debug;
|
||||
}
|
||||
commit_sql();
|
||||
unset($add_users); // free mem
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function auth_user_exists ($username) {
|
||||
global $CFG;
|
||||
$authdb = &ADONewConnection($CFG->auth_dbtype);
|
||||
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username' ");
|
||||
$authdb->Close();
|
||||
|
||||
if (!$rs) {
|
||||
notify("Could not connect to the specified authentication database...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
// user exists exterally
|
||||
// check username/password internally
|
||||
// ?? there is no $password variable, so why??
|
||||
/*if ($user = get_record('user', 'username', $username)) {
|
||||
return ($user->password == md5($password));
|
||||
}*/
|
||||
return $rs->RecordCount();
|
||||
} else {
|
||||
// user does not exist externally
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function auth_get_userlist() {
|
||||
|
||||
global $CFG;
|
||||
|
||||
// Connect to the external database
|
||||
$authdb = &ADONewConnection($CFG->auth_dbtype);
|
||||
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
|
||||
|
||||
// fetch userlist
|
||||
$rs = $authdb->Execute("SELECT $CFG->auth_dbfielduser AS username
|
||||
FROM $CFG->auth_dbtable ");
|
||||
$authdb->Close();
|
||||
|
||||
if (!$rs) {
|
||||
notify("Could not connect to the specified authentication database...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
$userlist = array();
|
||||
while ($rec = $rs->FetchRow()) {
|
||||
array_push($userlist, $rec['username']);
|
||||
}
|
||||
return $userlist;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* reads userinformation from DB and return it in an object
|
||||
*
|
||||
* @param string $username username
|
||||
* @return array
|
||||
*/
|
||||
function auth_get_userinfo_asobj($username){
|
||||
$user_array = truncate_userinfo(auth_get_userinfo($username));
|
||||
$user = new object;
|
||||
foreach($user_array as $key=>$value){
|
||||
$user->{$key} = $value;
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
function auth_db_update_user_record($username, $updatekeys=false) {
|
||||
/// will update a local user record from an external source.
|
||||
/// is a lighter version of the one in moodlelib -- won't do
|
||||
/// expensive ops such as enrolment
|
||||
///
|
||||
/// If you don't pass $updatekeys, there is a performance hit and
|
||||
/// values removed from DB won't be removed from moodle.
|
||||
|
||||
global $CFG;
|
||||
|
||||
$pcfg = get_config('auth/db');
|
||||
|
||||
//just in case check text case
|
||||
$username = trim(moodle_strtolower($username));
|
||||
|
||||
// get the current user record
|
||||
$user = get_record('user', 'username', $username);
|
||||
if (empty($user)) { // trouble
|
||||
error_log("Cannot update non-existent user: $username");
|
||||
die;
|
||||
}
|
||||
|
||||
if (function_exists('auth_get_userinfo')) {
|
||||
if ($newinfo = auth_get_userinfo($username)) {
|
||||
$newinfo = truncate_userinfo($newinfo);
|
||||
|
||||
if (empty($updatekeys)) { // all keys? this does not support removing values
|
||||
$updatekeys = array_keys($newinfo);
|
||||
}
|
||||
|
||||
foreach ($updatekeys as $key){
|
||||
unset($value);
|
||||
if (isset($newinfo[$key])) {
|
||||
$value = $newinfo[$key];
|
||||
$value = addslashes(stripslashes($value)); // Just in case
|
||||
} else {
|
||||
$value = '';
|
||||
}
|
||||
if (!empty($pcfg->{'field_updatelocal_' . $key})) {
|
||||
if ($user->{$key} != $value) { // only update if it's changed
|
||||
set_field('user', $key, $value, 'username', $username);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return get_record_select("user", "username = '$username' AND deleted <> '1'");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
<!-- No config needed -->
|
||||
<div align="center"><?php print_string('none'); ?></div>
|
||||
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// Standard authentication function
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
@@ -7,11 +7,11 @@ function auth_user_login ($username, $password) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($user = get_record('user', 'username', $username)) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
if (! $user = get_user_info_from_db("username", $username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return ($user->password == md5($password));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+84
-169
@@ -1,169 +1,84 @@
|
||||
<?php
|
||||
|
||||
if (!isset($config->auth_fchost)) {
|
||||
|
||||
$config->auth_fchost = "127.0.0.1";
|
||||
|
||||
}
|
||||
|
||||
if (!isset($config->auth_fcfppport)) {
|
||||
|
||||
$config->auth_fcfppport = "3333";
|
||||
|
||||
}
|
||||
|
||||
if (!isset($config->auth_fcuserid)) {
|
||||
|
||||
$config->auth_fcuserid = "fcMoodle";
|
||||
|
||||
}
|
||||
|
||||
if (!isset($config->auth_fcpasswd)) {
|
||||
|
||||
$config->auth_fcpasswd = "";
|
||||
|
||||
}
|
||||
|
||||
if (!isset($config->auth_fccreators)) {
|
||||
|
||||
$config->auth_fccreators = "";
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
|
||||
<td align="right">auth_fchost:</td>
|
||||
|
||||
<td>
|
||||
|
||||
<input name="auth_fchost" type="text" size="30" value="<?php echo $config->auth_fchost?>" />
|
||||
|
||||
<?php if (isset($err["auth_fchost"])) formerr($err["auth_fchost"]); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<?php print_string("auth_fchost","auth") ?>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
|
||||
<td align="right">auth_fcfppport:</td>
|
||||
|
||||
<td>
|
||||
|
||||
<input name="auth_fcfppport" type="text" size="30" value="<?php echo $config->auth_fcfppport?>" />
|
||||
|
||||
<?php if (isset($err["auth_fcfppport"])) formerr($err["auth_fchost"]); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<?php print_string("auth_fcfppport","auth") ?>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
|
||||
<td align="right">auth_fcuserid:</td>
|
||||
|
||||
<td>
|
||||
|
||||
<input name="auth_fcuserid" type="text" size="30" maxlength="15" value="<?php echo $config->auth_fcuserid?>" />
|
||||
|
||||
<?php if (isset($err["auth_fcuserid"])) formerr($err["auth_fcuserid"]); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<?php print_string("auth_fcuserid","auth") ?>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
|
||||
<td align="right">auth_fcpasswd:</td>
|
||||
|
||||
<td>
|
||||
|
||||
<input name="auth_fcpasswd" type="password" size="30" maxlength="12" value="<?php echo $config->auth_fcpasswd?>" />
|
||||
|
||||
<?php if (isset($err["auth_fcpasswd"])) formerr($err["auth_fcpasswd"]); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<?php print_string("auth_fcpasswd","auth") ?>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
|
||||
<td align="right">auth_fccreators:</td>
|
||||
|
||||
<td>
|
||||
|
||||
<input name="auth_fccreators" type="text" size="30" value="<?php echo $config->auth_fccreators?>" />
|
||||
|
||||
<?php if (isset($err["auth_fccreators"])) formerr($err["auth_fccreators"]); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<?php print_string("auth_fccreators","auth") ?>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<tr valign="top">
|
||||
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
|
||||
<td>
|
||||
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
<?PHP
|
||||
if (!isset($config->auth_fchost)) {
|
||||
$config->auth_fchost = "127.0.0.1";
|
||||
}
|
||||
if (!isset($config->auth_fcfppport)) {
|
||||
$config->auth_fcfppport = "3333";
|
||||
}
|
||||
if (!isset($config->auth_fcuserid)) {
|
||||
$config->auth_fcuserid = "fcMoodle";
|
||||
}
|
||||
if (!isset($config->auth_fcpasswd)) {
|
||||
$config->auth_fcpasswd = "";
|
||||
}
|
||||
if (!isset($config->auth_fccreators)) {
|
||||
$config->auth_fccreators = "";
|
||||
}
|
||||
?>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fchost:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fchost TYPE=text SIZE=30 VALUE="<?php echo $config->auth_fchost?>">
|
||||
<?php if (isset($err["auth_fchost"])) formerr($err["auth_fchost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fchost","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fcfppport:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fcfppport TYPE=text SIZE=30 VALUE="<?php echo $config->auth_fcfppport?>">
|
||||
<?php if (isset($err["auth_fcfppport"])) formerr($err["auth_fchost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fcfppport","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fcuserid:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fcuserid TYPE=text SIZE=30 MAXLENGTH=15 VALUE="<?php echo $config->auth_fcuserid?>">
|
||||
<?php if (isset($err["auth_fcuserid"])) formerr($err["auth_fcuserid"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fcuserid","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fcpasswd:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fcpasswd TYPE=password SIZE=30 MAXLENGTH=12 VALUE="<?php echo $config->auth_fcpasswd?>">
|
||||
<?php if (isset($err["auth_fcpasswd"])) formerr($err["auth_fcpasswd"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fcpasswd","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fccreators:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fccreators TYPE=text SIZE=30 VALUE="<?php echo $config->auth_fccreators?>">
|
||||
<?php if (isset($err["auth_fccreators"])) formerr($err["auth_fccreators"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fccreators","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ description Get data from users resume. Pictures will be removed.
|
||||
$userinfo['email'] = strtok($fpp->getUserInfo($username,"1252"),',');
|
||||
$userinfo['phone1'] = $fpp->getUserInfo($username,"1206");
|
||||
$userinfo['phone2'] = $fpp->getUserInfo($username,"1207");
|
||||
$userinfo['description'] = $fpp->getResume($username);
|
||||
$userinfo['description'] = $fpp->getResume($username);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -151,4 +151,4 @@ function auth_iscreator($username=0) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+33
-34
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?PHP
|
||||
if (!isset($config->auth_imaphost)) {
|
||||
$config->auth_imaphost = "127.0.0.1";
|
||||
}
|
||||
@@ -9,52 +9,51 @@
|
||||
$config->auth_imapport = "143";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_imaphost:</td>
|
||||
<td>
|
||||
<input name="auth_imaphost" type="text" size="30" value="<?php echo $config->auth_imaphost?>" />
|
||||
<?php if (isset($err["auth_imaphost"])) formerr($err["auth_imaphost"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_imaphost:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_imaphost TYPE=text SIZE=30 VALUE="<?php echo $config->auth_imaphost?>">
|
||||
<?php if (isset($err["auth_imaphost"])) formerr($err["auth_imaphost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_imaphost","auth") ?>
|
||||
<?php print_string("auth_multiplehosts","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_imaptype:</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_imaptype:</TD>
|
||||
<TD>
|
||||
<?php $imaptypes = array("imap","imapssl", "imapcert", "imaptls");
|
||||
foreach($imaptypes as $imaptype) {
|
||||
$imapoptions[$imaptype] = $imaptype;
|
||||
}
|
||||
choose_from_menu($imapoptions, "auth_imaptype", $config->auth_imaptype, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_imaptype","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_imapport:</td>
|
||||
<td>
|
||||
<input name="auth_imapport" type="text" size="6" value="<?php echo $config->auth_imapport?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_imapport:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?php echo $config->auth_imapport?>">
|
||||
<?php if (isset($err["auth_imapport"])) formerr($err["auth_imapport"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_imapport","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up an IMAP server
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/** auth_ldap_sync_users.php
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* backend in those setups where the LDAP backend acts as 'master'.
|
||||
*
|
||||
* Recommended cron entry:
|
||||
* # 5 minutes past 4am
|
||||
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
|
||||
*
|
||||
* Notes:
|
||||
* - If you have a large number of users, you may want to raise the memory limits
|
||||
* by passing -d momory_limit=256M
|
||||
* - For debugging & better logging, you are encouraged to use in the command line:
|
||||
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
|
||||
*
|
||||
* Performance notes:
|
||||
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if(!empty($_SERVER['GATEWAY_INTERFACE'])){
|
||||
error_log("should not be called from apache!");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/auth/ldap/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
$CFG->debug=10;
|
||||
auth_sync_users(1000, true );
|
||||
|
||||
?>
|
||||
+231
-358
@@ -1,395 +1,268 @@
|
||||
<?php
|
||||
// Initialize vars
|
||||
if (!isset($config->ldap_host_url))
|
||||
{ $config->ldap_host_url = ''; }
|
||||
if (!isset($config->ldap_contexts))
|
||||
{ $config->ldap_contexts = ''; }
|
||||
if (!isset($config->ldap_user_type))
|
||||
{ $config->ldap_user_type = ''; }
|
||||
if (!isset($config->ldap_user_attribute))
|
||||
{ $config->ldap_user_attribute = ''; }
|
||||
if (!isset($config->ldap_search_sub))
|
||||
{ $config->ldap_search_sub = ''; }
|
||||
if (!isset($config->ldap_opt_deref))
|
||||
{ $config->ldap_opt_deref = ''; }
|
||||
if (!isset($config->ldap_preventpassindb))
|
||||
{ $config->ldap_preventpassindb = 0; }
|
||||
if (!isset($config->ldap_bind_dn))
|
||||
{$config->ldap_bind_dn = ''; }
|
||||
if (!isset($config->ldap_bind_pw))
|
||||
{$config->ldap_bind_pw = ''; }
|
||||
if (!isset($config->ldap_version))
|
||||
{$config->ldap_version = '2'; }
|
||||
if (!isset($config->ldap_objectclass))
|
||||
{$config->ldap_objectclass = ''; }
|
||||
if (!isset($config->ldap_memberattribute))
|
||||
{$config->ldap_memberattribute = ''; }
|
||||
if (!isset($config->ldap_creators))
|
||||
{$config->ldap_creators = ''; }
|
||||
if (!isset($config->ldap_create_context))
|
||||
{$config->ldap_create_context = ''; }
|
||||
if (!isset($config->ldap_expiration))
|
||||
{$config->ldap_expiration = ''; }
|
||||
if (!isset($config->ldap_expiration_warning))
|
||||
{$config->ldap_expiration_warning = '10'; }
|
||||
if (!isset($config->ldap_expireattr))
|
||||
{$config->ldap_expireattr = ''; }
|
||||
if (!isset($config->ldap_gracelogins))
|
||||
{$config->ldap_gracelogins = ''; }
|
||||
if (!isset($config->ldap_graceattr))
|
||||
{$config->ldap_graceattr = ''; }
|
||||
if (!isset($config->auth_user_create))
|
||||
{$config->auth_user_create = ''; }
|
||||
if (!isset($config->auth_ldap_forcechangepassword))
|
||||
{$config->auth_ldap_forcechangepassword = false; }
|
||||
if (!isset($config->auth_ldap_stdchangepassword))
|
||||
{$config->auth_ldap_stdchangepassword = false; }
|
||||
<?PHP
|
||||
if (!isset($config->ldap_host_url)) {
|
||||
$config->ldap_host_url = "";
|
||||
}
|
||||
if (!isset($config->ldap_contexts)) {
|
||||
$config->ldap_contexts = "";
|
||||
}
|
||||
if (!isset($config->ldap_user_attribute)) {
|
||||
$config->ldap_user_attribute = "";
|
||||
}
|
||||
if (!isset($config->ldap_search_sub)) {
|
||||
$config->ldap_search_sub = "";
|
||||
}
|
||||
if (!isset($config->ldap_bind_dn)) {
|
||||
$config->ldap_bind_dn = "";
|
||||
}
|
||||
if (!isset($config->ldap_bind_pw)) {
|
||||
$config->ldap_bind_pw = "";
|
||||
}
|
||||
if (empty($config->ldap_version)) {
|
||||
$config->ldap_version = "2";
|
||||
}
|
||||
if (empty($config->ldap_memberattribute)) {
|
||||
$config->ldap_memberattribute = "";
|
||||
}
|
||||
if (empty($config->ldap_creators)) {
|
||||
$config->ldap_creators = "";
|
||||
}
|
||||
if (empty($config->ldap_create_context)) {
|
||||
$config->ldap_create_context = "";
|
||||
}
|
||||
if (empty($config->ldap_objectclass)) {
|
||||
$config->ldap_objectclass = "";
|
||||
}
|
||||
if (empty($config->auth_user_guid)) {
|
||||
$config->auth_user_guid = "";
|
||||
}
|
||||
|
||||
$yesno = array( get_string('no'), get_string('yes') );
|
||||
|
||||
if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
print '<tr><td><p align="center"><font color="red"><strong>Warning:
|
||||
The PHP LDAP module does not seem to be present.
|
||||
Please ensure it is installed and enabled.</strong></font></p></td></tr>';
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("auth_ldap_server_settings", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_host_url:</td>
|
||||
<td>
|
||||
<input name="ldap_host_url" type="text" size="30" value="<?php echo $config->ldap_host_url?>" />
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_host_url:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_host_url?>">
|
||||
<?php if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_host_url","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_version:</td>
|
||||
<td>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_version:</TD>
|
||||
<TD>
|
||||
<?php
|
||||
$versions[2] = "2";
|
||||
$versions[3] = "3";
|
||||
choose_from_menu($versions, "ldap_version", $config->ldap_version, "");
|
||||
if (isset($err["ldap_version"])) formerr($err["ldap_version"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_version","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("auth_ldap_bind_settings", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_preventpassindb:</td>
|
||||
<td>
|
||||
<?php
|
||||
$choices = array();
|
||||
$choices["0"] = get_string("no");
|
||||
$choices["1"] = get_string("yes");
|
||||
choose_from_menu ($choices, "ldap_preventpassindb", $config->ldap_preventpassindb, "");
|
||||
?>
|
||||
</td><td>
|
||||
<?php print_string("auth_ldap_preventpassindb","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_bind_dn:</td>
|
||||
<td>
|
||||
<input name="ldap_bind_dn" type="text" size="30" value="<?php echo $config->ldap_bind_dn?>" />
|
||||
<?php if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
|
||||
</td><td>
|
||||
<?php print_string("auth_ldap_bind_dn","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_bind_pw:</td>
|
||||
<td>
|
||||
<input name="ldap_bind_pw" type="password" size="30" value="<?php echo $config->ldap_bind_pw?>" />
|
||||
<?php if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
|
||||
</td><td>
|
||||
<?php print_string("auth_ldap_bind_pw","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("auth_ldap_user_settings", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_user_type:</td>
|
||||
<td>
|
||||
<?php choose_from_menu(auth_ldap_suppported_usertypes(), "ldap_user_type", $config->ldap_user_type, ""); ?>
|
||||
<?php if (isset($err["ldap_user_type"])) formerr($err["ldap_user_type"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_user_type","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_contexts:</td>
|
||||
<td>
|
||||
<input name="ldap_contexts" type="text" size="30" value="<?php echo $config->ldap_contexts?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_contexts:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_contexts?>">
|
||||
<?php if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_contexts","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_search_sub:</td>
|
||||
<td>
|
||||
<?php
|
||||
$choices = array();
|
||||
$choices["0"] = get_string("no");
|
||||
$choices["1"] = get_string("yes");
|
||||
choose_from_menu ($choices, "ldap_search_sub", $config->ldap_search_sub, "");
|
||||
?>
|
||||
<?php if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_search_sub","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_opt_deref:</td>
|
||||
<td>
|
||||
<?php
|
||||
$opt_deref[LDAP_DEREF_NEVER] = get_string("no");
|
||||
$opt_deref[LDAP_DEREF_ALWAYS] = get_string("yes");
|
||||
choose_from_menu($opt_deref, "ldap_opt_deref", $config->ldap_opt_deref, LDAP_DEREF_NEVER);
|
||||
if (isset($err["ldap_opt_deref"])) formerr($err["ldap_opt_deref"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_opt_deref","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_user_attribute:</td>
|
||||
<td>
|
||||
<input name="ldap_user_attribute" type="text" size="30" value="<?php echo $config->ldap_user_attribute?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_user_attribute?>">
|
||||
<?php if (isset($err["ldap_user_attribute"])) formerr($err["ldap_user_attribute"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_user_attribute","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_memberattribute:</td>
|
||||
<td>
|
||||
<input name="ldap_memberattribute" type="text" size="30" value="<?php echo $config->ldap_memberattribute?>" />
|
||||
<?php if (isset($err["ldap_memberattribute"])) formerr($err["ldap_memberattribute"]); ?>
|
||||
</td><td>
|
||||
<?php print_string("auth_ldap_memberattribute","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_objectclass:</td>
|
||||
<td>
|
||||
<input name="ldap_objectclass" type="text" size="30" value="<?php echo $config->ldap_objectclass?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_objectclass:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_objectclass TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_objectclass?>">
|
||||
<?php if (isset($err["ldap_objectclass"])) formerr($err["ldap_objectclass"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_objectclass","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("forcechangepassword", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?php echo $config->ldap_search_sub?>">
|
||||
<?php if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_search_sub","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right" valign="top"><?php print_string('forcechangepassword', 'auth') ?>:</td>
|
||||
<td>
|
||||
|
||||
<select name="auth_ldap_forcechangepassword">
|
||||
<option value="0" <?php echo ($config->auth_ldap_forcechangepassword ? '' : 'selected="yes"') ?> >
|
||||
<?php print_string("no") ?></option>
|
||||
<option value="1" <?php echo ($config->auth_ldap_forcechangepassword ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string("yes") ?></option>
|
||||
</select><br />
|
||||
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<p><?php print_string('forcechangepasswordfirst_help', 'auth') ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_dn?>">
|
||||
<?php if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_bind_dn","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right" valign="top"><?php print_string('stdchangepassword', 'auth') ?>:</td>
|
||||
<td>
|
||||
|
||||
<select name="auth_ldap_stdchangepassword">
|
||||
<option value="0" <?php echo ($config->auth_ldap_stdchangepassword ? '' : 'selected="yes"') ?> >
|
||||
<?php print_string("no") ?></option>
|
||||
<option value="1" <?php echo ($config->auth_ldap_stdchangepassword ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string("yes") ?></option>
|
||||
</select><br />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_pw?>">
|
||||
<?php if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_bind_pw","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<p><?php print_string('stdchangepassword_expl', 'auth') ?></p>
|
||||
<p><?php print_string('stdchangepassword_explldap', 'auth') ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_memberattribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_memberattribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_memberattribute?>">
|
||||
<?php if (isset($err["ldap_memberattribute"])) formerr($err["ldap_memberattribute"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_memberattribute","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("auth_ldap_passwdexpire_settings", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_expiration:</td>
|
||||
<td>
|
||||
<?php
|
||||
$expiration['0'] = "No";
|
||||
$expiration['1'] = "LDAP";
|
||||
choose_from_menu($expiration, "ldap_expiration", $config->ldap_expiration, "");
|
||||
if (isset($err["ldap_expiration"])) formerr($err["ldap_expiration"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_expiration_desc","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_expiration_warning:</td>
|
||||
<td>
|
||||
<input name="ldap_expiration_warning" type="text" size="2" value="<?php echo $config->ldap_expiration_warning?>" />
|
||||
<?php if (isset($err["ldap_expiration_warning"])) formerr($err["ldap_expiration_warning"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_expiration_warning_desc","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_exprireattr:</td>
|
||||
<td>
|
||||
<input name="ldap_expireattr" type="text" size="30" value="<?php echo $config->ldap_expireattr?>" />
|
||||
<?php if (isset($err["ldap_expireattr"])) formerr($err["ldap_expireattr"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_expireattr_desc","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_gracelogins:</td>
|
||||
<td>
|
||||
<?php
|
||||
$grace['0'] = get_string("no");
|
||||
$grace['1'] = get_string("yes");
|
||||
choose_from_menu($grace, "ldap_gracelogins", $config->ldap_gracelogins, "");
|
||||
if (isset($err["ldap_expiration"])) formerr($err["ldap_expiration"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_gracelogins_desc","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_graceattr:</td>
|
||||
<td>
|
||||
<input name="ldap_graceattr" type="text" size="30" value="<?php echo $config->ldap_graceattr?>" />
|
||||
<?php if (isset($err["ldap_graceattr"])) formerr($err["ldap_graceattr"]);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_ldap_graceattr_desc","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("auth_user_create", "auth") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_create_context:</td>
|
||||
<td>
|
||||
<input name="ldap_create_context" type="text" size="30" value="<?php echo $config->ldap_create_context?>" />
|
||||
<?php if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
|
||||
</td><td>
|
||||
<?php print_string("auth_ldap_create_context","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string("coursecreators") ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">ldap_creators:</td>
|
||||
<td>
|
||||
<input name="ldap_creators" type="text" size="30" value="<?php echo $config->ldap_creators?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_creators:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_creators TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_creators?>">
|
||||
<?php if (isset($err["ldap_creators"])) formerr($err["ldap_creators"]); ?>
|
||||
</td><td>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_creators","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<?php
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_create_context:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_create_context TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_create_context?>">
|
||||
<?php if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_create_context","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
$help = get_string("auth_ldapextrafields","auth");
|
||||
$help .= get_string("auth_updatelocal_expl","auth");
|
||||
$help .= get_string("auth_fieldlock_expl","auth");
|
||||
$help .= get_string("auth_updateremote_expl","auth");
|
||||
$help .= '<hr />';
|
||||
$help .= get_string("auth_updateremote_ldap","auth");
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("firstname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_firstname?>">
|
||||
</TD>
|
||||
<TD rowspan=12 VALIGN=CENTER>
|
||||
<?php print_string("auth_ldapextrafields","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
print_auth_lock_options($auth, $user_fields, $help, true, true);
|
||||
?>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("lastname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lastname?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("email") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_email?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 1:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone1?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 2:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone2?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("department") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_department?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("address") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_address?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("city") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_city?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("country") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_country?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("description") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_description?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("idnumber") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_idnumber?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("language") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lang?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("guid") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_guid" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_guid?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+289
-1199
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// manual method - Just does a simple check against the database
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns false if the username doesn't exist yet
|
||||
// Returns true if the username and password work
|
||||
|
||||
if ($user = get_record('user', 'username', $username)) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
if ($user = get_user_info_from_db("username", $username)) {
|
||||
return ($user->password == md5($password));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+26
-27
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?PHP
|
||||
if (!isset($config->auth_nntphost)) {
|
||||
$config->auth_nntphost = "127.0.0.1";
|
||||
}
|
||||
@@ -7,37 +7,36 @@
|
||||
}
|
||||
?>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_nntphost:</td>
|
||||
<td>
|
||||
<input name="auth_nntphost" type="text" size="30" value="<?php echo $config->auth_nntphost?>" />
|
||||
<?php if (isset($err["auth_nntphost"])) formerr($err["auth_nntphost"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_nntphost:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_nntphost" TYPE="text" SIZE=30 VALUE="<?php echo $config->auth_nntphost?>">
|
||||
<?php if (isset($err["auth_nntphost"])) formerr($err["auth_nntphost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_nntphost","auth") ?>
|
||||
<?php print_string("auth_multiplehosts","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_nntpport:</td>
|
||||
<td>
|
||||
<input name="auth_nntpport" type="text" size="6" value="<?php echo $config->auth_nntpport?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_nntpport:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_nntpport TYPE=text SIZE=6 VALUE="<?php echo $config->auth_nntpport?>">
|
||||
<?php if (isset($err["auth_nntpport"])) formerr($err["auth_nntpport"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_nntpport","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up an NNTP server
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
<!-- No config needed -->
|
||||
<div align="center"><?php print_string('none'); ?></div>
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// No authentication at all. This method approves everything!
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns true if the username doesn't exist yet
|
||||
// Returns true if the username and password work
|
||||
|
||||
if ($user = get_record('user', 'username', $username)) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
if (! $user = get_user_info_from_db("username", $username)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ($user->password == md5($password));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,5 +6,4 @@
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
</tr>
|
||||
+41
-43
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
if (!isset($config->auth_pop3host)) {
|
||||
$config->auth_pop3host = "127.0.0.1";
|
||||
}
|
||||
@@ -12,64 +12,62 @@
|
||||
$config->auth_pop3mailbox = "INBOX";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_pop3host:</td>
|
||||
<td>
|
||||
<input name="auth_pop3host" type="text" size="30" value="<?php echo $config->auth_pop3host?>" />
|
||||
<?php if (isset($err["auth_pop3host"])) formerr($err["auth_pop3host"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3host:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_pop3host TYPE=text SIZE=30 VALUE="<?php echo $config->auth_pop3host?>">
|
||||
<?php if (isset($err["auth_pop3host"])) formerr($err["auth_pop3host"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_pop3host","auth") ?>
|
||||
<?php print_string("auth_multiplehosts","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_pop3type:</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3type:</TD>
|
||||
<TD>
|
||||
<?php $pop3types = array("pop3","pop3cert", "pop3notls");
|
||||
foreach($pop3types as $pop3type) {
|
||||
$pop3options[$pop3type] = $pop3type;
|
||||
}
|
||||
choose_from_menu($pop3options, "auth_pop3type", $config->auth_pop3type, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_pop3type","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_pop3port:</td>
|
||||
<td>
|
||||
<input name="auth_pop3port" type="text" size="6" value="<?php echo $config->auth_pop3port?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3port:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_pop3port TYPE=text SIZE=6 VALUE="<?php echo $config->auth_pop3port?>">
|
||||
<?php if (isset($err["auth_pop3port"])) formerr($err["auth_pop3port"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_pop3port","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right">auth_pop3mailbox:</td>
|
||||
<td>
|
||||
<input name="auth_pop3mailbox" type="text" size="6" value="<?php echo $config->auth_pop3mailbox?>" />
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3mailbox:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_pop3mailbox TYPE=text SIZE=6 VALUE="<?php echo $config->auth_pop3mailbox?>">
|
||||
<?php if (isset($err["auth_pop3mailbox"])) formerr($err["auth_pop3mailbox"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_pop3mailbox","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php print_auth_lock_options($auth, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up a POP3 server
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
@@ -12,7 +12,7 @@ function auth_user_login ($username, $password) {
|
||||
foreach ($hosts as $host) { // Try each host in turn
|
||||
|
||||
$host = trim($host);
|
||||
|
||||
|
||||
// remove any trailing slash
|
||||
if (substr($host, -1) == '/') {
|
||||
$host = substr($host, 0, strlen($host) - 1);
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?PHP // $Id: config.html
|
||||
|
||||
if ((!include_once('Auth/RADIUS.php')) or (!class_exists(Auth_RADIUS_PAP))) { // Is Auth/RADIUS really there?
|
||||
print '<p align="center"><font color="red"><strong>Warning: The Auth_RADIUS module does not seem to be present. Please ensure it is installed and enabled.</strong></font></p>';
|
||||
}
|
||||
if (!isset($config->auth_radiushost)) {
|
||||
$config->auth_radiushost = "127.0.0.1";
|
||||
}
|
||||
if (!isset($config->auth_radiusnasport)) {
|
||||
$config->auth_radiusport = "0";
|
||||
}
|
||||
if (!isset($config->auth_radiussecret)) {
|
||||
$config->auth_radiussecret = "";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" >
|
||||
<td align="right"><P>auth_radiushost:</td>
|
||||
<td>
|
||||
<input name="auth_radiushost" type="text" size="30" value="<?php echo $config->auth_radiushost?>">
|
||||
<?php if (isset($err["auth_radiushost"]))
|
||||
formerr($err["auth_radiushost"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_radiushost","auth") ?>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" >
|
||||
<td align="right"><P>auth_radiusnasport:</td>
|
||||
<td>
|
||||
<input name="auth_radiusport" type="text" size="6" value="<?php echo $config->auth_radiusport ?>">
|
||||
<?php if (isset($err["auth_radiusnasport"])) formerr($err["auth_radiusnasport"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_radiusnasport","auth") ?>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" >
|
||||
<td align="right"><P>auth_radiussecret:</td>
|
||||
<td>
|
||||
<input name="auth_radiussecret" type="text" size="6" value="<?php echo $config->auth_radiussecret ?>">
|
||||
<?php if (isset($err["auth_radiussecret"])) formerr($err["auth_radiussecret"]); ?> </td>
|
||||
<td>
|
||||
<?php print_string("auth_radiussecret","auth") ?>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<TR valign="top">
|
||||
<td align="right"><P><?php print_string("instructions", "auth")
|
||||
?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php
|
||||
p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up a RADIUS server
|
||||
// Contributed by Clive Gould <clive@ce.bromley.ac.uk>
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns true if the username and password work
|
||||
// and false if they are wrong or don't exist.
|
||||
|
||||
require_once 'Auth/RADIUS.php';
|
||||
|
||||
global $CFG;
|
||||
|
||||
// Added by Clive on 7th May for test purposes
|
||||
// printf("Username: $username <br>");
|
||||
// printf("Password: $password <br>");
|
||||
// printf("auth_radiushost: $CFG->auth_radiushost <br>");
|
||||
// printf("auth_radiusnasport: $CFG->auth_radiusnasport <br>");
|
||||
// printf("auth_radiussecret: $CFG->auth_radiussecret <br>");
|
||||
|
||||
$rauth = new Auth_RADIUS_PAP($username, $password);
|
||||
$rauth->addServer($CFG->auth_radiushost, $CFG->auth_radiusnasport, $CFG->auth_radiussecret);
|
||||
|
||||
if (!$rauth->start()) {
|
||||
printf("Radius start: %s<br>\n", $rauth->getError());
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $rauth->send();
|
||||
if (PEAR::isError($result)) {
|
||||
printf("Radius send failed: %s<br>\n", $result->getMessage());
|
||||
exit;
|
||||
} else if ($result === true) {
|
||||
// printf("Radius Auth succeeded<br>\n");
|
||||
return true;
|
||||
} else {
|
||||
// printf("Radius Auth rejected<br>\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// get attributes, even if auth failed
|
||||
if (!$rauth->getAttributes()) {
|
||||
printf("Radius getAttributes: %s<br>\n", $rauth->getError());
|
||||
} else {
|
||||
$rauth->dumpAttributes();
|
||||
}
|
||||
|
||||
$rauth->close();
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
Shibboleth Authentication for Moodle
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Requirements:
|
||||
- Shibboleth target 1.1 or later. See documentation for your Shibboleth
|
||||
federation on how to set up Shibboleth.
|
||||
|
||||
Changes:
|
||||
- 11. 2004: Created by Markus Hagman
|
||||
- 05. 2005: Modifications to login process by Martin Dougiamas
|
||||
- 05. 2005: Various extensions and fixes by Lukas Haemmerle
|
||||
- 06. 2005: Adaptions to new field locks and plugin config structures by Marting
|
||||
Langhoff and Lukas Haemmerle
|
||||
- 10. 2005: Added better error messages and moved text to language directories
|
||||
- 02. 2006: Simplified authentication so that authorization works properly
|
||||
Added instructions for IIS
|
||||
|
||||
|
||||
|
||||
Moodle Configuration with Dual login
|
||||
-------------------------------------------------------------------------------
|
||||
1. Protect the directory moodle/auth/shibboleth/ with Shibboleth.
|
||||
The page index.php in that directory actually logs in a Shibboleth user.
|
||||
For Apache you have to define a rule like the following in the Apache config:
|
||||
|
||||
--
|
||||
<Location ~ "/auth/shibboleth">
|
||||
AuthType shibboleth
|
||||
ShibRequireSession On
|
||||
require valid-user
|
||||
</Location>
|
||||
--
|
||||
|
||||
To restrict access to Moodle, replace the access rule 'require valid-user'
|
||||
with something that fits your needs, e.g. 'require affiliation student'.
|
||||
|
||||
For IIS you have protect the auth/shibboleth directory directly in the
|
||||
RequestMap of the Shibboleth configuration file (shibboleth.xml). See
|
||||
https://authdev.it.ohio-state.edu/twiki/bin/view/Shibboleth/xmlaccesscontrol?topic=XMLAccessControl
|
||||
|
||||
2. As Moodle admin, go to the 'Administrations >> Users >> Authentication
|
||||
Options' and select the 'Shibboleth' authentication method from the pop-up.
|
||||
|
||||
3. Fill in the fields of the form. The fields 'Username', 'First name',
|
||||
'Surname', etc should contain the name of the environment variables of the
|
||||
Shibboleth attributes that you want to map onto the corresponding Moodle
|
||||
variable (e.g. 'HTTP_SHIB_PERSON_SURNAME' for the person's last name, refer
|
||||
the Shibboleth documentation or the documentation of your Shibboleth
|
||||
federation for information on which attributes are available).
|
||||
Especially the 'Username' field is of great importance because
|
||||
this attribute is used for the Moodle authentication of Shibboleth users.
|
||||
|
||||
#############################################################################
|
||||
Shibboleth Attributes needed by Moodle:
|
||||
For Moodle to work properly Shibboleth should at least provide the attributes
|
||||
that are used as username, firstname, lastname and email in Moodle.
|
||||
The attribute used for the username has to be unique for all Shibboleth user.
|
||||
All attributes must obey a certain length, otherwise Moodle cuts off the
|
||||
ends. Consult the Moodle documentation for further information on the maximum
|
||||
lengths for each field in the user profile.
|
||||
#############################################################################
|
||||
|
||||
4. The large text field 'Instructions' must contain a link to the
|
||||
moodle/auth/shibboleth/index.php file which is protected by
|
||||
Shibboleth (see step 1) and causes the Shibboleth login procedure to start.
|
||||
You could also use HTML code in that field, e.g. to create your own
|
||||
Shibboleth login button.
|
||||
|
||||
5. Save the changes for the Shibboleth authentication method.
|
||||
|
||||
Moodle Configuration with Shibboleth only login
|
||||
-------------------------------------------------------------------------------
|
||||
If you want Shibboleth as your only authentication method, configure Moodle as
|
||||
described in the dual login section above and do the following steps:
|
||||
|
||||
4.a On the Moodle Shibboleth settings page, set the 'Alternate Login URL' to
|
||||
the URL of the file 'moodle/auth/shibboleth/index.php'
|
||||
This will enforce Shibboleth login.
|
||||
|
||||
How the Shibboleth authentication works
|
||||
--------------------------------------------------------------------------------
|
||||
To get Shibboleth authenticated in Moodle a user basically must access the
|
||||
Shibboleth-protected page /auth/shibboleth/index.php. If Shibboleth is the only
|
||||
authentication method (see 4.a), this happens automatically when a user wants to
|
||||
login in Moodle. Otherwise, the user has to click on the link on the login page
|
||||
you provided in step 4.
|
||||
|
||||
Moodle basically checks whether the Shibboleth attribute that you mapped
|
||||
as the username is present. This attribute should only be present if a user is
|
||||
Shibboleth authenticated.
|
||||
|
||||
If the user's Moodle account has not existed yet, it gets automatically created.
|
||||
|
||||
To prevent that every Shibboleth user can access your Moodle site you have to
|
||||
adapt the 'require valid-user' line in your webserver's config (see step 1) to
|
||||
allow only specific users. If you defined some authorization rules in step 1,
|
||||
these are checked by Shibboleth itself. Only users who met these rules
|
||||
actually can access /auth/shibboleth/index.php and get logged in.
|
||||
|
||||
You can use Shibboleth AND another authentication method (it was tested with
|
||||
manual login). So, if there are a few users that don't have a Shibboleth
|
||||
login, you could create manual accounts for them and they could use the manual
|
||||
login. For other authentication methods you first have to configure them and
|
||||
then set Shibboleth as your authentication method. Users can log in only via one
|
||||
authentication method unless they have two accounts in Moodle.
|
||||
|
||||
Shibboleth dual login with custom login page
|
||||
--------------------------------------------------------------------------------
|
||||
Of course you can create a dual login page that better fits your needs. For this
|
||||
to work, you have to set up the two authentication methods (e.g. 'Manual' and
|
||||
'Shibboleth') and specify an alternate login link to your own dual login page.
|
||||
On that page you basically need a link to the Shibboleth-protected page
|
||||
('/auth/shibboleth/index.php') for the Shibboleth login and a
|
||||
form that sends 'username' and 'password' to moodle/login/index.php.
|
||||
Consult the Moodle documentation for further instructions and requirements.
|
||||
|
||||
How to customize the way the Shibboleth user data is used in Moodle
|
||||
--------------------------------------------------------------------------------
|
||||
Among the Shibboleth settings in Moodle there is a field that should contain a
|
||||
path to a php file that can be used as data manipulation hook.
|
||||
You can use this if you want to further process the way your Shibboleth
|
||||
attributes are used in Moodle.
|
||||
|
||||
Example 1: Your Shibboleth federation uses an attribute that specifies the
|
||||
user's preferred language, but the content of this attribute is not
|
||||
compatible with the Moodle data representation, e.g. the Shibboleth
|
||||
attribute contains 'German' but Moodle needs a two letter value like
|
||||
'de'.
|
||||
Example 2: The country, city and street are provided in one Shibboleth attribute
|
||||
and you want these values to be used in the Moodle user profile. So
|
||||
You have to parse the corresponding attribute to fill the user fields.
|
||||
|
||||
If you want to use this hook you have to be a skilled PHP programmer. It is
|
||||
strongly recommended that you take a look at the file
|
||||
moodle/auth/shibboleth/lib.php, especially the function 'auth_get_userinfo'
|
||||
where this file is included.
|
||||
The context of the file is the same as within this login function. So you
|
||||
can directly edit the object $result.
|
||||
|
||||
Example file:
|
||||
|
||||
--
|
||||
<?PHP
|
||||
|
||||
// Set the zip code and the adress
|
||||
if ($_SERVER[$pluginconfig->field_map_address] != '')
|
||||
{
|
||||
// $address contains something like 'SWITCH$Limmatquai 138$CH-8021 Zurich'
|
||||
// We want to split this up to get:
|
||||
// institution, street, zipcode, city and country
|
||||
$address = $_SERVER[$pluginconfig->field_map_address];
|
||||
list($institution, $street, $zip_city) = split('\$', $address);
|
||||
ereg(' (.+)',$zip_city, $regs);
|
||||
$city = $regs[1];
|
||||
|
||||
ereg('(.+)-',$zip_city, $regs);
|
||||
$country = $regs[1];
|
||||
|
||||
$result["address"] = $street;
|
||||
$result["city"] = $city;
|
||||
$result["country"] = $country;
|
||||
$result["department"] = $institution;
|
||||
}
|
||||
?>
|
||||
--
|
||||
|
||||
Bugs
|
||||
--------------------------------------------------------------------------------
|
||||
Please send bug reports concerning the Shibboleth part to
|
||||
Lukas Haemmerle <haemmerle@switch.ch>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
In case of problems and questions with Shibboleth authentication, contact
|
||||
Lukas Haemmerle <haemmerle@switch.ch> or Markus Hagman <hagman@hytti.uku.fi>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
// Set default values
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
if (!isset($config->auth_instructions) or empty($pluginconfig->shib_user_attribute)) {
|
||||
$config->auth_instructions = get_string('auth_shib_instructions', 'auth', $CFG->wwwroot.'/auth/shibboleth/index.php');
|
||||
}
|
||||
|
||||
if (!isset ($pluginconfig->user_attribute)) {
|
||||
$pluginconfig->user_attribute = '';
|
||||
}
|
||||
if (!isset ($pluginconfig->convert_data)) {
|
||||
$pluginconfig->convert_data = '';
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" align="left">
|
||||
<p>
|
||||
<?php print_string("auth_shib_username_description", "auth") ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("username") ?>:</td>
|
||||
<td>
|
||||
<input name="pluginconfig_shib_user_attribute" type="text" size="30" value="<?php echo $pluginconfig->shib_user_attribute ?>">
|
||||
</td>
|
||||
<td></td>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php print_auth_lock_options($auth, $user_fields, '<!-- empty help -->', true, false); ?>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_shib_instructions_help","auth", htmlspecialchars($CFG->wwwroot.'/auth/shibboleth/index.php')) ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_convert_data", "auth") ?>:</td>
|
||||
<td>
|
||||
<input name="pluginconfig_convert_data" type="text" size="30" value="<?php echo $pluginconfig->convert_data?>">
|
||||
<?php
|
||||
if ($pluginconfig->convert_data && $pluginconfig->convert_data != '' && !is_readable($pluginconfig->convert_data)){
|
||||
echo '<br><font color="red">';
|
||||
print_string("auth_shib_convert_data_warning", "auth");
|
||||
echo '</font>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string("auth_shib_convert_data_description", "auth") ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Designed to be redirected from moodle/login/index.php
|
||||
|
||||
require('../../config.php');
|
||||
require('lib.php');
|
||||
|
||||
if (isloggedin() && $USER->username != 'guest') { // Nothing to do
|
||||
if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)){
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
} else {
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
redirect($urltogo);
|
||||
}
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
// Check whether Shibboleth is configured properly
|
||||
if (empty($pluginconfig->shib_user_attribute)) {
|
||||
error(get_string( 'shib_not_set_up_error', 'auth'));
|
||||
}
|
||||
|
||||
/// If we can find the Shibboleth attribute, save it in session and return to main login page
|
||||
if (!empty($_SERVER[$pluginconfig->shib_user_attribute])) { // Shibboleth auto-login
|
||||
$frm->username = $_SERVER[$pluginconfig->shib_user_attribute];
|
||||
$frm->password = substr(base64_encode($_SERVER[$pluginconfig->shib_user_attribute]),0,8);
|
||||
// The random password consists of the first 8 letters of the base 64 encoded user ID
|
||||
// This password is never used unless the user account is converted to manual
|
||||
|
||||
/// Check if the user has actually submitted login data to us
|
||||
|
||||
if ($user = authenticate_user_login($frm->username, $frm->password)) {
|
||||
|
||||
// Let's get them all set up.
|
||||
$USER = $user;
|
||||
|
||||
add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $USER->id, 0, $USER->id);
|
||||
|
||||
update_user_login_times();
|
||||
set_moodle_cookie($USER->username);
|
||||
set_login_session_preferences();
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.SITEID;
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
} else {
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
redirect($urltogo);
|
||||
}
|
||||
}
|
||||
|
||||
// If we can find any (user independent) Shibboleth attributes but no user
|
||||
// attributes we probably didn't receive any user attributes
|
||||
elseif (!empty($_SERVER['HTTP_SHIB_APPLICATION_ID'])){
|
||||
error(get_string( 'shib_no_attributes_error', 'auth' , '\''.$pluginconfig->shib_user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\''));
|
||||
} else {
|
||||
error(get_string( 'shib_not_set_up_error', 'auth'));
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,87 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
//CHANGELOG:
|
||||
//28.10.2004 SHIBBOLETH Authentication functions v.0.1
|
||||
//Distributed under GPL (c)Markus Hagman 2004-
|
||||
|
||||
function auth_user_login($username, $password) {
|
||||
global $CFG;
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
// If we are in the shibboleth directory then we trust the server var
|
||||
if (!empty($_SERVER[$pluginconfig->shib_user_attribute])) {
|
||||
return ($_SERVER[$pluginconfig->shib_user_attribute] == $username);
|
||||
} else {
|
||||
// If we are not, the user has used the manual login and the login name is
|
||||
// unknown, so we return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function auth_get_userinfo($username) {
|
||||
// reads user information from shibboleth attributes and return it in array()
|
||||
global $CFG;
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
// Check whether we have got all the essential attributes
|
||||
if (
|
||||
empty($_SERVER[$pluginconfig->shib_user_attribute])
|
||||
|| empty($_SERVER[$pluginconfig->field_map_firstname])
|
||||
|| empty($_SERVER[$pluginconfig->field_map_lastname])
|
||||
|| empty($_SERVER[$pluginconfig->field_map_email])
|
||||
) {
|
||||
error(get_string( 'shib_not_all_attributes_error', 'auth' , "'".$pluginconfig->shib_user_attribute."' ('".$_SERVER[$pluginconfig->shib_user_attribute]."'), '".$pluginconfig->field_map_firstname."' ('".$_SERVER[$pluginconfig->field_map_firstname]."'), '".$pluginconfig->field_map_lastname."' ('".$_SERVER[$pluginconfig->field_map_lastname]."') and '".$pluginconfig->field_map_email."' ('".$_SERVER[$pluginconfig->field_map_email]."')"));
|
||||
}
|
||||
|
||||
$attrmap = auth_shib_attributes();
|
||||
|
||||
$result = array();
|
||||
$search_attribs = array();
|
||||
|
||||
foreach ($attrmap as $key=>$value) {
|
||||
if (!empty($CFG->unicodedb)) {
|
||||
$result[$key]=$_SERVER[$value];
|
||||
} else {
|
||||
$result[$key]=utf8_decode($_SERVER[$value]);
|
||||
}
|
||||
}
|
||||
|
||||
// Provide an API to modify the information to fit the Moodle internal
|
||||
// data representation
|
||||
if (
|
||||
$pluginconfig->convert_data
|
||||
&& $pluginconfig->convert_data != ''
|
||||
&& is_readable($pluginconfig->convert_data)
|
||||
){
|
||||
|
||||
// Include a custom file outside the Moodle dir to
|
||||
// modify the variable $moodleattributes
|
||||
include($pluginconfig->convert_data);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function auth_shib_attributes(){
|
||||
//returns array containg attribute mappings between Moodle and shibboleth
|
||||
global $CFG;
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
$pluginconfig = (array) $pluginconfig;
|
||||
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang", "guid");
|
||||
|
||||
$moodleattributes = array();
|
||||
foreach ($fields as $field) {
|
||||
if ($pluginconfig["field_map_$field"]) {
|
||||
$moodleattributes[$field] = $pluginconfig["field_map_$field"];
|
||||
}
|
||||
}
|
||||
$moodleattributes['username']=$pluginconfig["shib_user_attribute"];
|
||||
|
||||
return $moodleattributes;
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user