Compare commits
1322 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f02856794 | |||
| 64a129a4f6 | |||
| 7e6bc94ad2 | |||
| b498108933 | |||
| 472a880aac | |||
| d0f6d395cf | |||
| 5beaf7799d | |||
| 23d27ffd09 | |||
| 6a0ecb49b9 | |||
| 1989dfae9c | |||
| 1ef5fb3886 | |||
| 78275891b4 | |||
| 036110e055 | |||
| b7ab75c6bf | |||
| 8886ee0942 | |||
| 5d789427fe | |||
| c11e28959d | |||
| 87d7fdc584 | |||
| 0e48704206 | |||
| a4e53fb1f4 | |||
| 5e7012bc32 | |||
| 8fdba9a133 | |||
| 7facd141a8 | |||
| 9c87a260b6 | |||
| 8ae05f2387 | |||
| 4de514f468 | |||
| 5d87b5d826 | |||
| c6dd61eb2d | |||
| b70ba1648d | |||
| 83ba3e7007 | |||
| 172d47a14c | |||
| c54473ea39 | |||
| 191e4336d1 | |||
| 2a0bb0af92 | |||
| 208af78ccd | |||
| 11cbf773ea | |||
| 1ae1e84ec5 | |||
| 4714df2e67 | |||
| 97d8cdf4f6 | |||
| f7a669d89c | |||
| f8a6a83698 | |||
| 28a774b13e | |||
| 901d0f94a8 | |||
| e80ca6fb8d | |||
| b8b0f6dbe9 | |||
| 687a4c0557 | |||
| c322b22437 | |||
| be66bb9645 | |||
| b6c8102625 | |||
| 9aca363c1a | |||
| 6bb0231b7b | |||
| acef19a1e7 | |||
| 42dc0e903b | |||
| 14637fc14f | |||
| 0b4362228b | |||
| 9abb5a2390 | |||
| 003991588b | |||
| 7f8337032d | |||
| c41a30806a | |||
| 54902ff056 | |||
| 854e6f0b2c | |||
| 641649b051 | |||
| bc6c0782e9 | |||
| 0ef1487687 | |||
| e1ace7dd20 | |||
| 7e78d96097 | |||
| 27619c6598 | |||
| 6ba567ac63 | |||
| 5bccb31ec7 | |||
| efed457566 | |||
| f20d4d22e9 | |||
| e92893695d | |||
| fa19bf31ea | |||
| 5e816a727e | |||
| ae89234a65 | |||
| 65c8ff4d85 | |||
| 8a699d416d | |||
| c1bf1d81a9 | |||
| 0c2a8be918 | |||
| 0e5947dc2f | |||
| 231765c8ba | |||
| fe97411051 | |||
| cdb21087da | |||
| a74f39abcb | |||
| 82ff36e758 | |||
| 1d68b9b631 | |||
| 0c51f82bba | |||
| eaf0b2d89f | |||
| 47bd45c3f7 | |||
| 0ab0450f92 | |||
| de59c77a9b | |||
| 9e6091197b | |||
| ca478f374d | |||
| fe859633e8 | |||
| 6e66067f5f | |||
| 2c5ed3d234 | |||
| 58314eeec4 | |||
| 7c789e82c1 | |||
| 75f8ac4310 | |||
| efda10c098 | |||
| 86756eef37 | |||
| 9ccba19a12 | |||
| b26eb35a28 | |||
| 42c19f0e8d | |||
| c1b6ab8118 | |||
| 4027500f9d | |||
| 52bc379ce5 | |||
| 11fe3a4d74 | |||
| 5f2099b846 | |||
| df1cbe9f48 | |||
| a26a0e25dd | |||
| 1ab72c8499 | |||
| 4fad07671c | |||
| 2e6e9b8bdb | |||
| ec96bbc3e9 | |||
| 1e41ee920e | |||
| 1ede1981b8 | |||
| 437a4bf65b | |||
| 2f495119f9 | |||
| d00727cc52 | |||
| f0c3da1e7e | |||
| 798488d5ff | |||
| 16c346df93 | |||
| f29752571b | |||
| 73f25e0fca | |||
| d404868d2b | |||
| b974afac9c | |||
| c9ab45220c | |||
| e9bd42a226 | |||
| c3e7db99f9 | |||
| 83fade0c0a | |||
| 004b18ddb1 | |||
| c5a48a8908 | |||
| 8264da3c50 | |||
| 5cbc7a8b67 | |||
| f022a9ba9c | |||
| ecf0c6af79 | |||
| c6dba19212 | |||
| db83128e9d | |||
| 8d3b909251 | |||
| c01706d2d9 | |||
| c550d531b9 | |||
| 1c63afd97e | |||
| e86ac958ef | |||
| 89a44c34ba | |||
| 50bdf52662 | |||
| 694df151b4 | |||
| 445ec0d7e5 | |||
| 033cc8a223 | |||
| f497c755aa | |||
| 9182889ff9 | |||
| 851ae37718 | |||
| 82aac29073 | |||
| 09d4003426 | |||
| 75129c58b5 | |||
| f2f438ac79 | |||
| 4830bb4c53 | |||
| dca2e99977 | |||
| 98774fcb6b | |||
| 75108389bc | |||
| 677c077839 | |||
| 3719d2e2ec | |||
| e0b6f1b499 | |||
| 6ac4900f6c | |||
| ab4f0d249b | |||
| e13b1d135f | |||
| d994661015 | |||
| 561216b9c5 | |||
| 7b78a84785 | |||
| 44af81f7a7 | |||
| 0ec5a6d1f8 | |||
| 4eaf7d4cb2 | |||
| d5567f7328 | |||
| d63eab1287 | |||
| ecf7b75f77 | |||
| a6e2a2300a | |||
| 85b6606215 | |||
| e012c1f164 | |||
| 7a6b6d5f19 | |||
| 6049058f5e | |||
| 88cfea17a9 | |||
| 3cb97ea9fb | |||
| 1cd5223e73 | |||
| f8f2157fa1 | |||
| e07fcc6ef8 | |||
| bec56a397f | |||
| e940f40580 | |||
| 3fa1abaa40 | |||
| 69731e2cc5 | |||
| 6cd4abdac1 | |||
| 11b1927bd4 | |||
| c8aec2b7bb | |||
| a73917523e | |||
| aa31415e59 | |||
| 1c4bcba381 | |||
| a7d9cb49e0 | |||
| 5e99e6706d | |||
| 11d03ce9ab | |||
| 4d7bf254fc | |||
| 55d79da54f | |||
| a00e29d60a | |||
| 06114e7b15 | |||
| bd97afd006 | |||
| 8fe324726c | |||
| 4ece33a9a2 | |||
| 6e1af255df | |||
| c008505902 | |||
| babcb224b4 | |||
| 4fbdff9cde | |||
| 1e563d8e1e | |||
| afb96b0d7f | |||
| 79bf17b640 | |||
| cbac6369e3 | |||
| 0365831211 | |||
| 85cedef306 | |||
| 6bf829136a | |||
| 602174a3dc | |||
| 9a62345785 | |||
| b36185320d | |||
| 6c2ba19cdd | |||
| 356f30227a | |||
| 4689a3cd66 | |||
| 4aa8faabdb | |||
| e9ea8708b6 | |||
| b3faa81ad1 | |||
| f2760822ab | |||
| 727ad2124d | |||
| 56459ea6e1 | |||
| a328acd2f2 | |||
| 6f095c04a9 | |||
| 0591a08cf1 | |||
| dd05085802 | |||
| 8d8c444f9d | |||
| 9f0b60ed6f | |||
| 603a35322a | |||
| 9160e17321 | |||
| 6deece3386 | |||
| 7992d2032c | |||
| fb2371cea7 | |||
| 08f89eca4d | |||
| cfb1b6cc26 | |||
| f90015cf76 | |||
| 4b37b038ca | |||
| 096da37850 | |||
| 6f738c12bd | |||
| dc7ebee343 | |||
| 57d3f3d924 | |||
| f50c21e36a | |||
| c3633061ff | |||
| c1f0c0b5fa | |||
| 20c2b54542 | |||
| 8e0508945c | |||
| f2a26e4d66 | |||
| e895355a17 | |||
| 1941ca6586 | |||
| d64da4713d | |||
| 2b5f8fd827 | |||
| ea76c04ee9 | |||
| c63db8b61d | |||
| a92af1e3ad | |||
| 2c5b0f8154 | |||
| 1d4392b33f | |||
| 44501b674c | |||
| ca02fba3e5 | |||
| 25d21f0821 | |||
| 91cbd9b2ab | |||
| 54c5330c1a | |||
| aa004b4cfe | |||
| 7fd73b41ed | |||
| 4eb4ad04db | |||
| 3fc29386af | |||
| b38c5f2aaf | |||
| 29a698998b | |||
| 01c47c874b | |||
| e19f672835 | |||
| c7ac64d2db | |||
| 346dd8ca80 | |||
| ec60a0d59a | |||
| 398d4a8db2 | |||
| b514da01a0 | |||
| 5c0375b658 | |||
| 12d4023e43 | |||
| dee7fd6048 | |||
| e685ded405 | |||
| 20f32ed028 | |||
| 671d4819bc | |||
| 65b95660c0 | |||
| c8d01fb2e3 | |||
| 0168d3c716 | |||
| c991030e0a | |||
| 1dcef80b9f | |||
| a6c50876a3 | |||
| ed103c1a63 | |||
| 8982c7d343 | |||
| 63e9fa8bdb | |||
| e1f41e2260 | |||
| d928959877 | |||
| 0507e988a6 | |||
| e12cda81ef | |||
| 5c07ac6a7a | |||
| 8b3943e0b5 | |||
| da64b6a98e | |||
| e2c77dd01f | |||
| 6c94871c56 | |||
| e61fd9ab16 | |||
| 3471fa7ba0 | |||
| 7f80097841 | |||
| 20c4d467b8 | |||
| 6d26b502ae | |||
| 989b4dd302 | |||
| 9ee9f0bb08 | |||
| 03f91c22c6 | |||
| b79eee4520 | |||
| 566b2664e2 | |||
| bcb91f2abd | |||
| c529fcdbe1 | |||
| 1de5a75c8c | |||
| 251514b4bb | |||
| 8e815df623 | |||
| 0aeb823dc4 | |||
| c3ee28c440 | |||
| 893345b32b | |||
| b7119d1440 | |||
| f046c91c6e | |||
| a8c8fbf706 | |||
| 91c21f2b1b | |||
| 44bb2a6e0e | |||
| 9c11d36fe9 | |||
| 6a7aa3f9c0 | |||
| 1cc24851a2 | |||
| ff19ce674d | |||
| e1b434b129 | |||
| 76adec164b | |||
| 6eff731b3c | |||
| c196b29413 | |||
| 2e390fcb96 | |||
| b6cec9e900 | |||
| ead1951a57 | |||
| a0680c868b | |||
| 73e5412854 | |||
| 2affe0355e | |||
| 727a216d59 | |||
| 829f54d594 | |||
| eb707720f1 | |||
| 2cdcb56958 | |||
| b1192638c2 | |||
| 1e4ffe8752 | |||
| 43bee0ad7e | |||
| f4d8478a9d | |||
| b70ea3c680 | |||
| 3eb93697aa | |||
| 3d6fb28178 | |||
| 0c6e298228 | |||
| e2d7af8412 | |||
| 6482f073ac | |||
| 425e7df6ee | |||
| 79cc5ce839 | |||
| 43079e1883 | |||
| 1edb6e3555 | |||
| 3693b82020 | |||
| e80ad3b374 | |||
| a00cd5ad53 | |||
| a23b767ebb | |||
| d79aa15c71 | |||
| 07a40e5714 | |||
| b4ddf27cdd | |||
| 32855b4019 | |||
| e26aaed2a4 | |||
| 5fe35ab0e3 | |||
| 6add2dbfc7 | |||
| aadb24e091 | |||
| 88170baf19 | |||
| 0d6254cd8d | |||
| 0719af8aac | |||
| 1a08f75e50 | |||
| 9ef1ef1869 | |||
| 447a482619 | |||
| 1058cca34c | |||
| 1a750b6307 | |||
| 1d05050c6c | |||
| 2ffa17100e | |||
| 881075b287 | |||
| 2a386c0d74 | |||
| e546494f92 | |||
| c273a2f31f | |||
| dffc320511 | |||
| 2852f047aa | |||
| e0a9d6b93a | |||
| 32abe3255a | |||
| c2533292f0 | |||
| 7b82fe3699 | |||
| ab4333e1c9 | |||
| b2326e175a | |||
| 12fcbb1fab | |||
| 7a8a43763d | |||
| df677142d9 | |||
| ecc0c8b802 | |||
| fc823bf378 | |||
| 524b4ec865 | |||
| 06a56158a6 | |||
| 89394c8d6f | |||
| 0757dc7cec | |||
| d10b0ae93e | |||
| f0ee6c7b0b | |||
| 9d7b35c73c | |||
| 32321469bc | |||
| 33c895943e | |||
| fd466ef02d | |||
| b92e44c50d | |||
| 80fec54702 | |||
| d4d9b7adbe | |||
| 233993afd3 | |||
| f27efbf4b2 | |||
| c952ea8d4b | |||
| 221f65b6c3 | |||
| d437835d78 | |||
| cf2b886d4d | |||
| 4031b89e9b | |||
| 39952eee06 | |||
| c5d569c6af | |||
| 327df50025 | |||
| de311acd1d | |||
| 3408a01243 | |||
| 3b5271f34f | |||
| bf87cc5594 | |||
| 3da5aee8ab | |||
| 13ff917186 | |||
| 79aa2098a5 | |||
| 83d86ba626 | |||
| a5c0415580 | |||
| 770d88ced5 | |||
| 96393dd450 | |||
| a0c2d453c7 | |||
| 965d344017 | |||
| 02948ab08b | |||
| abcb2346b7 | |||
| 4809b5ea1d | |||
| fd2beb3383 | |||
| 86ea9f3820 | |||
| 92d7d849e9 | |||
| 01a661a5b2 | |||
| 23b6f32087 | |||
| bb8a86d2a7 | |||
| fa498fc83b | |||
| 0b16c0de19 | |||
| 29d263f26d | |||
| d630d32338 | |||
| 07799f187b | |||
| d072f34f5a | |||
| bf2dc956fa | |||
| 9fb48afe1a | |||
| cf4f33c352 | |||
| a554e7c33c | |||
| 40ea07e4d0 | |||
| 6f96b83473 | |||
| 88639aa1c8 | |||
| 829dc9522c | |||
| 1ee838b5ee | |||
| 226b5a8e12 | |||
| 4c023bf561 | |||
| 319f61e0d2 | |||
| 54b02a56a7 | |||
| 6b20b6587a | |||
| cbcee839e2 | |||
| 17f2f65a05 | |||
| 579a6b8ff8 | |||
| c6fab7af24 | |||
| 29b46bfc99 | |||
| 76c8cbd44e | |||
| b5e241a788 | |||
| 1fc6bb6ee3 | |||
| 45bcdfa9db | |||
| ee74d5e92a | |||
| df256b30e0 | |||
| c0f988a1e5 | |||
| 61cf7b168b | |||
| 61fd69b8ae | |||
| 49d7755163 | |||
| 49b2930b8d | |||
| cf5b77cd85 | |||
| 34853e7bc5 | |||
| 5a1ca11989 | |||
| 8f3e3695e3 | |||
| 7070d53107 | |||
| d673f73a37 | |||
| 1687749a16 | |||
| dfc6579e1e | |||
| d27c760508 | |||
| 9629cc6d78 | |||
| 0eed750d84 | |||
| 5f87491394 | |||
| 9b8a859781 | |||
| d031cf09b0 | |||
| 70057cf44f | |||
| d36fc3561d | |||
| 276ce5fb85 | |||
| 1a26550217 | |||
| 964556fdb6 | |||
| 4fb6abdd28 | |||
| cbe80a54c1 | |||
| d48f9fcfda | |||
| ba2e6a32ea | |||
| cc7d926e11 | |||
| aec645efcd | |||
| f5897334fb | |||
| 33fefcb567 | |||
| 85ad80a03f | |||
| 9b1e8d728a | |||
| 230783ba85 | |||
| fa62ca18e8 | |||
| 51f4d70284 | |||
| 575ba2443d | |||
| 9a7af7f0c9 | |||
| 3104265b51 | |||
| abb7e59d46 | |||
| d7083e8737 | |||
| e03ec5ca2a | |||
| 84d3c29dad | |||
| 37de8a3494 | |||
| b89ad2fc1e | |||
| 89a660aaba | |||
| 60b482f67f | |||
| 3a60417d9d | |||
| d96c4f3aa9 | |||
| 8dbd402a97 | |||
| c8b383e37a | |||
| 903d01ccb4 | |||
| 3ed1ef582f | |||
| eceda4634f | |||
| becc6bfc56 | |||
| 25618ea469 | |||
| fe1c4e6d89 | |||
| e0675c474f | |||
| 0f49980a0e | |||
| e74466b0a0 | |||
| cb0b4be6b7 | |||
| a2b2a68587 | |||
| 65a4df9d55 | |||
| 84ea026b4c | |||
| f608db22a8 | |||
| c9abc270f2 | |||
| 8a2e373a63 | |||
| c803207669 | |||
| 2b9c339fe6 | |||
| bceea57e1d | |||
| b05de5d96a | |||
| 849e4bf620 | |||
| c596036229 | |||
| 07f7a76fb7 | |||
| ea8acc1cdc | |||
| 907d3d2ef7 | |||
| e1ee24102f | |||
| 5957cbb539 | |||
| ef907c4840 | |||
| 7d748cfae1 | |||
| 5f8d3a3664 | |||
| fbed5b62ee | |||
| dc8c752c5d | |||
| 0b286cf21e | |||
| 76f24be0a5 | |||
| 1b1b729eb9 | |||
| f532678fe2 | |||
| e301c30ae8 | |||
| 4f310cd444 | |||
| 86e44d10ee | |||
| 92262dcb59 | |||
| 7ee5671e18 | |||
| c179fe2aa7 | |||
| 53363a8365 | |||
| 42bc1ad5fe | |||
| ce62d03091 | |||
| e187b9391d | |||
| c5c9ef2004 | |||
| c3d609a3f2 | |||
| 7024225764 | |||
| ca52c559a3 | |||
| 22da13bd0a | |||
| 29fe9e516e | |||
| f2e652004f | |||
| 1d660f65e4 | |||
| 357532c491 | |||
| 24cf7e4dc5 | |||
| ef3064ee84 | |||
| 0bcf2a3561 | |||
| 806e50b3c7 | |||
| de488ea4dd | |||
| 0971a70695 | |||
| 1fdb043504 | |||
| 649333df15 | |||
| fac088a544 | |||
| 4f667d4209 | |||
| 1404dd0e18 | |||
| 50033d9128 | |||
| 469b28034b | |||
| 38238a83da | |||
| 40b145b1aa | |||
| f70e4ac4b0 | |||
| 2c95341c64 | |||
| a4fa13ef70 | |||
| 0fdef6bcdf | |||
| 5ef7459355 | |||
| ea41487667 | |||
| 76a0d881b9 | |||
| 5d0fa584ca | |||
| 8c43043fdc | |||
| 6b47cfd866 | |||
| 468e60dda3 | |||
| 7d7b5a6a66 | |||
| 101ff90760 | |||
| 9df3490a99 | |||
| 938cd0f631 | |||
| 4e712f7bd6 | |||
| 6228beb135 | |||
| 8e1314c7a2 | |||
| 52fd07555f | |||
| 01e87a4673 | |||
| fd9329e7f7 | |||
| c1db910dda | |||
| 14249f8441 | |||
| 06469948a7 | |||
| 478ca9a9e2 | |||
| b9f436c930 | |||
| 5a644bd7d3 | |||
| 0de476e235 | |||
| b2b719935f | |||
| 5f6c0b1e98 | |||
| 937d7b52c5 | |||
| a1b3c3e4cf | |||
| 168873c341 | |||
| 782aa08eaa | |||
| d517d25943 | |||
| 7251542cd8 | |||
| 7b41d89fe4 | |||
| d361e66afc | |||
| 48753e1a1f | |||
| 88637d4c73 | |||
| f4acdcc176 | |||
| deea1d84d9 | |||
| b7f278fe1d | |||
| dcfd0dff70 | |||
| 3be1259eb9 | |||
| 88d295948d | |||
| 981ceefdf7 | |||
| adad4fd9f0 | |||
| c2f03bc722 | |||
| bd6b9530ef | |||
| 964d6dc73d | |||
| 96b39e79bb | |||
| 969bf35c2f | |||
| f39917d8d9 | |||
| 6d1e31c34b | |||
| 2bb01a4e58 | |||
| 824816e06f | |||
| 5a2658ca41 | |||
| eac6bc964d | |||
| 4f68b47504 | |||
| 7341e97c93 | |||
| 98227d36e1 | |||
| 4d48860e68 | |||
| be9e88091a | |||
| 8b0aa6ffb3 | |||
| 40f0a960f7 | |||
| 16975e3616 | |||
| 4e6f474a58 | |||
| 6532f6b856 | |||
| a1357fc970 | |||
| 1feaffe800 | |||
| 5b645d1016 | |||
| 91d602fb1a | |||
| dcefa09e57 | |||
| 2b429140e8 | |||
| 5e3d6406e9 | |||
| 9ce6c24791 | |||
| 25aeb72573 | |||
| 80a147e820 | |||
| 09dac5eebb | |||
| 3f6ae60106 | |||
| 8b8b5f43ee | |||
| 32741d16c0 | |||
| b10dc2d6ba | |||
| 2aa6346fa9 | |||
| 301ff2fe75 | |||
| 9c45d35790 | |||
| 18bb2e0325 | |||
| c8c6addcac | |||
| dd4bba5a50 | |||
| 4aecfad306 | |||
| f3fb3a2b2d | |||
| 088a5e5e12 | |||
| 1dd72d43c3 | |||
| 35ca4ed7ee | |||
| 323f1e49e2 | |||
| de20d6f610 | |||
| c3258231df | |||
| 917cc0fca4 | |||
| 5c64d1cdd3 | |||
| 1aed3e931b | |||
| 1636626882 | |||
| dbfb58b629 | |||
| b09e69a0b0 | |||
| 3c09aeec29 | |||
| 7bc7f28148 | |||
| 5f32625c01 | |||
| 2c329933cc | |||
| 6f4f6fe13c | |||
| d15b1bd91e | |||
| 57efcbc6dd | |||
| 7f407d1f3f | |||
| 4996d3d28c | |||
| 6128c50b39 | |||
| e167032c03 | |||
| 89a8b837ed | |||
| eb7b88ea9d | |||
| b357805a0d | |||
| 8d48260f84 | |||
| b0846bc19a | |||
| e36af790df | |||
| 740d5f70d7 | |||
| e9d0bcbcfd | |||
| 73a1ee602a | |||
| aa1b2fcd73 | |||
| 2c0717e001 | |||
| fb283cda43 | |||
| 901e6b6e6b | |||
| 9aaaed344c | |||
| 34648c65c3 | |||
| 8d87913195 | |||
| 6216697b79 | |||
| e510af822e | |||
| 9ee255715d | |||
| 1161f96fb1 | |||
| 16124ac3f5 | |||
| 490e05c698 | |||
| 5e69cf407f | |||
| 579769bded | |||
| d0f1967418 | |||
| d3332366f1 | |||
| dac4e79866 | |||
| f353928ad3 | |||
| 07f2bb581e | |||
| 0cc653c3a7 | |||
| 0607dc743c | |||
| 075433aef3 | |||
| 96ba4407f6 | |||
| 407c22a76f | |||
| b18baa0c89 | |||
| 8f5bc35905 | |||
| bb1b4b4784 | |||
| 52a40768b2 | |||
| a597bebb84 | |||
| 6066fdd301 | |||
| 1324f3c6af | |||
| d7f7862841 | |||
| 725200b03a | |||
| c40bd6ac20 | |||
| b2d5b92b96 | |||
| f2bb550ac0 | |||
| 58ed94fd9c | |||
| ea858dd7a0 | |||
| 5821db186e | |||
| 14e02c54ef | |||
| 4226f24829 | |||
| ebe63af223 | |||
| 24fc7d266f | |||
| f04eda06be | |||
| 957f001f04 | |||
| 716111f60e | |||
| 58c28f0269 | |||
| 382c50809b | |||
| 3608b0f6f5 | |||
| 014d8a9ab8 | |||
| 377c6fa437 | |||
| 2535c5777d | |||
| 2fbfbcdd7b | |||
| d3753d4c37 | |||
| ab8734e816 | |||
| 9c855ec4f0 | |||
| b7e133298d | |||
| 2e0a1774b9 | |||
| cf885520e7 | |||
| 36c83a5057 | |||
| ba98e4b6b1 | |||
| 478625d186 | |||
| d19a3b1fe2 | |||
| c313f211c0 | |||
| a0c477deef | |||
| 5b0f288d95 | |||
| 441c87bcb9 | |||
| ce111128d3 | |||
| b22f9bac31 | |||
| 13c9933c8f | |||
| b9b203357e | |||
| 499ac00af3 | |||
| d4268066cb | |||
| a9da346030 | |||
| 7fdd558af0 | |||
| c90930bf10 | |||
| c53755d7c4 | |||
| 4249a9a8d0 | |||
| bc55fae7b9 | |||
| 5f0ea84bbb | |||
| 9f8d9231fe | |||
| edf1c2d30d | |||
| 81bfee2947 | |||
| 8df6f37dc0 | |||
| 58cfbd4a84 | |||
| 7530078651 | |||
| 6406c48cd8 | |||
| 58f33bd7cd | |||
| 317311d645 | |||
| b4e2cde355 | |||
| cb5e71a635 | |||
| c8b589bb29 | |||
| 9fd70b1ac3 | |||
| 6eabcba137 | |||
| 530b8335f1 | |||
| 699c28ff92 | |||
| 257f67470b | |||
| 2876a137d8 | |||
| 52c1134dd4 | |||
| ffb7b55ea4 | |||
| 09206b48f2 | |||
| 2fea1d8480 | |||
| 30cb9ab4b5 | |||
| da84ec2f77 | |||
| 615824e242 | |||
| f08cbc787f | |||
| 69ae7d08af | |||
| 25a9851943 | |||
| 73afb49262 | |||
| 22d2a0fdc4 | |||
| f24e18ee85 | |||
| b20337b888 | |||
| e35720ef02 | |||
| 472b380522 | |||
| 094f41207b | |||
| d1c56c3939 | |||
| c156eef71e | |||
| 7e022f9345 | |||
| edab76787e | |||
| 815a82746b | |||
| 354673e358 | |||
| e135be2639 | |||
| 67353f95ef | |||
| 460f06f2a5 | |||
| 65b4efb096 | |||
| 1f93813304 | |||
| 95f0d3d486 | |||
| 7ba1e94556 | |||
| a7a97c933c | |||
| e29ed82aee | |||
| eba970bffc | |||
| 05786bc6fd | |||
| 357d789540 | |||
| 855aa8f8d6 | |||
| 42d3772a3f | |||
| 3d1f6ce525 | |||
| 1244ed75d2 | |||
| ac757a9fad | |||
| 194726468d | |||
| ecbf88d217 | |||
| bc9cec3cd6 | |||
| f9cff66906 | |||
| 5450baa28a | |||
| 422eaecc13 | |||
| e10ed4e667 | |||
| ecfbaad4b4 | |||
| e4cedd797a | |||
| 9dadc1a89e | |||
| 5b0ae9d41c | |||
| 2ac3cee674 | |||
| f3bb54f36f | |||
| e8edd40064 | |||
| b1120b07c9 | |||
| 00fcb704d3 | |||
| 2b1ebff73c | |||
| 26549e7692 | |||
| efd780a339 | |||
| 0c4a965346 | |||
| 7371dc44d0 | |||
| 16a8215aa1 | |||
| 6d0ea08227 | |||
| 85a6b27786 | |||
| db7f11c3d7 | |||
| 98133a3eec | |||
| 52de50d2d5 | |||
| 122299654f | |||
| 52fa982eba | |||
| 5eab4b5c43 | |||
| e68e7af8ed | |||
| 2e52e3c14b | |||
| 2be7e8b347 | |||
| b8187e5ae0 | |||
| 74be4f9a8d | |||
| cb21e292fa | |||
| 3a8e6b5f4b | |||
| cdd11103b7 | |||
| dab41ccfdc | |||
| 49e8438753 | |||
| 12c3f08cb0 | |||
| 2f6b3b1966 | |||
| 9d39272ded | |||
| 14bc8df569 | |||
| 6dca5725ea | |||
| bf3932fc42 | |||
| 2c8a7e32db | |||
| 3c76674f76 | |||
| fba559da7a | |||
| 468f3c1cc4 | |||
| fe0df5f546 | |||
| 370454c947 | |||
| 3010db0e48 | |||
| ae6a28706b | |||
| 63fd025955 | |||
| f5e2a57092 | |||
| 1edf4fcaa6 | |||
| 191ac5e692 | |||
| ad50e44876 | |||
| 1a833b187a | |||
| 5983511872 | |||
| df644c8811 | |||
| 52183b89b1 | |||
| cfe70c4f90 | |||
| 98a68126ed | |||
| 39538ed31a | |||
| 42bdd31e68 | |||
| d0fa39395c | |||
| 737d922645 | |||
| 5e3b40221a | |||
| fd91ea6371 | |||
| cee15d365b | |||
| c29cc45005 | |||
| 2db4405ca0 | |||
| 2e3d0ff372 | |||
| fe2c9820e8 | |||
| 72df247c50 | |||
| d35f4bcabd | |||
| a46eb2ee08 | |||
| 18ac802f51 | |||
| d520a0a173 | |||
| e264c29fa1 | |||
| 406d542d00 | |||
| a02176516b | |||
| 27b0d869e6 | |||
| 21971c4ed0 | |||
| e1c24a9dba | |||
| dcb1b0cbdf | |||
| 9c94bb15aa | |||
| bec8a5ca4b | |||
| cee8d7fb63 | |||
| 5a67edcc09 | |||
| c5f0945604 | |||
| ff642e93ba | |||
| 5ebe26c7d0 | |||
| a616b09790 | |||
| e64dfa80dd | |||
| 4a4d46cade | |||
| 905746771f | |||
| 82a838920f | |||
| d913dc4244 | |||
| 4aa3ac1609 | |||
| 775d4dd817 | |||
| e0b0ef395f | |||
| a21fc2b7c9 | |||
| aee2784751 | |||
| 3e41bf36a3 | |||
| cf26a12c62 | |||
| 90abc87934 | |||
| 8c040068ca | |||
| 67a8ef4235 | |||
| c17f91905a | |||
| 1b2457c312 | |||
| 2fbd81b02d | |||
| e729020eda | |||
| 6e296332ca | |||
| 94640580f3 | |||
| 113130bd32 | |||
| 1443433431 | |||
| 4fd2dff9fe | |||
| 680da3b4af | |||
| dc0d77760a | |||
| c700b6c43b | |||
| adb2f6e2fc | |||
| def727dc7d | |||
| c5d16299de | |||
| 93b2625047 | |||
| b769175004 | |||
| 816f68c8aa | |||
| c3f0763f7b | |||
| e0dcb5734f | |||
| 321aae1d8b | |||
| 9bb32eb744 | |||
| 2c20f70dca | |||
| a3247baa3a | |||
| c0624b017b | |||
| 81b1951adf | |||
| 73c1140d6a | |||
| 20fe7276ff | |||
| dd8fb6e848 | |||
| 1ece975598 | |||
| 4308feffbd | |||
| 66674833f6 | |||
| 578462059e | |||
| bd8b6c6f0e | |||
| e5e43b42ec | |||
| f309507a9f | |||
| 5c3cf81dfb | |||
| 5bf11225c4 | |||
| c10f0b5df7 | |||
| abac5c2107 | |||
| d6c5e20610 | |||
| b9b4610906 | |||
| 03231ca0b3 | |||
| 6d53e3b77d | |||
| a0b22b3218 | |||
| 0db7057a78 | |||
| 7bc02fa10a | |||
| 01737697a4 | |||
| 2eb6412ef8 | |||
| 4fad751ed9 | |||
| e32e7ca09c | |||
| da7d308c32 | |||
| 4a625f17af | |||
| 9fa1dad004 | |||
| 651dfa878e | |||
| 50da41e264 | |||
| 6406bef13e | |||
| 5a2cfa7efb | |||
| 0bb30298d0 | |||
| 37553f8493 | |||
| 1761c44531 | |||
| d1869b995e | |||
| 5e01a18606 | |||
| 1ef00c891f | |||
| 2d910a2d08 | |||
| 3b61c3c5d6 | |||
| 17dec907b9 | |||
| c90daf0b4b | |||
| a69f876e76 | |||
| a960f39fbb | |||
| 474ce18912 | |||
| 6c8f0ed5a8 | |||
| 5ace54167e | |||
| d981f1b6e3 | |||
| 0810574be1 | |||
| ee5b1788f7 | |||
| 9a6222dd38 | |||
| 46cc45f293 | |||
| 8e8380fb97 | |||
| 5aef10640e | |||
| b34d0917a6 | |||
| 1067cb28f1 | |||
| f94e02f057 | |||
| fec8049d34 | |||
| a111b749fc | |||
| f42449f77e | |||
| cc13541244 | |||
| d67ad45602 | |||
| 0ef063825f | |||
| 09be6630de | |||
| 26b9be1d7a | |||
| 10692d97e6 | |||
| f327821e4e | |||
| b9fc85815e | |||
| 312f8b5410 | |||
| 6d163e8a59 | |||
| 888faa0559 | |||
| 62dec3d6b5 | |||
| 06979a542b | |||
| 2f4ae7848b | |||
| 9199bfc986 | |||
| 3fde815636 | |||
| ea6787cb2f | |||
| 4f0f9f52c6 | |||
| e628acf30d | |||
| 97d94ab7f2 | |||
| 675522cb1b | |||
| 69f2570655 | |||
| 9206c92895 | |||
| d3f8a394bc | |||
| de735d30a8 | |||
| 8afa0586cc | |||
| 72a054b9f9 | |||
| 643f215f0a | |||
| 6acfcce9a8 | |||
| 6be3c99802 | |||
| 20101a6092 | |||
| 4d044e6e84 | |||
| d08c400d31 | |||
| 770764f392 | |||
| 4f6af1254b | |||
| e3cd7f35b9 | |||
| 2ba609cc8c | |||
| 3d7a1cbf2b | |||
| b50eee807b | |||
| 6b64601101 | |||
| 28d21ce79e | |||
| 07387b3124 | |||
| df699778c4 | |||
| 2d7915885a | |||
| 9d24e151bc | |||
| 9fbed4dc26 | |||
| 9896fa3de5 | |||
| ea5cb3bbde | |||
| 732216d72a | |||
| b08068e829 | |||
| 1622a2d06f | |||
| 0d4a213943 | |||
| 98823d2ac0 | |||
| facf76eede | |||
| 41591a4a17 | |||
| cd22423ceb | |||
| 479c8e5958 | |||
| 271228d527 | |||
| d592dc462d | |||
| bfaf3c876b | |||
| 3954fbf809 | |||
| c63bcbf27c | |||
| 0242dc70f3 | |||
| 25957101a8 | |||
| 6d079b698f | |||
| 0456f1c62a | |||
| 5c6c7224eb | |||
| a40014f758 | |||
| 53b9b145ab | |||
| ded3459821 | |||
| 331b64ac3f | |||
| b89246267b | |||
| cdbba24134 | |||
| fa84313875 | |||
| e2d02f322e | |||
| 2b545bff3b | |||
| ec0e8976e9 | |||
| 24ad970192 | |||
| 83bf0c7ac3 | |||
| 2a55ad8736 | |||
| 25b68ad11e | |||
| d347fbefd6 | |||
| 6124af76ab | |||
| 893e4ecc77 | |||
| f5925fe29a | |||
| d07e7183e6 | |||
| c82589c6b5 | |||
| 2c0436b1a6 | |||
| a1e04405ff | |||
| 0516af71ef | |||
| 8f459f900b | |||
| 866885022f | |||
| 350ad0ef85 | |||
| 6b73dbaa20 | |||
| 291f7bd8ba | |||
| 40fb06a8d0 | |||
| c4563fe0fb | |||
| 17c9ed588d | |||
| 9480b8f1f4 | |||
| 6c45d66129 | |||
| ae29b65979 | |||
| e43dd3defa | |||
| 02c71b5a1e | |||
| b6f1f29147 | |||
| 6b9ab9e4fc | |||
| cffd20cede | |||
| 3372fd30ff | |||
| 8353441838 | |||
| 5d213075c3 | |||
| 5da1448d69 | |||
| cc082cb176 | |||
| 53e1d700bf | |||
| b9441c6e63 | |||
| 98aa5c1e21 | |||
| fa43dc51f8 | |||
| ef405b2a1b | |||
| 58c4dc24c7 | |||
| 741ee69fad | |||
| 754e6ee60b | |||
| 780d107619 | |||
| 61842c3a01 | |||
| 8c28ed7838 | |||
| 8bfac5b93d | |||
| 6d64a7091d | |||
| 22ad0a2e45 | |||
| e8eaff0171 | |||
| f3bfb270af | |||
| 260d699c17 | |||
| bb25fc1bca | |||
| 7bc4158521 | |||
| a0028106e3 | |||
| fc0ee03121 | |||
| 987d846223 | |||
| e7c83f42ef | |||
| c8198e1311 | |||
| 17620a4193 | |||
| 61b7abf279 | |||
| 4be10f9c9d | |||
| 606f29ff1d | |||
| 6a43c2aae4 | |||
| 29a4e4e556 | |||
| c65086aab0 | |||
| 6d85897f87 | |||
| 83c5e8f6b1 | |||
| 3d8a508910 | |||
| cb9b40a576 | |||
| e21964e8b0 | |||
| d15938ce5f | |||
| 22f52e2bf3 | |||
| b6f8c22bc3 | |||
| c89d8d7636 | |||
| a17794496c | |||
| e545ae1876 | |||
| 236ec5b9b6 | |||
| bae75cb826 | |||
| 89552fc789 | |||
| 3684c9f4e2 | |||
| db3a8b8a59 | |||
| 2b82654492 | |||
| bb4e105b49 | |||
| 1819221450 | |||
| 4ac7b06a76 | |||
| 379298d6ae | |||
| 49307babf5 | |||
| ac6e8f1133 | |||
| ce34811cdd | |||
| 51f2f92ca5 | |||
| 3bcee5d4c7 | |||
| 07a5d7cb3e | |||
| 7adc79d42c | |||
| 069577e929 | |||
| cffe2e51bd | |||
| 317dbb6f67 | |||
| 0c06ed4263 | |||
| abb8d37084 | |||
| f0cffb1e49 | |||
| 16b96bf3c9 | |||
| e47e30a11f | |||
| 4431f7188f | |||
| 7f6d1637d0 | |||
| 7e01657166 | |||
| 51cb63459b | |||
| 5992f232aa | |||
| 688d2f7d5b | |||
| b5cb37d9ea | |||
| e892f04d05 | |||
| 01c784002a | |||
| 267a7811fc | |||
| 0ac29d7f60 | |||
| c975e6afad | |||
| 80118a25eb | |||
| 13bc6270d6 | |||
| 85b2ee359b | |||
| 9cd2e8b3d4 | |||
| 2dcc168e63 | |||
| 05f64e893d | |||
| f40c81f9b7 | |||
| fac82b6f2a | |||
| d55bcca3a5 | |||
| bbc338767a | |||
| e88d8a3aa4 | |||
| bb0ceba26d | |||
| 2b63e793a2 | |||
| e0514c228d | |||
| 8f92195276 | |||
| 4a21ecc113 | |||
| 3217988a86 | |||
| 65497822b9 | |||
| 5bd1036974 | |||
| 01d08c35d6 | |||
| 8415a420df | |||
| fa614c0451 | |||
| 532231e9e8 | |||
| 98dba5cea6 | |||
| d29f2368de | |||
| 234c4e5276 | |||
| f5e5206c00 | |||
| d19c7d4459 | |||
| 50e20544b7 | |||
| a4f3ee5b1e | |||
| 192d6a6ea9 | |||
| 705e3a7f76 | |||
| d716e12ac4 | |||
| e8b9d71f03 | |||
| aabfe78ed5 | |||
| e41e727022 | |||
| fcee2e9780 | |||
| 94acf297c6 | |||
| b94257273c | |||
| fc071f0cfc | |||
| 6680874953 | |||
| dbf8f55057 | |||
| 477647c885 | |||
| 8fe1a6a72f | |||
| 6f1a4d5f55 | |||
| f96e334571 | |||
| 14b7da1527 | |||
| 101415b202 | |||
| 11e9ca5af1 | |||
| a4369a6ac4 | |||
| f0eda67f46 | |||
| 3ea6ab6652 | |||
| 4597517cf5 | |||
| d7a8d13cb4 | |||
| 289d8f834b | |||
| cb219861eb | |||
| 206f13e19a | |||
| 141f2eb969 | |||
| 54c362fdaf | |||
| b7f3681c1d | |||
| c71b977964 | |||
| f86849b8e5 | |||
| 0d07ff6170 | |||
| cf1db6bad7 | |||
| 7e85d1188a | |||
| 76de166ee1 | |||
| 76e2cb0a9b | |||
| 1b0649d558 | |||
| 05ac097e4c | |||
| 4c21136a5b | |||
| d38835ab1b | |||
| b0fe38fc78 | |||
| ce2e784b47 | |||
| 9114cce39b | |||
| 0d00dc375f | |||
| 27437410f4 |
+3
-3
@@ -5,9 +5,9 @@
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
$add = optional_param('add', "", PARAM_ALPHA);
|
||||
$remove = optional_param('remove', '', PARAM_ALPHA);
|
||||
$search = optional_param('search', '', PARAM_ALPHA);
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
optional_variable($search, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
+9
-51
@@ -2,9 +2,6 @@
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
include("../config.php");
|
||||
|
||||
$auth = optional_param( 'auth','',PARAM_CLEAN );
|
||||
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
@@ -21,7 +18,6 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
$config = (array)$config;
|
||||
@@ -36,6 +32,7 @@
|
||||
}
|
||||
|
||||
if (count($err) == 0) {
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
if (preg_match('/^pluginconfig_(.+?)$/', $name, $matches)) {
|
||||
$plugin = "auth/$auth";
|
||||
@@ -70,19 +67,11 @@
|
||||
$options[$module] = get_string("auth_$module"."title", "auth");
|
||||
}
|
||||
asort($options);
|
||||
if (!empty($auth) && in_array($auth, $modules)) {
|
||||
if (isset($_GET['auth']) && in_array($_GET['auth'], $modules)) {
|
||||
$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_filename($auth);
|
||||
require_once("$CFG->dirroot/auth/$auth/lib.php"); //just to make sure that current authentication functions are loaded
|
||||
if (! isset($config->guestloginbutton)) {
|
||||
@@ -97,12 +86,6 @@
|
||||
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");
|
||||
|
||||
if (empty($focus)) {
|
||||
@@ -152,32 +135,15 @@
|
||||
echo '<td/></tr>';
|
||||
|
||||
if ($auth != "email" and $auth != "none" and $auth != "manual") {
|
||||
// display box for URL to change password. NB now on a per-method basis (multiple auth)
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\" nowrap=\"nowrap\">";
|
||||
print_string("changepassword", "auth");
|
||||
echo ":</td>";
|
||||
echo "<td>";
|
||||
$passurl = $config->{'auth_'.$auth.'_changepasswordurl'};
|
||||
echo "<input type=\"text\" name=\"auth_{$auth}_changepasswordurl\" size=\"40\" value=\"$passurl\" />";
|
||||
echo "<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>";
|
||||
|
||||
}
|
||||
@@ -274,18 +240,10 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
|
||||
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"} = '';
|
||||
}
|
||||
optional_variable($pluginconfig->{"field_map_$field"}, '');
|
||||
optional_variable($pluginconfig->{"field_updatelocal_$field"}, '');
|
||||
optional_variable($pluginconfig->{"field_updateremote_$field"}, '');
|
||||
optional_variable($pluginconfig->{"field_lock_$field"}, '');
|
||||
|
||||
// define the fieldname we display to the user
|
||||
$fieldname = $field;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
$config = (object)$a_config;
|
||||
//weekdays conversions done. Continue
|
||||
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
backup_set_config($name, $value);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
unset($config->$item);
|
||||
}
|
||||
$block->config_save($config);
|
||||
print_header();
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
<form method="post" action="calendar.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table class="formtable">
|
||||
<tr>
|
||||
<th>adminseesall:</th>
|
||||
|
||||
+1
-10
@@ -30,20 +30,11 @@
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
if ($name == "sessioncookie") {
|
||||
$value = eregi_replace("[^a-zA-Z]", "", $value);
|
||||
}
|
||||
if ($name == "defaultallowedmodules") {
|
||||
$value = implode(',',$value);
|
||||
}
|
||||
if ($name == 'hiddenuserfields') {
|
||||
if (in_array('none', $value)) {
|
||||
$value = '';
|
||||
} else {
|
||||
$value = implode(',',$value);
|
||||
}
|
||||
}
|
||||
unset($conf);
|
||||
$conf->name = $name;
|
||||
$conf->value = $value;
|
||||
|
||||
+1
-148
@@ -74,9 +74,6 @@ class configvar {
|
||||
$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() {
|
||||
@@ -88,8 +85,7 @@ class configvarrss extends configvar {
|
||||
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));
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@@ -139,9 +135,6 @@ class configvarrss extends configvar {
|
||||
$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";
|
||||
@@ -213,71 +206,6 @@ class configvarrss extends configvar {
|
||||
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['defaultallowedmoules'] = 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
|
||||
@@ -375,23 +303,6 @@ class configvarrss extends configvar {
|
||||
$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>' );
|
||||
|
||||
|
||||
|
||||
@@ -554,66 +465,10 @@ class configvarrss extends configvar {
|
||||
$mail['denyemailaddresses'] = new configvar (get_string('configdenyemailaddresses', 'admin'),
|
||||
'<input name="denyemailaddresses" type="text" size="60" value="'.s($config->denyemailaddresses).'" alt="denyemailaddresses" />' );
|
||||
|
||||
/// 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.'" />');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -624,8 +479,6 @@ class configvarrss extends configvar {
|
||||
$configvars['mail'] = $mail;
|
||||
$configvars['user'] = $user;
|
||||
$configvars['permissions'] = $permissions;
|
||||
$configvars['requestedcourse'] = $reqcourse;
|
||||
$configvars['misc'] = $misc;
|
||||
$configvars['stats'] = $stats;
|
||||
|
||||
?>
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
$search = optional_param('search', '', PARAM_CLEAN);
|
||||
$add = optional_param('add', '', PARAM_CLEAN);
|
||||
$remove = optional_param('remove', '', PARAM_CLEAN );
|
||||
optional_variable($search, "");
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
+1
-96
@@ -27,7 +27,6 @@
|
||||
}
|
||||
|
||||
require_once("../config.php");
|
||||
require_once($CFG->dirroot.'/lib/adminlib.php');
|
||||
|
||||
if (!$alreadyadmin = isadmin()) {
|
||||
unset($_SESSION['USER']);
|
||||
@@ -35,8 +34,6 @@
|
||||
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
|
||||
@@ -107,28 +104,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...)
|
||||
|
||||
@@ -153,31 +134,6 @@
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -186,12 +142,6 @@
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("128M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
// if we are running from Apache, give httpd a hint that
|
||||
// it can recycle the process after it's done. Apache's
|
||||
// memory management is truly awful but we can help it.
|
||||
@apache_child_terminate();
|
||||
}
|
||||
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
|
||||
file_exists("$CFG->dirroot/backup/backuplib.php") and
|
||||
file_exists("$CFG->dirroot/backup/lib.php") and
|
||||
@@ -229,51 +179,6 @@
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Unset session variables and destroy it
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
$topframe = optional_param( 'topframe', '', PARAM_ALPHA);
|
||||
$bottomframe = optional_param( 'bottomframe', '', PARAM_ALPHA);
|
||||
$do = optional_param( 'do','',PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
@@ -17,13 +13,13 @@
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
if (!empty($topframe)) {
|
||||
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;
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ function editor_get_dictionaries () {
|
||||
$dictionaries = array();
|
||||
$dicts = array();
|
||||
|
||||
if(!($handle = @popen(escapeshellarg($cmd) .' dump dicts', 'r'))) {
|
||||
if(!($handle = @popen($cmd .' dump dicts', 'r'))) {
|
||||
return $strerror = "Couldn't create handle!";
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -1,79 +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
|
||||
$params = new Object;
|
||||
$param->filter = required_param( 'filter' );
|
||||
|
||||
// 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 ($config = data_submitted()) {
|
||||
|
||||
// check session key
|
||||
if (!confirm_sesskey()) {
|
||||
error( get_string('confirmsesskeybad', 'error' ) );
|
||||
}
|
||||
|
||||
// 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( substr( $param->filter, strpos( $param->filter, '/' )+1 ) );
|
||||
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" value="<?php print_string('savechanges'); ?>" /></center>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php print_simple_box_start("center"); ?>
|
||||
|
||||
<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"); ?>
|
||||
|
||||
<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[604800] = get_string('numdays', '', 7);
|
||||
$options[86400] = get_string('numdays', '', 1);
|
||||
$options[43200] = get_string('numhours', '', 12);
|
||||
$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 nowrap="nowrap" align="right"><?php p($strfilterall) ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "filterall", $CFG->filterall, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php p($strconfigfilterall) ?>
|
||||
</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(); ?>
|
||||
+138
-295
@@ -1,330 +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 (!$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_ALPHA );
|
||||
$params->filterpath = optional_param( 'filterpath', '',PARAM_PATH );
|
||||
$params->cachetext = optional_param( 'cachetext','0',PARAM_INT );
|
||||
$params->filteruploadedfiles = optional_param( 'filteruploadedfiles','',PARAM_ALPHA );
|
||||
$params->filterall = optional_param( 'filterall','',PARAM_ALPHA );
|
||||
$params->filtermatchoneperpage = optional_param( 'filtermatchoneperpage','',PARAM_ALPHA );
|
||||
$params->filtermatchonepertext = optional_param( 'filtermatchonepertext','',PARAM_ALPHA );
|
||||
/// Print headings
|
||||
|
||||
// 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');
|
||||
$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", 'admin');
|
||||
$strfilteruploadedfiles = get_string("filteruploadedfiles", "admin");
|
||||
$strfilterall = get_string("filterall", "admin");
|
||||
$strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles", 'admin');
|
||||
$strconfigfilterall = get_string("configfilterall", "admin");
|
||||
|
||||
// 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
|
||||
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();
|
||||
$filtersettings = array();
|
||||
$filterlocations = array('mod','filter');
|
||||
|
||||
$filterlocations = array("mod", "filter");
|
||||
|
||||
foreach ($filterlocations as $filterlocation) {
|
||||
$plugins = get_list_of_plugins( $filterlocation );
|
||||
foreach ($plugins as $plugin) {
|
||||
$pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php";
|
||||
$settingspath = "$CFG->dirroot/$filterlocation/$plugin/filterconfig.html";
|
||||
if (is_readable( $pluginpath )) {
|
||||
$name = trim( get_string("filtername", $plugin) );
|
||||
if (empty($name) or ($name == '[[filtername]]')) {
|
||||
$plugins = get_list_of_plugins($filterlocation);
|
||||
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 = $plugin;
|
||||
}
|
||||
$allfilters[ "$filterlocation/$plugin" ] = ucfirst( $name );
|
||||
}
|
||||
if (is_readable($settingspath)) {
|
||||
$filtersettings[] = "$filterlocation/$plugin";
|
||||
$allfilters["$filterlocation/$plugin"] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all the currently selected filters
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$installedfilters = explode( ',', $CFG->textfilters );
|
||||
}
|
||||
else {
|
||||
$installedfilters = array();
|
||||
}
|
||||
|
||||
/// Make an array of all the currently installed filters
|
||||
|
||||
// take this opportunity to clean up filters
|
||||
$oldinstalledfilters = $installedfilters;
|
||||
$installedfilters = array();
|
||||
foreach ($oldinstalledfilters as $key => $installedfilter ) {
|
||||
if (!empty( $installedfilter ) and array_key_exists( $installedfilter, $allfilters ) ) {
|
||||
$installedfilters[ $key ] = $installedfilter;
|
||||
}
|
||||
}
|
||||
$installedfilters = array_unique($installedfilters);
|
||||
set_config( 'textfilters', implode( ',', $installedfilters ) );
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$installedfilters = explode(',',$CFG->textfilters);
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
if (($params->action=="hide") and confirm_sesskey()) {
|
||||
$key=array_search( $params->filterpath, $installedfilters );
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error( "Filter $params->filterpath is not a currently installed filter" );
|
||||
}
|
||||
// just delete it
|
||||
unset( $installedfilters[ $key ] );
|
||||
set_config( 'textfilters', implode( ',', $installedfilters ) );
|
||||
}
|
||||
|
||||
if (($params->action=="show") and confirm_sesskey()) {
|
||||
// check filterpath is valid
|
||||
if (!array_key_exists( $params->filterpath, $allfilters ) ) {
|
||||
error( "Filter $params->filterpath is not a currently installed filter" );
|
||||
}
|
||||
if (array_search( $params->filterpath,$installedfilters ) ) {
|
||||
error( "Filter $params->filterpath is already active" );
|
||||
}
|
||||
// add it to installed filters
|
||||
$installedfilters[] = $params->filterpath;
|
||||
$installedfilters = array_unique($installedfilters);
|
||||
set_config( 'textfilters', implode( ',', $installedfilters ) );
|
||||
}
|
||||
|
||||
if (($params->action=="down") and confirm_sesskey()) {
|
||||
$key=array_search( $params->filterpath, $installedfilters );
|
||||
// check filterpath is valid
|
||||
if ($key===false ) {
|
||||
error( "Filter $params->filterpath is not a currently installed filter" );
|
||||
}
|
||||
if ($key>=(count($installedfilters)-1)) {
|
||||
error( "Filter $params->filterpath cannot be moved any further down" );
|
||||
}
|
||||
// swap with $key+1
|
||||
$fsave = $installedfilters[$key];
|
||||
$installedfilters[$key] = $installedfilters[$key+1];
|
||||
$installedfilters[$key+1] = $fsave;
|
||||
set_config( 'textfilters', implode( ',', $installedfilters ) );
|
||||
}
|
||||
|
||||
if (($params->action=="up") and confirm_sesskey()) {
|
||||
$key=array_search( $params->filterpath, $installedfilters );
|
||||
// check filterpath is valid
|
||||
if ($key===false ) {
|
||||
error( "Filter $params->filterpath is not a currently installed filter" );
|
||||
}
|
||||
if ($key<1) {
|
||||
error( "Filter $params->filterpath cannot be moved any further up" );
|
||||
}
|
||||
// swap with $key-1
|
||||
$fsave = $installedfilters[$key];
|
||||
$installedfilters[$key] = $installedfilters[$key-1];
|
||||
$installedfilters[$key-1] = $fsave;
|
||||
set_config( 'textfilters', implode( ',', $installedfilters ) );
|
||||
}
|
||||
|
||||
if (($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 ($installedfilters as $installedfilter) {
|
||||
$name = $allfilters[ $installedfilter ];
|
||||
$displayfilters[ $installedfilter ] = $name;
|
||||
}
|
||||
foreach ($allfilters 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->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->setup();
|
||||
|
||||
// some basic information
|
||||
$url = strip_querystring( qualified_me() );
|
||||
$myurl = "$url?sesskey=" . sesskey();
|
||||
$img = "$CFG->pixpath/t";
|
||||
|
||||
// iterate through filters adding to display table
|
||||
$updowncount = 1;
|
||||
$installedfilterscount = count( $installedfilters );
|
||||
foreach( $displayfilters as $path => $name ) {
|
||||
$upath = urlencode( $path );
|
||||
// get hide/show link
|
||||
if (in_array( $path, $installedfilters )) {
|
||||
$hideshow = "<a href=\"$myurl&action=hide&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"$img/hide.gif\" alt=\"hide\" /></a>";
|
||||
$hidden = false;
|
||||
$displayname = "<span>$name</span>";
|
||||
}
|
||||
else {
|
||||
$hideshow = "<a href=\"$myurl&action=show&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"$img/show.gif\" 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<$installedfilterscount) {
|
||||
$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()) && confirm_sesskey()) {
|
||||
unset($config->options);
|
||||
unset($config->sesskey);
|
||||
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) and confirm_sesskey()) {
|
||||
$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) and confirm_sesskey()) {
|
||||
$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->no,$txt->yes), "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) and confirm_sesskey()) {
|
||||
|
||||
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();
|
||||
|
||||
?>
|
||||
|
||||
+2
-4
@@ -7,8 +7,6 @@
|
||||
define('SEVERITY_SIGNIFICANT', 'significant');
|
||||
define('SEVERITY_CRITICAL', 'critical');
|
||||
|
||||
$resetsesserrorcounter = optional_param( 'resetsesserrorcounter' );
|
||||
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error('Only the admin can use this page');
|
||||
@@ -500,7 +498,7 @@ class problem_000011 extends problem_base {
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
if (!empty($resetsesserrorcounter)) {
|
||||
if (isset($_GET['resetsesserrorcounter'])) {
|
||||
if (get_field('config', 'name', 'name', 'session_error_counter')) {
|
||||
delete_records('config', 'name', 'session_error_counter');
|
||||
}
|
||||
@@ -539,4 +537,4 @@ TODO:
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
?>
|
||||
+64
-91
@@ -5,14 +5,10 @@
|
||||
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','');
|
||||
|
||||
|
||||
/// Check that PHP is of a sufficient version
|
||||
|
||||
@@ -75,7 +71,7 @@
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
@ob_end_flush();
|
||||
|
||||
|
||||
|
||||
/// Check if the main tables have been installed yet or not.
|
||||
|
||||
@@ -145,7 +141,7 @@
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string("databasechecking", "", $a);
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
if (empty($_GET['confirmupgrade'])) {
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
|
||||
@@ -206,18 +202,9 @@
|
||||
if (!set_config("release", $release)) {
|
||||
notify("ERROR: Could not update release version in database!!");
|
||||
}
|
||||
if (!empty($CFG->unicodedb)) {
|
||||
$defaultlang = 'en_utf8';
|
||||
} else {
|
||||
$defaultlang = 'en';
|
||||
}
|
||||
print_continue("index.php");
|
||||
print_simple_box_start("CENTER");
|
||||
if (file_exists("$CFG->dataroot/lang/$defaultlang/docs/release.html")) {
|
||||
include("$CFG->dataroot/lang/$defaultlang/docs/release.html");
|
||||
} else if (file_exists("$CFG->dirroot/lang/$defaultlang/docs/release.html")) {
|
||||
include("$CFG->dirroot/lang/$defaultlang/docs/release.html");
|
||||
}
|
||||
include("$CFG->dirroot/lang/en/docs/release.html");
|
||||
print_simple_box_end();
|
||||
print_continue("index.php");
|
||||
exit;
|
||||
@@ -262,9 +249,6 @@
|
||||
/// Check all enrolment plugins and upgrade if necessary
|
||||
upgrade_enrol_plugins("$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.
|
||||
@@ -309,8 +293,8 @@
|
||||
|
||||
/// 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) {
|
||||
if (!empty($_GET['id'])) {
|
||||
if ($_GET['id'] == $CFG->siteidentifier) {
|
||||
set_config('registered', time());
|
||||
}
|
||||
}
|
||||
@@ -328,11 +312,6 @@
|
||||
print_spacer(10,10);
|
||||
}
|
||||
|
||||
if (ini_get_bool('register_globals') && !ini_get_bool('magic_quotes_gpc')) {
|
||||
print_simple_box(get_string('globalsquoteswarning', 'admin'), 'center');
|
||||
}
|
||||
|
||||
|
||||
/// If no recently cron run
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
@@ -365,87 +344,81 @@
|
||||
$table->cellspacing = 0;
|
||||
$table->width = "40%";
|
||||
|
||||
$configdata = '<div class="adminlink"><a href="config.php">'.get_string('configvariables', 'admin').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpconfigvariables').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="site.php">'.get_string('sitesettings').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpsitesettings').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="../theme/index.php">'.get_string('themes').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpthemes').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="lang.php">'.get_string('language').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelplanguage').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="modules.php">'.get_string('managemodules').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagemodules').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="blocks.php">'.get_string('manageblocks').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanageblocks').'</span></div>';
|
||||
$configdata .= '<div class="adminlink"><a href="filters.php">'.get_string('managefilters').
|
||||
'</a> - <span class="explanation">'.get_string('adminhelpmanagefilters').'</span></div>';
|
||||
$configdata = "<font size=\"+1\"> </font><a href=\"config.php\">".get_string("configvariables", 'admin')."</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\">".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\">".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\">". get_string("editorsettings") ."</a> - <font size=\"1\">".
|
||||
get_string("adminhelpeditorsettings")."</font><br />";
|
||||
$configdata .= "<font size=\"+1\"> </font><a href=\"calendar.php\">". get_string('calendarsettings', 'admin') ."</a> - <font size=\"1\">".
|
||||
get_string('helpcalendarsettings', 'admin')."</font><br />";
|
||||
$configdata .= "<font size=\"+1\"> </font><a href=\"maintenance.php\">". get_string('sitemaintenancemode', 'admin') ."</a> - <font size=\"1\">".
|
||||
get_string('helpsitemaintenance', 'admin')."</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></font>",
|
||||
$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('enrolments').
|
||||
'</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\" alt=\"\" /></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></font>", $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="../course/log.php?id='.$site->id.'">'.get_string('logs').'</a></strong>',
|
||||
'<div class="explanation">'.get_string('adminhelplogs').'</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("<font size=\"+1\"><b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("courses")."</a></b></font>",
|
||||
"<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>",
|
||||
"<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>",
|
||||
"<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>',
|
||||
get_string('adminhelpmanagedatabase'));
|
||||
$table->data[] = array("<font size=\"+1\"><b><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></b></font>",
|
||||
"<font size=\"+1\"> </font>".get_string("adminhelpmanagedatabase"));
|
||||
}
|
||||
if (!empty($CFG->enablestats)) {
|
||||
$table->data[] = array('<strong><a href="reports.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>');
|
||||
|
||||
|
||||
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="../doc/?frame=release.html">'.$CFG->release.'</a> ('.$CFG->version.')<br />'.
|
||||
'Copyright © 1999-2006 Martin Dougiamas<br />'.
|
||||
'<a href="../doc/?frame=licence.html">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-2005 Martin Dougiamas<br />".
|
||||
"<a href=\"../doc/?frame=licence.html\">GNU Public License</a>";
|
||||
echo "<center><p><font size=\"1\">$copyrighttext</font></p></center>";
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
+1
-12
@@ -54,15 +54,6 @@
|
||||
'', '', 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\">";
|
||||
@@ -71,13 +62,11 @@
|
||||
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"));
|
||||
print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||
echo "</td></tr></table>";
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare\">$streditstrings</a>");
|
||||
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
|
||||
echo '</td></tr></table>';
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
<?php
|
||||
///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.
|
||||
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('CHANGE_SITE_LANG', 3);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
include('../config.php');
|
||||
$mode = optional_param('mode',0,PARAM_INT); //phase
|
||||
$pack = optional_param('pack','',PARAM_NOTAGS); //pack to install
|
||||
$displaylang = $pack;
|
||||
$uninstalllang = optional_param('uninstalllang','',PARAM_NOTAGS);
|
||||
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()) {
|
||||
if (optional_param('confirm')) {
|
||||
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
$source = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$langpack = $CFG->dataroot.'/temp/'.$pack.'.zip';
|
||||
$destination = $CFG->dataroot.'/lang/';
|
||||
if ($contents = file_get_contents($source)) { // Grab whole page
|
||||
if ($file = fopen($langpack, 'w')) { // Make local copy
|
||||
if (!fwrite($file, $contents)) { //copy zip to temp folder..
|
||||
error ('could not copy file');
|
||||
}
|
||||
fclose($file);
|
||||
|
||||
///recursively remove the whole directory since unzip does not overwrites anything
|
||||
if (file_exists($destination.$pack)) {
|
||||
@remove_dir($destination.$pack.'/');
|
||||
}
|
||||
//unpack the zip
|
||||
if (unzip_file($langpack, $destination, false)) {
|
||||
print_heading(get_string('langimportsuccess','admin'));
|
||||
} else {
|
||||
error('language installation failed');
|
||||
}
|
||||
//now, we update the md5key of the lang pack, this is used to check version
|
||||
$md5file = $CFG->dataroot.'/lang/'.$pack.'/'.$pack.'.md5';
|
||||
if ($file = fopen($md5file, 'w')) {
|
||||
fwrite($file, md5($contents)); //manually generate md5 from zip
|
||||
}
|
||||
fclose($file);
|
||||
@unlink ($langpack); //bye bye zip file, come back when you get a little better
|
||||
echo '<div align="center"><form action="langimport.php" method="POST">';
|
||||
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||
echo '</form></div>';
|
||||
}
|
||||
}
|
||||
} else { //print confirm box, no confirmation yet
|
||||
if (confirm_sesskey()) {
|
||||
print_simple_box_start('center','100%');
|
||||
echo '<div align="center">';
|
||||
echo '<form name="langform" action="langimport.php?mode=2" method="POST">';
|
||||
echo '<input name="pack" type="hidden" value="'.$pack.'" />';
|
||||
echo '<input name="displaylang" type="hidden" value="'.$displaylang.'" />';
|
||||
echo '<input name="confirm" type="hidden" value="1" />';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
print_heading(get_string('confirminstall','admin',$displaylang),2);
|
||||
echo '<input type="submit" value="'.get_string('ok').'"/>';
|
||||
echo ' <input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CHANGE_SITE_LANG: //change site language
|
||||
|
||||
if (confirm_sesskey) {
|
||||
$langconfig = get_record('config','name','lang');
|
||||
$sitelang = required_param('sitelangconfig',PARAM_NOTAGS);
|
||||
$langconfig->value = $sitelang;
|
||||
if (update_record('config',$langconfig)){
|
||||
echo '<div align="center">';
|
||||
notify (get_string('sitelangchanged','admin'));
|
||||
echo '<form action="langimport.php" method="POST">';
|
||||
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||
echo '</form></div>';
|
||||
} else {
|
||||
error ('can not update site language');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
|
||||
|
||||
if (!optional_param('confirm') && confirm_sesskey()) {
|
||||
print_simple_box_start('center','100%');
|
||||
echo '<div align="center">';
|
||||
echo '<form name="langform" action="langimport.php?mode=4" method="POST">';
|
||||
echo '<input name="uninstalllang" type="hidden" value="'.$uninstalllang.'" />';
|
||||
echo '<input name="confirm" type="hidden" value="1" />';
|
||||
print_heading(get_string('uninstallconfirm','admin',$uninstalllang),2);
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
echo '<input type="submit" value="'.get_string('uninstall','admin').'"/>';
|
||||
echo ' <input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
}
|
||||
else if (confirm_sesskey()) {
|
||||
$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) {
|
||||
echo '<div align="center">';
|
||||
print_string('langpackremoved','admin');
|
||||
echo '<form action="langimport.php" method="POST">';
|
||||
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||
echo '</form></div>';
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
error ('An error has occurred, language pack is not completely uninstalled, please check file permission');
|
||||
}
|
||||
}
|
||||
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();
|
||||
$update = 0; //any packs updated?
|
||||
$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 ($fp = fopen($source, 'r')) { /// attempt to get the list from Moodle.org.
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
} else {
|
||||
error('can not fopen!');
|
||||
}
|
||||
//and build an associative array
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
//first build a list of all the language packs,
|
||||
|
||||
//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
|
||||
|
||||
//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
|
||||
|
||||
$source = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$langpack = $CFG->dataroot.'/temp/'.$pack.'.zip';
|
||||
$destination = $CFG->dataroot.'/lang/';
|
||||
if ($contents = file_get_contents($source)) { // Grab whole page
|
||||
if ($file = fopen($langpack, 'w')) { // Make local copy
|
||||
if (!fwrite($file, $contents)) { //copy zip to temp folder..
|
||||
error ('could not copy file');
|
||||
}
|
||||
fclose($file);
|
||||
|
||||
//unpack the zip
|
||||
if (!unzip_file($langpack, $destination, false)) {
|
||||
error('language installation failed - can not unzip language pack');
|
||||
}
|
||||
//now, we update the md5key of the lang pack, this is used to check version
|
||||
$md5file = $CFG->dataroot.'/lang/'.$pack.'/'.$pack.'.md5';
|
||||
if ($file = fopen($md5file, 'w')) {
|
||||
fwrite($file, md5($contents));
|
||||
}
|
||||
fclose($file);
|
||||
@unlink ($langpack); //remove the zip file
|
||||
echo '<div align="center">';
|
||||
notify(print_string('langpackupdated','admin',$pack));
|
||||
$updated = 1;
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div align="center"><form action="langimport.php" method="POST">';
|
||||
if ($updated) {
|
||||
notify(print_string('langupdatecomplete','admin'));
|
||||
} else {
|
||||
notify(print_string('nolangupdateneeded','admin'));
|
||||
}
|
||||
echo '<input type="submit" value="'.get_string('ok').'" />';
|
||||
echo '</form></div>';
|
||||
|
||||
break;
|
||||
|
||||
default: //display choice mode
|
||||
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$remote = 0; //flag for reading from remote or local
|
||||
|
||||
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().'" />';
|
||||
$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 ($remote){
|
||||
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
||||
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$alang[0].')</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');
|
||||
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;
|
||||
}
|
||||
|
||||
?>
|
||||
+3
-1
@@ -37,6 +37,8 @@
|
||||
$moduleprefix = '';
|
||||
}
|
||||
|
||||
print_header();
|
||||
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($moduleprefix.$name, $value);
|
||||
}
|
||||
@@ -46,7 +48,7 @@
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$module = optional_param('module', '', PARAM_CLEANFILE);
|
||||
$module = required_param('module', '', PARAM_CLEANFILE);
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
|
||||
+4
-4
@@ -4,10 +4,10 @@
|
||||
require_once("../config.php");
|
||||
require_once("../course/lib.php");
|
||||
|
||||
$disable = optional_param('disable');
|
||||
$enable = optional_param('enable');
|
||||
$delete = optional_param('delete');
|
||||
$confirm = optional_param('confirm');
|
||||
optional_variable($disable);
|
||||
optional_variable($enable);
|
||||
optional_variable($delete);
|
||||
optional_variable($confirm);
|
||||
|
||||
require_login();
|
||||
|
||||
|
||||
+2
-15
@@ -29,20 +29,7 @@ function online_assignment_cleanup($output=false) {
|
||||
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
|
||||
// get the module id for assignments from db
|
||||
$arecord = get_record('modules', 'name', 'assignment');
|
||||
$aid = $arecord->id;
|
||||
|
||||
@@ -57,7 +44,7 @@ function online_assignment_cleanup($output=false) {
|
||||
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';
|
||||
$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;
|
||||
|
||||
+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,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/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);
|
||||
|
||||
$strheader = get_string('reports');
|
||||
|
||||
$strnav = '<a href="'.$CFG->wwwroot.'/admin/index.php">'.get_string('administration').'</a> -> '.$strheader;
|
||||
|
||||
$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($strheader,$strheader,$strnav,'','',true,' ');
|
||||
|
||||
echo '<form action="reports.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/reports.php');
|
||||
}
|
||||
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/admin/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[] = print_numeric_value($c->line1);
|
||||
if (isset($c->line2)) {
|
||||
$a[] = print_numeric_value($c->line2);
|
||||
}
|
||||
if (isset($c->line3)) {
|
||||
$a[] = print_numeric_value($c->line3);
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
function print_numeric_value($value) {
|
||||
list($whole, $decimals) = split ('[.,]', $value, 2);
|
||||
if (intval($decimals) > 0)
|
||||
return number_format($value,2,".",",");
|
||||
else
|
||||
return $value;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
{
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/lib/graphlib.php');
|
||||
|
||||
$report = required_param('report',0,PARAM_INT);
|
||||
$time = required_param('time',0,PARAM_INT);
|
||||
$numcourses = required_param('numcourses',20,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/reports.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();
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
+5
-20
@@ -29,34 +29,19 @@
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("frontpageformat") ?>:</td>
|
||||
<td>
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<td>
|
||||
<?php
|
||||
<td><?php
|
||||
$options = array(FRONTPAGENEWS => get_string("frontpagenews"),
|
||||
FRONTPAGECOURSELIST => get_string("frontpagecourselist"),
|
||||
FRONTPAGECATEGORYNAMES => get_string("frontpagecategorynames"),
|
||||
);
|
||||
$values = array(get_string('hide'), 1, 2);
|
||||
$seq = array_flip(explode(',',$form->frontpage));
|
||||
foreach ($seq as $k => $s) {
|
||||
$seq[$k]++;
|
||||
}
|
||||
FRONTPAGETOPICONLY => get_string("frontpagetopiconly"));
|
||||
if (count_records("course") > 200) {
|
||||
unset($options[FRONTPAGECOURSELIST]);
|
||||
if (isset($seq[FRONTPAGECOURSELIST])) {
|
||||
unset($options[1]);
|
||||
if ($form->frontpage == 1) {
|
||||
$form->frontpage = 2;
|
||||
}
|
||||
} else {
|
||||
$values[] = 3;
|
||||
}
|
||||
foreach ($options as $key => $option) {
|
||||
echo "<td>$option<br />";
|
||||
choose_from_menu ($values, "frontpage[$key]", isset($seq[$key])?$seq[$key]:0, "");
|
||||
}
|
||||
choose_from_menu ($options, "frontpage", "$form->frontpage", "");
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
|
||||
+1
-6
@@ -25,13 +25,8 @@
|
||||
|
||||
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) {
|
||||
if ($form->frontpage == FRONTPAGETOPICONLY) {
|
||||
$form->numsections = 1; // Force the topic display for this format
|
||||
}
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<?
|
||||
{
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/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_CLEAN);
|
||||
|
||||
$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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -3,7 +3,7 @@
|
||||
require("../config.php");
|
||||
require("$CFG->dirroot/mod/forum/lib.php");
|
||||
|
||||
$confirm = optional_param('confirm');
|
||||
optional_variable($confirm);
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
print_header("$site->shortname: $stradministration: $strupgradingdata", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strupgradingdata");
|
||||
|
||||
if (empty($confirm)) {
|
||||
if (empty($_GET['confirm'])) {
|
||||
notice_yesno(get_string("upgradeforumreadinfo", "admin"),
|
||||
"upgradeforumread.php?confirm=true&sesskey=$USER->sesskey",
|
||||
"index.php");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require("../config.php");
|
||||
|
||||
$confirm = optional_param('confirm');
|
||||
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");
|
||||
|
||||
+19
-131
@@ -5,7 +5,7 @@
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
$numusers = optional_param('numusers', 0, PARAM_INT);
|
||||
optional_variable($numusers, 0);
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
$struser = get_string("user");
|
||||
$strusers = get_string("users");
|
||||
$strusersnew = get_string("usersnew");
|
||||
$strusersupdated = get_string("usersupdated");
|
||||
$struploadusers = get_string("uploadusers");
|
||||
$straddnewuser = get_string("importuser");
|
||||
|
||||
@@ -63,15 +62,6 @@
|
||||
if ($um->preprocess_files()) {
|
||||
$filename = $um->files['userfile']['tmp_name'];
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
//Fix mac/dos newlines
|
||||
$text = my_file_get_contents($filename);
|
||||
$text = preg_replace('!\r\n?!',"\n",$text);
|
||||
@@ -118,20 +108,6 @@
|
||||
"group4" => 1,
|
||||
"group5" =>1);
|
||||
|
||||
// form data cleanup
|
||||
$frmpassword = optional_param('frmpassword', '', PARAM_ALPHA);
|
||||
$updateaccounts = optional_param('updateaccounts', false, PARAM_BOOL);
|
||||
$allowrenames = optional_param('allowrenames', false, PARAM_BOOL);
|
||||
|
||||
if ($frmpassword === 'create') {
|
||||
unset($required['password']);
|
||||
$optional['password'] = 1;
|
||||
}
|
||||
|
||||
if ($allowrenames) {
|
||||
$optional['oldusername'] = 1;
|
||||
}
|
||||
|
||||
// --- get header (field names) ---
|
||||
$header = split($csv_delimiter, fgets($fp,1024));
|
||||
// check for valid field names
|
||||
@@ -152,16 +128,6 @@
|
||||
}
|
||||
$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');
|
||||
|
||||
while (!feof ($fp)) {
|
||||
foreach ($optionalDefaults as $key => $value) {
|
||||
$user->$key = addslashes($adminuser->$key);
|
||||
@@ -175,7 +141,7 @@
|
||||
}
|
||||
if ($record[$header[0]]) {
|
||||
// add a new user to the database
|
||||
$newuser = optional_param('newuser', "", PARAM_CLEAN);
|
||||
optional_variable($newuser, "");
|
||||
|
||||
// add fields to object $user
|
||||
foreach ($record as $name => $value) {
|
||||
@@ -187,7 +153,7 @@
|
||||
'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
// password needs to be encrypted
|
||||
else if ($name == "password" && !empty($value)) {
|
||||
else if ($name == "password") {
|
||||
$user->password = md5($value);
|
||||
}
|
||||
else if ($name == "username") {
|
||||
@@ -212,7 +178,7 @@
|
||||
$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;
|
||||
}
|
||||
@@ -223,73 +189,20 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
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) && $frmpassword === 'create') {
|
||||
// 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;
|
||||
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]) {
|
||||
@@ -345,47 +258,22 @@
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
notify("$strusersnew: $numusers");
|
||||
|
||||
echo '<hr />';
|
||||
}
|
||||
|
||||
/// Print the form
|
||||
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.'">';
|
||||
print_heading(get_string('settings'));
|
||||
echo '<table>';
|
||||
echo '<tr><td>' . get_string('passwordhandling', 'auth') . "</td><td>";
|
||||
$passwordopts = array( infile => get_string('infilefield', 'auth'),
|
||||
create => get_string('createpassword', 'auth'),
|
||||
);
|
||||
choose_from_menu($passwordopts, 'frmpassword', 'infile');
|
||||
echo "</td></tr>";
|
||||
|
||||
echo '<tr><td>' . get_string('updateaccounts', 'admin') . "</td><td>";
|
||||
choose_from_menu($noyesoptions, 'updateaccounts', 0);
|
||||
echo "</td></tr>";
|
||||
|
||||
echo '<tr><td>' . get_string('allowrenames', 'admin') . "</td><td>";
|
||||
choose_from_menu($noyesoptions, 'allowrenames', 0);
|
||||
echo "</td></tr>";
|
||||
|
||||
echo '</table>';
|
||||
echo '</form></br>';
|
||||
'<input type="submit" value="'.$struploadusers.'">'.
|
||||
'</form></br>';
|
||||
echo '</center>';
|
||||
|
||||
print_footer($course);
|
||||
|
||||
+11
-11
@@ -2,20 +2,20 @@
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
$newuser = optional_param('newuser', "");
|
||||
$delete = optional_param('delete', "");
|
||||
$confirm = optional_param('confirm', "");
|
||||
$confirmuser = optional_param('confirmuser', "");
|
||||
$sort = optional_param('sort', "name", PARAM_ALPHA);
|
||||
$dir = optional_param('dir', "ASC");
|
||||
$page = optional_param('page', 0);
|
||||
$search = optional_param('search', "");
|
||||
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);
|
||||
}
|
||||
$lastinitial = optional_param('lastinitial', ""); // only show students with this last initial
|
||||
$firstinitial = optional_param('firstinitial', ""); // only show students with this first initial
|
||||
$perpage = optional_param('perpage', 30, PARAM_INT); // how many per page
|
||||
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);
|
||||
|
||||
@@ -1,435 +0,0 @@
|
||||
<?
|
||||
function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
//pointing to the num of records to process would be
|
||||
//useful. And it won't break anything, because the
|
||||
//crash system will continue the next time it was
|
||||
//executed. Also, the function could return:
|
||||
//0 = Some sort of error
|
||||
//1 = Finished completelly!
|
||||
//2 = Finished limit records
|
||||
//(using constants, of course ;-))
|
||||
//Then, all those errors, should be converted to
|
||||
//mtrace() and return 0. (showing the current
|
||||
//table/field/recordid)
|
||||
global $db, $CFG;
|
||||
|
||||
$ignoretables = array(); //list of tables to ignore
|
||||
$ignoretables[] = $CFG->prefix.'log';
|
||||
$ignoretables[] = $CFG->prefix.'cache_text';
|
||||
$ignoretables[] = $CFG->prefix.'cache_filters';
|
||||
|
||||
$textlib = textlib_get_instance(); //Eloy: I haven't measured this but perhaps
|
||||
|
||||
//Eloy: This lines should be uncomented in final release, isn't it? To
|
||||
//avoid double processing completely.
|
||||
|
||||
//if unicodedb is set, migration is complete. die here;
|
||||
/* if ($CFG->unicodedb) {
|
||||
error ('unicode db migration has already been performed!');
|
||||
}
|
||||
*/
|
||||
if (!$crash = get_record('config','name','dbmigration')) {
|
||||
|
||||
$migrationconfig = new object;
|
||||
$migrationconfig->name = 'dbmigration';
|
||||
$migrationconfig->value = '-1';
|
||||
insert_record('config',$migrationconfig); //process initiated
|
||||
|
||||
} else {
|
||||
|
||||
$crashdata = explode('##',$crash->value);
|
||||
$crash->table = $crashdata[0];
|
||||
$crash->field = $crashdata[1];
|
||||
$crash->record = $crashdata[2];
|
||||
|
||||
print_heading('Resume information :');
|
||||
echo '<br>Resuming from @ table : '.$crash->table;
|
||||
echo '<br>Resuming from @ field : '.$crash->field;
|
||||
echo '<br>Resuming from @ record : '.$crash->record;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/lib/xmlize.php');
|
||||
|
||||
//one gigantic array to hold all db table information read from all the migrate2utf8.xml file.
|
||||
$xmls = array();
|
||||
|
||||
/*****************************************************************************
|
||||
* traverse order is mod->backup->block->block_plugin->enroll_plugin->global *
|
||||
*****************************************************************************/
|
||||
|
||||
///mod
|
||||
if (!$mods = get_list_of_plugins('mod')) {
|
||||
error('No modules installed!');
|
||||
}
|
||||
|
||||
foreach ($mods as $mod){
|
||||
if (file_exists($CFG->dirroot.'/mod/'.$mod.'/db/migrate2utf8.xml')) {
|
||||
$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/mod/'.$mod.'/db/migrate2utf8.xml'));
|
||||
}
|
||||
}
|
||||
|
||||
///Backups
|
||||
//$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/backup/db/migrate2utf8.xml'));
|
||||
|
||||
///Blocks
|
||||
//$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/blocks/db/migrate2utf8.xml'));
|
||||
|
||||
///Block Plugins
|
||||
if (!$blocks = get_list_of_plugins('blocks')) {
|
||||
//error('No blocks installed!'); //Eloy: Is this a cause to stop?
|
||||
}
|
||||
|
||||
foreach ($blocks as $block){
|
||||
if (file_exists($CFG->dirroot.'/blocks/'.$block.'/db/migrate2utf8.xml')) {
|
||||
//$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/blocks/'.$block.'/db/migrate2utf8.xml'));
|
||||
}
|
||||
}
|
||||
|
||||
///Enrol
|
||||
|
||||
if (!$enrols = get_list_of_plugins('enrol')) {
|
||||
//error('No blocks installed!'); //Eloy: enrol, not blocks :-) Is this a cause to stop?
|
||||
}
|
||||
|
||||
foreach ($enrols as $enrol){
|
||||
if (file_exists($CFG->dirroot.'/enrol/'.$enrol.'/db/migrate2utf8.xml')) {
|
||||
//$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/enrol/'.$enrol.'/db/migrate2utf8.xml'));
|
||||
}
|
||||
}
|
||||
|
||||
///Lastly, globals
|
||||
|
||||
//$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/lib/db/migrate2utf8.xml'));
|
||||
|
||||
/************************************************************************
|
||||
* Now we got all our tables in order *
|
||||
************************************************************************/
|
||||
|
||||
foreach ($xmls as $xml) { ///foreach xml file, we must get a list of tables
|
||||
$dir = $xml['DBMIGRATION']['@']['type'];
|
||||
$dbtables = $xml['DBMIGRATION']['#']['TABLES'][0]['#']['TABLE']; //real db tables
|
||||
|
||||
foreach ($dbtables as $dbtable) {
|
||||
$dbtablename = $dbtable['@']['name'];
|
||||
if ($crash && ($dbtablename != $crash->table)) { //resuming from crash
|
||||
continue;
|
||||
}
|
||||
|
||||
print_heading("<br><b>Processsing db table ".$dbtablename.'...</b>');
|
||||
|
||||
if (!empty($dbtable['#']) && ($fields = $dbtable['#']['FIELDS'][0]['#']['FIELD']) and (!in_array($dbtablename, $ignoretables))) {
|
||||
|
||||
$colnames = array();
|
||||
$coltypes = array(); //array to hold all column types for the table
|
||||
$collengths = array(); //array to hold all column lengths for the table
|
||||
$defaults = array(); //array to hold defaults, if any
|
||||
//reset holders
|
||||
$addindexarray = array();
|
||||
$adduniqueindexarray = array();
|
||||
$addprimaryarray = array();
|
||||
|
||||
foreach ($fields as $field){
|
||||
|
||||
//if in crash state, and field name is not the same as crash field name
|
||||
|
||||
$fieldname = $field['@']['name'];
|
||||
$method = $field['@']['method'];
|
||||
$type = $field['@']['type'];
|
||||
$length = $field['@']['length'];
|
||||
|
||||
if ($crash && ($crash->field != $fieldname)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dropindex = $field['@']['dropindex'];
|
||||
$addindex = $field['@']['addindex'];
|
||||
$adduniqueindex = $field['@']['adduniqueindex'];
|
||||
|
||||
$dropprimary = $field['@']['dropprimary'];
|
||||
$addprimary = $field['@']['addprimary'];
|
||||
$defaults[] = isset($field['@']['default'])?"'".$field['@']['default']."'":"''";
|
||||
|
||||
$colnames[] = $fieldname;
|
||||
$coltypes[] = $type;
|
||||
$collengths[]= $length;
|
||||
|
||||
echo "<br>--><b>processsing db field ".$fieldname.'</b>';
|
||||
echo "<br>---><b>method ".$method.'</b>';
|
||||
|
||||
$patterns[]='/RECORDID/i'; //for preg_replace
|
||||
$patterns[]='/\{\$CFG\-\>prefix\}/i'; //same here
|
||||
|
||||
if ($method == 'PLAIN_SQL_UPDATE') {
|
||||
$sqldetectuser = $field['#']['SQL_DETECT_USER'][0]['#'];
|
||||
$sqldetectcourse = $field['#']['SQL_DETECT_COURSE'][0]['#'];
|
||||
}
|
||||
else if ($method == 'PHP_FUNCTION') {
|
||||
$phpfunction = 'migrate2utf8_'.$dbtablename.'_'.$fieldname;
|
||||
}
|
||||
|
||||
///get the total number of records for this field
|
||||
|
||||
$totalrecords = count_records($dbtablename);
|
||||
$counter = 0;
|
||||
$recordsetsize = 4;
|
||||
|
||||
if ($crash) { //if resuming from crash
|
||||
//find the number of records with id smaller than the crash id
|
||||
$indexSQL = 'SELECT COUNT(*) FROM '.$CFG->prefix.$dbtablename.' WHERE id < '.$crash->record;
|
||||
$counter = count_records_sql($indexSQL);
|
||||
}
|
||||
|
||||
echo "<br>Total number of recrods is ..".$totalrecords;
|
||||
|
||||
while($counter < $totalrecords) { //while there is still something restore_create_logs()
|
||||
$SQL = 'SELECT * FROM '.$CFG->prefix.$dbtablename.' '.sql_paging_limit($counter, $recordsetsize);
|
||||
echo "<br> SQL: ".$SQL;
|
||||
if ($records = get_records_sql($SQL)) {
|
||||
foreach ($records as $record) {
|
||||
|
||||
//if we are up this far, either no crash, or crash with same table, field name.
|
||||
if ($crash){
|
||||
if ($crash->record != $record->id) {
|
||||
continue;
|
||||
} else {
|
||||
$crash = 0;
|
||||
print_heading('recovering from '.$dbtablename.'--'.$fieldname.'--'.$record->id);
|
||||
}
|
||||
}
|
||||
|
||||
$migrationconfig = get_record('config','name','dbmigration');
|
||||
$migrationconfig->name = 'dbmigration';
|
||||
$migrationconfig->value = $dbtablename.'##'.$fieldname.'##'.$record->id;
|
||||
update_record('config',$migrationconfig);
|
||||
|
||||
$replacements = array(); //manual refresh
|
||||
$replacements[] = $record->id;
|
||||
$replacements[] = $CFG->prefix;
|
||||
|
||||
switch ($method){
|
||||
case 'PLAIN_SQL_UPDATE': //use the 2 statements to update
|
||||
|
||||
if (!empty($record->{$fieldname})) { //only update if not empty
|
||||
//$db->debug=999;
|
||||
//replace $CFG->prefix, and USERID in the queries
|
||||
$userid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectuser));
|
||||
$courseid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectcourse));
|
||||
//$db->debug=0;
|
||||
///get course, user, site lang
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($courseid->course);
|
||||
$userlang = get_user_lang($userid->userid);
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
|
||||
/// Convert the text
|
||||
//$db->debug=999;
|
||||
$result = $textlib->convert($record->{$fieldname}, $fromenc);
|
||||
//$db->debug=0;
|
||||
|
||||
$newrecord = new object;
|
||||
$newrecord->id = $record->id;
|
||||
$newrecord->{$fieldname} = $result;
|
||||
if ($dbtablename == "data_content"){
|
||||
echo "<br>here we go ".$record->{$fieldname};
|
||||
echo "<br>after conversion".$result;
|
||||
print_object($newrecord);
|
||||
}
|
||||
update_record($dbtablename,$newrecord);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'PHP_FUNCTION'; //use the default php function to execute
|
||||
//$db->debug=999;
|
||||
require_once($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php');
|
||||
$phpfunction($record->id);
|
||||
//$db->debug=0;
|
||||
break;
|
||||
|
||||
default: //no_conv, don't do anything ;-)
|
||||
break;
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
} //close the while loop
|
||||
//change field endocing here??
|
||||
|
||||
if ($CFG->dbtype == 'mysql') {
|
||||
if ($dropindex){ //drop index if index is varchar, text etc type
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' DROP INDEX '.$dropindex.';';
|
||||
execute_sql($SQL);
|
||||
} else if ($dropprimary) { //drop primary key
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' DROP PRIMARY KEY;';
|
||||
execute_sql($SQL);
|
||||
}
|
||||
|
||||
//BLOB TIME!
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' CHANGE '.$fieldname.' '.$fieldname.' BLOB;';
|
||||
} else {
|
||||
//posgresql code here
|
||||
}
|
||||
//$db->debug=999;
|
||||
execute_sql($SQL);
|
||||
//$db->debug=0;
|
||||
|
||||
//add index back
|
||||
if ($addindex){
|
||||
$addindexarray[] = $addindex;
|
||||
} else if ($adduniqueindex) {
|
||||
$adduniqueindexarray[] = $adduniqueindex;
|
||||
} else if ($addprimary) {
|
||||
$addprimaryarray[] = $addprimary;
|
||||
}
|
||||
}
|
||||
|
||||
//change table encoding here (change column encoding together here?)
|
||||
if ($CFG->dbtype == 'mysql') {
|
||||
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
|
||||
|
||||
for ($i=0;$i<sizeof($colnames);$i++) {
|
||||
|
||||
$thiscolname = $colnames[$i];
|
||||
$thistype = $coltypes[$i];
|
||||
$thislength = $collengths[$i];
|
||||
|
||||
$SQL.= ' CHANGE '.$thiscolname.' '.$thiscolname.' '.$thistype;
|
||||
if ($thislength > 0) {
|
||||
$SQL.='('.$thislength.')';
|
||||
}
|
||||
$SQL.=' CHARACTER SET utf8 NOT NULL DEFAULT '.array_shift($defaults).', ';
|
||||
}
|
||||
|
||||
$SQL = rtrim($SQL, ', ');
|
||||
$SQL.=';';
|
||||
} else { //posgresql query here
|
||||
|
||||
}
|
||||
//$db->debug=999; // Eloy: Silly thing, what if you save the current value and then,
|
||||
echo $SQL; // after execute_sql(), restore it
|
||||
execute_sql($SQL); //change charset for columns
|
||||
//$db->debug=0;
|
||||
/**********************************
|
||||
* Add the index back *
|
||||
*********************************/
|
||||
$alter = 0;
|
||||
|
||||
if ($CFG->dbtype=='mysql'){
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
|
||||
|
||||
if (!empty($addindexarray)) {
|
||||
foreach ($addindexarray as $aidx){
|
||||
$SQL .= ' ADD INDEX '.$aidx.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($adduniqueindexarray)) {
|
||||
foreach ($adduniqueindexarray as $auidx){
|
||||
$SQL .= ' ADD UNIQUE INDEX '.$auidx.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($addprimaryarray)) {
|
||||
foreach ($addprimaryarray as $apm){
|
||||
$SQL .= ' ADD PRIMARY KEY '.$apm.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
$SQL = rtrim($SQL, ', ');
|
||||
$SQL.=';';
|
||||
|
||||
} else {
|
||||
///posgresql code here
|
||||
|
||||
}
|
||||
|
||||
if ($alter) {
|
||||
execute_sql($SQL);
|
||||
}
|
||||
///Done adding indexes back!
|
||||
} //if there are fields
|
||||
//now we modify the table encoding
|
||||
|
||||
$SQL = 'ALTER TABLE '.$dbtablename.' CHARACTER SET utf8';
|
||||
//$db->debug=999;
|
||||
execute_sql($SQL);
|
||||
//$db->debug=0;
|
||||
}
|
||||
}
|
||||
|
||||
//set config unicode db to 1
|
||||
$SQL = 'ALTER DATABASE '.$CFG->dbname.' CHARACTER SET utf8';
|
||||
execute_sql($SQL);
|
||||
delete_records('config','name','dbmigration'); //bye bye
|
||||
}
|
||||
|
||||
|
||||
/* returns the course lang
|
||||
* @param int courseid
|
||||
* @return string
|
||||
*/
|
||||
function get_course_lang($courseid) {
|
||||
if ($course = get_record('course','id',$courseid)){
|
||||
return $course->lang;
|
||||
}
|
||||
}
|
||||
|
||||
/* returns the teacher's lang
|
||||
* @param int courseid
|
||||
* @return string
|
||||
*/
|
||||
function get_main_teacher_lang($courseid) {
|
||||
//editting teacher > non editting teacher
|
||||
global $CFG;
|
||||
$SQL = 'SELECT u.lang from '.$CFG->prefix.'user_teachers ut,
|
||||
'.$CFG->prefix.'course c,
|
||||
'.$CFG->prefix.'user u WHERE
|
||||
c.id = ut.course AND ut.course = '.$courseid.' AND u.id = ut.userid ORDER BY ut.authority ASC';
|
||||
|
||||
if ($teacher = get_record_sql($SQL)) {
|
||||
return $teacher->lang;
|
||||
}
|
||||
}
|
||||
|
||||
function get_original_encoding($sitelang, $courselang, $userlang){
|
||||
global $CFG;
|
||||
$lang = '';
|
||||
if ($courselang) {
|
||||
$lang = $courselang;
|
||||
}
|
||||
else if ($userlang) {
|
||||
$lang = $userlang;
|
||||
}
|
||||
else if ($sitelang) {
|
||||
$lang = $sitelang;
|
||||
}
|
||||
else {
|
||||
error ('no language found!');
|
||||
}
|
||||
$langfile = $CFG->dirroot.'/lang/'.$lang.'/moodle.php';
|
||||
$result = get_string_from_file('thischarset', $langfile, "\$resultstring");
|
||||
eval($result);
|
||||
return $resultstring;
|
||||
}
|
||||
|
||||
/* returns the user's lang
|
||||
* @param int userid
|
||||
* @return string
|
||||
*/
|
||||
function get_user_lang($userid) {
|
||||
if ($user = get_record('user','id',$userid)){
|
||||
return $user->lang;
|
||||
}
|
||||
}
|
||||
|
||||
// a placeholder for now
|
||||
function log_the_problem_somewhere() { //Eloy: Nice function, perhaps we could use it, perhpas no. :-)
|
||||
|
||||
}
|
||||
+7
-21
@@ -1,27 +1,13 @@
|
||||
<?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";
|
||||
}
|
||||
optional_variable($config->cas_hostname,"");
|
||||
optional_variable($config->cas_port,"");
|
||||
optional_variable($config->cas_version,"");
|
||||
optional_variable($config->cas_baseuri,"");
|
||||
optional_variable($config->cas_language,"");
|
||||
optional_variable($config->cas_use_cas,"");
|
||||
optional_variable($config->cas_create_user,"0");
|
||||
?>
|
||||
|
||||
|
||||
|
||||
+10
-9
@@ -99,9 +99,12 @@ function cas_authenticate_user_login ($username, $password) {
|
||||
|
||||
global $CFG;
|
||||
$cas_validate=true;
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(int)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
phpCAS::setLang($CFG->cas_language);
|
||||
phpCAS::forceAuthentication();
|
||||
if (!phpCAS::isAuthenticated()){
|
||||
phpCAS::authenticateIfNeeded();
|
||||
}
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (record_exists('user', 'username', phpCAS::getUser())) {
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
@@ -133,13 +136,12 @@ function cas_automatic_authenticate ($user="") {
|
||||
global $CFG;
|
||||
if (!$cas_validate){
|
||||
$cas_validate=true;
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(int)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$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 (!phpCAS::isAuthenticated() && !$CFG->guestloginbutton){
|
||||
phpCAS::authenticateIfNeeded();
|
||||
}
|
||||
if ($cas_user_exist){
|
||||
if (phpCAS::isAuthenticated()){
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (record_exists('user', 'username', phpCAS::getUser())) {
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
@@ -165,5 +167,4 @@ function cas_automatic_authenticate ($user="") {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
+5
-9
@@ -1,15 +1,11 @@
|
||||
<?php
|
||||
<?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);
|
||||
}
|
||||
include_once($CFG->dirroot.'/lib/cas/CAS.php');
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$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 );
|
||||
|
||||
?>
|
||||
@@ -26,10 +26,7 @@
|
||||
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>
|
||||
@@ -129,8 +126,6 @@
|
||||
<?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, "");
|
||||
?>
|
||||
|
||||
|
||||
+21
-339
@@ -21,59 +21,31 @@ function auth_user_login ($username, $password) {
|
||||
}
|
||||
|
||||
// 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 ($user->password == md5($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();
|
||||
|
||||
$CFG->prefix = $prefix;
|
||||
|
||||
if (!$rs) {
|
||||
notify("Could not connect to the specified authentication database...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +76,7 @@ function auth_get_userinfo($username){
|
||||
if ($rs = $authdb->Execute("SELECT ".$pcfg["field_map_$field"]." FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username'")) {
|
||||
if ( $rs->RecordCount() == 1 ) {
|
||||
$result["$field"] = addslashes(stripslashes(utf8_decode($rs->fields[0])));
|
||||
$result["$field"] = $rs->fields[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,294 +85,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
|
||||
if ($user = get_record('user', 'username', $username)) {
|
||||
return ($user->password == md5($password));
|
||||
}
|
||||
} 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'");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
+38
-60
@@ -1,51 +1,29 @@
|
||||
<?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; }
|
||||
|
||||
$yesno = array( get_string('no'), get_string('yes') );
|
||||
optional_variable($config->ldap_host_url, "");
|
||||
optional_variable($config->ldap_contexts, "");
|
||||
optional_variable($config->ldap_user_type, "");
|
||||
optional_variable($config->ldap_user_attribute, "");
|
||||
optional_variable($config->ldap_search_sub, "");
|
||||
optional_variable($config->ldap_opt_deref, "");
|
||||
optional_variable($config->ldap_preventpassindb, 0);
|
||||
optional_variable($config->ldap_bind_dn, "");
|
||||
optional_variable($config->ldap_bind_pw, "");
|
||||
optional_variable($config->ldap_version, "2");
|
||||
optional_variable($config->ldap_objectclass, "");
|
||||
optional_variable($config->ldap_memberattribute, "");
|
||||
optional_variable($config->ldap_creators, "");
|
||||
optional_variable($config->ldap_create_context, "");
|
||||
optional_variable($config->ldap_expiration, "");
|
||||
optional_variable($config->ldap_expiration_warning, "10");
|
||||
optional_variable($config->ldap_expireattr, "");
|
||||
optional_variable($config->ldap_gracelogins, "");
|
||||
optional_variable($config->ldap_graceattr, "");
|
||||
optional_variable($config->auth_user_create, "");
|
||||
optional_variable($config->auth_user_create, "");
|
||||
optional_variable($config->auth_ldap_forcechangepassword, "");
|
||||
|
||||
optional_variable($config->auth_ldap_stdchangepassword, false);
|
||||
|
||||
if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
print '<tr><td><p align="center"><font color="red"><strong>Warning:
|
||||
@@ -63,7 +41,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -109,7 +87,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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") ?>
|
||||
@@ -119,7 +97,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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") ?>
|
||||
@@ -146,7 +124,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -189,7 +167,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -200,7 +178,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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") ?>
|
||||
@@ -210,7 +188,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -233,7 +211,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<?php print_string("no") ?></option>
|
||||
<option value="1" <?php echo ($config->auth_ldap_forcechangepassword ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string("yes") ?></option>
|
||||
</select><br />
|
||||
</select><br>
|
||||
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
@@ -250,7 +228,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<?php print_string("no") ?></option>
|
||||
<option value="1" <?php echo ($config->auth_ldap_stdchangepassword ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string("yes") ?></option>
|
||||
</select><br />
|
||||
</select><br>
|
||||
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
@@ -284,7 +262,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -296,7 +274,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -323,7 +301,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
@@ -344,7 +322,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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") ?>
|
||||
@@ -361,7 +339,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
|
||||
<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?>" />
|
||||
<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>
|
||||
<?php print_string("auth_ldap_creators","auth") ?>
|
||||
|
||||
+45
-80
@@ -68,7 +68,7 @@ function auth_user_login ($username, $password) {
|
||||
}
|
||||
|
||||
// Try to bind with current username and password
|
||||
$ldap_login = @ldap_bind($ldapconnection, $ldap_user_dn, stripslashes($password));
|
||||
$ldap_login = @ldap_bind($ldapconnection, $ldap_user_dn, $password);
|
||||
ldap_close($ldapconnection);
|
||||
if ($ldap_login) {
|
||||
return true;
|
||||
@@ -124,19 +124,11 @@ function auth_get_userinfo($username){
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
$ldapval = NULL;
|
||||
foreach ($values as $value) {
|
||||
if(is_array($user_entry[0][strtolower($value)])) {
|
||||
$newval = addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)][0])));
|
||||
if(isset($user_entry[0][strtolower($value)][0])){
|
||||
$result[$key]=addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)][0])));
|
||||
}
|
||||
else {
|
||||
$newval = addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)])));
|
||||
}
|
||||
if (!empty($newval)) { // favour ldap entries that are set
|
||||
$ldapval = $newval;
|
||||
}
|
||||
}
|
||||
$result[$key] = $ldapval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,14 +210,14 @@ function auth_user_create ($userobject,$plainpass) {
|
||||
|
||||
switch ($CFG->ldap_user_type) {
|
||||
case 'edir':
|
||||
$newuser['objectClass']= array("inetOrgPerson","organizationalPerson","person","top");
|
||||
$newuser['uniqueId']= $userobject->username;
|
||||
$newuser['logindisabled']="TRUE";
|
||||
$newuser['userpassword']=$plainpass;
|
||||
break;
|
||||
$newuser['objectClass']= array("inetOrgPerson","organizationalPerson","person","top");
|
||||
$newuser['uniqueId']= $userobject->username;
|
||||
$newuser['logindisabled']="TRUE";
|
||||
$newuser['userpassword']=$plainpass;
|
||||
default:
|
||||
error('auth: ldap auth_user_create() does not support selected usertype:"'.$CFG->ldap_user_type.'" (..yet)');
|
||||
error('auth: ldap auth_user_create() does not support selected usertype (..yet)');
|
||||
}
|
||||
|
||||
$uadd = ldap_add($ldapconnection, $CFG->ldap_user_attribute."=$userobject->username,".$CFG->ldap_create_context, $newuser);
|
||||
|
||||
ldap_close($ldapconnection);
|
||||
@@ -387,10 +379,10 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
|
||||
if(strtolower($CFG->dbtype) === 'mysql'){
|
||||
// help old mysql versions cope with large temp tables
|
||||
execute_sql('SET SQL_BIG_TABLES=1', false);
|
||||
execute_sql('CREATE TEMPORARY TABLE ' . $CFG->prefix .'extuser (idnumber VARCHAR(64), PRIMARY KEY (idnumber)) TYPE=MyISAM',false);
|
||||
execute_sql('CREATE TEMPORARY TABLE ' . $CFG->prefix .'extuser (idnumber VARCHAR(12), PRIMARY KEY (idnumber)) TYPE=MyISAM',false);
|
||||
} elseif (strtolower($CFG->dbtype) === 'postgres7'){
|
||||
$bulk_insert_records = 1; // no support for multiple sets of values
|
||||
execute_sql('CREATE TEMPORARY TABLE '.$CFG->prefix.'extuser (idnumber VARCHAR(64), PRIMARY KEY (idnumber))',false);
|
||||
execute_sql('CREATE TEMPORARY TABLE '.$CFG->prefix.'extuser (idnumber VARCHAR(12), PRIMARY KEY (idnumber))',false);
|
||||
}
|
||||
|
||||
|
||||
@@ -516,11 +508,7 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
|
||||
$updatekeys = array();
|
||||
foreach ($all_keys as $key) {
|
||||
if (preg_match('/^field_updatelocal_(.+)$/',$key, $match)) {
|
||||
// if we have a field to update it from
|
||||
// and it must be updated 'onlogin' we
|
||||
// update it on cron
|
||||
if ( !empty($pcfg->{'field_map_'.$match[1]})
|
||||
&& $pcfg->{$match[0]} === 'onlogin') {
|
||||
if ($pcfg->{$match[0]}) { // if it has a true value
|
||||
array_push($updatekeys, $match[1]); // the actual key name
|
||||
}
|
||||
}
|
||||
@@ -612,7 +600,7 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
|
||||
$CFG->debug=$old_debug;
|
||||
$userobj = auth_ldap_update_user_record($user->username);
|
||||
if(isset($CFG->{'auth_ldap_forcechangepassword'}) && $CFG->{'auth_ldap_forcechangepassword'}){
|
||||
set_user_preference('auth_forcepasswordchange', 1, $userobj->id);
|
||||
set_user_preference('auth_forcepasswordchange', 1, $userobj);
|
||||
}
|
||||
|
||||
// update course creators
|
||||
@@ -626,7 +614,7 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
|
||||
}
|
||||
} else {
|
||||
if ( record_exists("user_coursecreators", "userid", $user->id)) {
|
||||
$creator = delete_records("user_coursecreators", "userid", $user->id);
|
||||
$creator = delete_records("user_coursecreators", "userid", $$user->id);
|
||||
if (! $creator) {
|
||||
error("Cannot remove user from course creators.");
|
||||
}
|
||||
@@ -715,19 +703,17 @@ function auth_ldap_bulk_insert($users){
|
||||
* @return boolen result
|
||||
*/
|
||||
function auth_user_activate ($username) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$ldapconnection = auth_ldap_connect();
|
||||
|
||||
$ldapconnection = auth_ldap_connect();
|
||||
|
||||
$userdn = auth_ldap_find_userdn($ldapconnection, $username);
|
||||
switch ($CFG->ldap_user_type) {
|
||||
case 'edir':
|
||||
$newinfo['loginDisabled']="FALSE";
|
||||
break;
|
||||
default:
|
||||
error ('auth: ldap auth_user_activate() does not support selected usertype:"'.$CFG->ldap_user_type.'" (..yet)');
|
||||
}
|
||||
case 'edir':
|
||||
$newinfo['loginDisabled']="FALSE";
|
||||
default;
|
||||
error ('auth: ldap auth_user_activate() does not support selected usertype (..yet)');
|
||||
}
|
||||
$result = ldap_modify($ldapconnection, $userdn, $newinfo);
|
||||
ldap_close($ldapconnection);
|
||||
return $result;
|
||||
@@ -749,8 +735,7 @@ function auth_user_disable ($username) {
|
||||
$userdn = auth_ldap_find_userdn($ldapconnection, $username);
|
||||
switch ($CFG->ldap_user_type) {
|
||||
case 'edir':
|
||||
$newinfo['loginDisabled']="TRUE";
|
||||
break;
|
||||
$newinfo['loginDisabled']="TRUE";
|
||||
default:
|
||||
error ('auth: ldap auth_user_disable() does not support selected usertype (..yet)');
|
||||
}
|
||||
@@ -826,19 +811,10 @@ function auth_user_update($olduser, $newuser) {
|
||||
if ($user_info_result){
|
||||
|
||||
$user_entry = auth_ldap_get_entries($ldapconnection, $user_info_result);
|
||||
if (count($user_entry)) {
|
||||
trigger_error("ldap: Strange! More than one user record found in ldap. Only using the first one.");
|
||||
}
|
||||
$user_entry = $user_entry[0];
|
||||
|
||||
//error_log(var_export($user_entry) . 'fpp' );
|
||||
|
||||
foreach ($attrmap as $key=>$ldapkeys){
|
||||
|
||||
// only process if the moodle field ($key) has changed and we
|
||||
// are set to update LDAP with it
|
||||
if ($olduser->$key !== $newuser->$key &&
|
||||
!empty($pcfg->{'field_updateremote_'. $key})) {
|
||||
if (!empty($pcfg->{'field_updateremote_'. $key})) {
|
||||
|
||||
// for ldap values that could be in more than one
|
||||
// ldap key, we will do our best to match
|
||||
@@ -846,42 +822,33 @@ function auth_user_update($olduser, $newuser) {
|
||||
$ambiguous = true;
|
||||
$changed = false;
|
||||
if (!is_array($ldapkeys)) {
|
||||
$ldapkeys = array($ldapkeys);
|
||||
$ldapkeys = $array($ldapkeys);
|
||||
}
|
||||
if (count($ldapkeys) < 2) {
|
||||
$ambiguous = false;
|
||||
}
|
||||
|
||||
foreach ($ldapkeys as $ldapkey) {
|
||||
$ldapkey = strtolower($ldapkey);
|
||||
$ldapvalue = $user_entry[$ldapkey][0];
|
||||
if (!$ambiguous) {
|
||||
// skip update if the values already match
|
||||
if( !($newuser->$key === $ldapvalue) ){
|
||||
if( !($newuser->$key === $user_entry[0][strtolower($ldapkey)][0]) ){
|
||||
ldap_modify($ldapconnection, $user_dn, array($ldapkey => $newuser->$key));
|
||||
} else {
|
||||
error_log("Skip updating field $key for entry $user_dn: it seems to be already same on LDAP. " .
|
||||
" old moodle value: '" . $olduser->$key .
|
||||
"' new value '" . $newuser->$key .
|
||||
"' current value in ldap entry " . $ldapvalue);
|
||||
"' current value in ldap entry " . $user_entry[0][strtolower($ldapkey)][0]);
|
||||
}
|
||||
} else { // ambiguous
|
||||
// value empty before in Moodle (and LDAP) - use 1st ldap candidate field
|
||||
// no need to guess
|
||||
if (empty($olduser->$key)) { // value empty before - use 1st ldap candidate
|
||||
if(ldap_modify($ldapconnection, $user_dn, array($ldapkey => $newuser->$key))){
|
||||
$changed=true;
|
||||
last;
|
||||
} else {
|
||||
error ('Error updating LDAP record. Error code: '
|
||||
. ldap_errno($ldapconnection) . '; Error string : '
|
||||
. ldap_err2str(ldap_errno($ldapconnection)));
|
||||
}
|
||||
}
|
||||
|
||||
// we found which ldap key to update!
|
||||
if ( !empty($ldapvalue) && $olduser->$key === $ldapvalue ) {
|
||||
// error_log("Matched: ". $olduser->$key . " === " . $ldapvalue);
|
||||
// check the old values match
|
||||
//error_log("keys $key $ldapkey");
|
||||
//error_log("olduser " . $olduser->$key);
|
||||
//error_log("ldapuser " . $user_entry[0][strtolower($ldapkey)][0]);
|
||||
if ( !empty($olduser->$key)
|
||||
&& !empty($user_entry[0][strtolower($ldapkey)][0])
|
||||
&& $olduser->$key === $user_entry[0][strtolower($ldapkey)][0] ) {
|
||||
// we found which value to update!
|
||||
error_log("Matched: ". $olduser->$key . " === " . $user_entry[0][strtolower($ldapkey)][0]);
|
||||
if(ldap_modify($ldapconnection, $user_dn, array($ldapkey => $newuser->$key))){
|
||||
$changed=true;
|
||||
last;
|
||||
@@ -1063,15 +1030,15 @@ function auth_ldap_getdefaults(){
|
||||
'rfc2307' => 'member',
|
||||
'rfc2307bis' => 'member',
|
||||
'samba' => 'member',
|
||||
'ad' => 'member',
|
||||
'ad' => 'member', //is this right?
|
||||
'default' => 'member'
|
||||
);
|
||||
$default['ldap_memberattribute_isdn'] = array(
|
||||
'edir' => '1',
|
||||
'rfs2307' => '0',
|
||||
'rfs2307bis' => '1',
|
||||
'rfc2307' => '0',
|
||||
'rfc2307bis' => '1',
|
||||
'samba' => '0', //is this right?
|
||||
'ad' => '1',
|
||||
'ad' => '0', //is this right?
|
||||
'default' => '0'
|
||||
);
|
||||
$default['ldap_expireattr'] = array (
|
||||
@@ -1246,8 +1213,7 @@ function auth_ldap_isgroupmember ($username='', $groupdns='') {
|
||||
}
|
||||
//echo "Checking group $group for member $username\n";
|
||||
$search = @ldap_read($ldapconnection, $group, '('.$CFG->ldap_memberattribute.'='.$username.')', array($CFG->ldap_memberattribute));
|
||||
|
||||
if (!empty($search) AND ldap_count_entries($ldapconnection, $search)) {$info = auth_ldap_get_entries($ldapconnection, $search);
|
||||
if (ldap_count_entries($ldapconnection, $search)) {$info = auth_ldap_get_entries($ldapconnection, $search);
|
||||
|
||||
if (count($info) > 0 ) {
|
||||
// user is member of group
|
||||
@@ -1304,8 +1270,7 @@ function auth_ldap_connect($binddn='',$bindpwd=''){
|
||||
|
||||
if (!empty($binddn)){
|
||||
//bind with search-user
|
||||
//$debuginfo .= 'Using bind user'.$binddn.'and password:'.$bindpwd;
|
||||
$bindresult=ldap_bind($connresult, $binddn,$bindpwd);
|
||||
$bindresult=@ldap_bind($connresult, $binddn,$bindpwd);
|
||||
} else {
|
||||
//bind anonymously
|
||||
$bindresult=@ldap_bind($connresult);
|
||||
@@ -1319,7 +1284,7 @@ function auth_ldap_connect($binddn='',$bindpwd=''){
|
||||
return $connresult;
|
||||
}
|
||||
|
||||
$debuginfo .= "<br/>Server: '$server' <br/> Connection: '$connresult'<br/> Bind result: '$bindresult'</br>";
|
||||
$debuginfo == "<br/>Server: '$server' <br/> Connection: '$connresult'<br/> Bind result: '$bindresult'</br>";
|
||||
}
|
||||
|
||||
//If any of servers are alive we have already returned connection
|
||||
@@ -1449,7 +1414,7 @@ function auth_ldap_get_userlist($filter="*") {
|
||||
$filter,
|
||||
array($CFG->ldap_user_attribute));
|
||||
}
|
||||
|
||||
|
||||
$users = auth_ldap_get_entries($ldapconnection, $ldap_result);
|
||||
|
||||
//add found users to list
|
||||
@@ -1477,7 +1442,7 @@ function auth_ldap_get_entries($conn, $searchresult){
|
||||
$fresult=array();
|
||||
$entry = ldap_first_entry($conn, $searchresult);
|
||||
do {
|
||||
$attributes = @ldap_get_attributes($conn, $entry);
|
||||
$attributes = ldap_get_attributes($conn, $entry);
|
||||
for($j=0; $j<$attributes['count']; $j++) {
|
||||
$values = ldap_get_values_len($conn, $entry,$attributes[$j]);
|
||||
if (is_array($values)) {
|
||||
@@ -1488,7 +1453,7 @@ function auth_ldap_get_entries($conn, $searchresult){
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
while ($entry = @ldap_next_entry($conn, $entry));
|
||||
while ($entry = ldap_next_entry($conn, $entry));
|
||||
//were done
|
||||
return ($fresult);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -12,7 +12,6 @@ Changes:
|
||||
- 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
|
||||
|
||||
Moodle Configuration with Dual login
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -152,6 +151,7 @@ Example file:
|
||||
// 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];
|
||||
|
||||
@@ -168,7 +168,8 @@ Example file:
|
||||
|
||||
Bugs
|
||||
--------------------------------------------------------------------------------
|
||||
Please send bug reports concerning the Shibboleth part to
|
||||
The current implementation has not yet been extensively tested. So there may be
|
||||
bugs. Please send bug reports concerning the Shibboleth part to
|
||||
Lukas Haemmerle <haemmerle@switch.ch>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
<?php
|
||||
// Set default values
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
// 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/shib-protected.php');
|
||||
}
|
||||
if (!isset($config->auth_instructions) or empty($pluginconfig->shib_user_attribute)) {
|
||||
$config->auth_instructions = get_string('auth_shib_instructions', 'auth', $CFG->wwwroot.'/auth/shibboleth/shib-protected.php');
|
||||
}
|
||||
|
||||
optional_variable($pluginconfig->user_attribute, '');
|
||||
optional_variable($pluginconfig->convert_data, '');
|
||||
|
||||
if (!isset ($pluginconfig->user_attribute)) {
|
||||
$pluginconfig->user_attribute = '';
|
||||
}
|
||||
if (!isset ($pluginconfig->convert_data)) {
|
||||
$pluginconfig->convert_data = '';
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" align="left">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
require('../../config.php');
|
||||
require('lib.php');
|
||||
|
||||
if (isloggedin() && $USER->username != 'guest') { // Nothing to do
|
||||
if (isloggedin()) { // Nothing to do
|
||||
redirect($CFG->wwwroot.'/index.php');
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
// Check whether Shibboleth is configured properly
|
||||
if (empty($pluginconfig->shib_user_attribute)) {
|
||||
error(get_string( 'shib_not_set_up_error', 'auth'));
|
||||
}
|
||||
error('Shibboleth authentication (\'shib_user_attribute\') is not set up correctly. You probably haven\'t yet configured the Shibboleth authentication. Please consult the README in moodle/auth/shibboleth for further instructions on how to set up Shibboleth authentication.');
|
||||
}
|
||||
|
||||
/// 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
|
||||
@@ -50,16 +50,7 @@
|
||||
|
||||
redirect($urltogo);
|
||||
}
|
||||
}
|
||||
|
||||
// If we can find any (user independent) Shibboleth attributes but no user
|
||||
// attributes we probably didn't receive any user attributes
|
||||
if ( !empty($_SERVER['HTTP_SHIB_APPLICATION_ID'])
|
||||
&& empty($_SERVER[$pluginconfig->shib_user_attribute]))
|
||||
{
|
||||
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.'\''));
|
||||
}
|
||||
|
||||
|
||||
$SESSION->shibboleth_checked = true; // This will stop us bouncing back here
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ function auth_get_userinfo($username) {
|
||||
// reads user information from shibboleth attributes and return it in array()
|
||||
global $CFG;
|
||||
|
||||
$config = (array)$CFG;
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
// Check whether we have got all the essential attributes
|
||||
@@ -35,7 +36,7 @@ function auth_get_userinfo($username) {
|
||||
|| 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]."')"));
|
||||
error("Moodle needs certain Shibboleth attributes which are not present in your case. The attributes are: '".$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]."')<br>Please contact your Identity Service Provider.");
|
||||
}
|
||||
|
||||
$attrmap = auth_shib_attributes();
|
||||
@@ -46,18 +47,18 @@ function auth_get_userinfo($username) {
|
||||
foreach ($attrmap as $key=>$value) {
|
||||
$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)
|
||||
$config["shib_convert_data"]
|
||||
&& $config["shib_convert_data"] != ''
|
||||
&& is_readable($config["shib_convert_data"])
|
||||
){
|
||||
|
||||
// Include a custom file outside the Moodle dir to
|
||||
// modify the variable $moodleattributes
|
||||
include($pluginconfig->convert_data);
|
||||
include($config["shib_convert_data"]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -67,6 +68,7 @@ function auth_shib_attributes(){
|
||||
//returns array containg attribute mappings between Moodle and shibboleth
|
||||
global $CFG;
|
||||
|
||||
$config = (array)$CFG;
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
$pluginconfig = (array) $pluginconfig;
|
||||
|
||||
@@ -80,7 +82,7 @@ function auth_shib_attributes(){
|
||||
$moodleattributes[$field] = $pluginconfig["field_map_$field"];
|
||||
}
|
||||
}
|
||||
$moodleattributes['username']=$pluginconfig["shib_user_attribute"];
|
||||
$moodleattributes['username']=$config["shib_user_attribute"];
|
||||
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
This file must be Shibboleth protected with something like:
|
||||
|
||||
--
|
||||
<Location ~ "/auth/shibboleth/shib-protected.php">
|
||||
AuthType shibboleth
|
||||
ShibRequireSession On
|
||||
require valid-user
|
||||
</Location>
|
||||
--
|
||||
|
||||
in your web server configuration.
|
||||
|
||||
Consult moodle/auth/shibboleth/README.txt for further instructions.
|
||||
*/
|
||||
// This file must be Shibboleth protected
|
||||
// Consult the README for further instructions
|
||||
|
||||
require_once("../../config.php");
|
||||
header("Location: ".$CFG->wwwroot."/auth/shibboleth/");
|
||||
|
||||
@@ -116,8 +116,6 @@
|
||||
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
// if we're at the start, clear the cache of prefs
|
||||
unset($SESSION->backupprefs[$course->id]);
|
||||
include_once("backup_form.html");
|
||||
} else if ($launch == "check") {
|
||||
include_once("backup_check.html");
|
||||
|
||||
+107
-53
@@ -20,16 +20,47 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$backupprefs = new StdClass;
|
||||
$count = 0;
|
||||
backup_fetch_prefs_from_request($backupprefs,$count,$course);
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Checks for the required files/functions to backup every mod
|
||||
//And check if there is data about it
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
$$var = optional_param( $var,0);
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
$$var = optional_param( $var,0);
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
$backup_metacourse = optional_param('backup_metacourse',1);
|
||||
$backup_users = optional_param('backup_users',1);
|
||||
$backup_logs = optional_param('backup_logs',0);
|
||||
$backup_user_files = optional_param('backup_user_files',1);
|
||||
$backup_course_files = optional_param('backup_course_files',1);
|
||||
$backup_messages = optional_param('backup_messages',1);
|
||||
|
||||
if ($count == 0) {
|
||||
notice("No backupable modules are installed!");
|
||||
}
|
||||
@@ -39,6 +70,46 @@
|
||||
<table cellpadding="5">
|
||||
<?php
|
||||
|
||||
//Calculate the backup string
|
||||
|
||||
//Calculate the backup word
|
||||
//Take off some characters in the filename !!
|
||||
$takeoff = array(" ", ":", "/", "\\", "|");
|
||||
$backup_word = str_replace($takeoff,"_",strtolower(get_string("backupfilename")));
|
||||
//If non-translated, use "backup"
|
||||
if (substr($backup_word,0,1) == "[") {
|
||||
$backup_word= "backup";
|
||||
}
|
||||
|
||||
//Calculate the date format string
|
||||
$backup_date_format = str_replace(" ","_",get_string("backupnameformat"));
|
||||
//If non-translated, use "%Y%m%d-%H%M"
|
||||
if (substr($backup_date_format,0,1) == "[") {
|
||||
$backup_date_format = "%%Y%%m%%d-%%H%%M";
|
||||
}
|
||||
|
||||
//Calculate the shortname
|
||||
$backup_shortname = clean_filename($course->shortname);
|
||||
if (empty($backup_shortname) or $backup_shortname == '_' ) {
|
||||
$backup_shortname = $course->id;
|
||||
}
|
||||
|
||||
//Calculate the final backup filename
|
||||
//The backup word
|
||||
$backup_name = $backup_word."-";
|
||||
//The shortname
|
||||
$backup_name .= strtolower($backup_shortname)."-";
|
||||
//The date format
|
||||
$backup_name .= userdate(time(),$backup_date_format,99,false);
|
||||
//The extension
|
||||
$backup_name .= ".zip";
|
||||
//And finally, clean everything
|
||||
$backup_name = clean_filename($backup_name);
|
||||
|
||||
//Calculate the backup unique code to allow simultaneus backups (to define
|
||||
//the temp-directory name and records in backup temp tables
|
||||
$backup_unique_code = time();
|
||||
|
||||
if (empty($to)) {
|
||||
//Now print the Backup Name tr
|
||||
echo "<tr>";
|
||||
@@ -46,7 +117,7 @@
|
||||
echo get_string("name").":";
|
||||
echo "</b></td><td>";
|
||||
//Add as text field
|
||||
echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backupprefs->backup_name."\" />";
|
||||
echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backup_name."\" />";
|
||||
echo "</td></tr>";
|
||||
|
||||
//Line
|
||||
@@ -56,30 +127,32 @@
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\" align=\"center\"><b>";
|
||||
|
||||
} else {
|
||||
echo '<input type="hidden" name="backup_name" value="'.$backup_name.'" /></b>';
|
||||
}
|
||||
|
||||
|
||||
//Here we check if backup_users = None. Then, we switch off every module
|
||||
//user info, user_files, logs and exercises, workshop and messages backups. A Warning is showed to
|
||||
//inform the user.
|
||||
if ($backupprefs->backup_users == 2) {
|
||||
if ($backup_users == 2) {
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (isset($backupprefs->$var)) {
|
||||
$backupprefs->$var = 0;
|
||||
if (isset($$var)) {
|
||||
$$var = 0;
|
||||
}
|
||||
$var = "backup_".$modname;
|
||||
if (isset($backupprefs->$var)) {
|
||||
if (isset($$var)) {
|
||||
if ($modname == "exercise" || $modname == "workshop") {
|
||||
$backupprefs->$var = 0;
|
||||
$$var = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
$backupprefs->backup_user_files = 0;
|
||||
$backupprefs->backup_logs = 0;
|
||||
$backupprefs->backup_messages = 0;
|
||||
$backup_user_files = 0;
|
||||
$backup_logs = 0;
|
||||
$backup_messages = 0;
|
||||
}
|
||||
print_simple_box("<font color=\"red\">".get_string("backupnoneusersinfo")."</font>","center", "70%", '', "20", "noticebox");
|
||||
echo "<hr />";
|
||||
@@ -96,24 +169,21 @@
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = $CFG->dirroot.'/mod/'.$modname.'/backuplib.php';
|
||||
if (!file_exists($modfile)) {
|
||||
continue;
|
||||
}
|
||||
require_once($modfile);
|
||||
$modbackup = $modname."_backup_mods";
|
||||
//If exists the lib & function
|
||||
$var = "exists_".$modname;
|
||||
if (isset($backupprefs->$var) && $backupprefs->$var) {
|
||||
if (isset($$var) && $$var) {
|
||||
$var = "backup_".$modname;
|
||||
//Only if selected
|
||||
if ($backupprefs->$var == 1) {
|
||||
if ($$var == 1) {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\">";
|
||||
//Add hidden fields
|
||||
$var = "backup_".$modname;
|
||||
echo "<input type=\"hidden\" name=\"".$var."\" value=\"".$$var."\" />";
|
||||
$var = "backup_user_info_".$modname;
|
||||
echo "<input type=\"hidden\" name=\"".$var."\" value=\"".$$var."\" />";
|
||||
//Print the mod name
|
||||
echo "<b>".get_string("include")." ".get_string("modulenameplural",$modname)." ";
|
||||
//Now look for user-data status
|
||||
@@ -121,29 +191,10 @@
|
||||
$backup_user_options[1] = get_string("withuserdata");
|
||||
$var = "backup_user_info_".$modname;
|
||||
//Print the user info
|
||||
echo $backup_user_options[$backupprefs->$var]."</b>";
|
||||
echo $backup_user_options[$$var]."</b>";
|
||||
//Call the check function to show more info
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
$var = $modname.'_instances';
|
||||
$instancestopass = array();
|
||||
if (!empty($backupprefs->$var) && is_array($backupprefs->$var) && count($backupprefs->$var)) {
|
||||
$table->data = array();
|
||||
$countinstances = 0;
|
||||
foreach ($backupprefs->$var as $instance) {
|
||||
$var1 = 'backup_'.$modname.'_instance_'.$instance->id;
|
||||
$var2 = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
if (!empty($backupprefs->$var1)) {
|
||||
$obj = new StdClass;
|
||||
$obj->name = $instance->name;
|
||||
$obj->userdata = $backupprefs->$var2;
|
||||
$obj->id = $instance->id;
|
||||
$instancestopass[$instance->id]= $obj;
|
||||
$countinstances++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$table->data = $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code,$instancestopass);
|
||||
$table->data = $modcheckbackup($id,$$var,$backup_unique_code);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
@@ -161,16 +212,16 @@
|
||||
$user_options[0] = get_string("includeallusers");
|
||||
$user_options[1] = get_string("includecourseusers");
|
||||
$user_options[2] = get_string("includenoneusers");
|
||||
echo $user_options[$backupprefs->backup_users].'</b>';
|
||||
echo $user_options[$backup_users].'</b>';
|
||||
//Print info
|
||||
$table->data = user_check_backup($id,$backupprefs->backup_unique_code,$backupprefs->backup_users,$backupprefs->backup_messages);
|
||||
$table->data = user_check_backup($id,$backup_unique_code,$backup_users,$backup_messages);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
|
||||
}
|
||||
|
||||
//Now print the Logs tr conditionally
|
||||
if ($backupprefs->backup_logs && empty($to)) {
|
||||
if ($backup_logs && empty($to)) {
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><b>";
|
||||
echo get_string("includelogentries").'</b>';
|
||||
@@ -181,35 +232,38 @@
|
||||
}
|
||||
|
||||
//Now print the User Files tr conditionally
|
||||
if ($backupprefs->backup_user_files) {
|
||||
if ($backup_user_files) {
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><b>";
|
||||
echo get_string("includeuserfiles").'</b>';
|
||||
//Print info
|
||||
$table->data = user_files_check_backup($id,$backupprefs->backup_unique_code);
|
||||
$table->data = user_files_check_backup($id,$backup_unique_code);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
//Now print the Course Files tr conditionally
|
||||
if ($backupprefs->backup_course_files) {
|
||||
if ($backup_course_files) {
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><b>";
|
||||
echo get_string("includecoursefiles").'</b>';
|
||||
//Print info
|
||||
$table->data = course_files_check_backup($id,$backupprefs->backup_unique_code);
|
||||
$table->data = course_files_check_backup($id,$backup_unique_code);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
// now keep it for next time.
|
||||
$SESSION->backupprefs[$course->id] = $backupprefs;
|
||||
|
||||
?>
|
||||
</table>
|
||||
<br />
|
||||
<center>
|
||||
<input type="hidden" name="backup_unique_code" value="<?php p($backup_unique_code) ?>" />
|
||||
<input type="hidden" name="backup_metacourse" value="<?php p($backup_metacourse) ?>" />
|
||||
<input type="hidden" name="backup_users" value="<?php p($backup_users) ?>" />
|
||||
<input type="hidden" name="backup_logs" value="<?php p($backup_logs) ?>" />
|
||||
<input type="hidden" name="backup_user_files" value="<?php p($backup_user_files) ?>" />
|
||||
<input type="hidden" name="backup_course_files" value="<?php p($backup_course_files) ?>" />
|
||||
<input type="hidden" name="backup_messages" value="<?php p($backup_messages) ?>" />
|
||||
<input type="hidden" name="to" value="<?php p($to) ?>" />
|
||||
<input type="hidden" name="id" value="<?php p($id) ?>" />
|
||||
<input type="hidden" name="launch" value="execute" />
|
||||
|
||||
+70
-10
@@ -26,8 +26,71 @@
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
$preferences = new StdClass;
|
||||
backup_fetch_prefs_from_request($preferences,$count,$course);
|
||||
//Checks for the required files/functions to backup every mod
|
||||
//And check if there is data about it
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
$$var = optional_param( $var,0,PARAM_INT );
|
||||
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->backup = $$var;
|
||||
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
$$var = optional_param( $var,0,PARAM_INT );
|
||||
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->userinfo = $$var;
|
||||
//And the name of the mod
|
||||
$preferences->mods[$modname]->name = $modname;
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
$backup_metacourse = optional_param( 'backup_metacourse',1,PARAM_INT );
|
||||
$preferences->backup_metacourse = $backup_metacourse;
|
||||
|
||||
$backup_users = optional_param( 'backup_users',1,PARAM_INT );
|
||||
$preferences->backup_users = $backup_users;
|
||||
|
||||
$backup_logs = optional_param( 'backup_logs',0,PARAM_INT );
|
||||
$preferences->backup_logs = $backup_logs;
|
||||
|
||||
$backup_user_files = optional_param( 'backup_user_files',1,PARAM_INT );
|
||||
$preferences->backup_user_files = $backup_user_files;
|
||||
|
||||
$backup_course_files = optional_param( 'backup_course_files',2,PARAM_INT );
|
||||
$preferences->backup_course_files = $backup_course_files;
|
||||
|
||||
$backup_messages = optional_param( 'backup_messages',1,PARAM_INT );
|
||||
$preferences->backup_messages = $backup_messages;
|
||||
|
||||
$id = required_param('id');
|
||||
$preferences->backup_course = $id;
|
||||
|
||||
$backup_name = required_param('backup_name',PARAM_FILE );
|
||||
$preferences->backup_name = $backup_name;
|
||||
|
||||
$backup_unique_code = required_param('backup_unique_code');
|
||||
$preferences->backup_unique_code = $backup_unique_code;
|
||||
|
||||
//Another Info
|
||||
$preferences->moodle_version = $CFG->version;
|
||||
$preferences->moodle_release = $CFG->release;
|
||||
@@ -61,10 +124,10 @@
|
||||
//Check for temp and backup and backup_unique_code directory
|
||||
//Create them as needed
|
||||
echo "<li>".get_string("creatingtemporarystructures").'</li>';
|
||||
$status = check_and_create_backup_dir($preferences->backup_unique_code);
|
||||
$status = check_and_create_backup_dir($backup_unique_code);
|
||||
//Empty dir
|
||||
if ($status) {
|
||||
$status = clear_backup_dir($preferences->backup_unique_code);
|
||||
$status = clear_backup_dir($backup_unique_code);
|
||||
}
|
||||
|
||||
//Delete old_entries from backup tables
|
||||
@@ -81,7 +144,7 @@
|
||||
echo "<ul>";
|
||||
echo "<li>".get_string("writingheader").'</li>';
|
||||
//Obtain the xml file (create and open) and print prolog information
|
||||
$backup_file = backup_open_xml($preferences->backup_unique_code);
|
||||
$backup_file = backup_open_xml($backup_unique_code);
|
||||
echo "<li>".get_string("writinggeneralinfo").'</li>';
|
||||
//Prints general info about backup to file
|
||||
if ($backup_file) {
|
||||
@@ -127,7 +190,7 @@
|
||||
echo "</ul></li>";
|
||||
|
||||
//User info
|
||||
if ($status) {
|
||||
if ($status && $preferences->backup_users) {
|
||||
echo "<li>".get_string("writinguserinfo").'</li>';
|
||||
if (!$status = backup_user_info($backup_file,$preferences)) {
|
||||
notify("An error occurred while backing up user info");
|
||||
@@ -147,7 +210,6 @@
|
||||
//questions structure (step 1). See notes on mod/quiz/backuplib.php
|
||||
if ($status and $preferences->mods['quiz']->backup) {
|
||||
echo "<li>".get_string("writingcategoriesandquestions").'</li>';
|
||||
require_once($CFG->dirroot.'/mod/quiz/backuplib.php');
|
||||
if (!$status = quiz_backup_question_categories($backup_file,$preferences)) {
|
||||
notify("An error occurred while backing up quiz categories");
|
||||
}
|
||||
@@ -318,8 +380,6 @@
|
||||
}
|
||||
error_log($filename);
|
||||
$SESSION->import_preferences = $preferences;
|
||||
print_continue($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
|
||||
print_continue($CFG->wwwroot.'/course/import.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
|
||||
}
|
||||
|
||||
$SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time.
|
||||
?>
|
||||
|
||||
+4
-76
@@ -33,7 +33,6 @@
|
||||
$modname = $mod->name;
|
||||
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modbackupone = $modname.'_backup_one_mod';
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
@@ -41,11 +40,6 @@
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
// check that there are instances and we can back them up individually
|
||||
if (count_records('course_modules','course',$course->id,'module',$mod->id) && function_exists($modbackupone)) {
|
||||
$var = 'exists_one_'.$modname;
|
||||
$$var = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check data
|
||||
@@ -100,7 +94,7 @@ function selectItemInRadioByName(formId, radioName, selectIndex ) {
|
||||
}
|
||||
|
||||
function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
myForm = document.getElementById(formId);
|
||||
myForm = document.getElementById(formId)
|
||||
for (i=0,n=myForm.elements.length;i<n;i++) {
|
||||
myLen = checkName.length;
|
||||
myName = myForm.elements[i].name;
|
||||
@@ -150,42 +144,19 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
$var = "backup_".$modname;
|
||||
//choose_from_menu($backup_options, $var, $$var, "");
|
||||
//Print the checkbox
|
||||
print_checkbox($var, $$var, $$var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'backup_'.$modname.'\',this.checked)');
|
||||
print_checkbox($var, $$var, $$var, get_string("modulenameplural",$modname));
|
||||
$var = "backup_user_info_".$modname;
|
||||
echo "</td><td align=\"right\"> ";
|
||||
echo "</td><td>";
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (empty($to)) {
|
||||
$backup_user_options[0] = get_string("withoutuserdata");
|
||||
$backup_user_options[1] = get_string("withuserdata");
|
||||
//choose_from_menu($backup_user_options, $var, $$var, "");
|
||||
print_checkbox($var, $$var, $$var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'backup_user_info_'.$modname.'\',this.checked)');
|
||||
print_checkbox($var, $$var, $$var, get_string("userdata"));
|
||||
} else {
|
||||
echo '<input type="hidden" name="'.$var.'" value="0" />';
|
||||
}
|
||||
echo "</td></tr>\n";
|
||||
// if we have the backup_one_mod function, loop here.
|
||||
$var = 'exists_one_'.$modname;
|
||||
if (!empty($$var)) {
|
||||
echo '<tr><td></td><td colspan="3"><table class="backup-form-instances">';
|
||||
$instances = get_all_instances_in_course($modname,$course);
|
||||
foreach ($instances as $instance) {
|
||||
echo '<tr><td>';
|
||||
$var = 'backup_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,1);
|
||||
print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'backup_'.$modname.'\'].checked=1;');
|
||||
echo '</td><td align="right"> ';
|
||||
$var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,1);
|
||||
if (empty($to)) {
|
||||
print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'backup_user_info_'.$modname.'\'].checked=1;');
|
||||
} else {
|
||||
echo '<input type="hidden" name="'.$var.'" value="0" />';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table></td></tr>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//Line
|
||||
@@ -276,55 +247,12 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
echo '<input type="hidden" name="backup_messages" value="0" />';
|
||||
}
|
||||
}
|
||||
|
||||
$backup_unique_code = time();
|
||||
|
||||
//Calculate the backup string
|
||||
|
||||
//Calculate the backup word
|
||||
//Take off some characters in the filename !!
|
||||
$takeoff = array(" ", ":", "/", "\\", "|");
|
||||
$backup_word = str_replace($takeoff,"_",strtolower(get_string("backupfilename")));
|
||||
//If non-translated, use "backup"
|
||||
if (substr($backup_word,0,1) == "[") {
|
||||
$backup_word= "backup";
|
||||
}
|
||||
|
||||
//Calculate the date format string
|
||||
$backup_date_format = str_replace(" ","_",get_string("backupnameformat"));
|
||||
//If non-translated, use "%Y%m%d-%H%M"
|
||||
if (substr($backup_date_format,0,1) == "[") {
|
||||
$backup_date_format = "%%Y%%m%%d-%%H%%M";
|
||||
}
|
||||
|
||||
//Calculate the shortname
|
||||
$backup_shortname = clean_filename($course->shortname);
|
||||
if (empty($backup_shortname) or $backup_shortname == '_' ) {
|
||||
$backup_shortname = $course->id;
|
||||
}
|
||||
|
||||
//Calculate the final backup filename
|
||||
//The backup word
|
||||
$backup_name = $backup_word."-";
|
||||
//The shortname
|
||||
$backup_name .= strtolower($backup_shortname)."-";
|
||||
//The date format
|
||||
$backup_name .= userdate(time(),$backup_date_format,99,false);
|
||||
//The extension
|
||||
$backup_name .= ".zip";
|
||||
//And finally, clean everything
|
||||
$backup_name = clean_filename($backup_name);
|
||||
|
||||
//Calculate the backup unique code to allow simultaneus backups (to define
|
||||
//the temp-directory name and records in backup temp tables
|
||||
?>
|
||||
</table>
|
||||
<br />
|
||||
<center>
|
||||
<input type="hidden" name="id" value="<?php p($id) ?>" />
|
||||
<input type="hidden" name="to" value="<?php p($to) ?>" />
|
||||
<input type="hidden" name="backup_unique_code" value="<?php p($backup_unique_code); ?>" />
|
||||
<input type="hidden" name="backup_name" value="<?php p($backup_name); ?>" />
|
||||
<input type="hidden" name="launch" value="check" />
|
||||
<input type="submit" value="<?php print_string("continue") ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
|
||||
|
||||
+17
-37
@@ -363,46 +363,26 @@ function schedule_backup_course_configure($course,$starttime = 0) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
|
||||
// PENNY NOTES: I have moved from here to the closing brace inside
|
||||
// by two sets of ifs()
|
||||
// to avoid the backup failing on a non existant backup.
|
||||
// If the file/function/whatever doesn't exist, we don't want to set this
|
||||
// this module in backup preferences at all.
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = $backup_config->backup_sche_modules;
|
||||
}
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->backup = $$var;
|
||||
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = $backup_config->backup_sche_withuserdata;
|
||||
}
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->userinfo = $$var;
|
||||
//And the name of the mod
|
||||
$preferences->mods[$modname]->name = $modname;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// now set instances
|
||||
if ($coursemods = get_course_mods($course->id)) {
|
||||
foreach ($coursemods as $mod) {
|
||||
if (array_key_exists($mod->modname,$preferences->mods)) { // we are to backup this module
|
||||
if (empty($preferences->mods[$mod->modname]->instances)) {
|
||||
$preferences->mods[$mod->modname]->instances = array(); // avoid warnings
|
||||
}
|
||||
$preferences->mods[$mod->modname]->instances[$mod->instance]->backup = $preferences->mods[$modname]->backup;
|
||||
$preferences->mods[$mod->modname]->instances[$mod->instance]->userinfo = $preferences->mods[$modname]->userinfo;
|
||||
// there isn't really a nice way to do this...
|
||||
$preferences->mods[$mod->modname]->instances[$mod->instance]->name = get_field($mod->modname,'name','id',$mod->instance);
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = $backup_config->backup_sche_modules;
|
||||
}
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->backup = $$var;
|
||||
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = $backup_config->backup_sche_withuserdata;
|
||||
}
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->userinfo = $$var;
|
||||
//And the name of the mod
|
||||
$preferences->mods[$modname]->name = $modname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-215
@@ -78,7 +78,7 @@
|
||||
|
||||
//Insert the record id. backup_users decide it.
|
||||
//When all users
|
||||
$status = insert_record('backup_ids', $backupids_rec, false);
|
||||
$status = insert_record("backup_ids",$backupids_rec,false,"backup_code");
|
||||
$count_users++;
|
||||
}
|
||||
//Do some output
|
||||
@@ -271,7 +271,7 @@
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
|
||||
(backup_code, file_type, path, old_id)
|
||||
VALUES
|
||||
('$backup_unique_code','user','".addslashes($dir)."','$userid')",false);
|
||||
('$backup_unique_code','user','$dir','$userid')",false);
|
||||
}
|
||||
//Do some output
|
||||
backup_flush(30);
|
||||
@@ -315,7 +315,7 @@
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
|
||||
(backup_code, file_type, path)
|
||||
VALUES
|
||||
('$backup_unique_code','course','".addslashes($dir)."')",false);
|
||||
('$backup_unique_code','course','$dir')",false);
|
||||
}
|
||||
//Do some output
|
||||
backup_flush(30);
|
||||
@@ -414,20 +414,13 @@
|
||||
}
|
||||
|
||||
//Return the xml start tag
|
||||
function start_tag($tag,$level=0,$endline=false,$attributes=null) {
|
||||
function start_tag($tag,$level=0,$endline=false) {
|
||||
if ($endline) {
|
||||
$endchar = "\n";
|
||||
} else {
|
||||
$endchar = "";
|
||||
}
|
||||
$attrstring = '';
|
||||
if (!empty($attributes) && is_array($attributes)) {
|
||||
foreach ($attributes as $key => $value) {
|
||||
$attrstring .= " ".xml_tag_safe_content($key)."=\"".
|
||||
xml_tag_safe_content($value)."\"";
|
||||
}
|
||||
}
|
||||
return str_repeat(" ",$level*2)."<".strtoupper($tag).$attrstring.">".$endchar;
|
||||
return str_repeat(" ",$level*2)."<".strtoupper($tag).">".$endchar;
|
||||
}
|
||||
|
||||
//Return the xml end tag
|
||||
@@ -441,37 +434,18 @@
|
||||
}
|
||||
|
||||
//Return the start tag, the contents and the end tag
|
||||
function full_tag($tag,$level=0,$endline=true,$content,$attributes=null) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
function full_tag($tag,$level=0,$endline=true,$content,$to_utf=true) {
|
||||
//Here we encode absolute links
|
||||
$content = backup_encode_absolute_links($content);
|
||||
|
||||
$st = start_tag($tag,$level,$endline,$attributes);
|
||||
|
||||
$co = xml_tag_safe_content($content);
|
||||
|
||||
$et = end_tag($tag,0,true);
|
||||
|
||||
return $st.$co.$et;
|
||||
}
|
||||
|
||||
|
||||
function xml_tag_safe_content($content) {
|
||||
global $CFG;
|
||||
//If enabled, we strip all the control chars from the text but tabs, newlines and returns
|
||||
//because they are forbiden in XML 1.0 specs. The expression below seems to be
|
||||
//UTF-8 safe too because it simply ignores the rest of characters.
|
||||
$content = preg_replace("/(?(?=[[:cntrl:]])[^\n\r\t])/is","",$content);
|
||||
if (!empty($CFG->unicodedb)) {
|
||||
// Don't perform the conversion. Contents are Unicode.
|
||||
$content = preg_replace("/\r\n|\r/", "\n", htmlspecialchars($content));
|
||||
$st = start_tag($tag,$level,$endline);
|
||||
$co="";
|
||||
if ($to_utf) {
|
||||
$co = preg_replace("/\r\n|\r/", "\n", utf8_encode(htmlspecialchars($content)));
|
||||
} else {
|
||||
// Perform the conversion. Contents aren't Unicode.
|
||||
$content = preg_replace("/\r\n|\r/", "\n", utf8_encode(htmlspecialchars($content)));
|
||||
}
|
||||
return $content;
|
||||
$co = preg_replace("/\r\n|\r/", "\n", htmlspecialchars($content));
|
||||
}
|
||||
$et = end_tag($tag,0,true);
|
||||
return $st.$co.$et;
|
||||
}
|
||||
|
||||
//Prints General info about the course
|
||||
@@ -512,39 +486,13 @@
|
||||
$included = "true";
|
||||
if ($element->userinfo) {
|
||||
$userinfo = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
//Prints the mod start
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$element->name));
|
||||
fwrite ($bf,full_tag("INCLUDED",4,false,$included));
|
||||
fwrite ($bf,full_tag("USERINFO",4,false,$userinfo));
|
||||
|
||||
if (is_array($preferences->mods[$element->name]->instances)
|
||||
&& count($preferences->mods[$element->name]->instances)) {
|
||||
fwrite ($bf, start_tag("INSTANCES",4,true));
|
||||
foreach ($preferences->mods[$element->name]->instances as $id => $object) {
|
||||
if (!empty($object->backup)) {
|
||||
//Calculate info
|
||||
$included = "false";
|
||||
$userinfo = "false";
|
||||
if ($object->backup) {
|
||||
$included = "true";
|
||||
if ($object->userinfo) {
|
||||
$userinfo = "true";
|
||||
}
|
||||
}
|
||||
fwrite ($bf, start_tag("INSTANCE",5,true));
|
||||
fwrite ($bf, full_tag("ID",5,false,$id));
|
||||
fwrite ($bf, full_tag("NAME",5,false,$object->name));
|
||||
fwrite ($bf, full_tag("INCLUDED",5,false,$included)) ;
|
||||
fwrite ($bf, full_tag("USERINFO",5,false,$userinfo));
|
||||
fwrite ($bf, end_tag("INSTANCE",5,true));
|
||||
}
|
||||
}
|
||||
fwrite ($bf, end_tag("INSTANCES",4,true));
|
||||
}
|
||||
|
||||
|
||||
//Print the end
|
||||
fwrite ($bf,end_tag("MOD",3,true));
|
||||
@@ -649,7 +597,6 @@
|
||||
fwrite ($bf,full_tag("LANG",3,false,$course->lang));
|
||||
fwrite ($bf,full_tag("THEME",3,false,$course->theme));
|
||||
fwrite ($bf,full_tag("COST",3,false,$course->cost));
|
||||
fwrite ($bf,full_tag("CURRENCY",3,false,$course->currency));
|
||||
fwrite ($bf,full_tag("MARKER",3,false,$course->marker));
|
||||
fwrite ($bf,full_tag("VISIBLE",3,false,$course->visible));
|
||||
fwrite ($bf,full_tag("HIDDENSECTIONS",3,false,$course->hiddensections));
|
||||
@@ -986,14 +933,6 @@
|
||||
fwrite ($bf,start_tag("MODS",4,true));
|
||||
$first_record = false;
|
||||
}
|
||||
// if we're doing selected instances, check that too.
|
||||
if (is_array($preferences->mods[$moduletype]->instances)
|
||||
&& count($preferences->mods[$moduletype]->instances)
|
||||
&& (!array_key_exists($course_module[$tok]->instance,$preferences->mods[$moduletype]->instances)
|
||||
|| empty($preferences->mods[$moduletype]->instances[$course_module[$tok]->instance]->backup))) {
|
||||
$tok = strtok(",");
|
||||
continue;
|
||||
}
|
||||
//Print mod info from course_modules
|
||||
fwrite ($bf,start_tag("MOD",5,true));
|
||||
//Save neccesary info to backup_ids
|
||||
@@ -1660,29 +1599,14 @@
|
||||
|
||||
$status = true;
|
||||
|
||||
require_once($CFG->dirroot.'/mod/'.$module.'/backuplib.php');
|
||||
|
||||
if (is_array($preferences->mods[$module]->instances)) {
|
||||
$onemodbackup = $module.'_backup_one_mod';
|
||||
if (function_exists($onemodbackup)) {
|
||||
foreach ($preferences->mods[$module]->instances as $instance => $object) {
|
||||
if (!empty($object->backup)) {
|
||||
$status = $onemodbackup($bf,$preferences,$instance);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
} else { // whole module.
|
||||
//First, re-check if necessary functions exists
|
||||
$modbackup = $module."_backup_mods";
|
||||
if (function_exists($modbackup)) {
|
||||
//Call the function
|
||||
$status = $modbackup($bf,$preferences);
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
}
|
||||
//First, re-check if necessary functions exists
|
||||
$modbackup = $module."_backup_mods";
|
||||
if (function_exists($modbackup)) {
|
||||
//Call the function
|
||||
$status = $modbackup($bf,$preferences);
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
}
|
||||
|
||||
return $status;
|
||||
@@ -1920,120 +1844,4 @@
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* compatibility function
|
||||
* with new granular backup
|
||||
* we need to know
|
||||
*/
|
||||
function backup_userdata_selected($preferences,$modname,$modid) {
|
||||
return ((empty($preferences->mods[$modname]->instances)
|
||||
&& !empty($preferences->mods[$modname]->userinfo))
|
||||
|| (is_array($preferences->mods[$modname]->instances)
|
||||
&& array_key_exists($modid,$preferences->mods[$modname]->instances)
|
||||
&& !empty($preferences->mods[$modname]->instances[$modid]->userinfo)));
|
||||
}
|
||||
|
||||
|
||||
function backup_mod_selected($preferences,$modname,$modid) {
|
||||
return ((empty($preferences->mods[$modname]->instances)
|
||||
&& !empty($preferences->mods[$modname]->backup))
|
||||
|| (is_array($preferences->mods[$modname]->instances)
|
||||
&& array_key_exists($modid,$preferences->mods[$modname]->instances)
|
||||
&& !empty($preferences->mods[$modname]->instances[$modid]->backup)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks for the required files/functions to backup every mod
|
||||
* And check if there is data about it
|
||||
*/
|
||||
function backup_fetch_prefs_from_request(&$preferences,&$count,$course) {
|
||||
global $CFG,$SESSION;
|
||||
|
||||
// check to see if it's in the session already
|
||||
if (!empty($SESSION->backupprefs) && array_key_exists($course->id,$SESSION->backupprefs) && !empty($SESSION->backupprefs[$course->id])) {
|
||||
$sprefs = $SESSION->backupprefs[$course->id];
|
||||
$preferences = $sprefs;
|
||||
// refetch backup_name just in case.
|
||||
$bn = optional_param('backup_name','',PARAM_FILE);
|
||||
if (!empty($bn)) {
|
||||
$preferences->backup_name = $bn;
|
||||
}
|
||||
$count = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modbackupone = $modname."_backup_one_mod";
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (!file_exists($modfile)) {
|
||||
continue;
|
||||
}
|
||||
include_once($modfile);
|
||||
if (!function_exists($modbackup) || !function_exists($modcheckbackup)) {
|
||||
continue;
|
||||
}
|
||||
$var = "exists_".$modname;
|
||||
$preferences->$var = true;
|
||||
$count++;
|
||||
// check that there are instances and we can back them up individually
|
||||
if (!count_records('course_modules','course',$course->id,'module',$mod->id) || !function_exists($modbackupone)) {
|
||||
continue;
|
||||
}
|
||||
$var = 'exists_one_'.$modname;
|
||||
$preferences->$var = true;
|
||||
$varname = $modname.'_instances';
|
||||
$preferences->$varname = get_all_instances_in_course($modname,$course);
|
||||
foreach ($preferences->$varname as $instance) {
|
||||
$preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
|
||||
$var = 'backup_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,0);
|
||||
$preferences->$var = $$var;
|
||||
$preferences->mods[$modname]->instances[$instance->id]->backup = $$var;
|
||||
$var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,0);
|
||||
$preferences->$var = $$var;
|
||||
$preferences->mods[$modname]->instances[$instance->id]->userinfo = $$var;
|
||||
$var = 'backup_'.$modname.'_instances';
|
||||
$preferences->$var = 1; // we need this later to determine what to display in modcheckbackup.
|
||||
}
|
||||
|
||||
//Check data
|
||||
//Check module info
|
||||
$preferences->mods[$modname]->name = $modname;
|
||||
|
||||
$var = "backup_".$modname;
|
||||
$$var = optional_param( $var,0);
|
||||
$preferences->$var = $$var;
|
||||
$preferences->mods[$modname]->backup = $$var;
|
||||
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
$$var = optional_param( $var,0);
|
||||
$preferences->$var = $$var;
|
||||
$preferences->mods[$modname]->userinfo = $$var;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
$preferences->backup_metacourse = optional_param('backup_metacourse',1,PARAM_INT);
|
||||
$preferences->backup_users = optional_param('backup_users',1,PARAM_INT);
|
||||
$preferences->backup_logs = optional_param('backup_logs',0,PARAM_INT);
|
||||
$preferences->backup_user_files = optional_param('backup_user_files',1,PARAM_INT);
|
||||
$preferences->backup_course_files = optional_param('backup_course_files',1,PARAM_INT);
|
||||
$preferences->backup_messages = optional_param('backup_messages',1,PARAM_INT);
|
||||
$preferences->backup_course = $course->id;
|
||||
$preferences->backup_name = required_param('backup_name',PARAM_FILE );
|
||||
$preferences->backup_unique_code = required_param('backup_unique_code');
|
||||
|
||||
// put it (back) in the session
|
||||
$SESSION->backupprefs[$course->id] = $preferences;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+13
-10
@@ -1,9 +1,10 @@
|
||||
Ziba Scott <ziba@linuxbox.com> 06/23/05
|
||||
Ziba Scott <ziba@linuxbox.com> 11/19/04
|
||||
|
||||
This is a utility to convert Blackboard Course export zip files into
|
||||
Moodle course export zip files. It has been successfully tested with
|
||||
Blackboard 5.5 and Moodle 1.4.1 and Moodle CVS. There is minimal
|
||||
Blackboard 6 support. It will convert:
|
||||
This is a beta demonstration of a utility to convert Blackboard
|
||||
Course export zip files into Moodle course export zip files. It
|
||||
has been successfully tested with Blackboard 5.5 and
|
||||
Moodle 1.4.1 and Moodle CVS. There is minimal Blackboard 6 support.
|
||||
It will convert:
|
||||
|
||||
* Course Name/Title
|
||||
* Forum Topics
|
||||
@@ -11,14 +12,17 @@ Blackboard 6 support. It will convert:
|
||||
* Assignments
|
||||
* External Links
|
||||
|
||||
The current status of this project is
|
||||
exploration/proof-of-concept. We have successfully converted
|
||||
basic Blackboard course information as well as course documents
|
||||
and forum topics using the XSLT methods described above.
|
||||
|
||||
AUTOMATED OPERATION:
|
||||
|
||||
REQUIREMENTS FOR WEB INTERFACE:
|
||||
*Moodle 1.4.1 or greater
|
||||
*PHP 4.3 compiled with --enable-xslt --with-xslt-sablot options
|
||||
*PHP compiled with --enable-xslt --with-xslt-sablot options
|
||||
(Check php.net for instructions on enabling xslt for your platform)
|
||||
*Alternatively, PHP 5 compiled with xml and xsl support (-with-xsl)
|
||||
|
||||
INSTALLATION:
|
||||
*Unpack this file into the "backup" directory
|
||||
@@ -32,11 +36,10 @@ MANUAL OPERATION:
|
||||
*An XSLT 1.0 processor (like Sablotron)
|
||||
*A zipping utility
|
||||
|
||||
REQUIREMENTS FOR COMMAND LINE INTERFACE:
|
||||
REQUIREMENTS FOR WEB INTERFACE:
|
||||
|
||||
*Linux/Unix
|
||||
*PHP 4 compiled with --enable-xslt --with-xslt-sablot options.
|
||||
*PHP 5 compiled with -with-xsl and the default xml support left in.
|
||||
*PHP compiled with --enable-xslt --with-xslt-sablot options.
|
||||
*Apache with write access to /tmp
|
||||
*A commandline zipping utility
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ function blackboard_convert($dir){
|
||||
|
||||
|
||||
// Check for a Blackboard manifest file
|
||||
if (is_readable($dir.'/imsmanifest.xml') && !is_readable($dir.'/moodle.xml')){
|
||||
if (is_readable($dir.'/imsmanifest.xml')){
|
||||
|
||||
if (!function_exists('xslt_create')) { // XSLT MUST be installed for this to work
|
||||
notify('You need the XSLT library installed in PHP to open this Blackboard file');
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?
|
||||
function migrate2utf8_backup_log_info($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$backuplog = get_record('backup_log', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($backuplog->courseid); //Non existing!
|
||||
$userlang = get_main_teacher_lang($backuplog->courseid); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($backuplog->info, $fromenc);
|
||||
|
||||
$newbackuplog = new object;
|
||||
$newbackuplog->id = $recordid;
|
||||
$newbackuplog->info = $result;
|
||||
update_record('backup_log',$newbackuplog);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function migrate2utf8_backup_ids_info($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$backupids= get_record('backup_ids', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = null;
|
||||
$userlang = null; //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($backupids->info, $fromenc);
|
||||
|
||||
$newbackupids = new object;
|
||||
$newbackupids->id = $recordid;
|
||||
$newbackupids->info = $result;
|
||||
update_record('backup_ids',$newbackupids);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
@@ -1,40 +0,0 @@
|
||||
<DBMIGRATION type="backup" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="backup_config">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="NO_CONV" type="varchar" length="255" dropindex="name" adduniqueindex="name (name(255))"/>
|
||||
<FIELD name="value" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="backup_courses">
|
||||
<FIELDS>
|
||||
<FIELD name="laststatus" method="NO_CONV" type="char" length="1" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="backup_files">
|
||||
<FIELDS>
|
||||
<FIELD name="file_type" method="NO_CONV" type="varchar" length="10" dropprimary="true" />
|
||||
<FIELD name="path" method="NO_CONV" type="varchar" length="255" addprimary="(backup_code, file_type(10), path(255))"/>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="backup_ids">
|
||||
<FIELDS>
|
||||
<FIELD name="table_name" method="NO_CONV" type="varchar" length="30" dropprimary="true" addprimary="(backup_code, table_name(30), old_id)"/>
|
||||
<FIELD name="info" method="PHP_FUNCTION" type="mediumtext" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_backup_ids_info(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="backup_log">
|
||||
<FIELDS>
|
||||
<FIELD name="info" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_backup_log_info(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
||||
+1
-32
@@ -1,4 +1,4 @@
|
||||
<?php //$Id$
|
||||
<?PHP //$Id$
|
||||
//
|
||||
// This file keeps track of upgrades to Moodle's
|
||||
// backup/restore utility.
|
||||
@@ -104,37 +104,6 @@ function backup_upgrade($oldversion=0) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011600 and $result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_files` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`backup_code` int(10) unsigned NOT NULL default '0',
|
||||
`file_type` varchar(10) NOT NULL default '',
|
||||
`path` varchar(255) NOT NULL default '',
|
||||
`old_id` int(10) unsigned default NULL,
|
||||
`new_id` int(10) unsigned default NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `backup_files_uk` (`backup_code`,`file_type`,`path`)
|
||||
) TYPE=MyISAM COMMENT='To store and recode ids to user and course files.'");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_ids` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`backup_code` int(12) unsigned NOT NULL default '0',
|
||||
`table_name` varchar(30) NOT NULL default '',
|
||||
`old_id` int(10) unsigned NOT NULL default '0',
|
||||
`new_id` int(10) unsigned default NULL,
|
||||
`info` mediumtext,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `backup_ids_uk` (`backup_code` ,`table_name`,`old_id`)
|
||||
) TYPE=MyISAM COMMENT='To store and convert ids in backup/restore'");
|
||||
}
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
|
||||
+2
-6
@@ -3,14 +3,12 @@
|
||||
#
|
||||
|
||||
CREATE TABLE `prefix_backup_files` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`backup_code` int(10) unsigned NOT NULL default '0',
|
||||
`file_type` varchar(10) NOT NULL default '',
|
||||
`path` varchar(255) NOT NULL default '',
|
||||
`old_id` int(10) unsigned default NULL,
|
||||
`new_id` int(10) unsigned default NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `backup_files_uk` (`backup_code`,`file_type`,`path`)
|
||||
PRIMARY KEY (`backup_code`,`file_type`,`path`)
|
||||
) TYPE=MyISAM COMMENT='To store and recode ids to user and course files.';
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -19,14 +17,12 @@ CREATE TABLE `prefix_backup_files` (
|
||||
#
|
||||
|
||||
CREATE TABLE `prefix_backup_ids` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`backup_code` int(12) unsigned NOT NULL default '0',
|
||||
`table_name` varchar(30) NOT NULL default '',
|
||||
`old_id` int(10) unsigned NOT NULL default '0',
|
||||
`new_id` int(10) unsigned default NULL,
|
||||
`info` mediumtext,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `backup_ids_uk` (`backup_code` ,`table_name`,`old_id`)
|
||||
PRIMARY KEY (`backup_code`,`table_name`,`old_id`)
|
||||
) TYPE=MyISAM COMMENT='To store and convert ids in backup/restore';
|
||||
# --------------------------------------------------------
|
||||
|
||||
|
||||
+4
-28
@@ -1,4 +1,4 @@
|
||||
<?php //$Id$
|
||||
<?PHP //$Id$
|
||||
//
|
||||
// This file keeps track of upgrades to Moodle's
|
||||
// backup/restore utility.
|
||||
@@ -23,34 +23,10 @@ function backup_upgrade($oldversion=0) {
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2006011600 and $result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}backup_files (
|
||||
id SERIAL PRIMARY KEY,
|
||||
backup_code integer NOT NULL default '0',
|
||||
file_type varchar(10) NOT NULL default '',
|
||||
path varchar(255) NOT NULL default '',
|
||||
old_id integer default NULL,
|
||||
new_id integer default NULL,
|
||||
CONSTRAINT backup_files_uk UNIQUE (backup_code, file_type, path))");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}backup_ids (
|
||||
id SERIAL PRIMARY KEY,
|
||||
backup_code integer NOT NULL default '0',
|
||||
table_name varchar(30) NOT NULL default '',
|
||||
old_id integer NOT NULL default '0',
|
||||
new_id integer default NULL,
|
||||
info text,
|
||||
CONSTRAINT backup_ids_uk UNIQUE (backup_code, table_name, old_id))");
|
||||
}
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
+19
-19
@@ -1,32 +1,35 @@
|
||||
# THIS FILE IS UNTESTED!!!
|
||||
# PLEASE HELP TEST/FIX IT AND CONTACT MARTIN OR ELOY!
|
||||
|
||||
#
|
||||
# Table structure for table prefix_backup_files
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_backup_files (
|
||||
id SERIAL PRIMARY KEY,
|
||||
backup_code integer NOT NULL default '0',
|
||||
file_type varchar(10) NOT NULL default '',
|
||||
path varchar(255) NOT NULL default '',
|
||||
old_id integer default NULL,
|
||||
new_id integer default NULL,
|
||||
CONSTRAINT backup_files_uk UNIQUE (backup_code, file_type, path)
|
||||
new_id integer default NULL
|
||||
);
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
CREATE INDEX prefix_backup_codetypepath_idx ON prefix_backup_files (backup_code,file_type,path);
|
||||
|
||||
#
|
||||
# Table structure for table prefix_backup_ids
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_backup_ids (
|
||||
id SERIAL PRIMARY KEY,
|
||||
backup_code integer NOT NULL default '0',
|
||||
backup_code int8 NOT NULL default '0',
|
||||
table_name varchar(30) NOT NULL default '',
|
||||
old_id integer NOT NULL default '0',
|
||||
new_id integer default NULL,
|
||||
info text,
|
||||
CONSTRAINT backup_ids_uk UNIQUE (backup_code, table_name, old_id)
|
||||
old_id int8 NOT NULL default '0',
|
||||
new_id int8 default NULL,
|
||||
info text
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_backup_codenameid_idx ON prefix_backup_ids (backup_code,table_name,old_id);
|
||||
|
||||
#
|
||||
# Table structure for table prefix_backup_config
|
||||
@@ -38,30 +41,27 @@ CREATE TABLE prefix_backup_config (
|
||||
value varchar(255) NOT NULL default ''
|
||||
);
|
||||
|
||||
|
||||
#
|
||||
# Table structure for table prefix_backup_courses
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_backup_courses (
|
||||
id SERIAL PRIMARY KEY,
|
||||
courseid integer UNIQUE NOT NULL default '0',
|
||||
laststarttime integer NOT NULL default '0',
|
||||
lastendtime integer NOT NULL default '0',
|
||||
courseid int8 UNIQUE NOT NULL default '0',
|
||||
laststarttime int8 NOT NULL default '0',
|
||||
lastendtime int8 NOT NULL default '0',
|
||||
laststatus varchar(1) NOT NULL default '0',
|
||||
nextstarttime integer NOT NULL default '0'
|
||||
nextstarttime int8 NOT NULL default '0'
|
||||
);
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Table structure for table prefix_backup_log
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_backup_log (
|
||||
id SERIAL PRIMARY KEY,
|
||||
courseid integer NOT NULL default '0',
|
||||
time integer NOT NULL default '0',
|
||||
laststarttime integer NOT NULL default '0',
|
||||
courseid int8 NOT NULL default '0',
|
||||
time int8 NOT NULL default '0',
|
||||
laststarttime int8 NOT NULL default '0',
|
||||
info varchar(255) NOT NULL default ''
|
||||
);
|
||||
|
||||
+5
-118
@@ -1,4 +1,4 @@
|
||||
<?php //$Id$
|
||||
<?PHP //$Id$
|
||||
//This file contains all the general function needed (file manipulation...)
|
||||
//not directly part of the backup/restore utility
|
||||
|
||||
@@ -289,8 +289,7 @@
|
||||
//$perms=fileperms($from_file);
|
||||
//return copy($from_file,$to_file) && chmod($to_file,$perms);
|
||||
umask(0000);
|
||||
if (copy($from_file,$to_file)) {
|
||||
chmod($to_file,$CFG->directorypermissions);
|
||||
if (copy($from_file,$to_file) && chmod($to_file,$CFG->directorypermissions)) {
|
||||
if (!empty($log_clam)) {
|
||||
clam_log_upload($to_file,null,true);
|
||||
}
|
||||
@@ -430,7 +429,7 @@
|
||||
$rec->new_id =$new_id;
|
||||
$rec->info = $info_to_save;
|
||||
|
||||
$status = insert_record('backup_ids', $rec, false);
|
||||
$status = insert_record ("backup_ids", $rec, false,"backup_code");
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
@@ -497,25 +496,17 @@
|
||||
//This function is used to check that every necessary function to
|
||||
//backup/restore exists in the current php installation. Thanks to
|
||||
//gregb@crowncollege.edu by the idea.
|
||||
function backup_required_functions($justcheck=false) {
|
||||
function backup_required_functions() {
|
||||
|
||||
if(!function_exists('utf8_encode')) {
|
||||
if (empty($justcheck)) {
|
||||
error('You need to add XML support to your PHP installation');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
error('You need to add XML support to your PHP installation');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//This function send n white characters to the browser and flush the
|
||||
//output buffer. Used to avoid browser timeouts and to show the progress.
|
||||
function backup_flush($n=0,$time=false) {
|
||||
if (defined('RESTORE_SILENTLY_NOFLUSH')) {
|
||||
return;
|
||||
}
|
||||
if ($time) {
|
||||
$ti = strftime("%X",time());
|
||||
} else {
|
||||
@@ -551,108 +542,4 @@
|
||||
|
||||
return ($status && $status2);
|
||||
}
|
||||
|
||||
/** this function will restore an entire backup.zip into the specified course
|
||||
* using standard moodle backup/restore functions, but silently.
|
||||
* @param string $pathtofile the absolute path to the backup file.
|
||||
* @param int $destinationcourse the course id to restore to.
|
||||
* @param boolean $emptyfirst whether to delete all coursedata first.
|
||||
* @param boolean $userdata whether to include any userdata that may be in the backup file.
|
||||
*/
|
||||
function import_backup_file_silently($pathtofile,$destinationcourse,$emptyfirst=false,$userdata=false) {
|
||||
global $CFG,$SESSION,$USER; // is there such a thing on cron? I guess so..
|
||||
|
||||
if (empty($USER)) {
|
||||
$USER = get_admin();
|
||||
$USER->admin = 1; // not sure why, but this doesn't get set
|
||||
}
|
||||
|
||||
define('RESTORE_SILENTLY',true); // don't output all the stuff to us.
|
||||
|
||||
$debuginfo = 'import_backup_file_silently: ';
|
||||
$cleanupafter = false;
|
||||
$errorstr = ''; // passed by reference to restore_precheck to get errors from.
|
||||
|
||||
if (!$course = get_record('course','id',$destinationcourse)) {
|
||||
mtrace($debuginfo.'Course with id $destinationcourse was not a valid course!');
|
||||
return false;
|
||||
}
|
||||
|
||||
// first check we have a valid file.
|
||||
if (!file_exists($pathtofile) || !is_readable($pathtofile)) {
|
||||
mtrace($debuginfo.'File '.$pathtofile.' either didn\'t exist or wasn\'t readable');
|
||||
return false;
|
||||
}
|
||||
|
||||
// now make sure it's a zip file
|
||||
require_once($CFG->dirroot.'/lib/filelib.php');
|
||||
$filename = substr($pathtofile,strrpos($pathtofile,'/')+1);
|
||||
$mimetype = mimeinfo("type", $filename);
|
||||
if ($mimetype != 'application/zip') {
|
||||
mtrace($debuginfo.'File '.$pathtofile.' was of wrong mimetype ('.$mimetype.')' );
|
||||
return false;
|
||||
}
|
||||
|
||||
// restore_precheck wants this within dataroot, so lets put it there if it's not already..
|
||||
if (strstr($pathtofile,$CFG->dataroot) === false) {
|
||||
// first try and actually move it..
|
||||
if (!check_dir_exists($CFG->dataroot.'/temp/backup/',true)) {
|
||||
mtrace($debuginfo.'File '.$pathtofile.' outside of dataroot and couldn\'t move it! ');
|
||||
return false;
|
||||
}
|
||||
if (!copy($pathtofile,$CFG->dataroot.'/temp/backup/'.$filename)) {
|
||||
mtrace($debuginfo.'File '.$pathtofile.' outside of dataroot and couldn\'t move it! ');
|
||||
return false;
|
||||
} else {
|
||||
$pathtofile = 'temp/backup/'.$filename;
|
||||
$cleanupafter = true;
|
||||
}
|
||||
} else {
|
||||
// it is within dataroot, so take it off the path for restore_precheck.
|
||||
$pathtofile = substr($pathtofile,strlen($CFG->dataroot.'/'));
|
||||
}
|
||||
|
||||
if (!backup_required_functions()) {
|
||||
mtrace($debuginfo.'Required function check failed (see backup_required_functions)');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("128M");
|
||||
|
||||
if (!$backup_unique_code = restore_precheck($destinationcourse,$pathtofile,$errorstr,true)) {
|
||||
mtrace($debuginfo.'Failed restore_precheck (error was '.$errorstr.')');
|
||||
return false;
|
||||
}
|
||||
|
||||
restore_setup_for_check($SESSION->restore,$backup_unique_code);
|
||||
|
||||
// add on some extra stuff we need...
|
||||
$SESSION->restore->restoreto = 1;
|
||||
$SESSION->restore->course_id = $destinationcourse;
|
||||
$SESSION->restore->deleting = $emptyfirst;
|
||||
|
||||
// maybe we need users (defaults to 2 in restore_setup_for_check)
|
||||
if (!empty($userdata)) {
|
||||
$SESSION->restore->users = 1;
|
||||
}
|
||||
|
||||
// we also need modules...
|
||||
if ($allmods = get_records("modules")) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
//Now check that we have that module info in the backup file
|
||||
if (isset($SESSION->info->mods[$modname]) && $SESSION->info->mods[$modname]->backup == "true") {
|
||||
$SESSION->restore->mods[$modname]->restore = true;
|
||||
$SESSION->restore->mods[$modname]->userinfo = $userdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!restore_execute($SESSION->restore,$SESSION->info,$SESSION->course_header,$errorstr)) {
|
||||
mtrace($debuginfo.'Failed restore_execute (error was '.$errorstr.')');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
require_once("../config.php");
|
||||
require_once("../backup/lib.php");
|
||||
|
||||
$courseid = optional_param('courseid',0,PARAM_INT);
|
||||
optional_variable($courseid);
|
||||
|
||||
require_login();
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("128M");
|
||||
raise_memory_limit("memory_limit","128M");
|
||||
|
||||
//Call the form, depending the step we are
|
||||
|
||||
|
||||
@@ -42,13 +42,6 @@
|
||||
$$var = optional_param( $var,0);
|
||||
$var = "restore_user_info_".$modname;
|
||||
$$var = optional_param( $var,0);
|
||||
$instances = $info->mods[$mod->name]->instances;
|
||||
foreach ($instances as $instance) {
|
||||
$var = 'restore_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,0);
|
||||
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//restoreto
|
||||
@@ -82,14 +75,6 @@
|
||||
$restore->mods[$modname]->restore=$$var;
|
||||
$var = "restore_user_info_".$modname;
|
||||
$restore->mods[$modname]->userinfo=$$var;
|
||||
|
||||
$instances = $info->mods[$mod->name]->instances;
|
||||
foreach ($instances as $instance) {
|
||||
$var = 'restore_'.$modname.'_instance_'.$instance->id;
|
||||
$restore->mods[$modname]->instances[$instance->id]->restore = $$var;
|
||||
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
$restore->mods[$modname]->instances[$instance->id]->userinfo = $$var;
|
||||
}
|
||||
}
|
||||
}
|
||||
$restore->restoreto=$restore_restoreto;
|
||||
@@ -164,19 +149,11 @@
|
||||
|
||||
//Now, select the course if needed
|
||||
if (($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id == 0) and (iscreator())) {
|
||||
if ($courses = get_courses("all","c.fullname","c.id,c.fullname,c.shortname,c.visible")) {
|
||||
if ($courses = get_courses("all","c.fullname","c.id,c.fullname,c.shortname")) {
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("center");
|
||||
foreach ($courses as $course) {
|
||||
if (!isteacheredit($course->id)) {
|
||||
continue;
|
||||
}
|
||||
if (empty($course->visible)) {
|
||||
$optdimmed = ' class="dimmed" ';
|
||||
} else {
|
||||
$optdimmed = '';
|
||||
}
|
||||
echo "<a $optdimmed href=\"restore.php?course_id=$course->id&launch=check&id=$id&file=$file\">$course->fullname ($course->shortname)</a><br />";
|
||||
echo "<a href=\"restore.php?course_id=$course->id&launch=check&id=$id&file=$file\">$course->fullname ($course->shortname)</a><br />";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
@@ -185,12 +162,6 @@
|
||||
}
|
||||
//Checks everything and execute restore
|
||||
} else if ((($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id != 0)) or ($restore->restoreto == 2)) {
|
||||
//Final access control check
|
||||
if ($restore->course_id == 0 and !iscreator()) {
|
||||
error("You need to be a creator or admin to restore into new course!");
|
||||
} else if ($restore->course_id != 0 and !isteacheredit($restore->course_id)) {
|
||||
error("You need to be an edit teacher or admin to restore into selected course!");
|
||||
}
|
||||
$show_continue_button = true;
|
||||
//Check if we've selected any mod's user info and restore->users
|
||||
//is set to none. Change it to course and inform.
|
||||
|
||||
+344
-2
@@ -41,8 +41,350 @@
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
$errorstr = '';
|
||||
$status = restore_execute($restore,$info,$course_header,$errorstr);
|
||||
|
||||
//Checks for the required files/functions to restore every module
|
||||
//and include them
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$CFG->dirroot/mod/$modname/restorelib.php";
|
||||
//If file exists and we have selected to restore that type of module
|
||||
if ((file_exists($modfile)) and ($restore->mods[$modname]->restore)) {
|
||||
include_once($modfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Start the main table
|
||||
echo "<table cellpadding=\"5\">";
|
||||
echo "<tr><td>";
|
||||
|
||||
//Start the main ul
|
||||
echo "<ul>";
|
||||
|
||||
//Init status
|
||||
$status = true;
|
||||
|
||||
//Localtion of the xml file
|
||||
$xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code."/moodle.xml";
|
||||
|
||||
//If we've selected to restore into new course
|
||||
//create it (course)
|
||||
//Saving conversion id variables into backup_tables
|
||||
if ($restore->restoreto == 2) {
|
||||
echo "<li>".get_string("creatingnewcourse");
|
||||
$oldidnumber = $course_header->course_idnumber;
|
||||
if (!$status = restore_create_new_course($restore,$course_header)) {
|
||||
notify("Error while creating the new empty course.");
|
||||
}
|
||||
//Print course fullname and shortname and category
|
||||
if ($status) {
|
||||
echo "<ul>";
|
||||
echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")".'</li>';
|
||||
echo "<li>".get_string("category").": ".$course_header->category->name.'</li>';
|
||||
if (!empty($oldidnumber)) {
|
||||
echo "<li>".get_string("nomoreidnumber","moodle",$oldidnumber)."</li>";
|
||||
}
|
||||
echo "</ul></li>";
|
||||
//Put the destination course_id
|
||||
$restore->course_id = $course_header->course_id;
|
||||
}
|
||||
} else {
|
||||
$course = get_record("course","id",$restore->course_id);
|
||||
if ($course) {
|
||||
echo "<li>".get_string("usingexistingcourse");
|
||||
echo "<ul>";
|
||||
echo "<li>".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")".'</li>';
|
||||
echo "<li>".get_string("to").": ".$course->fullname." (".$course->shortname.")".'</li>';
|
||||
if (($restore->deleting)) {
|
||||
echo "<li>".get_string("deletingexistingcoursedata").'</li>';
|
||||
} else {
|
||||
echo "<li>".get_string("addingdatatoexisting").'</li>';
|
||||
}
|
||||
echo "</ul></li>";
|
||||
//If we have selected to restore deleting, we do it now.
|
||||
if ($restore->deleting) {
|
||||
echo "<li>".get_string("deletingolddata").'</li>';
|
||||
$status = remove_course_contents($restore->course_id,false) and
|
||||
delete_dir_contents($CFG->dataroot."/".$restore->course_id,"backupdata");
|
||||
if ($status) {
|
||||
//Now , this situation is equivalent to the "restore to new course" one (we
|
||||
//have a course record and nothing more), so define it as "to new course"
|
||||
$restore->restoreto = 2;
|
||||
} else {
|
||||
notify("An error occurred while deleting some of the course contents.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notify("Error opening existing course.");
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Now create the course_sections and their associated course_modules
|
||||
if ($status) {
|
||||
//Into new course
|
||||
if ($restore->restoreto == 2) {
|
||||
echo "<li>".get_string("creatingsections").'</li>';
|
||||
if (!$status = restore_create_sections($restore,$xml_file)) {
|
||||
notify("Error creating sections in the existing course.");
|
||||
}
|
||||
//Into existing course
|
||||
} else if ($restore->restoreto == 0 or $restore->restoreto == 1) {
|
||||
echo "<li>".get_string("checkingsections").'</li>';
|
||||
if (!$status = restore_create_sections($restore,$xml_file)) {
|
||||
notify("Error creating sections in the existing course.");
|
||||
}
|
||||
//Error
|
||||
} else {
|
||||
notify("Neither a new course or an existing one was specified.");
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Now create users as needed
|
||||
if ($status and ($restore->users == 0 or $restore->users == 1)) {
|
||||
echo "<li>".get_string("creatingusers")."<br />";
|
||||
if (!$status = restore_create_users($restore,$xml_file)) {
|
||||
notify("Could not restore users.");
|
||||
}
|
||||
//Now print info about the work done
|
||||
if ($status) {
|
||||
$recs = get_records_sql("select old_id, new_id from {$CFG->prefix}backup_ids
|
||||
where backup_code = '$restore->backup_unique_code' and
|
||||
table_name = 'user'");
|
||||
//We've records
|
||||
if ($recs) {
|
||||
$new_count = 0;
|
||||
$exists_count = 0;
|
||||
$student_count = 0;
|
||||
$teacher_count = 0;
|
||||
$counter = 0;
|
||||
//Iterate, filling counters
|
||||
foreach ($recs as $rec) {
|
||||
//Get full record, using backup_getids
|
||||
$record = backup_getid($restore->backup_unique_code,"user",$rec->old_id);
|
||||
if (strpos($record->info,"new") !== false) {
|
||||
$new_count++;
|
||||
}
|
||||
if (strpos($record->info,"exists") !== false) {
|
||||
$exists_count++;
|
||||
}
|
||||
if (strpos($record->info,"student") !== false) {
|
||||
$student_count++;
|
||||
} else if (strpos($record->info,"teacher") !== false) {
|
||||
$teacher_count++;
|
||||
}
|
||||
//Do some output
|
||||
$counter++;
|
||||
if ($counter % 10 == 0) {
|
||||
echo ".";
|
||||
if ($counter % 200 == 0) {
|
||||
echo "<br />";
|
||||
}
|
||||
backup_flush(300);
|
||||
}
|
||||
}
|
||||
//Now print information gathered
|
||||
echo " (".get_string("new").": ".$new_count.", ".get_string("existing").": ".$exists_count.")";
|
||||
echo "<ul>";
|
||||
echo "<li>".get_string("students").": ".$student_count.'</li>';
|
||||
echo "<li>".get_string("teachers").": ".$teacher_count.'</li>';
|
||||
echo "</ul>";
|
||||
} else {
|
||||
notify("No users were found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now create metacourse info
|
||||
if ($status and $restore->metacourse) {
|
||||
//Only to new courses!
|
||||
if ($restore->restoreto == 2) {
|
||||
echo "</li><li>".get_string("creatingmetacoursedata");
|
||||
if (!$status = restore_create_metacourse($restore,$xml_file)) {
|
||||
notify("Error creating metacourse in the course.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Now create categories and questions as needed (STEP1)
|
||||
if ($status and ($restore->mods['quiz']->restore)) {
|
||||
echo "</li><li>".get_string("creatingcategoriesandquestions");
|
||||
echo "<ul>";
|
||||
if (!$status = restore_create_questions($restore,$xml_file)) {
|
||||
notify("Could not restore categories and questions!");
|
||||
}
|
||||
echo "</ul></li>";
|
||||
}
|
||||
|
||||
//Now create user_files as needed
|
||||
if ($status and ($restore->user_files)) {
|
||||
echo "<li>".get_string("copyinguserfiles");
|
||||
if (!$status = restore_user_files($restore)) {
|
||||
notify("Could not restore user files!");
|
||||
}
|
||||
//If all is ok (and we have a counter)
|
||||
if ($status and ($status !== true)) {
|
||||
//Inform about user dirs created from backup
|
||||
echo "<ul>";
|
||||
echo "<li>".get_string("userzones").": ".$status;
|
||||
echo "</li></ul>";
|
||||
}
|
||||
}
|
||||
|
||||
//Now create course files as needed
|
||||
if ($status and ($restore->course_files)) {
|
||||
echo "</li><li>".get_string("copyingcoursefiles")."</li>";
|
||||
if (!$status = restore_course_files($restore)) {
|
||||
notify("Could not restore course files!");
|
||||
}
|
||||
//If all is ok (and we have a counter)
|
||||
if ($status and ($status !== true)) {
|
||||
//Inform about user dirs created from backup
|
||||
echo "<ul>";
|
||||
echo "<li>".get_string("filesfolders").": ".$status;
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
|
||||
//Now create messages as needed
|
||||
if ($status and ($restore->messages)) {
|
||||
echo "<li>".get_string("creatingmessagesinfo");
|
||||
if (!$status = restore_create_messages($restore,$xml_file)) {
|
||||
notify("Could not restore messages!");
|
||||
}
|
||||
echo "</li>";
|
||||
}
|
||||
|
||||
//Now create scales as needed
|
||||
if ($status) {
|
||||
echo "<li>".get_string("creatingscales").'</li>';
|
||||
if (!$status = restore_create_scales($restore,$xml_file)) {
|
||||
notify("Could not restore custom scales!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now create groups as needed
|
||||
if ($status) {
|
||||
echo "<li>".get_string("creatinggroups").'</li>';
|
||||
if (!$status = restore_create_groups($restore,$xml_file)) {
|
||||
notify("Could not restore groups!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now create events as needed
|
||||
if ($status) {
|
||||
echo "<li>".get_string("creatingevents").'</li>';
|
||||
if (!$status = restore_create_events($restore,$xml_file)) {
|
||||
notify("Could not restore course events!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now create course modules as needed
|
||||
if ($status) {
|
||||
echo "<li>".get_string("creatingcoursemodules");
|
||||
if (!$status = restore_create_modules($restore,$xml_file)) {
|
||||
notify("Could not restore modules!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now create gradebook as needed -- AFTER modules!!!
|
||||
if ($status) {
|
||||
echo "<li>".get_string("creatinggradebook");
|
||||
if (!$status = restore_create_gradebook($restore,$xml_file)) {
|
||||
notify("Could not restore gradebook!");
|
||||
}
|
||||
}
|
||||
|
||||
//Bring back the course blocks -- do it AFTER the modules!!!
|
||||
if($status) {
|
||||
//If we are deleting and bringing into a course or making a new course, same situation
|
||||
if($restore->restoreto == 0 || $restore->restoreto == 2) {
|
||||
echo '<li>'.get_string('creatingblocks').'</li>';
|
||||
if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) {
|
||||
notify('Error while creating the course blocks');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now create log entries as needed
|
||||
if ($status and ($restore->logs)) {
|
||||
echo "</li><li>".get_string("creatinglogentries");
|
||||
if (!$status = restore_create_logs($restore,$xml_file)) {
|
||||
notify("Could not restore logs!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now, if all is OK, adjust the instance field in course_modules !!
|
||||
if ($status) {
|
||||
echo "</li><li>".get_string("checkinginstances").'</li>';
|
||||
if (!$status = restore_check_instances($restore)) {
|
||||
notify("Could not adjust instances in course_modules!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now, if all is OK, adjust activity events
|
||||
if ($status) {
|
||||
echo "<li>".get_string("refreshingevents").'</li>';
|
||||
if (!$status = restore_refresh_events($restore)) {
|
||||
notify("Could not refresh events for activities!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now, if all is OK, adjust inter-activity links
|
||||
if ($status) {
|
||||
echo "<li>".get_string("decodinginternallinks");
|
||||
if (!$status = restore_decode_content_links($restore)) {
|
||||
notify("Could not refresh events for activities!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now, with backup files prior to version 2005041100,
|
||||
//convert all the wiki texts in the course to markdown
|
||||
if ($status && $restore->backup_version < 2005041100) {
|
||||
echo "<li>".get_string("convertingwikitomarkdown");
|
||||
if (!$status = restore_convert_wiki2markdown($restore)) {
|
||||
notify("Could not convert wiki texts to markdown!");
|
||||
}
|
||||
}
|
||||
|
||||
//Now if all is OK, update:
|
||||
// - course modinfo field
|
||||
// - categories table
|
||||
// - add user as teacher
|
||||
if ($status) {
|
||||
echo "</li><li>".get_string("checkingcourse").'</li>';
|
||||
//modinfo field
|
||||
rebuild_course_cache($restore->course_id);
|
||||
//categories table
|
||||
$course = get_record("course","id",$restore->course_id);
|
||||
fix_course_sortorder();
|
||||
//Make the user a teacher if the course hasn't teachers (bug 2381)
|
||||
if (!isadmin()) {
|
||||
if (!$checktea = get_records('user_teachers','course', $restore->course_id)) {
|
||||
//Add the teacher to the course
|
||||
$status = add_teacher($USER->id, $restore->course_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Cleanup temps (files and db)
|
||||
if ($status) {
|
||||
echo "<li>".get_string("cleaningtempdata").'</li>';
|
||||
if (!$status = clean_temp_data ($restore)) {
|
||||
notify("Could not clean up temporary data from files and database");
|
||||
}
|
||||
}
|
||||
|
||||
//End the main ul
|
||||
echo "</ul>";
|
||||
|
||||
|
||||
//End the main table
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
if (!$status) {
|
||||
error ("An error has occurred and the restore could not be completed!");
|
||||
|
||||
@@ -213,7 +213,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//choose_from_menu($restore_options, $restore_var, $$restore_var, "");
|
||||
//choose_from_radio($restore_options, $restore_var, $$restore_var);
|
||||
//Print the checkbox
|
||||
print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'restore_'.$modname.'\',this.checked)');
|
||||
print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname));
|
||||
//If backup contains user data, then show menu, else fix it to
|
||||
//without user data
|
||||
echo "</td><td align=\"right\"> ";
|
||||
@@ -223,33 +223,13 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
$restore_user_options[0] = get_string("no");
|
||||
//choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
|
||||
//choose_from_radio($restore_user_options, $user_info_var, $$user_info_var);
|
||||
print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'restore_user_info_'.$modname.'\',this.checked)');
|
||||
print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"));
|
||||
} else {
|
||||
//Module haven't userdata
|
||||
echo get_string("withoutuserdata");
|
||||
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
$instances = $info->mods[$modname]->instances;
|
||||
if (!empty($instances) && is_array($instances)) {
|
||||
echo '<tr><td></td><td colspan="3"><table class="restore-form-instances">';
|
||||
foreach ($instances as $instance) {
|
||||
echo '<tr><td>';
|
||||
$var = 'restore_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,1);
|
||||
print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'restore_'.$modname.'\'].checked=1;');
|
||||
echo '</td><td align="right"> ';
|
||||
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,1);
|
||||
if ($info->mods[$modname]->instances[$instance->id]->userinfo == 'true') {
|
||||
print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'restore_user_info_'.$modname.'\'].checked=1;');
|
||||
} else {
|
||||
echo '<input type="hidden" name="'.$var.'" value="0" />';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table></td></tr>';
|
||||
}
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
|
||||
@@ -34,11 +34,7 @@
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
$errorstr = '';
|
||||
if (!empty($SESSION->restore->importing)) {
|
||||
define('RESTORE_SILENTLY',true);
|
||||
}
|
||||
$status = restore_precheck($id,$file,$errorstr);
|
||||
$status = restore_precheck($id,$file,!empty($SESSION->restore->importing));
|
||||
|
||||
if (!$status) {
|
||||
error("An error occured");
|
||||
|
||||
+151
-890
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -5,6 +5,6 @@
|
||||
// database (backup_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$backup_version = 2006011600; // The current version is a date (YYYYMMDDXX)
|
||||
$backup_version = 2005070500; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
$backup_release = "1.6dev"; // User-friendly version number
|
||||
$backup_release = "1.5.1"; // User-friendly version number
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
<?php //$Id$
|
||||
<?PHP //$Id$
|
||||
|
||||
class block_activity_modules extends block_list {
|
||||
function init() {
|
||||
$this->title = get_string('activities');
|
||||
$this->version = 2006011300;
|
||||
$this->version = 2004041000;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG;
|
||||
|
||||
// TODO: FIX: HACK: (any other tags I should add? :P)
|
||||
// Hacker's improvised caching scheme: avoid fetching the mod
|
||||
// data from db if the course format has already fetched them
|
||||
if(!isset($GLOBALS['modnamesplural']) || !isset($GLOBALS['modnamesused'])) {
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
}
|
||||
else {
|
||||
$modnamesplural = $GLOBALS['modnamesplural'];
|
||||
$modnamesused = $GLOBALS['modnamesused'];
|
||||
}
|
||||
// This is really NOT pretty, but let's do it simple for now...
|
||||
global $modnamesused, $modnamesplural;
|
||||
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@@ -41,10 +32,6 @@ class block_activity_modules extends block_list {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'mod' => false, 'my' => false);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -55,12 +55,6 @@ class block_admin extends block_list {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/log.php?id='.SITEID.'">'.get_string('logs').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
|
||||
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/stats.php?course='.SITEID.'">'.get_string('stats').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/stats.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'">'.get_string('sitefiles').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
|
||||
|
||||
@@ -92,9 +86,9 @@ class block_admin extends block_list {
|
||||
if ($isteacheredit) {
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" />';
|
||||
if (isediting($this->instance->pageid)) {
|
||||
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=off&sesskey='.sesskey().'">'.get_string('turneditingoff').'</a>';
|
||||
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=off">'.get_string('turneditingoff').'</a>';
|
||||
} else {
|
||||
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=on&sesskey='.sesskey().'">'.get_string('turneditingon').'</a>';
|
||||
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=on">'.get_string('turneditingon').'</a>';
|
||||
}
|
||||
|
||||
$this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'</a>';
|
||||
@@ -126,9 +120,8 @@ class block_admin extends block_list {
|
||||
$this->content->items[]='<a href="student.php?id='.$this->instance->pageid.'">'.$course->students.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
} else {
|
||||
$strchildcourses = get_string('childcourses');
|
||||
$this->content->items[]='<a href="importstudents.php?id='.$this->instance->pageid.'">'.$strchildcourses.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/course.gif" height="16" width="16" alt="" />';
|
||||
$this->content->items[]='<a href="importstudents.php?id='.$this->instance->pageid.'">'.$course->students.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
|
||||
}
|
||||
if ($course->groupmode || !$course->groupmodeforce) {
|
||||
$strgroups = get_string('groups');
|
||||
@@ -142,16 +135,11 @@ class block_admin extends block_list {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&wdir=/backupdata">'.get_string('restore').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$this->instance->pageid.'">'.get_string('import').'</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$this->instance->pageid.'">'.get_string('importdata').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="" />';
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/stats.php?course='.$this->instance->pageid.'">'.get_string('stats').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/stats.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
}
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
|
||||
@@ -201,16 +189,12 @@ class block_admin extends block_list {
|
||||
$this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
if ($CFG->allowunenroll && !$course->metacourse) {
|
||||
if ($CFG->allowunenroll) {
|
||||
$this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'mod' => false, 'my' => false);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,8 +12,8 @@ class block_calendar_month extends block_base {
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG, $SESSION;
|
||||
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
|
||||
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
|
||||
optional_variable($_GET['cal_m']);
|
||||
optional_variable($_GET['cal_y']);
|
||||
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
@@ -25,24 +25,24 @@ class block_calendar_month extends block_base {
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
// [pj] To me it looks like this if would never be needed, but Penny added it
|
||||
// when committing the /my/ stuff. Reminder to discuss and learn what it's about.
|
||||
// It definitely needs SOME comment here!
|
||||
if (!empty($this->instance->pageid)) {
|
||||
$courseshown = $this->instance->pageid;
|
||||
}
|
||||
else {
|
||||
$courseshown = SITEID;
|
||||
}
|
||||
if (empty($this->instance)) { // Overrides: use no course at all
|
||||
|
||||
if($courseshown == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
// the list of courses it will be grabbing events from.
|
||||
$filtercourse = NULL;
|
||||
}
|
||||
else {
|
||||
// Forcibly filter events to include only those from the particular course we are in.
|
||||
$filtercourse = array($courseshown => 1);
|
||||
$courseshown = false;
|
||||
$filtercourse = array();
|
||||
|
||||
} else {
|
||||
|
||||
$courseshown = $this->instance->pageid;
|
||||
|
||||
if($courseshown == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
// the list of courses it will be grabbing events from.
|
||||
$filtercourse = NULL;
|
||||
}
|
||||
else {
|
||||
// Forcibly filter events to include only those from the particular course we are in.
|
||||
$filtercourse = array($courseshown => 1);
|
||||
}
|
||||
}
|
||||
|
||||
// We 'll need this later
|
||||
@@ -54,15 +54,15 @@ class block_calendar_month extends block_base {
|
||||
if ($courseshown == SITEID) {
|
||||
// For the front page
|
||||
$this->content->text .= calendar_overlib_html();
|
||||
$this->content->text .= calendar_top_controls('frontpage', array('m' => $cal_m, 'y' => $cal_y));
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
|
||||
$this->content->text .= calendar_top_controls('frontpage', array('m' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
|
||||
// No filters for now
|
||||
|
||||
} elseif (!empty($courseshown)) {
|
||||
// For any other course
|
||||
$this->content->text .= calendar_overlib_html();
|
||||
$this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
|
||||
$this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
$this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $course).'</div>';
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ class block_calendar_upcoming extends block_base {
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG, $SESSION;
|
||||
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
|
||||
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
|
||||
optional_variable($_GET['cal_m']);
|
||||
optional_variable($_GET['cal_y']);
|
||||
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
@@ -27,12 +27,8 @@ class block_calendar_upcoming extends block_base {
|
||||
$this->content->footer = '';
|
||||
|
||||
} else {
|
||||
if (!empty($this->instance->pageid)) {
|
||||
$courseshown = $this->instance->pageid;
|
||||
}
|
||||
else {
|
||||
$courseshown = SITEID;
|
||||
}
|
||||
|
||||
$courseshown = $this->instance->pageid;
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.
|
||||
'/calendar/view.php?view=upcoming&course='.$courseshown.'">'.
|
||||
get_string('gotocalendar', 'calendar').'</a>...';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
include_once($CFG->dirroot . '/course/lib.php');
|
||||
|
||||
class block_course_list extends block_list {
|
||||
function init() {
|
||||
$this->title = get_string('courses');
|
||||
|
||||
@@ -23,9 +23,6 @@ class block_course_summary extends block_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($this->instance->pageid)) {
|
||||
$this->instance->pageid = SITEID;
|
||||
}
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$this->content = New stdClass;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?
|
||||
function migrate2utf8_block_instance_configdata($recordid){
|
||||
global $CFG;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function migrate2utf8_block_pinned_configdata($recordid){
|
||||
global $CFG;
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,31 +0,0 @@
|
||||
<DBMIGRATION type="blocks" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="block">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="NO_CONV" type="varchar" length="40" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="block_instance">
|
||||
<FIELDS>
|
||||
<FIELD name="pagetype" method="NO_CONV" type="varchar" length="20" dropindex="pagetype" addindex="pagetype (pagetype(20))"/>
|
||||
<FIELD name="position" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="configdata" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_block_instance_configdata(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="block_pinned">
|
||||
<FIELDS>
|
||||
<FIELD name="pagetype" method="NO_CONV" type="varchar" length="20" />
|
||||
<FIELD name="position" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="configdata" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_block_instance_configdata(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
||||
+4
-22
@@ -58,7 +58,7 @@ global $CFG;
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
$block->multiple = 0;
|
||||
insert_record('block', $block, false);
|
||||
insert_record('block', $block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ global $CFG;
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('course', '','','', 'id, shortname, blockinfo');
|
||||
$records = get_records('course');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $thiscourse) {
|
||||
// The @ suppresses a notice emitted if there is no : in the string
|
||||
@@ -98,7 +98,7 @@ global $CFG;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
if(!empty($right)) {
|
||||
@@ -112,7 +112,7 @@ global $CFG;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,24 +143,6 @@ global $CFG;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005081600) {
|
||||
$result = $result && modify_database('',"CREATE TABLE `prefix_block_pinned` (
|
||||
`id` int(10) not null auto_increment,
|
||||
`blockid` int(10) not null default '0',
|
||||
`pagetype` varchar(20) not null default '',
|
||||
`position` varchar(10) not null default '',
|
||||
`weight` tinyint(3) not null default '0',
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
PRIMARY KEY(`id`)
|
||||
) TYPE=MyISAM;");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005090200) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}block_instance ADD INDEX pagetype (pagetype);",false); // do it silently, in case it's already there from 1.5
|
||||
modify_database('','ALTER TABLE prefix_block_pinned ADD INDEX pagetype (pagetype);');
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
+1
-16
@@ -24,21 +24,6 @@ CREATE TABLE `prefix_block_instance` (
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX pageid(`pageid`),
|
||||
INDEX pagetype(`pagetype`)
|
||||
INDEX pageid(`pageid`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
CREATE TABLE `prefix_block_pinned` (
|
||||
`id` int(10) not null auto_increment,
|
||||
`blockid` int(10) not null default '0',
|
||||
`pagetype` varchar(20) not null default '',
|
||||
`position` varchar(10) not null default '',
|
||||
`weight` tinyint(3) not null default '0',
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
PRIMARY KEY(`id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
+5
-30
@@ -59,9 +59,9 @@ global $CFG;
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
$block->multiple = 0;
|
||||
insert_record('block', $block, false);
|
||||
unset($block->id);
|
||||
insert_record('block', $block);
|
||||
}
|
||||
execute_sql("SELECT setval('{$CFG->prefix}block_id_seq', (SELECT MAX(id) FROM {$CFG->prefix}block), true)");
|
||||
}
|
||||
|
||||
execute_sql("DROP TABLE {$CFG->prefix}blocks");
|
||||
@@ -81,7 +81,7 @@ global $CFG;
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('course', '','','', 'id, shortname, blockinfo');
|
||||
$records = get_records('course');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $thiscourse) {
|
||||
// The @ suppresses a notice emitted if there is no : in the string
|
||||
@@ -97,7 +97,7 @@ global $CFG;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
if(!empty($right)) {
|
||||
@@ -111,7 +111,7 @@ global $CFG;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,31 +138,6 @@ global $CFG;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005022401 && $result) { // Mass cleanup of bad upgrade scripts
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pageid_idx ON {$CFG->prefix}block_instance (pageid)",false); // this one should be quiet...
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET DEFAULT \'\'');
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER position SET DEFAULT \'\'');
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET NOT NULL');
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER position SET NOT NULL');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005081600) {
|
||||
$result = $result && modify_database('',"CREATE TABLE prefix_block_pinned (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
blockid INT8 NOT NULL default 0,
|
||||
pagetype varchar(20) NOT NULL default '',
|
||||
position varchar(10) NOT NULL default '',
|
||||
weight INT NOT NULL default 0,
|
||||
visible INT NOT NULL default 0,
|
||||
configdata text NOT NULL default 0
|
||||
);");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005090200) {
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pagetype_idx ON {$CFG->prefix}block_instance (pagetype);",false); // do it silently, in case it's already there from 1.5
|
||||
modify_database('','CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);');
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
+1
-15
@@ -10,7 +10,7 @@ CREATE TABLE prefix_block (
|
||||
cron INT8 NOT NULL default '0',
|
||||
lastcron INT8 NOT NULL default '0',
|
||||
visible int NOT NULL default '1',
|
||||
multiple int NOT NULL default '0'
|
||||
multiple int NOT NULL default '1'
|
||||
) ;
|
||||
|
||||
CREATE TABLE prefix_block_instance (
|
||||
@@ -23,19 +23,5 @@ CREATE TABLE prefix_block_instance (
|
||||
visible int not null default '0',
|
||||
configdata text not null default ''
|
||||
) ;
|
||||
CREATE INDEX prefix_block_instance_pageid_idx ON prefix_block_instance (pageid);
|
||||
CREATE INDEX prefix_block_instance_pagetype_idx ON prefix_block_instance (pagetype);
|
||||
|
||||
CREATE TABLE prefix_block_pinned (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
blockid INT8 NOT NULL default 0,
|
||||
pagetype varchar(20) NOT NULL default '',
|
||||
position varchar(10) NOT NULL default '',
|
||||
weight INT NOT NULL default 0,
|
||||
visible INT NOT NULL default 0,
|
||||
configdata text NOT NULL default 0
|
||||
) ;
|
||||
|
||||
CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -118,12 +118,9 @@ class block_glossary_random extends block_base {
|
||||
|
||||
// select glossaries to put in dropdown box ...
|
||||
$glossaries = get_records_select_menu('glossary', 'course='.$this->course->id,'name','id,name');
|
||||
|
||||
//format menu texts to avoid html and to filter multilang values
|
||||
if(!empty($glossaries)) {
|
||||
foreach($glossaries as $key => $value) {
|
||||
$glossaries[$key] = strip_tags(format_string($value,true));
|
||||
}
|
||||
foreach($glossaries as $key => $value) {
|
||||
$glossaries[$key] = strip_tags(format_string($value,true));
|
||||
}
|
||||
|
||||
// and select quotetypes to put in dropdown box
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
|
||||
class block_loancalc extends block_base {
|
||||
|
||||
function init() {
|
||||
$this->title = get_string('loancalc','block_loancalc');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->version = 2005022100;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG;
|
||||
|
||||
$calc = $CFG->pixpath.'/i/calc.gif';
|
||||
|
||||
$this->content->text = '
|
||||
<script language="JavaScript">
|
||||
<!--
|
||||
function Next()
|
||||
{
|
||||
submitScreen("Next");
|
||||
document.vbankform.submit();
|
||||
}
|
||||
function Back()
|
||||
{
|
||||
submitScreen("Back");
|
||||
document.vbankform.submit();
|
||||
}
|
||||
|
||||
function num_format(x) { // format numbers with two digits
|
||||
sgn = (x < 0);
|
||||
x = Math.abs(x);
|
||||
x = Math.floor((x * 100) + .5);
|
||||
i = 3;
|
||||
y = "";
|
||||
while(((i--) > 0) || (x > 0)) {
|
||||
y = (x % 10) + y;
|
||||
x = Math.floor(x / 10);
|
||||
if(i == 1) {
|
||||
y = "." + y;
|
||||
}
|
||||
}
|
||||
if(sgn) {
|
||||
y = "-" + y;
|
||||
}
|
||||
return(y);
|
||||
}
|
||||
function comp(v) { // general entry point for all cases
|
||||
|
||||
// convert all entry fields into variables
|
||||
x = document.vbankform;
|
||||
pv = parseFloat(x.LOANAMOUNT.value);
|
||||
lpp = parseFloat(x.LOANPAYPERIOD[x.LOANPAYPERIOD.selectedIndex].value);
|
||||
if (isNaN(pv) && (v != "pv"))
|
||||
{
|
||||
x.LOANAMOUNT.select();
|
||||
x.LOANAMOUNT.focus();
|
||||
alert("Numbers only to be entered");
|
||||
return;
|
||||
}
|
||||
fv = parseFloat("0");
|
||||
yr = parseFloat(x.LOANTERM.value);
|
||||
if (isNaN(yr) && (v != "np"))
|
||||
{
|
||||
x.LOANTERM.select();
|
||||
x.LOANTERM.focus();
|
||||
alert("Numbers only to be entered");
|
||||
return;
|
||||
}
|
||||
np = lpp * yr;
|
||||
pmt = -parseFloat(x.LOANREPAYMENT.value);
|
||||
if (isNaN(pmt) && (v != "pmt"))
|
||||
{
|
||||
x.LOANREPAYMENT.select();
|
||||
x.LOANREPAYMENT.focus();
|
||||
alert("Numbers only to be entered");
|
||||
return;
|
||||
}
|
||||
if(x.LOANINTRATE.value == "") {
|
||||
alert("You must enter an interest rate (ir).");
|
||||
}
|
||||
else {
|
||||
ir = parseFloat(x.LOANINTRATE.value);
|
||||
if (isNaN(ir))
|
||||
{
|
||||
x.LOANINTRATE.select();
|
||||
x.LOANINTRATE.focus();
|
||||
alert("Numbers only to be entered");
|
||||
return;
|
||||
}
|
||||
ir = ((ir / lpp) / 100);
|
||||
|
||||
// test and compute all cases
|
||||
|
||||
if (v == "pv") {
|
||||
if(ir == 0) {
|
||||
pv = -(fv + (pmt * np));
|
||||
}
|
||||
else {
|
||||
q1 = Math.pow(1 + ir,-np);
|
||||
q2 = Math.pow(1 + ir,np);
|
||||
pv = -(q1 * (fv * ir - pmt + q2 * pmt))/ir;
|
||||
}
|
||||
x.LOANAMOUNT.value = num_format(pv);
|
||||
}
|
||||
|
||||
if (v == "np") {
|
||||
if(ir == 0) {
|
||||
if(pmt != 0) {
|
||||
np = - (fv + pv)/pmt;
|
||||
}
|
||||
else {
|
||||
alert("Divide by zero error.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
np = Math.log((-fv * ir + pmt)/(pmt + ir * pv))/ Math.log(1 + ir);
|
||||
}
|
||||
if(np == 0) {
|
||||
alert("Can\'t compute Number of Periods for the present values.");
|
||||
}
|
||||
else {
|
||||
np = (np / lpp)
|
||||
if (isNaN(np)) {
|
||||
alert("The repayment amount is less than the interest. You must increase your repayments to pay off this loan!");
|
||||
} else {
|
||||
x.LOANTERM.value = num_format(np);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (v == "pmt") {
|
||||
if(ir == 0.0) {
|
||||
if(np != 0) {
|
||||
pmt = (fv + pv)/np;
|
||||
}
|
||||
else {
|
||||
alert("Divide by zero error.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
q = Math.pow(1 + ir,np);
|
||||
pmt = ((ir * (fv + q * pv))/(-1 + q));
|
||||
}
|
||||
x.LOANREPAYMENT.value = num_format(pmt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // function comp
|
||||
//-->
|
||||
</script>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1></h1>
|
||||
<form method="post" id="vbankform" name="vbankform">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">'.get_string('amountofloan','block_loancalc').'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="LOANAMOUNT" id="LOANAMOUNT" size="17"></td>
|
||||
<td><a href="JavaScript:comp(\'pv\');"><img src="'.$calc.'" alt="calculate" border="0"></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">'.get_string('repaymentamount','block_loancalc').'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="LOANREPAYMENT" id="LOANREPAYMENT" size="17"></td>
|
||||
<td><a href="JavaScript:comp(\'pmt\');"><img src="'.$calc.'" alt="calculate" border="0"></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">'.get_string('loanterm','block_loancalc').'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="LOANTERM" id="LOANTERM" size="17"></td>
|
||||
<td><a href="JavaScript:comp(\'np\');"><img src="'.$calc.'" alt="calculate" border="0"></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">'.get_string('interestrate','block_loancalc').'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="LOANINTRATE" id="LOANINTRATE" size="17"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">'.get_string('repaymentfreq','block_loancalc').'</td>
|
||||
</tr>
|
||||
<td>';
|
||||
$options[52] = get_string('weekly','block_loancalc');
|
||||
$options[26] = get_string('fortnightly','block_loancalc');
|
||||
$options[12] = get_string('monthly','block_loancalc');
|
||||
$this->content->text .= choose_from_menu($options,'LOANPAYPERIOD','12',NULL,NULL,NULL,true);
|
||||
$this->content->text .= '</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>';
|
||||
|
||||
return $this->content;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -27,20 +27,16 @@ class block_login extends block_base {
|
||||
$wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
|
||||
}
|
||||
|
||||
if ($CFG->auth == 'email') {
|
||||
if (is_internal_auth()) {
|
||||
$signup = $wwwroot . '/login/signup.php';
|
||||
$forgot = $wwwroot . '/login/forgot_password.php';
|
||||
} else {
|
||||
if (!empty($CFG->{'auth_'.$CFG->auth.'_stdchangepassword'})
|
||||
|| $CFG->changepassword
|
||||
|| is_internal_auth() ) {
|
||||
if (is_internal_auth() || !empty($CFG->{'auth_'.$CFG->auth.'_stdchangepassword'})) {
|
||||
$forgot = $wwwroot . '/login/forgot_password.php';
|
||||
}
|
||||
else {
|
||||
$forgot = $CFG->changepassword;
|
||||
}
|
||||
if (!empty($CFG->changepassword)) {
|
||||
$forgot = $CFG->changepassword;
|
||||
} else {
|
||||
$forgot = '';
|
||||
}
|
||||
$signup = $wwwroot . '/login/index.php'; // to see instructions!
|
||||
}
|
||||
|
||||
$username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
|
||||
|
||||
@@ -37,7 +37,16 @@ class block_messages extends block_base {
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$this->content->text .= '<div style="text-align: left; font-size: 0.75em; padding-top: 5px;">';
|
||||
$this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 16, true).' ';
|
||||
if ($user->picture) {
|
||||
if ($CFG->slasharguments) {
|
||||
$imgtag = '<img src="'.$CFG->wwwroot.'/user/pix.php/'.$user->id.'/f2.jpg" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
|
||||
} else {
|
||||
$imgtag = '<img src="'.$CFG->wwwroot.'/user/pix.php?file=/'.$user->id.'/f2.jpg" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
|
||||
}
|
||||
$this->content->text .= $imgtag;
|
||||
} else {
|
||||
$this->content->text .= '<img src="'.$CFG->pixpath.'/i/user.gif" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
|
||||
}
|
||||
$timeago = format_time(time() - $user->lastaccess);
|
||||
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">'.fullname($user).'</a>';
|
||||
$this->content->text .= ' <a target="message_'.$user->id.'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img height="11" width="11" src="'.$CFG->pixpath.'/t/message.gif" alt="" /> '.$user->count.'</a>';
|
||||
|
||||
@@ -279,16 +279,13 @@ class block_base {
|
||||
$title = $this->str->show;
|
||||
}
|
||||
|
||||
if (empty($this->instance->pageid)) {
|
||||
$this->instance->pageid = 0;
|
||||
}
|
||||
$page = page_create_object($this->instance->pagetype, $this->instance->pageid);
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey));
|
||||
|
||||
$movebuttons .= '<a class="icon hide" title="'. $title .'" href="'.$script.'&blockaction=toggle">' .
|
||||
'<img src="'. $CFG->pixpath.$icon .'" alt="'.$title.'" /></a>';
|
||||
|
||||
if ($options & BLOCK_CONFIGURE && $this->user_can_edit()) {
|
||||
if ($options & BLOCK_CONFIGURE) {
|
||||
$movebuttons .= '<a class="icon edit" title="'. $this->str->configure .'" href="'.$script.'&blockaction=config">' .
|
||||
'<img src="'. $CFG->pixpath .'/t/edit.gif" alt="'. $this->str->configure .'" /></a>';
|
||||
}
|
||||
@@ -399,6 +396,8 @@ class block_base {
|
||||
* @return boolean
|
||||
*/
|
||||
function config_save($data) {
|
||||
// Default behavior: save all variables as $CFG properties
|
||||
// You don't need to override this if you 're satisfied with the above
|
||||
foreach ($data as $name => $value) {
|
||||
set_config($name, $value);
|
||||
}
|
||||
@@ -421,6 +420,7 @@ class block_base {
|
||||
* @return int
|
||||
*/
|
||||
function preferred_width() {
|
||||
// Default case: the block wants to be 180 pixels wide
|
||||
return 180;
|
||||
}
|
||||
|
||||
@@ -429,15 +429,17 @@ class block_base {
|
||||
* @return boolean
|
||||
*/
|
||||
function hide_header() {
|
||||
//Default, false--> the header is shown
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default case: an id with the instance and a class with our name in it
|
||||
* Default case: just an id for the block, with our name in it
|
||||
* @return array
|
||||
* @todo finish documenting this function
|
||||
*/
|
||||
function html_attributes() {
|
||||
// Default case: an id with the instance and a class with our name in it
|
||||
return array('id' => 'inst'.$this->instance->id, 'class' => 'block_'. $this->name());
|
||||
}
|
||||
|
||||
@@ -527,14 +529,10 @@ class block_base {
|
||||
* @return boolean
|
||||
* @todo finish documenting this function
|
||||
*/
|
||||
function instance_config_save($data,$pinned=false) {
|
||||
function instance_config_save($data) {
|
||||
$data = stripslashes_recursive($data);
|
||||
$this->config = $data;
|
||||
$table = 'block_instance';
|
||||
if (!empty($pinned)) {
|
||||
$table = 'block_pinned';
|
||||
}
|
||||
return set_field($table, 'configdata', base64_encode(serialize($data)), 'id', $this->instance->id);
|
||||
return set_field('block_instance', 'configdata', base64_encode(serialize($data)), 'id', $this->instance->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,12 +540,8 @@ class block_base {
|
||||
* @return boolean
|
||||
* @todo finish documenting this function
|
||||
*/
|
||||
function instance_config_commit($pinned=false) {
|
||||
$table = 'block_instance';
|
||||
if (!empty($pinned)) {
|
||||
$table = 'block_pinned';
|
||||
}
|
||||
return set_field($table, 'configdata', base64_encode(serialize($this->config)), 'id', $this->instance->id);
|
||||
function instance_config_commit() {
|
||||
return set_field('block_instance', 'configdata', base64_encode(serialize($this->config)), 'id', $this->instance->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -568,29 +562,6 @@ class block_base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the block class to have a say in the user's ability to edit (i.e., configure) blocks of this type.
|
||||
* The framework has first say in whether this will be allowed (e.g., no editing allowed unless in edit mode)
|
||||
* but if the framework does allow it, the block can still decide to refuse.
|
||||
* @return boolean
|
||||
* @todo finish documenting this function
|
||||
*/
|
||||
function user_can_edit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the block class to have a say in the user's ability to create new instances of this block.
|
||||
* The framework has first say in whether this will be allowed (e.g., no adding allowed unless in edit mode)
|
||||
* but if the framework does allow it, the block can still decide to refuse.
|
||||
* This function has access to the complete page object, the creation related to which is being determined.
|
||||
* @return boolean
|
||||
* @todo finish documenting this function
|
||||
*/
|
||||
function user_can_addto(&$page) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,9 +22,6 @@ class block_news_items extends block_base {
|
||||
}
|
||||
|
||||
|
||||
if ($this->instance->pageid == 0) {
|
||||
$this->instance->pageid = SITEID;
|
||||
}
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
if ($course->newsitems) { // Create a nice listing of recent postings
|
||||
|
||||
@@ -61,8 +61,7 @@ class block_online_users extends block_base {
|
||||
{$CFG->prefix}user_students s
|
||||
$groupmembers
|
||||
WHERE u.id = s.userid $courseselect $groupselect $timeselect
|
||||
ORDER BY s.timeaccess DESC ".sql_paging_limit(0,20))) {
|
||||
|
||||
ORDER BY s.timeaccess DESC")) {
|
||||
foreach ($students as $student) {
|
||||
$student->fullname = fullname($student);
|
||||
$users[$student->id] = $student;
|
||||
@@ -73,7 +72,7 @@ class block_online_users extends block_base {
|
||||
if ($siteusers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess
|
||||
FROM {$CFG->prefix}user u
|
||||
WHERE u.lastaccess > $timefrom AND u.username <> 'guest'
|
||||
ORDER BY u.lastaccess DESC ".sql_paging_limit(0,20))) {
|
||||
ORDER BY u.lastaccess DESC")) {
|
||||
foreach ($siteusers as $siteuser) {
|
||||
$siteuser->fullname = fullname($siteuser);
|
||||
$siteuser->timeaccess = $siteuser->lastaccess;
|
||||
@@ -98,7 +97,7 @@ class block_online_users extends block_base {
|
||||
//Calculate minutes
|
||||
$minutes = floor($timetoshowusers/60);
|
||||
|
||||
$this->content->text = "<div class=\"message\">(".get_string("periodnminutes","block_online_users",$minutes).")</div>";
|
||||
$this->content->text = "<center><font size=\"-2\">(".get_string("periodnminutes","block_online_users",$minutes).")</font></center>";
|
||||
|
||||
//Now, we have in users, the list of users to show
|
||||
//Because they are online
|
||||
@@ -106,7 +105,16 @@ class block_online_users extends block_base {
|
||||
foreach ($users as $user) {
|
||||
$this->content->text .= '<div class="listentry">';
|
||||
$timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage
|
||||
$this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 16, true).' ';
|
||||
if ($user->picture) {
|
||||
if ($CFG->slasharguments) {
|
||||
$imgtag = '<img src="'.$CFG->wwwroot.'/user/pix.php/'.$user->id.'/f2.jpg" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
|
||||
} else {
|
||||
$imgtag = '<img src="'.$CFG->wwwroot.'/user/pix.php?file=/'.$user->id.'/f2.jpg" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
|
||||
}
|
||||
$this->content->text .= $imgtag;
|
||||
} else {
|
||||
$this->content->text .= '<img src="'.$CFG->pixpath.'/i/user.gif" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
|
||||
}
|
||||
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">'.$user->fullname.'</a>';
|
||||
if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and !isguest()) { // Only when logged in
|
||||
$this->content->text .= ' <a target="message_'.$user->id.'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img height="11" width="11" src="'.$CFG->pixpath.'/t/message.gif" alt="" /></a>';
|
||||
@@ -114,7 +122,7 @@ class block_online_users extends block_base {
|
||||
$this->content->text .= '</div>';
|
||||
}
|
||||
} else {
|
||||
$this->content->text .= "<div class=\"message\">".get_string("none")."</div>";
|
||||
$this->content->text .= "<center><font size=\"-1\">".get_string("none")."</font></center>";
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
+12
-22
@@ -1,7 +1,5 @@
|
||||
<?php // $Id$
|
||||
|
||||
die; //must be fixed before enabling again, see SC#971
|
||||
|
||||
// All of this is standard Moodle fixtures
|
||||
|
||||
require_once('../config.php');
|
||||
@@ -121,18 +119,10 @@
|
||||
// minor tweaks to display the page layout!
|
||||
|
||||
// Calculate the preferred width for left, right and center (both center positions will use the same)
|
||||
if (empty($preferred_width_left)) {
|
||||
$preferred_width_left = blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]);
|
||||
}
|
||||
if (empty($preferred_width_right)) {
|
||||
$preferred_width_right = blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]);
|
||||
}
|
||||
if (empty($preferred_width_centerup)) {
|
||||
$preferred_width_centerup = blocks_preferred_width($pageblocks[BLOCK_POS_CENTERUP]);
|
||||
}
|
||||
if (empty($preferred_width_centerdown)) {
|
||||
$preferred_width_centerdown = blocks_preferred_width($pageblocks[BLOCK_POS_CENTERDOWN]);
|
||||
}
|
||||
optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
|
||||
optional_variable($preferred_width_right, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]));
|
||||
optional_variable($preferred_width_centerup, blocks_preferred_width($pageblocks[BLOCK_POS_CENTERUP]));
|
||||
optional_variable($preferred_width_centerdown, blocks_preferred_width($pageblocks[BLOCK_POS_CENTERDOWN]));
|
||||
$preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
|
||||
$preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
|
||||
@@ -163,15 +153,15 @@
|
||||
// The actual display logic is here
|
||||
echo '<table style="width: 100%;"><tr>';
|
||||
|
||||
if(blocks_have_content($pageblocks,BLOCK_POS_LEFT) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;">';
|
||||
blocks_print_group($PAGE, $pageblocks,BLOCK_POS_LEFT);
|
||||
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_LEFT]);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
echo '<td style="border: 1px black solid; width: '.$preferred_width_center.'px;"><p style="text-align: center; padding: 10px; background: black; color: white;">Center-up position:</p>';
|
||||
if(blocks_have_content($pageblocks,BLOCK_POS_CENTERUP) || $editing) {
|
||||
blocks_print_group($PAGE, $pageblocks,BLOCK_POS_CENTERUP);
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_CENTERUP]) || $editing) {
|
||||
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_CENTERUP]);
|
||||
}
|
||||
|
||||
echo '<div style="padding: 10px; background: gold; text-align: center;">Content Here';
|
||||
@@ -181,14 +171,14 @@
|
||||
echo '</div>';
|
||||
|
||||
echo '<p style="text-align: center; padding: 10px; background: black; color: white;">Center-down position:</p>';
|
||||
if(blocks_have_content($pageblocks,BLOCK_POS_CENTERDOWN) || $editing) {
|
||||
blocks_print_group($PAGE, $pageblocks,BLOCK_POS_CENTERDOWN);
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_CENTERDOWN]) || $editing) {
|
||||
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_CENTERDOWN]);
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
if(blocks_have_content($pageblocks,BLOCK_POS_RIGHT) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
blocks_print_group($PAGE, $pageblocks,BLOCK_POS_RIGHT);
|
||||
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
|
||||
if ($editing) {
|
||||
blocks_print_adminblock($PAGE, $pageblocks);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@ class block_participants extends block_list {
|
||||
$this->content->footer = '';
|
||||
|
||||
|
||||
if (empty($this->instance->pageid)) {
|
||||
$this->instance->pageid = SITEID;
|
||||
}
|
||||
|
||||
if ($this->instance->pageid != SITEID ||
|
||||
$CFG->showsiteparticipantslist > 1 ||
|
||||
($CFG->showsiteparticipantslist == 1 && isteacherinanycourse()) ||
|
||||
@@ -36,25 +32,11 @@ class block_participants extends block_list {
|
||||
$CFG->wwwroot.'/user/index.php?id='.$this->instance->pageid.'">'.get_string('participants').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
|
||||
if (isteacher($this->instance->pageid)) {
|
||||
$strparticipation = get_string('participationreport');
|
||||
$this->content->items[] = '<a title="'.$strparticipation.'" href="'.
|
||||
$CFG->wwwroot.'/course/participation.php?id='.$this->instance->pageid.'">'.$strparticipation.'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// my moodle can only have SITEID and it's redundant here, so take it away
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'my' => false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
<?php //$Id$
|
||||
|
||||
define('B_QUIZRESULTS_NAME_FORMAT_FULL', 1);
|
||||
define('B_QUIZRESULTS_NAME_FORMAT_ID', 2);
|
||||
define('B_QUIZRESULTS_NAME_FORMAT_ANON', 3);
|
||||
define('B_QUIZRESULTS_GRADE_FORMAT_PCT', 1);
|
||||
define('B_QUIZRESULTS_GRADE_FORMAT_FRA', 2);
|
||||
define('B_QUIZRESULTS_GRADE_FORMAT_ABS', 3);
|
||||
define('GRADE_FORMAT_PCT', 1);
|
||||
define('GRADE_FORMAT_FRA', 2);
|
||||
define('GRADE_FORMAT_ABS', 3);
|
||||
|
||||
class block_quiz_results extends block_base {
|
||||
function init() {
|
||||
$this->title = get_string('formaltitle', 'block_quiz_results');
|
||||
$this->version = 2005082300;
|
||||
$this->version = 2005012600;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
@@ -23,15 +20,15 @@ class block_quiz_results extends block_base {
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
if (empty($this->instance)) {
|
||||
$this->content = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->instance)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if($this->instance->pagetype == 'course-view') {
|
||||
// We need to see if we are monitoring a quiz
|
||||
$quizid = empty($this->config->quizid) ? 0 : $this->config->quizid;
|
||||
@@ -81,16 +78,9 @@ class block_quiz_results extends block_base {
|
||||
$best = array();
|
||||
$worst = array();
|
||||
|
||||
$nameformat = intval(empty($this->config->nameformat) ? B_QUIZRESULTS_NAME_FORMAT_FULL : $this->config->nameformat);
|
||||
|
||||
// If the block is configured to operate in group mode, or if the name display format
|
||||
// is other than "fullname", then we need to retrieve the full course record
|
||||
if(!empty($this->config->usegroups) || $nameformat != B_QUIZRESULTS_NAME_FORMAT_FULL) {
|
||||
$course = get_record_select('course', 'id = '.$courseid, 'groupmode, groupmodeforce, student');
|
||||
}
|
||||
|
||||
if(!empty($this->config->usegroups)) {
|
||||
// The block was configured to operate in group mode
|
||||
$course = get_record_select('course', 'id = '.$courseid, 'groupmode, groupmodeforce');
|
||||
if($course->groupmodeforce) {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
@@ -173,7 +163,7 @@ class block_quiz_results extends block_base {
|
||||
}
|
||||
|
||||
// Ready for output!
|
||||
$gradeformat = intval(empty($this->config->gradeformat) ? B_QUIZRESULTS_GRADE_FORMAT_PCT : $this->config->gradeformat);
|
||||
$gradeformat = intval(empty($this->config->gradeformat) ? GRADE_FORMAT_PCT : $this->config->gradeformat);
|
||||
|
||||
if($this->instance->pagetype != 'mod-quiz-view') {
|
||||
// Don't show header and link to the quiz if we ARE at the quiz...
|
||||
@@ -186,26 +176,16 @@ class block_quiz_results extends block_base {
|
||||
$this->content->text .= ($numbest == 1?get_string('bestgroupgrade', 'block_quiz_results'):get_string('bestgroupgrades', 'block_quiz_results', $numbest));
|
||||
$this->content->text .= '</caption><colgroup class="number" /><colgroup class="name" /><colgroup class="grade" /><tbody>';
|
||||
foreach($best as $groupid => $averagegrade) {
|
||||
switch($nameformat) {
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ANON:
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ID:
|
||||
$thisname = get_string('group');
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_NAME_FORMAT_FULL:
|
||||
$thisname = '<a href="'.$CFG->wwwroot.'/course/group.php?group='.$groupid.'&id='.$courseid.'">'.$groupgrades[$groupid]['group'].'</a>';
|
||||
break;
|
||||
}
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td><a href="'.$CFG->wwwroot.'/course/group.php?group='.$groupid.'&id='.$courseid.'">'.$groupgrades[$groupid]['group'].'</a></td><td>';
|
||||
switch($gradeformat) {
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_FRA:
|
||||
case GRADE_FORMAT_FRA:
|
||||
$this->content->text .= (format_float($averagegrade,$quiz->decimalpoints).'/'.$quiz->grade);
|
||||
break;
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_ABS:
|
||||
case GRADE_FORMAT_ABS:
|
||||
$this->content->text .= format_float($averagegrade,$quiz->decimalpoints);
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_PCT:
|
||||
case GRADE_FORMAT_PCT:
|
||||
$this->content->text .= round((float)$averagegrade / (float)$quiz->grade * 100).'%';
|
||||
break;
|
||||
}
|
||||
@@ -221,26 +201,16 @@ class block_quiz_results extends block_base {
|
||||
$this->content->text .= ($numworst == 1?get_string('worstgroupgrade', 'block_quiz_results'):get_string('worstgroupgrades', 'block_quiz_results', $numworst));
|
||||
$this->content->text .= '</caption><colgroup class="number" /><colgroup class="name" /><colgroup class="grade" /><tbody>';
|
||||
foreach($worst as $groupid => $averagegrade) {
|
||||
switch($nameformat) {
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ANON:
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ID:
|
||||
$thisname = get_string('group');
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_NAME_FORMAT_FULL:
|
||||
$thisname = '<a href="'.$CFG->wwwroot.'/course/group.php?group='.$groupid.'&id='.$courseid.'">'.$groupgrades[$groupid]['group'].'</a>';
|
||||
break;
|
||||
}
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td><a href="'.$CFG->wwwroot.'/course/group.php?group='.$groupid.'&id='.$courseid.'">'.$groupgrades[$groupid]['group'].'</a></td><td>';
|
||||
switch($gradeformat) {
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_FRA:
|
||||
case GRADE_FORMAT_FRA:
|
||||
$this->content->text .= (format_float($averagegrade,$quiz->decimalpoints).'/'.$quiz->grade);
|
||||
break;
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_ABS:
|
||||
case GRADE_FORMAT_ABS:
|
||||
$this->content->text .= format_float($averagegrade,$quiz->decimalpoints);
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_PCT:
|
||||
case GRADE_FORMAT_PCT:
|
||||
$this->content->text .= round((float)$averagegrade / (float)$quiz->grade * 100).'%';
|
||||
break;
|
||||
}
|
||||
@@ -301,11 +271,11 @@ class block_quiz_results extends block_base {
|
||||
|
||||
// Now grab all the users from the database
|
||||
$userids = array_merge(array_keys($best), array_keys($worst));
|
||||
$users = get_records_list('user', 'id', implode(',',$userids), '', 'id, firstname, lastname, idnumber');
|
||||
$users = get_records_list('user', 'id', implode(',',$userids), '', 'id, firstname, lastname');
|
||||
|
||||
// Ready for output!
|
||||
|
||||
$gradeformat = intval(empty($this->config->gradeformat) ? B_QUIZRESULTS_GRADE_FORMAT_PCT : $this->config->gradeformat);
|
||||
$gradeformat = intval(empty($this->config->gradeformat) ? GRADE_FORMAT_PCT : $this->config->gradeformat);
|
||||
|
||||
if($this->instance->pagetype != 'mod-quiz-view') {
|
||||
// Don't show header and link to the quiz if we ARE at the quiz...
|
||||
@@ -318,28 +288,16 @@ class block_quiz_results extends block_base {
|
||||
$this->content->text .= ($numbest == 1?get_string('bestgrade', 'block_quiz_results'):get_string('bestgrades', 'block_quiz_results', $numbest));
|
||||
$this->content->text .= '</caption><colgroup class="number" /><colgroup class="name" /><colgroup class="grade" /><tbody>';
|
||||
foreach($best as $userid => $gradeid) {
|
||||
switch($nameformat) {
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ID:
|
||||
$thisname = $course->student.' '.intval($users[$userid]->idnumber);
|
||||
break;
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ANON:
|
||||
$thisname = $course->student;
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_NAME_FORMAT_FULL:
|
||||
$thisname = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'&course='.$courseid.'">'.fullname($users[$userid]).'</a>';
|
||||
break;
|
||||
}
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td><a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'&course='.$courseid.'">'.fullname($users[$userid]).'</a></td><td>';
|
||||
switch($gradeformat) {
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_FRA:
|
||||
case GRADE_FORMAT_FRA:
|
||||
$this->content->text .= (format_float($grades[$gradeid]->grade,$quiz->decimalpoints).'/'.$quiz->grade);
|
||||
break;
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_ABS:
|
||||
case GRADE_FORMAT_ABS:
|
||||
$this->content->text .= format_float($grades[$gradeid]->grade,$quiz->decimalpoints);
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_PCT:
|
||||
case GRADE_FORMAT_PCT:
|
||||
if ($quiz->grade) {
|
||||
$this->content->text .= round((float)$grades[$gradeid]->grade / (float)$quiz->grade * 100).'%';
|
||||
} else {
|
||||
@@ -359,28 +317,16 @@ class block_quiz_results extends block_base {
|
||||
$this->content->text .= ($numworst == 1?get_string('worstgrade', 'block_quiz_results'):get_string('worstgrades', 'block_quiz_results', $numworst));
|
||||
$this->content->text .= '</caption><colgroup class="number" /><colgroup class="name" /><colgroup class="grade" /><tbody>';
|
||||
foreach($worst as $userid => $gradeid) {
|
||||
switch($nameformat) {
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ID:
|
||||
$thisname = $course->student.' '.intval($users[$userid]->idnumber);
|
||||
break;
|
||||
case B_QUIZRESULTS_NAME_FORMAT_ANON:
|
||||
$thisname = $course->student;
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_NAME_FORMAT_FULL:
|
||||
$thisname = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'&course='.$courseid.'">'.fullname($users[$userid]).'</a>';
|
||||
break;
|
||||
}
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
|
||||
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td><a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'&course='.$courseid.'">'.fullname($users[$userid]).'</a></td><td>';
|
||||
switch($gradeformat) {
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_FRA:
|
||||
case GRADE_FORMAT_FRA:
|
||||
$this->content->text .= (format_float($grades[$gradeid]->grade,$quiz->decimalpoints).'/'.$quiz->grade);
|
||||
break;
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_ABS:
|
||||
case GRADE_FORMAT_ABS:
|
||||
$this->content->text .= format_float($grades[$gradeid]->grade,$quiz->decimalpoints);
|
||||
break;
|
||||
default:
|
||||
case B_QUIZRESULTS_GRADE_FORMAT_PCT:
|
||||
case GRADE_FORMAT_PCT:
|
||||
$this->content->text .= round((float)$grades[$gradeid]->grade / (float)$quiz->grade * 100).'%';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,24 +51,13 @@
|
||||
<input name="usegroups" type="radio" id="usegroups_no" <?php if(empty($this->config->usegroups)) echo 'checked="checked"'; ?> value="0" /> <label for="usegroups_no"><?php print_string('no'); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<?php print_string('config_name_format', 'block_quiz_results') ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$usenames = array(B_QUIZRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_quiz_results'), B_QUIZRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_quiz_results'), B_QUIZRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_quiz_results'));
|
||||
choose_from_menu($usenames, 'nameformat', empty($this->config->nameformat) ? B_QUIZRESULTS_NAME_FORMAT_FULL : $this->config->nameformat, '');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<?php print_string('config_grade_format', 'block_quiz_results') ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$formats = array(B_QUIZRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_quiz_results'), B_QUIZRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_quiz_results'), B_QUIZRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_quiz_results'));
|
||||
$formats = array(GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_quiz_results'), GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_quiz_results'), GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_quiz_results'));
|
||||
choose_from_menu($formats, 'gradeformat', empty($this->config->gradeformat) ? 0 : $this->config->gradeformat, '');
|
||||
?>
|
||||
</td>
|
||||
|
||||
@@ -31,9 +31,6 @@ class block_recent_activity extends block_base {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'my' => false);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
<?php //$Id$
|
||||
|
||||
/*******************************************************************
|
||||
* This file contains one class which defines a block for display on
|
||||
* any Moodle page. This block can be configured to display the contents
|
||||
* of a remote RSS news feed in your web site.
|
||||
*
|
||||
* @author Daryl Hawes
|
||||
* @version $Id$
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package base
|
||||
******************************************************************/
|
||||
|
||||
// Developer's debug assistant - if true then the display string will not cache, only
|
||||
// the magpie object's built in caching will be used
|
||||
define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
|
||||
/**
|
||||
* This class is for a block which defines a block for display on
|
||||
* any Moodle page.
|
||||
*/
|
||||
class block_rss_client extends block_base {
|
||||
class block_rss_client extends block_base {
|
||||
|
||||
function init() {
|
||||
$this->title = get_string('feedstitle', 'block_rss_client');
|
||||
$this->version = 2005111400;
|
||||
$this->version = 2004112000;
|
||||
}
|
||||
|
||||
function preferred_width() {
|
||||
@@ -40,7 +25,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
$this->title = get_string('remotenewsfeed', 'block_rss_client');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $editing;
|
||||
|
||||
@@ -51,11 +36,11 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
}
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
|
||||
if (empty($this->instance)) {
|
||||
// We're being asked for content without an associated instance
|
||||
$this->content->text = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -103,16 +88,14 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
if ( $userisloggedin && ($submitters == SUBMITTERS_ALL_ACCOUNT_HOLDERS || ($submitters == SUBMITTERS_ADMIN_AND_TEACHER && $isteacher)) ) {
|
||||
|
||||
$page = page_create_object($this->instance->pagetype, $this->instance->pageid);
|
||||
if ($page->user_allowed_editing()) { // for SUBMITTERS_ALL_ACCOUNT_HOLDERS we're going to run into trouble later if we show it and then they don't have write access to the page.
|
||||
if (isset($this->config)) {
|
||||
// this instance is configured - show Add/Edit feeds link
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $this->courseid));
|
||||
$output .= '<div align="center"><a title="'. get_string('feedsaddedit', 'block_rss_client') .'" href="'. $script .'">'. get_string('feedsaddedit', 'block_rss_client') .'</a></div>';
|
||||
} else {
|
||||
// this instance has not been configured yet - show configure link
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $this->courseid));
|
||||
$output .= '<div align="center"><a title="'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'" href="'. $script.'">'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'</a></div>';
|
||||
}
|
||||
if (isset($this->config)) {
|
||||
// this instance is configured - show Add/Edit feeds link
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds'));
|
||||
$output .= '<div align="center"><a title="'. get_string('feedsaddedit', 'block_rss_client') .'" href="'. $script .'">'. get_string('feedsaddedit', 'block_rss_client') .'</a></div>';
|
||||
} else {
|
||||
// this instance has not been configured yet - show configure link
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock'));
|
||||
$output .= '<div align="center"><a title="'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'" href="'. $script.'">'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +113,11 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->content->text = $output;
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
|
||||
function instance_allow_multiple() {
|
||||
return true;
|
||||
}
|
||||
@@ -146,7 +129,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
function instance_allow_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $rssid The feed to be displayed
|
||||
* @param bool $display_description Should the description information from the feed be displayed or simply the title?
|
||||
@@ -161,9 +144,9 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
require_once($CFG->libdir .'/rsslib.php');
|
||||
require_once(MAGPIE_DIR .'rss_fetch.inc');
|
||||
if (!defined('MAGPIE_OUTPUT_ENCODING')) {
|
||||
define('MAGPIE_OUTPUT_ENCODING', current_charset()); // see bug 3107
|
||||
define('MAGPIE_OUTPUT_ENCODING', get_string('thischarset')); // see bug 3107
|
||||
}
|
||||
|
||||
|
||||
// Check if there is a cached string which has not timed out.
|
||||
if (BLOCK_RSS_SECONDARY_CACHE_ENABLED &&
|
||||
isset($this->config->{'rssid'. $rssid}) &&
|
||||
@@ -176,6 +159,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
|
||||
$rss_record = get_record('block_rss_client', 'id', $rssid);
|
||||
if (isset($rss_record) && isset($rss_record->id)) {
|
||||
|
||||
// By capturing the output from fetch_rss this way
|
||||
// error messages do not display and clutter up the moodle interface
|
||||
// however, we do lose out on seeing helpful messages like "cache hit", etc.
|
||||
@@ -183,7 +167,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
$rss = fetch_rss($rss_record->url);
|
||||
$rsserror = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
if ($rss === false) {
|
||||
if ($CFG->debug && !empty($rsserror)) {
|
||||
// There was a failure in loading the rss feed, print link to full error text
|
||||
@@ -196,9 +180,9 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
}
|
||||
|
||||
if (empty($rss_record->preferredtitle)) {
|
||||
$feedtitle = $this->format_title($rss->channel['title']);
|
||||
$feedtitle = stripslashes_safe(rss_unhtmlentities($rss->channel['title']));
|
||||
} else {
|
||||
$feedtitle = $this->format_title($rss_record->preferredtitle);
|
||||
$feedtitle = stripslashes_safe($rss_record->preferredtitle);
|
||||
}
|
||||
// print_object($rss);
|
||||
if (isset($this->config) &&
|
||||
@@ -214,20 +198,16 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
|
||||
$formatoptions->para = false;
|
||||
|
||||
// first we must verify that the rss feed is loaded
|
||||
// by checking $rss and $rss->items exist before using them
|
||||
if (empty($rss) || empty($rss->items)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
foreach ($rss->items as $item) {
|
||||
$item['title'] = stripslashes_safe(rss_unhtmlentities($item['title']));
|
||||
$item['description'] = stripslashes_safe(rss_unhtmlentities($item['description']));
|
||||
if ($item['title'] == '') {
|
||||
// no title present, use portion of description
|
||||
$item['title'] = substr(strip_tags($item['description']), 0, 20) . '...';
|
||||
} else {
|
||||
$item['title'] = break_up_long_words($item['title'], 30);
|
||||
}
|
||||
|
||||
|
||||
if ($item['link'] == '') {
|
||||
$item['link'] = $item['guid'];
|
||||
}
|
||||
@@ -236,6 +216,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
|
||||
$returnstring .= '<div class="link"><a href="'. $item['link'] .'" target="_blank">'. $item['title'] . '</a></div>' ."\n";
|
||||
|
||||
|
||||
if ($display_description && !empty($item['description'])) {
|
||||
$item['description'] = break_up_long_words($item['description'], 30);
|
||||
$returnstring .= '<div class="description">'.
|
||||
@@ -262,26 +243,12 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
$this->title = $feedtitle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// store config setting for this rssid so we do not need to read from file each time
|
||||
$this->config->{'rssid'. $rssid} = addslashes($returnstring);
|
||||
$this->config->{'rssid'. $rssid .'timestamp'} = $now;
|
||||
$this->instance_config_save($this->config);
|
||||
return $returnstring;
|
||||
}
|
||||
|
||||
// just strips the title down and adds ... for excessively long titles.
|
||||
function format_title($title,$max=64) {
|
||||
|
||||
/// Loading the textlib singleton instance. We are going to need it.
|
||||
$textlib = textlib_get_instance();
|
||||
|
||||
if ($textlib->strlen($title,current_charset()) <= $max) {
|
||||
return $title;
|
||||
}
|
||||
else {
|
||||
return $textlib->substr($title,0,$max-3,current_charset()).'...';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,249 +1,227 @@
|
||||
<?php //$Id$
|
||||
|
||||
/*******************************************************************
|
||||
* This file contains no classes. It will display a list of existing feeds
|
||||
* defined for the site and allow add/edit/delete of site feeds.
|
||||
*
|
||||
* @author Daryl Hawes
|
||||
* @version $Id$
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package base
|
||||
******************************************************************/
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir .'/rsslib.php');
|
||||
require_once(MAGPIE_DIR .'rss_fetch.inc');
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir .'/rsslib.php');
|
||||
require_once(MAGPIE_DIR .'rss_fetch.inc');
|
||||
|
||||
require_login();
|
||||
global $USER;
|
||||
|
||||
//ensure that the logged in user is not using the guest account
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$referrer = $_SERVER['HTTP_REFERER'];
|
||||
} else {
|
||||
$referrer = $CFG->wwwroot;
|
||||
}
|
||||
if (isguest()) {
|
||||
error(get_string('noguestpost', 'forum'), $referrer);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($url)) {
|
||||
// attempting to replace feed and rss url types with http
|
||||
// it appears that the rss feed validator will validate these url types but magpie will not load them $url = str_replace ("feed://", "http://", "$url");
|
||||
// Shifting this forward since PARAM_URL rejects these feed types as invalid entries!
|
||||
$url = str_replace ("feed://", "http://", "$url");
|
||||
$url = str_replace ("FEED://", "http://", "$url");
|
||||
$url = str_replace ("rss://", "http://", "$url");
|
||||
$url = str_replace ("RSS://", "http://", "$url");
|
||||
}
|
||||
|
||||
$act = optional_param('act', NULL, PARAM_ALPHA);
|
||||
$rssid = optional_param('rssid', NULL, PARAM_INT);
|
||||
$id = optional_param('id', SITEID, PARAM_INT);
|
||||
$url = clean_param($url, PARAM_URL);
|
||||
$preferredtitle = optional_param('preferredtitle', '', PARAM_ALPHA);
|
||||
|
||||
if (!defined('MAGPIE_OUTPUT_ENCODING')) {
|
||||
define('MAGPIE_OUTPUT_ENCODING', current_charset()); // see bug 3107
|
||||
}
|
||||
|
||||
if (!empty($id)) {
|
||||
// we get the complete $course object here because print_header assumes this is
|
||||
// a complete object (needed for proper course theme settings)
|
||||
$course = get_record('course', 'id', $id);
|
||||
}
|
||||
|
||||
$straddedit = get_string('feedsaddedit', 'block_rss_client');
|
||||
if ( isadmin() ) {
|
||||
$navigation = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.get_string('administration').'</a> -> '.
|
||||
'<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/configure.php">'.get_string('configuration').'</a> -> '.$straddedit;
|
||||
} else if (!empty($course)) {
|
||||
$navigation = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$id.'">'.$course->shortname.'</a> -> '.$straddedit;
|
||||
} else {
|
||||
$navigation = $straddedit;
|
||||
}
|
||||
|
||||
print_header($straddedit, $straddedit, $navigation);
|
||||
|
||||
//check to make sure that the user is allowed to post new feeds
|
||||
$submitters = $CFG->block_rss_client_submitters;
|
||||
$isteacher = empty($course) ? false : isteacher($id);
|
||||
|
||||
if ( !isset($act) ) {
|
||||
rss_display_feeds($id);
|
||||
rss_print_form($act, $url, $rssid, $preferredtitle, $id);
|
||||
print_footer();
|
||||
die();
|
||||
}
|
||||
|
||||
if ( isset($rssid) ) {
|
||||
$rss_record = get_record('block_rss_client', 'id', $rssid);
|
||||
}
|
||||
|
||||
//if the user is an admin or course teacher then allow the user to
|
||||
//assign categories to other uses than personal
|
||||
if (isset($rss_record) && !( isadmin() || $submitters == SUBMITTERS_ALL_ACCOUNT_HOLDERS ||
|
||||
($submitters == SUBMITTERS_ADMIN_AND_TEACHER && $isteacher) ||
|
||||
( ($act == 'rssedit' || $act == 'delfeed' || $act == 'updfeed') && $USER->id == $rss_record->userid) ) ) {
|
||||
error(get_string('noguestpost', 'forum').' You are not allowed to make modifications to this RSS feed at this time.', $referrer);
|
||||
}
|
||||
|
||||
if ($act == 'updfeed') {
|
||||
if (empty($url)) {
|
||||
error( 'url not defined for rss feed' );
|
||||
}
|
||||
|
||||
// By capturing the output from fetch_rss this way
|
||||
// error messages do not display and clutter up the moodle interface
|
||||
// however, we do lose out on seeing helpful messages like "cache hit", etc.
|
||||
$message = '';
|
||||
ob_start();
|
||||
$rss = fetch_rss($url);
|
||||
if ($CFG->debug) {
|
||||
$message .= ob_get_contents();
|
||||
}
|
||||
ob_end_clean();
|
||||
|
||||
$dataobject->id = $rssid;
|
||||
if ($rss === false) {
|
||||
$dataobject->description = '';
|
||||
$dataobject->title = '';
|
||||
$dataobject->preferredtitle = '';
|
||||
require_login();
|
||||
global $USER;
|
||||
|
||||
//ensure that the logged in user is not using the guest account
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$referrer = $_SERVER['HTTP_REFERER'];
|
||||
} else {
|
||||
$dataobject->description = addslashes($rss->channel['description']);
|
||||
$dataobject->title = addslashes($rss->channel['title']);
|
||||
$dataobject->preferredtitle = addslashes($preferredtitle);
|
||||
$referrer = $CFG->wwwroot;
|
||||
}
|
||||
$dataobject->url = addslashes($url);
|
||||
|
||||
if (!update_record('block_rss_client', $dataobject)) {
|
||||
error('There was an error trying to update rss feed with id:'. $rssid);
|
||||
if (isguest()) {
|
||||
error(get_string('noguestpost', 'forum'), $referrer);
|
||||
}
|
||||
|
||||
$message .= '<br />'. get_string('feedupdated', 'block_rss_client');
|
||||
redirect($referrer, $message);
|
||||
optional_variable($act, 'none');
|
||||
optional_variable($rssid, 'none');
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
optional_variable($url);
|
||||
optional_variable($preferredtitle, '');
|
||||
optional_variable($item);
|
||||
|
||||
} else if ($act == 'addfeed' ) {
|
||||
|
||||
if (empty($url)) {
|
||||
error('url not defined for rss feed');
|
||||
}
|
||||
$dataobject->userid = $USER->id;
|
||||
$dataobject->description = '';
|
||||
$dataobject->title = '';
|
||||
$dataobject->url = addslashes($url);
|
||||
$dataobject->preferredtitle = addslashes($preferredtitle);
|
||||
|
||||
$rssid = insert_record('block_rss_client', $dataobject);
|
||||
if (!$rssid) {
|
||||
error('There was an error trying to add a new rss feed:'. $url);
|
||||
if (!defined('MAGPIE_OUTPUT_ENCODING')) {
|
||||
define('MAGPIE_OUTPUT_ENCODING', get_string('thischarset')); // see bug 3107
|
||||
}
|
||||
|
||||
// By capturing the output from fetch_rss this way
|
||||
// error messages do not display and clutter up the moodle interface
|
||||
// however, we do lose out on seeing helpful messages like "cache hit", etc.
|
||||
$message = '';
|
||||
ob_start();
|
||||
$rss = fetch_rss($url);
|
||||
if ($CFG->debug) {
|
||||
$message .= ob_get_contents();
|
||||
if (!empty($courseid)) {
|
||||
$course = get_record('course', 'id', $courseid, '', '', '', '', 'shortname');
|
||||
}
|
||||
ob_end_clean();
|
||||
|
||||
if ($rss === false) {
|
||||
$message .= '<br /><br />There was an error loading this rss feed. You may want to verify the url you have specified before using it.'; //Daryl Hawes note: localize this line
|
||||
$straddedit = get_string('feedsaddedit', 'block_rss_client');
|
||||
if ( isadmin() ) {
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$navigation = "<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"$CFG->wwwroot/$CFG->admin/configure.php\">$strconfiguration</a> -> $straddedit";
|
||||
} else if (!empty($course)) {
|
||||
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> -> $straddedit";
|
||||
} else {
|
||||
|
||||
$dataobject->id = $rssid;
|
||||
if (!empty($rss->channel['description'])) {
|
||||
$dataobject->description = addslashes($rss->channel['description']);
|
||||
}
|
||||
if (!empty($rss->channel['title'])) {
|
||||
$dataobject->title = addslashes($rss->channel['title']);
|
||||
}
|
||||
if (!update_record('block_rss_client', $dataobject)) {
|
||||
error('There was an error trying to update rss feed with id:'. $rssid);
|
||||
}
|
||||
$message .= '<br />'. get_string('feedadded', 'block_rss_client');
|
||||
$navigation = $straddedit;
|
||||
}
|
||||
redirect($referrer, $message);
|
||||
/*
|
||||
rss_display_feeds($id);
|
||||
rss_print_form($act, $dataobject->url, $dataobject->id, $dataobject->preferredtitle, $id);
|
||||
*/
|
||||
} else if ( isset($rss_record) && $act == 'rssedit' ) {
|
||||
|
||||
print_header(get_string('feedsaddedit', 'block_rss_client'),
|
||||
get_string('feedsaddedit', 'block_rss_client'),
|
||||
$navigation );
|
||||
|
||||
$preferredtitle = stripslashes_safe($rss_record->preferredtitle);
|
||||
if (empty($preferredtitle)) {
|
||||
$preferredtitle = stripslashes_safe($rss_record->title);
|
||||
}
|
||||
$url = stripslashes_safe($rss_record->url);
|
||||
rss_display_feeds($id, '', $rssid);
|
||||
rss_print_form($act, $url, $rssid, $preferredtitle, $id);
|
||||
|
||||
} else if ($act == 'delfeed') {
|
||||
|
||||
$file = $CFG->dataroot .'/cache/rsscache/'. $rssid .'.xml';
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
//check to make sure that the user is allowed to post new feeds
|
||||
$submitters = $CFG->block_rss_client_submitters;
|
||||
$isteacher = false;
|
||||
if (!empty($course)) {
|
||||
$isteacher = isteacher($course->id);
|
||||
}
|
||||
|
||||
// echo "DEBUG: act = delfeed"; //debug
|
||||
delete_records('block_rss_client', 'id', $rssid);
|
||||
//if the user is an admin or course teacher then allow the user to
|
||||
//assign categories to other uses than personal
|
||||
if (!( isadmin() || $submitters == SUBMITTERS_ALL_ACCOUNT_HOLDERS || ($submitters == SUBMITTERS_ADMIN_AND_TEACHER && $isteacher) ) ) {
|
||||
error(get_string('noguestpost', 'forum'), $referrer);
|
||||
}
|
||||
|
||||
redirect($referrer, get_string('feeddeleted', 'block_rss_client') );
|
||||
if ($act == 'none') {
|
||||
rss_display_feeds();
|
||||
rss_get_form($act, $url, $rssid, $preferredtitle);
|
||||
|
||||
} else if ( isset($rss_record) && $act == 'view' ) {
|
||||
// echo $sql; //debug
|
||||
// print_object($res); //debug
|
||||
if (!$rss_record->id) {
|
||||
print '<strong>'. get_string('couldnotfindfeed', 'block_rss_client') .': '. $rssid .'</strong>';
|
||||
} else {
|
||||
} else if ($act == 'updfeed') {
|
||||
require_variable($url);
|
||||
|
||||
// By capturing the output from fetch_rss this way
|
||||
// error messages do not display and clutter up the moodle interface
|
||||
// however, we do lose out on seeing helpful messages like "cache hit", etc.
|
||||
ob_start();
|
||||
$rss = fetch_rss($rss_record->url);
|
||||
$rss = fetch_rss($url);
|
||||
$rsserror = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if (empty($rss_record->preferredtitle)) {
|
||||
$feedtitle = $rss_record->preferredtitle;
|
||||
|
||||
$dataobject->id = $rssid;
|
||||
if ($rss === false) {
|
||||
$dataobject->description = '';
|
||||
$dataobject->title = '';
|
||||
$dataobject->preferredtitle = '';
|
||||
} else {
|
||||
$feedtitle = $rss->channel['title'];
|
||||
$dataobject->description = addslashes(rss_unhtmlentities($rss->channel['description']));
|
||||
$dataobject->title = addslashes(rss_unhtmlentities($rss->channel['title']));
|
||||
$dataobject->preferredtitle = addslashes($preferredtitle);
|
||||
}
|
||||
print '<table align="center" width="50%" cellspacing="1">'."\n";
|
||||
print '<tr><td colspan="2"><strong>'. $feedtitle .'</strong></td></tr>'."\n";
|
||||
for($y=0; $y < count($rss->items); $y++) {
|
||||
if ($rss->items[$y]['link'] == '') {
|
||||
$rss->items[$y]['link'] = $rss->items[$y]['guid'];
|
||||
}
|
||||
$dataobject->url = addslashes($url);
|
||||
|
||||
if ($rss->items[$y]['title'] == '') {
|
||||
$rss->items[$y]['title'] = '>>';
|
||||
}
|
||||
if (!update_record('block_rss_client', $dataobject)) {
|
||||
error('There was an error trying to update rss feed with id:'. $rssid);
|
||||
}
|
||||
|
||||
print '<tr><td valign="middle">'."\n";
|
||||
print '<a href="'. $rss->items[$y]['link'] .'" target="_blank"><strong>'. $rss->items[$y]['title'];
|
||||
print '</strong></a>'."\n";
|
||||
print '</td>'."\n";
|
||||
if (file_exists($CFG->dirroot .'/blog/lib.php')) {
|
||||
//Blog module is installed - provide "blog this" link
|
||||
print '<td align="right">'."\n";
|
||||
print '<img src="'. $CFG->pixpath .'/blog/blog.gif" alt="'. get_string('blogthis', 'blog').'" title="'. get_string('blogthis', 'blog') .'" border="0" align="middle" />'."\n";
|
||||
print '<a href="'. $CFG->wwwroot .'/blog/blogthis.php?userid='. $userid .'&act=use&item='. $y .'&rssid='. $rssid .'"><small><strong>'. get_string('blogthis', 'blog') .'</strong></small></a>'."\n";
|
||||
redirect($referrer, get_string('feedupdated', 'block_rss_client'));
|
||||
/* rss_display_feeds();
|
||||
rss_get_form($act, $dataobject->url, $rssid, $dataobject->preferredtitle);
|
||||
*/
|
||||
} else if ($act == 'addfeed' ) {
|
||||
|
||||
require_variable($url);
|
||||
$dataobject->userid = $USER->id;
|
||||
$dataobject->description = '';
|
||||
$dataobject->title = '';
|
||||
$dataobject->url = addslashes($url);
|
||||
$dataobject->preferredtitle = addslashes($preferredtitle);
|
||||
|
||||
$rssid = insert_record('block_rss_client', $dataobject);
|
||||
if (!$rssid) {
|
||||
error('There was an error trying to add a new rss feed:'. $url);
|
||||
}
|
||||
|
||||
// By capturing the output from fetch_rss this way
|
||||
// error messages do not display and clutter up the moodle interface
|
||||
// however, we do lose out on seeing helpful messages like "cache hit", etc.
|
||||
ob_start();
|
||||
$rss = fetch_rss($url);
|
||||
$rsserror = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if ($rss === false) {
|
||||
$message = 'There was an error loading this rss feed. You may want to verify the url you have specified before using it.'; //Daryl Hawes note: localize this line
|
||||
} else {
|
||||
|
||||
$dataobject->id = $rssid;
|
||||
if (!empty($rss->channel['description'])) {
|
||||
$dataobject->description = addslashes(rss_unhtmlentities($rss->channel['description']));
|
||||
}
|
||||
if (!empty($rss->channel['title'])) {
|
||||
$dataobject->title = addslashes(rss_unhtmlentities($rss->channel['title']));
|
||||
}
|
||||
if (!update_record('block_rss_client', $dataobject)) {
|
||||
error('There was an error trying to update rss feed with id:'. $rssid);
|
||||
}
|
||||
$message = get_string('feedadded', 'block_rss_client');
|
||||
}
|
||||
redirect($referrer, $message);
|
||||
/*
|
||||
rss_display_feeds();
|
||||
rss_get_form($act, $dataobject->url, $dataobject->id, $dataobject->preferredtitle);
|
||||
*/
|
||||
} else if ( $act == 'rss_edit') {
|
||||
|
||||
$rss_record = get_record('block_rss_client', 'id', $rssid);
|
||||
$preferredtitle = stripslashes_safe($rss_record->preferredtitle);
|
||||
if (empty($preferredtitle)) {
|
||||
$preferredtitle = stripslashes_safe($rss_record->title);
|
||||
}
|
||||
$url = stripslashes_safe($rss_record->url);
|
||||
rss_display_feeds('', $rssid);
|
||||
rss_get_form($act, $url, $rssid, $preferredtitle);
|
||||
|
||||
} else if ($act == 'delfeed') {
|
||||
|
||||
$file = $CFG->dataroot .'/cache/rsscache/'. $rssid .'.xml';
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
// echo "DEBUG: act = delfeed"; //debug
|
||||
//Daryl Hawes note: convert this sql statement to a moodle function call
|
||||
$sql = 'DELETE FROM '. $CFG->prefix .'block_rss_client WHERE id='. $rssid;
|
||||
$res= $db->Execute($sql);
|
||||
|
||||
redirect($referrer, get_string('feeddeleted', 'block_rss_client') );
|
||||
|
||||
/* rss_display_feeds();
|
||||
rss_get_form($act, $url, $rssid, $preferredtitle);
|
||||
*/
|
||||
} else if ($act == 'view') {
|
||||
// echo $sql; //debug
|
||||
// print_object($res); //debug
|
||||
$rss_record = get_record('block_rss_client', 'id', $rssid);
|
||||
if (!$rss_record->id) {
|
||||
print '<strong>'. get_string('couldnotfindfeed', 'block_rss_client') .': '. $rssid .'</strong>';
|
||||
} else {
|
||||
// By capturing the output from fetch_rss this way
|
||||
// error messages do not display and clutter up the moodle interface
|
||||
// however, we do lose out on seeing helpful messages like "cache hit", etc.
|
||||
ob_start();
|
||||
$rss = fetch_rss($rss_record->url);
|
||||
$rsserror = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if (empty($rss_record->preferredtitle)) {
|
||||
$feedtitle = stripslashes_safe($rss_record->preferredtitle);
|
||||
} else {
|
||||
print '<td> ';
|
||||
$feedtitle = stripslashes_safe(rss_unhtmlentities($rss->channel['title']));
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
print '<tr><td colspan=2><small>';
|
||||
print $rss->items[$y]['description'] .'</small></td></tr>'."\n";
|
||||
print '<table align="center" width="50%" cellspacing="1">'."\n";
|
||||
print '<tr><td colspan="2"><strong>'. $feedtitle .'</strong></td></tr>'."\n";
|
||||
for($y=0; $y < count($rss->items); $y++) {
|
||||
$rss->items[$y]['title'] = stripslashes_safe(rss_unhtmlentities($rss->items[$y]['title']));
|
||||
$rss->items[$y]['description'] = stripslashes_safe(rss_unhtmlentities($rss->items[$y]['description']));
|
||||
if ($rss->items[$y]['link'] == '') {
|
||||
$rss->items[$y]['link'] = $rss->items[$y]['guid'];
|
||||
}
|
||||
|
||||
if ($rss->items[$y]['title'] == '') {
|
||||
$rss->items[$y]['title'] = '>>';
|
||||
}
|
||||
|
||||
print '<tr><td valign="middle">'."\n";
|
||||
print '<a href="'. $rss->items[$y]['link'] .'" target="_blank"><strong>'. $rss->items[$y]['title'];
|
||||
print '</strong></a>'."\n";
|
||||
print '</td>'."\n";
|
||||
if (file_exists($CFG->dirroot .'/blog/lib.php')) {
|
||||
//Blog module is installed - provide "blog this" link
|
||||
print '<td align="right">'."\n";
|
||||
print '<img src="'. $CFG->pixpath .'/blog/blog.gif" alt="'. get_string('blogthis', 'blog').'" title="'. get_string('blogthis', 'blog') .'" border="0" align="middle" />'."\n";
|
||||
print '<a href="'. $CFG->wwwroot .'/blog/blogthis.php?blogid='. $blogid .'&act=use&item='. $y .'&rssid='. $rssid .'"><small><strong>'. get_string('blogthis', 'blog') .'</strong></small></a>'."\n";
|
||||
} else {
|
||||
print '<td> ';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
print '<tr><td colspan=2><small>';
|
||||
print $rss->items[$y]['description'] .'</small></td></tr>'."\n";
|
||||
}
|
||||
print '</table>'."\n";
|
||||
}
|
||||
print '</table>'."\n";
|
||||
} else {
|
||||
rss_display_feeds();
|
||||
rss_get_form($act, $url, $rssid, $preferredtitle);
|
||||
}
|
||||
} else {
|
||||
rss_display_feeds($id);
|
||||
rss_print_form($act, $url, $rssid, $preferredtitle, $id);
|
||||
}
|
||||
print_footer();
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php //$Id$
|
||||
// Print an error page condition
|
||||
require_once('../../config.php');
|
||||
|
||||
$error = required_param('error', PARAM_CLEAN);
|
||||
require_once('../../config.php');
|
||||
|
||||
print_header(get_string('error'),
|
||||
get_string('error'),
|
||||
get_string('error') );
|
||||
require_variable($error);
|
||||
|
||||
print clean_text(urldecode($error));
|
||||
print_header(get_string('error'),
|
||||
get_string('error'),
|
||||
get_string('error') );
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
print clean_text(urldecode($error));
|
||||
|
||||
print_footer();
|
||||
?>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php //$Id$
|
||||
<?php
|
||||
require_once($CFG->libdir .'/rsslib.php');
|
||||
?>
|
||||
<table cellpadding="9" cellspacing="0">
|
||||
@@ -17,7 +17,6 @@
|
||||
<?php print_string('clientnumentries', 'block_rss_client') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">block_rss_timeout:</td>
|
||||
<td>
|
||||
@@ -32,7 +31,6 @@
|
||||
<?php print_string('timeout', 'block_rss_client') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">block_rss_client_submitters:</td>
|
||||
<td>
|
||||
@@ -42,15 +40,13 @@
|
||||
$selected = '0';
|
||||
$CFG->block_rss_client_submitters = 0;
|
||||
}
|
||||
|
||||
// SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody')
|
||||
// removed everybody option for 1.5 beta
|
||||
// things are not quite working yet to allow this - revisit later
|
||||
// also 'everybody' should be 'site members' or something clearer since
|
||||
// it does not include guests
|
||||
$options = array (
|
||||
SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody'),
|
||||
SUBMITTERS_ADMIN_ONLY => get_string('administrators'),
|
||||
SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers') );
|
||||
$options = array ( SUBMITTERS_ADMIN_ONLY => get_string('administrators'),
|
||||
SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers') );
|
||||
|
||||
choose_from_menu ($options, 'block_rss_client_submitters', $selected);
|
||||
?>
|
||||
@@ -60,16 +56,13 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="3" align="center">
|
||||
<input type="submit" value="<?php print_string('savechanges') ?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center"><a href=" <?php echo $CFG->wwwroot; ?>/blocks/rss_client/block_rss_client_action.php?id=<?php
|
||||
if (!isset($id)) {
|
||||
$id = '';
|
||||
}
|
||||
echo $id; ?>"><?php print_string('feedsaddedit', 'block_rss_client')?></a></center><br /><br />
|
||||
|
||||
<td colspan="3" align="center"><a href=" <?php echo $CFG->wwwroot; ?>/blocks/rss_client/block_rss_client_action.php?courseid=<?php echo $courseid; ?>"><?php print_string('feedsaddedit', 'block_rss_client')?></a></center><br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<?php // $Id$ //
|
||||
<?php
|
||||
require_once($CFG->libdir .'/rsslib.php');
|
||||
|
||||
$id = optional_param('id', SITEID, PARAM_INT);
|
||||
|
||||
//create a page object for url_get_full()
|
||||
$page = page_create_object($this->instance->pagetype, $this->instance->pageid);
|
||||
|
||||
/// Print tabs at top
|
||||
$currentaction = optional_param('currentaction', '', PARAM_ALPHA);
|
||||
global $currentaction;
|
||||
if (empty($currentaction) || $currentaction == 'configblock') {
|
||||
$currentaction = 'configblock';
|
||||
} else {
|
||||
@@ -38,7 +36,6 @@ if ($currentaction == 'configblock') {
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" width="50%">
|
||||
<?php print_string('shownumentrieslabel', 'block_rss_client') ?>
|
||||
@@ -57,7 +54,6 @@ if ($currentaction == 'configblock') {
|
||||
?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" width="50%">
|
||||
<?php print_string('choosefeedlabel', 'block_rss_client') ?>
|
||||
@@ -74,15 +70,7 @@ if ($currentaction == 'configblock') {
|
||||
$selectedarray = array($this->config->rssid);
|
||||
}
|
||||
}
|
||||
global $USER;
|
||||
$admins = get_admins();
|
||||
$adminsql = '';
|
||||
if (!empty($admins)) {
|
||||
foreach ($admins as $admin) {
|
||||
$adminsql = ' OR userid = '.$admin->id;
|
||||
}
|
||||
}
|
||||
if ($rssfeeds = get_records_select('block_rss_client','userid = '.$USER->id . $adminsql)) {
|
||||
if ($rssfeeds = get_records('block_rss_client')) {
|
||||
foreach($rssfeeds as $rssfeed) {
|
||||
if (!empty($rssfeed->preferredtitle)) {
|
||||
$feedtitle = stripslashes_safe($rssfeed->preferredtitle);
|
||||
@@ -99,16 +87,12 @@ if ($currentaction == 'configblock') {
|
||||
} else {
|
||||
print_string('nofeeds', 'block_rss_client');
|
||||
if ( isadmin() ) {
|
||||
$addrsspage = $page->url_get_full(array('instanceid' => $this->instance->id,
|
||||
'sesskey' => $USER->sesskey, 'blockaction' => 'config',
|
||||
'currentaction' => 'managefeeds', 'id' => $id));
|
||||
print ' <a href="'.$addrsspage.'">'. get_string('editnewsfeeds', 'block_rss_client') .'</a><br />';
|
||||
print ' <a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php"> '. get_string('editnewsfeeds', 'block_rss_client') .'</a><br />';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" width="50%"><?php print_string('uploadlabel'); ?></td>
|
||||
<?php
|
||||
@@ -120,7 +104,6 @@ if ($currentaction == 'configblock') {
|
||||
<td width="50%"><input type="text" name="title" size="30" value="<?php echo $title; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" width="50%"><?php print_string('clientshowchannellinklabel', 'block_rss_client'); ?></td>
|
||||
<td width="50%">
|
||||
@@ -137,7 +120,6 @@ if ($currentaction == 'configblock') {
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right" width="50%"><?php print_string('clientshowimagelabel', 'block_rss_client'); ?></td>
|
||||
<td width="50%">
|
||||
@@ -154,7 +136,6 @@ if ($currentaction == 'configblock') {
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2" align="center">
|
||||
<input type="submit" value="<?php print_string('savechanges') ?>">
|
||||
@@ -166,8 +147,8 @@ if ($currentaction == 'configblock') {
|
||||
global $act, $url, $rssid, $preferredtitle;
|
||||
print '<table cellpadding="9" cellspacing="0" class="blockconfigtable">';
|
||||
print '<tr valign="top"><td>';
|
||||
rss_display_feeds($id,$USER->id);
|
||||
rss_display_feeds();
|
||||
print '</form>'; //not sure that this is needed
|
||||
rss_print_form($act, $url, $rssid, $preferredtitle, $id);
|
||||
rss_get_form($act, $url, $rssid, $preferredtitle);
|
||||
print '</td></tr></table>';
|
||||
} ?>
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
/// This file to be included so we can assume config.php has already been included.
|
||||
/// We also assume that $inactive, $activetab and $currentaction have been set
|
||||
|
||||
global $USER;
|
||||
$tabs = $row = array();
|
||||
global $USER;
|
||||
$tabs = $row = array();
|
||||
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id));
|
||||
$row[] = new tabobject('configblock', $script,
|
||||
get_string('configblock', 'block_rss_client'));
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock'));
|
||||
$row[] = new tabobject('configblock', $script,
|
||||
get_string('configblock', 'block_rss_client'));
|
||||
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $id));
|
||||
$row[] = new tabobject('managefeeds', $script,
|
||||
get_string('managefeeds', 'block_rss_client'));
|
||||
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds'));
|
||||
$row[] = new tabobject('managefeeds', $script,
|
||||
get_string('managefeeds', 'block_rss_client'));
|
||||
|
||||
$tabs[] = $row;
|
||||
$tabs[] = $row;
|
||||
|
||||
/// Print out the tabs and continue!
|
||||
print '<div align="center">';
|
||||
print_tabs($tabs, $currentaction);
|
||||
print '</div>';
|
||||
/// Print out the tabs and continue!
|
||||
print '<div align="center">';
|
||||
print_tabs($tabs, $currentaction);
|
||||
print '</div>';
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user