Compare commits
686 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e3db7108a8 | |||
| 2750460adc | |||
| 23e1dc24f3 | |||
| 377da1a0e2 | |||
| 8b33bf0124 | |||
| ce9d5ce529 | |||
| 9401569e39 | |||
| 696b50fff2 | |||
| 85bf673124 | |||
| 3849917982 | |||
| ae4d27ee4e | |||
| b70af87f04 | |||
| ba9c840c99 | |||
| d90cb507f3 | |||
| 853bb906ba | |||
| 8f99b22439 | |||
| b608d7cad3 | |||
| 60b6fc1004 | |||
| 7dfca8bbb1 | |||
| bf54a837aa | |||
| 8ed47badec | |||
| dab8b4662a | |||
| 6317557cfe | |||
| ef5a26d701 | |||
| 293d2ce08e | |||
| 4cbacc2c88 | |||
| c7b1aaeed4 | |||
| 8a57655b50 | |||
| fa3ce02ba1 | |||
| 344c50611d | |||
| c9666935af | |||
| 7cf3b7fabd | |||
| f81b4b1a1b | |||
| 79eebc83aa | |||
| 989f2ccd47 | |||
| daea824d68 | |||
| e21c0ffc23 | |||
| 41fd8ea177 | |||
| e8a51e3f44 | |||
| fa62c456eb | |||
| cca01e1519 | |||
| 293d56acaa | |||
| b0bbcb5647 | |||
| d86dca38ec | |||
| ac594757cb | |||
| fcdca8b2ba | |||
| 0927364827 | |||
| 7d5bb42327 | |||
| c807105f75 | |||
| 5a60645dc7 | |||
| 64622defdd | |||
| 2fe9f46996 | |||
| 9228be2bd2 | |||
| 5c33b48580 | |||
| 993f282295 | |||
| 6df6296812 | |||
| 668ce6df14 | |||
| 87e70ea390 | |||
| 60d12f2e35 | |||
| 7330a604c7 | |||
| def6f22e27 | |||
| 7567dcd370 | |||
| a26f30774b | |||
| b24126e9a9 | |||
| c9609a1f0d | |||
| 37841afffe | |||
| 81b65eaec6 | |||
| 8c2eb9802e | |||
| 6920a2a59c | |||
| b6e33658e3 | |||
| ed22c4f3bc | |||
| 8d5e99f086 | |||
| bd52a0145e | |||
| 3c58497b82 | |||
| f48f0e399d | |||
| 68b8dfa13b | |||
| b0e97aec74 | |||
| c13722179f | |||
| 7e7b0ef002 | |||
| 7b2ce0378b | |||
| 42693210f1 | |||
| 6e1cef3394 | |||
| cad6cf5134 | |||
| d71004a3a2 | |||
| 00db7acb37 | |||
| dcd981ac12 | |||
| 97aa751b03 | |||
| 67b71d5027 | |||
| 1e89d31bf8 | |||
| 33f23cb8df | |||
| e17732128a | |||
| 0e6b0d5c48 | |||
| 2659a6411d | |||
| 91e546cc58 | |||
| 6872a4ee5f | |||
| 3417898861 | |||
| e8c36b7a7a | |||
| d099661cd4 | |||
| 466c30cf6e | |||
| b0aeae8288 | |||
| a655cd9a38 | |||
| 401e26306e | |||
| a5762bd531 | |||
| 6a1a294942 | |||
| 5b78424ea3 | |||
| 01f35fac14 | |||
| 5466503ec1 | |||
| 2e177ee4bc | |||
| 13d6383c9a | |||
| 250aa125bb | |||
| 6e7cd09c2f | |||
| af2146d651 | |||
| 5f73b9b758 | |||
| d62c52b985 | |||
| 9ba5cf85e0 | |||
| 9e6f284ae6 | |||
| 3c8c7ad245 | |||
| acccc0148b | |||
| 1a91392796 | |||
| 19f417f6c3 | |||
| e58aa8db4a | |||
| 47578048b9 | |||
| a045329951 | |||
| bb82c7ba82 | |||
| 79dc9d16be | |||
| 803efadffc | |||
| f6ee732c66 | |||
| 90b6a3282f | |||
| f9109b1c40 | |||
| 66adefcbf6 | |||
| c01c3954af | |||
| c48ca9308f | |||
| f77192322f | |||
| 73b318a63f | |||
| fe4acc87a0 | |||
| db3f7a489c | |||
| aff7b7bd00 | |||
| f213d5dd64 | |||
| 8489b65737 | |||
| 8d96b8a10a | |||
| af007d91ee | |||
| d60572c8dd | |||
| bd9abfe3db | |||
| 1d3301fc3d | |||
| 52742e6f05 | |||
| f9cecaf2f1 | |||
| d3e5a45ac7 | |||
| e80947d967 | |||
| 5bd068b7ad | |||
| 7f1908567b | |||
| 1043fa2dff | |||
| 900022293b | |||
| 36244d8f41 | |||
| 5838338e84 | |||
| f90d3476c6 | |||
| 0bd255acd7 | |||
| b8b2eacad4 | |||
| 638a8adc7b | |||
| 3af559d414 | |||
| ca31757ba3 | |||
| d609b3a37b | |||
| 09b4e87bf9 | |||
| c9b34a7861 | |||
| 32c0a71736 | |||
| 2f49a4fbbc | |||
| 5ce30e94ed | |||
| b1995508c1 | |||
| 4b593df481 | |||
| fe219370ad | |||
| 2076251d51 | |||
| de41196269 | |||
| 99feca8c8e | |||
| e78860178a | |||
| a5566c36e8 | |||
| 87290838c9 | |||
| 20ad9953df | |||
| d3e7c0e206 | |||
| a20d27df81 | |||
| 374e173f11 | |||
| 01cb839f5c | |||
| 0c2153fd8a | |||
| 633e1ee493 | |||
| 8921708582 | |||
| 52f979d9a1 | |||
| 87cba17acf | |||
| 239a789ebd | |||
| 8cc503ed77 | |||
| 32c4ae7dc3 | |||
| 84d46ef3d5 | |||
| 5c044b8812 | |||
| f6cb1501e4 | |||
| 88e8672ef6 | |||
| 26cce91d9b | |||
| f80e271577 | |||
| 7bae742ae7 | |||
| 5930e65512 | |||
| 28894c72b2 | |||
| d9c201e1a0 | |||
| 27c18c1776 | |||
| ca9825f48e | |||
| 8a08a041f4 | |||
| 843808a9d8 | |||
| b139c82dfc | |||
| 5e57504798 | |||
| c7e53eba46 | |||
| 6bfdfaffe9 | |||
| fa86dd5898 | |||
| f1d9c9af1d | |||
| 99fc498b2f | |||
| e9f89ed558 | |||
| d3dd9635ea | |||
| 7a3631b6ee | |||
| 5e24f43df6 | |||
| d15c13904e | |||
| e217284df4 | |||
| 0f26f875f5 | |||
| e5636d3015 | |||
| 1ccb8ec916 | |||
| 0f5a44ca98 | |||
| aba846b248 | |||
| 264062798b | |||
| 1e7321b854 | |||
| cafd7f019a | |||
| 09ea9739f3 | |||
| 6a3d064a00 | |||
| e1578125e4 | |||
| 88b367e331 | |||
| 5c8e9c9d6e | |||
| b1fcf3d343 | |||
| bd72653e3c | |||
| 81cdbf08e9 | |||
| a2b74a9300 | |||
| d2d26c34ba | |||
| 0ace4d2116 | |||
| 19db0355d3 | |||
| 2e8ee5302f | |||
| 8bfa3f6c5f | |||
| 3271d9e6d1 | |||
| 98c51965c1 | |||
| 84b23dce22 | |||
| 3563c6c420 | |||
| 1e266ae4b0 | |||
| b4d17605c1 | |||
| cf6ffbe73b | |||
| a628b65cfa | |||
| 7f51421503 | |||
| f6a157d14a | |||
| fc4ac66431 | |||
| 94e16c079c | |||
| f8c56dd156 | |||
| d8fcdab45c | |||
| 27fb92f48f | |||
| 5dc53c6b7b | |||
| f0d2d9ae0c | |||
| 7a43fb909b | |||
| 77f814a368 | |||
| 8eaa523a2c | |||
| 01d38e9938 | |||
| 04bfc2247d | |||
| 050ed53908 | |||
| 24243ec058 | |||
| 170ab43ad0 | |||
| f7b1762793 | |||
| f4fb213988 | |||
| d8572e7021 | |||
| 521a96d4ef | |||
| 2bab640cd6 | |||
| ffe67636f7 | |||
| c2f3c09b3b | |||
| 9751ebf3ac | |||
| 9e2c7c7fa3 | |||
| af7471c268 | |||
| eb87e4be97 | |||
| e6a99eac77 | |||
| 1eca074507 | |||
| 56bb24458a | |||
| 538e5a2810 | |||
| c6d9f6a175 | |||
| 116244fbae | |||
| 02c9b15942 | |||
| 656e41c472 | |||
| fc80a68f89 | |||
| b40f8bad2f | |||
| 2a0a625e35 | |||
| 4f510e2ec8 | |||
| 803b4bf64c | |||
| 775db8e809 | |||
| 7585949466 | |||
| 6b344faba7 | |||
| 9609ee0a4f | |||
| 4dfc8f1d79 | |||
| 9143ed3366 | |||
| 472da9a27d | |||
| 4d2892942a | |||
| 831b76108a | |||
| 9eb89d835c | |||
| 90459a1db8 | |||
| ee4cee1a4c | |||
| 6c60a57d31 | |||
| b97b59961e | |||
| 858c53d8c9 | |||
| ae5c32e389 | |||
| 1a9c4ef509 | |||
| 787b30c0c2 | |||
| edfda53d51 | |||
| 26aac52ce0 | |||
| 1f322589be | |||
| eab3ae18fc | |||
| 96ef423773 | |||
| a8d9136e89 | |||
| 1244ef78ac | |||
| 03008bca7e | |||
| 33981a427d | |||
| eea7d42fd1 | |||
| a4fa47e7ea | |||
| d4dd4c07fe | |||
| df58100c31 | |||
| a080d1ec16 | |||
| 321a287501 | |||
| 9ed43273aa | |||
| 6365af1cf6 | |||
| 7044ea9423 | |||
| 54618b81a4 | |||
| 585b98c78c | |||
| b0c7638f9c | |||
| 4fc82e8dc9 | |||
| b978bf3a87 | |||
| dda4dbce59 | |||
| c6a5a391d4 | |||
| ed6e226e64 | |||
| 410cc4e472 | |||
| e3ff4d6046 | |||
| e8e22b7718 | |||
| 445ef592dd | |||
| 3fff3a34f7 | |||
| a6376758d6 | |||
| 8231ca599e | |||
| 80ababd00a | |||
| cab7778f18 | |||
| 950acb9c73 | |||
| d5fedfa4a3 | |||
| fa730d469f | |||
| 9b4c44e5ed | |||
| 1558c8e6b4 | |||
| b259fd9a25 | |||
| 6e18a9b615 | |||
| 3ad5be78b5 | |||
| 9cd5f2f577 | |||
| 668483e068 | |||
| 7da5cf7efd | |||
| 75889b48e3 | |||
| d9571844fc | |||
| 30cdc044f7 | |||
| f4f53da543 | |||
| d8b405fda9 | |||
| 2237ea1c13 | |||
| ad961eab24 | |||
| e92c4dcb0a | |||
| 52a84d9eb8 | |||
| 64a6329f61 | |||
| 86c91b1210 | |||
| 88dd35ee8e | |||
| b47bbe5255 | |||
| 7a258d4168 | |||
| 4eaf16f264 | |||
| 40242aaa8f | |||
| 1ad36c7821 | |||
| ba1d266228 | |||
| 84bf769f6b | |||
| 80546a1195 | |||
| 45dd6a2241 | |||
| 3b563f5893 | |||
| a33d21b7d9 | |||
| b2ee750780 | |||
| e53a867fa4 | |||
| 3c5ecd5859 | |||
| b332877b96 | |||
| 0ac94304fc | |||
| 4e59cc4453 | |||
| 4a6638f689 | |||
| e699a73bf4 | |||
| be19968cb3 | |||
| a2d608daf9 | |||
| 0b2db6dca0 | |||
| d9f6fdc21e | |||
| a6109173a2 | |||
| c522818828 | |||
| 59316ec573 | |||
| 4d4e0c7d3d | |||
| 196b6f3918 | |||
| e747435fcd | |||
| dcdb86c08a | |||
| a396bc7d75 | |||
| c1e4fa8fbf | |||
| 011d1af528 | |||
| 62e3a52588 | |||
| 461594cc72 | |||
| ecfecb994d | |||
| 1a5c004e96 | |||
| 8730f7dd53 | |||
| 0b22495f37 | |||
| 7aa951a2cc | |||
| 2fc29c74ab | |||
| c2a4225d1d | |||
| 31e1d6582c | |||
| ca4f8f38b3 | |||
| a8d101b5c4 | |||
| 1235148f9f | |||
| a734c1f59f | |||
| 917aaad1a2 | |||
| f4f655747d | |||
| b8b21c5d2a | |||
| 1b94c6e4b7 | |||
| 6bfdf6cd1e | |||
| 9908a3f5a1 | |||
| 211d5844d4 | |||
| cd784f2438 | |||
| 45e3b380d2 | |||
| fabf55370a | |||
| c0b6773831 | |||
| 74fefb48d5 | |||
| f138d59dba | |||
| 7252b5889b | |||
| 0af074a894 | |||
| fa8452c1d7 | |||
| 81de2d85a6 | |||
| 09182fa82d | |||
| 4e50a79a26 | |||
| b5820d9add | |||
| a8ec259abf | |||
| a62af9c397 | |||
| ce53b30a7a | |||
| 9416fe3a9c | |||
| b3cbec74d9 | |||
| 718ffbfb63 | |||
| cc00f2763f | |||
| f10451c414 | |||
| 562dc5fdda | |||
| e2dfe8bfca | |||
| a28ee0a933 | |||
| 1fdce070c4 | |||
| 69d788e2af | |||
| 15f2ccbbbd | |||
| 66a988f08e | |||
| b9a6d9cd1e | |||
| 179fc95c04 | |||
| a2182b2420 | |||
| 86726446ab | |||
| 3b3b5b4cc5 | |||
| db68f9fedf | |||
| ea799baf48 | |||
| 5bb9d213fe | |||
| 2c550eefbd | |||
| c34b9b9c97 | |||
| 3ee2c02ec3 | |||
| 59900bd490 | |||
| c40999b0b6 | |||
| 36be64d1da | |||
| 54e296b115 | |||
| 20ed8a7215 | |||
| 504af96b2e | |||
| f1b29e2e69 | |||
| 7c1fb23156 | |||
| 31eb4b15b8 | |||
| 826ea2ba9a | |||
| 83dbd468f9 | |||
| 68696f6aa8 | |||
| b7e97fcc73 | |||
| a836952539 | |||
| ba34f3372d | |||
| d6fd65c9c9 | |||
| ed6df9192e | |||
| 727c9ec658 | |||
| 562a703ffd | |||
| 1bd32f7b63 | |||
| 19c8c196b2 | |||
| 233fd3da0b | |||
| 0f3a1c9382 | |||
| d9fc0fc2ad | |||
| af8e80ec8a | |||
| c5150fe5a9 | |||
| 09eb304cf7 | |||
| 14b9196e8d | |||
| fdefa7ef01 | |||
| 9abd181aee | |||
| 2b7a363f02 | |||
| e85a202ba3 | |||
| 3056105182 | |||
| 7c596baca7 | |||
| ef3df6f086 | |||
| 9e0c47a5bc | |||
| 8e4e1d73bd | |||
| 052fdabdbd | |||
| b336fbda27 | |||
| ae2ed9974a | |||
| 28e9a6e43c | |||
| 1d0a5c8ff5 | |||
| 19623c973c | |||
| c2b7ac3fb7 | |||
| 76b58ae598 | |||
| 6fce318ec5 | |||
| e3455f160a | |||
| 95e5c19295 | |||
| a78af87881 | |||
| 34949d8dcb | |||
| 1589c98c56 | |||
| 68060caee6 | |||
| 4089c20bd1 | |||
| cbc2417b31 | |||
| 40e2eda7ae | |||
| 414c6bd2e7 | |||
| 8732dca153 | |||
| 7c08ef3653 | |||
| e696821ea4 | |||
| cb8e73e2c7 | |||
| d6693a3400 | |||
| 104189c1f4 | |||
| a727be0829 | |||
| 083dad4922 | |||
| 9f60b599b9 | |||
| 1b98048119 | |||
| 74f350d482 | |||
| 042117ea4f | |||
| 7ac2e04a44 | |||
| 6575c6f5ad | |||
| bec90d263d | |||
| 9920530563 | |||
| 63513603e7 | |||
| 41d7faf891 | |||
| ecec5caee8 | |||
| 95a3fb3aad | |||
| 04adc7de38 | |||
| 4854bec6cf | |||
| 8e74a6eb9e | |||
| 7a201b247e | |||
| 437ef94eb2 | |||
| 8e1e849480 | |||
| e790b61e38 | |||
| 551f0b5d7e | |||
| dbd594ed15 | |||
| ab1736ab1f | |||
| 9f39ff6d96 | |||
| 96f56bc4ff | |||
| 5d4c573887 | |||
| f1ad20d929 | |||
| bf522dad40 | |||
| 2273ddbb27 | |||
| 5f70ddb676 | |||
| a8088232b1 | |||
| ff1b96e9f0 | |||
| 7ccb369f67 | |||
| 2eb638be81 | |||
| 2ded7bc2eb | |||
| c799044c2c | |||
| 660d3b9530 | |||
| 0a6a753a7f | |||
| 1c7166a8d4 | |||
| 71989c5d39 | |||
| 5066b1258c | |||
| 9c221df743 | |||
| 47fcfc7317 | |||
| ffeeed9b32 | |||
| f943a78cbe | |||
| 0e2b6268f0 | |||
| 8e0b21b0b2 | |||
| 45864cc86e | |||
| ef8197d3af | |||
| 686bbac879 | |||
| 9ee705e74a | |||
| a453501cdc | |||
| af4a1292af | |||
| a5c3aabca8 | |||
| e0d92ff281 | |||
| 03abe79e77 | |||
| b17d944267 | |||
| 7aecee0977 | |||
| 9988588aed | |||
| a7bd7637b4 | |||
| dea80d1f30 | |||
| 60eaa2e72d | |||
| 3364157a4b | |||
| 7d728003ae | |||
| d1451e4f0e | |||
| 0bc4168200 | |||
| 6c6f7c851b | |||
| 4bba5a6f44 | |||
| 4404eb3b01 | |||
| a65d282818 | |||
| 8aee86e196 | |||
| afb3efd947 | |||
| 4987fdbaef | |||
| 8f83745255 | |||
| 2f6b6e9241 | |||
| 577a9f5805 | |||
| 7f871f939b | |||
| 73da033354 | |||
| b94129bc1c | |||
| e8c5ac5251 | |||
| de4add7e1e | |||
| 617ef2a336 | |||
| a55eff0fab | |||
| a081748db4 | |||
| d0afc97d3e | |||
| 4f7e719598 | |||
| ad2f4cff93 | |||
| 8bd763d2da | |||
| ea40ec3c8f | |||
| 20f2564695 | |||
| cc01353321 | |||
| 9cf078114f | |||
| 0542e675b9 | |||
| 3cae7304e5 | |||
| 59194f400e | |||
| 7577a51e48 | |||
| cd735125df | |||
| c6ce18c221 | |||
| 4b8a063ad3 | |||
| 545fa9f30f | |||
| 73de424b0b | |||
| 9bfb8bdbe3 | |||
| 154965a441 | |||
| 4b5fbbed17 | |||
| a2d6e38bd9 | |||
| 4ac48edb9b | |||
| 9f9743cb88 | |||
| 255e7cc375 | |||
| 1c63d8955d | |||
| b74a216ad1 | |||
| 41a5673659 | |||
| 56e1965f4f | |||
| d1e3c0f2ec | |||
| 7b8c690ecf | |||
| f800bf46f6 | |||
| fdcabcb3f1 | |||
| 28b7f29fbc | |||
| 7575a38529 | |||
| ca57f3dd0d | |||
| c819e5cadd | |||
| 872964f140 | |||
| 28a1d6e3c9 | |||
| fc1e2380e4 | |||
| eada4f02cc | |||
| 70cf311253 | |||
| b0f625ebf3 | |||
| 9c9c50d8ec | |||
| e2f5df2d6f | |||
| 3ca50b0dd3 | |||
| 1ecce737cc | |||
| f882530904 | |||
| 6a800f3825 | |||
| fb6c31f207 | |||
| 3d5bd70fea | |||
| c32580cea0 | |||
| 88178d9b78 | |||
| 5553359aa4 | |||
| 503fc99f88 | |||
| ae21a6519b | |||
| cfc90a8c60 | |||
| a3572566d3 | |||
| c8f324143a | |||
| bf4846358f | |||
| e3c1819c36 | |||
| fd95bf5153 | |||
| 7342c508e7 | |||
| d41d24ce4f | |||
| 37e936ab77 | |||
| d8b289ae95 | |||
| 635b51757a | |||
| b7b0aa01a5 | |||
| 837a9c5c12 | |||
| fe0bcf738c | |||
| 3d18158bc8 | |||
| 1e35f5f18e | |||
| c3c9612c1c | |||
| e5da5f70ef | |||
| 864a2b3414 | |||
| 4eec1cbcee | |||
| d8f605d675 | |||
| b3cac2f0e8 | |||
| 930eaf9ec8 | |||
| b3bef28cc0 | |||
| 444014a57e | |||
| 982a81c41f | |||
| fd9e9c6404 | |||
| e8e6e54b7d | |||
| 67faedb211 |
+142
-118
@@ -7,117 +7,122 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/config.php';
|
||||
require_once $CFG->libdir . '/tablelib.php';
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('userauthentication', $adminroot);
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$authsavailable = get_list_of_plugins('auth');
|
||||
if (empty($CFG->auth_plugins_enabled)) {
|
||||
set_config('auth_plugins_enabled', $CFG->auth);
|
||||
$CFG->auth_plugins_enabled = $CFG->auth;
|
||||
}
|
||||
$authsenabled = explode(',', $CFG->auth_plugins_enabled);
|
||||
|
||||
// save form
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (! isset($form->guestloginbutton)) {
|
||||
$form->guestloginbutton = 1;
|
||||
}
|
||||
if (empty($form->alternateloginurl)) {
|
||||
$form->alternateloginurl = '';
|
||||
}
|
||||
if (empty($form->register)) {
|
||||
$form->register = 'manual';
|
||||
}
|
||||
set_config('guestloginbutton', $form->guestloginbutton);
|
||||
set_config('alternateloginurl', $form->alternateloginurl);
|
||||
set_config('auth', $form->register);
|
||||
|
||||
// add $CFG->auth to auth_plugins_enabled list
|
||||
if (!array_search($form->register, $authsenabled)) {
|
||||
$authsenabled[] = $form->register;
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth_plugins_enabled', implode(',', $authsenabled));
|
||||
}
|
||||
//revert auth_plugins_enabled
|
||||
if (isset($CFG->auth_plugins_enabled)) {
|
||||
set_config('auth', $CFG->auth_plugins_enabled);
|
||||
delete_records('config', 'name', 'auth_plugins_enabled');
|
||||
unset($CFG->auth_plugins_enabled);
|
||||
}
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
$authsenabled = array();
|
||||
} else {
|
||||
$authsenabled = explode(',', $CFG->auth);
|
||||
}
|
||||
|
||||
if (!isset($CFG->registerauth)) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
|
||||
if (!isset($CFG->auth_instructions)) {
|
||||
set_config('auth_instructions', '');
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
error(get_string('pluginnotinstalled', 'auth', $auth), $url);
|
||||
}
|
||||
|
||||
// grab GET/POST parameters
|
||||
$params = new object();
|
||||
$params->action = optional_param('action', '', PARAM_ACTION);
|
||||
$params->auth = optional_param('auth', $CFG->auth, PARAM_ALPHANUM);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
switch ($params->action) {
|
||||
$status = '';
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case 'save':
|
||||
if (data_submitted() and confirm_sesskey()) {
|
||||
|
||||
// save settings
|
||||
set_config('guestloginbutton', required_param('guestloginbutton', PARAM_BOOL));
|
||||
set_config('alternateloginurl', stripslashes(trim(required_param('alternateloginurl', PARAM_RAW))));
|
||||
set_config('registerauth', required_param('register', PARAM_SAFEDIR));
|
||||
set_config('auth_instructions', stripslashes(trim(required_param('auth_instructions', PARAM_RAW))));
|
||||
|
||||
// enable registerauth in $CFG->auth if needed
|
||||
if (!empty($CFG->registerauth) and !in_array($CFG->registerauth, $authsenabled)) {
|
||||
$authsenabled[] = $CFG->registerauth;
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
$status = get_string('changessaved');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'disable':
|
||||
// remove from enabled list
|
||||
$key = array_search($params->auth, $authsenabled);
|
||||
if ($key !== false and $params->auth != $CFG->auth) {
|
||||
// remove from enabled list
|
||||
$key = array_search($auth, $authsenabled);
|
||||
if ($key !== false) {
|
||||
unset($authsenabled[$key]);
|
||||
set_config('auth_plugins_enabled', implode(',', $authsenabled));
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
|
||||
if ($auth == $CFG->registerauth) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'enable':
|
||||
// check auth plugin is valid first
|
||||
if (!exists_auth_plugin($params->auth)) {
|
||||
error(get_string('pluginnotinstalled', 'auth', $params->auth), $url);
|
||||
}
|
||||
// add to enabled list
|
||||
if (!array_search($params->auth, $authsenabled)) {
|
||||
$authsenabled[] = $params->auth;
|
||||
if (!in_array($auth, $authsenabled)) {
|
||||
$authsenabled[] = $auth;
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth_plugins_enabled', implode(',', $authsenabled));
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'down':
|
||||
$key = array_search($params->auth, $authsenabled);
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
error(get_string('pluginnotenabled', 'auth', $params->auth), $url);
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
}
|
||||
// move down the list
|
||||
if ($key < (count($authsenabled) - 1)) {
|
||||
$fsave = $authsenabled[$key];
|
||||
$authsenabled[$key] = $authsenabled[$key + 1];
|
||||
$authsenabled[$key + 1] = $fsave;
|
||||
set_config('auth_plugins_enabled', implode(',', $authsenabled));
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'up':
|
||||
$key = array_search($params->auth, $authsenabled);
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth is valid
|
||||
if ($key === false) {
|
||||
error(get_string('pluginnotenabled', 'auth', $params->auth), $url);
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
}
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
$fsave = $authsenabled[$key];
|
||||
$authsenabled[$key] = $authsenabled[$key - 1];
|
||||
$authsenabled[$key - 1] = $fsave;
|
||||
set_config('auth_plugins_enabled', implode(',', $authsenabled));
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
// save settings
|
||||
set_config('auth_plugins_enabled', implode(',', $authsenabled));
|
||||
set_config('auth', $authsenabled[0]);
|
||||
redirect("auth.php?sesskey=$USER->sesskey", get_string('changessaved'), 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -132,43 +137,52 @@ $txt->updown = "$txt->up/$txt->down";
|
||||
// construct the display array, with enabled auth plugins at the top, in order
|
||||
$displayauths = array();
|
||||
$registrationauths = array();
|
||||
$registrationauths['manual'] = $txt->disable;
|
||||
$registrationauths[''] = $txt->disable;
|
||||
foreach ($authsenabled as $auth) {
|
||||
$displayauths[$auth] = get_string("auth_{$auth}title", 'auth');
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
if (method_exists($authplugin, 'user_signup')) {
|
||||
$displayauths[$auth] = get_string("auth_{$auth}title", 'auth');
|
||||
if ($authplugin->can_signup()) {
|
||||
$registrationauths[$auth] = get_string("auth_{$auth}title", 'auth');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($authsavailable as $auth) {
|
||||
if (!array_key_exists($auth, $displayauths)) {
|
||||
$displayauths[$auth] = get_string("auth_{$auth}title", 'auth');
|
||||
if (array_key_exists($auth, $displayauths)) {
|
||||
continue; //already in the list
|
||||
}
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
if (method_exists($authplugin, 'user_signup')) {
|
||||
$displayauths[$auth] = get_string("auth_{$auth}title", 'auth');
|
||||
if ($authplugin->can_signup()) {
|
||||
$registrationauths[$auth] = get_string("auth_{$auth}title", 'auth');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build the display table
|
||||
$table = new flexible_table('auth_admin_table');
|
||||
$table->define_columns(array('name', 'enable', 'order', 'settings'));
|
||||
$table->column_style('enable', 'text-align', 'center');
|
||||
$table->column_style('order', 'text-align', 'center');
|
||||
$table->column_style('settings', 'text-align', 'center');
|
||||
$table->define_headers(array($txt->name, $txt->enable, $txt->updown, $txt->settings));
|
||||
$table->define_baseurl("{$CFG->wwwroot}/{$CFG->admin}/auth.php");
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'flexible generaltable generalbox');
|
||||
$table->set_attribute('style', 'margin:auto;');
|
||||
$table->set_attribute('cellpadding', '5');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
//add always enabled plugins first
|
||||
$displayname = "<span>".$displayauths['manual']."</span>";
|
||||
$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&auth=manual\">{$txt->settings}</a>";
|
||||
$table->add_data(array($displayname, '', '', $settings));
|
||||
$displayname = "<span>".$displayauths['nologin']."</span>";
|
||||
$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&auth=nologin\">{$txt->settings}</a>";
|
||||
$table->add_data(array($displayname, '', '', $settings));
|
||||
|
||||
|
||||
// iterate through auth plugins and add to the display table
|
||||
$updowncount = 1;
|
||||
$authcount = count($authsenabled);
|
||||
$url = "auth.php?sesskey=" . sesskey();
|
||||
foreach ($displayauths as $auth => $name) {
|
||||
if ($auth == 'manual' or $auth == 'nologin') {
|
||||
continue;
|
||||
}
|
||||
// hide/show link
|
||||
if (in_array($auth, $authsenabled)) {
|
||||
$hideshow = "<a href=\"$url&action=disable&auth=$auth\">";
|
||||
@@ -204,7 +218,7 @@ foreach ($displayauths as $auth => $name) {
|
||||
}
|
||||
++ $updowncount;
|
||||
}
|
||||
|
||||
|
||||
// settings link
|
||||
$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&auth=$auth\">{$txt->settings}</a>";
|
||||
|
||||
@@ -214,65 +228,75 @@ foreach ($displayauths as $auth => $name) {
|
||||
|
||||
// output form
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
//print stus messages
|
||||
if ($status !== '') {
|
||||
notify($status, 'notifysuccess');
|
||||
}
|
||||
|
||||
print_simple_box(get_string('configauthenticationplugins', 'admin'), 'center', '700');
|
||||
|
||||
echo "<form $CFG->frametarget id=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
echo "<fieldset class=\"invisiblefieldset\"><input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" /></fieldset>";
|
||||
print_table($table);
|
||||
$table->print_html();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$guestoptions = array();
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo '<form '.$CFG->frametarget.' id="adminsettings" method="post" action="auth.php">';
|
||||
echo '<div class="settingsform">';
|
||||
print_heading(get_string('auth_common_settings', 'auth'));
|
||||
echo '<table cellspacing="0" cellpadding="5" border="0" style="margin-left:auto;margin-right:auto">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="action" value="save" />';
|
||||
echo '<fieldset>';
|
||||
##echo '<table cellspacing="0" cellpadding="5" border="0" style="margin-left:auto;margin-right:auto">';
|
||||
|
||||
// User self registration
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\" style=\"white-space:nowrap\">\n";
|
||||
print_string("selfregistration", "auth");
|
||||
echo ":</td>\n";
|
||||
echo "<td>\n";
|
||||
choose_from_menu($registrationauths, "register", $CFG->auth, "");
|
||||
echo "</td>\n";
|
||||
echo "<td>\n";
|
||||
print_string("selfregistration_help", "auth");
|
||||
echo "</td></tr>\n";
|
||||
echo '<div class="form-item" id="admin-register">';
|
||||
echo '<label for = "menuregister">' . get_string("selfregistration", "auth");
|
||||
echo '<span class="form-shortname">registerauth</span>';
|
||||
echo '</label>';
|
||||
choose_from_menu($registrationauths, "register", $CFG->registerauth, "");
|
||||
echo '<div class="description">' . get_string("selfregistration_help", "auth") . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
// Login as guest button enabled
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td style=\"white-space:nowrap;text-align:right\">\n";
|
||||
print_string("guestloginbutton", "auth");
|
||||
echo ":</td>\n";
|
||||
echo "<td>\n";
|
||||
echo '<div class="form-item" id="admin-guestloginbutton">';
|
||||
echo '<label for = "menuguestloginbutton">' . get_string("guestloginbutton", "auth");
|
||||
echo '<span class="form-shortname">guestloginbutton</span>';
|
||||
echo '</label>';
|
||||
choose_from_menu($guestoptions, "guestloginbutton", $CFG->guestloginbutton, "");
|
||||
echo "</td>\n";
|
||||
echo "<td>\n";
|
||||
print_string("showguestlogin","auth");
|
||||
echo "</td></tr>\n";
|
||||
echo '<div class="description">' . get_string("showguestlogin", "auth") . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
/// An alternate url for the login form. It means we can use login forms that are integrated
|
||||
/// into non-moodle pages
|
||||
echo "<tr valign=\"top\">\n";
|
||||
echo "<td align=\"right\" style=\"white-space:nowrap\">\n";
|
||||
print_string('alternateloginurl', 'auth');
|
||||
echo "</td>\n";
|
||||
echo "<td>\n";
|
||||
echo '<input type="text" size="40" name="alternateloginurl" alt="'.get_string('alternateloginurl', 'auth').'" value="'.$CFG->alternateloginurl."\" />\n";
|
||||
echo "</td>\n";
|
||||
echo "<td>\n";
|
||||
print_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot.'/login/index.php'));
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo '<div class="form-item" id="admin-alternateloginurl">';
|
||||
echo '<label for = "alternateloginurl">' . get_string("alternateloginurl", "auth");
|
||||
echo '<span class="form-shortname">alternateloginurl</span>';
|
||||
echo '</label>';
|
||||
echo '<input type="text" size="60" name="alternateloginurl" id="alternateloginurl" value="'.$CFG->alternateloginurl."\" />\n";
|
||||
echo '<div class="description">' . get_string("alternatelogin", "auth", htmlspecialchars($CFG->wwwroot.'/login/index.php')) . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo "</table>\n";
|
||||
/// Instructions about login/password
|
||||
/// to be showed to users
|
||||
echo '<div class="form-item" id="admin-auth_instructions">';
|
||||
echo '<label for = "auth_instructions">' . get_string("instructions", "auth");
|
||||
echo '<span class="form-shortname">auth_instructions</span>';
|
||||
echo '</label>';
|
||||
echo '<textarea cols="30" rows="4" name="auth_instructions" id="auth_instructions">'.s($CFG->auth_instructions)."</textarea>\n";
|
||||
echo '<div class="description">' . get_string("authinstructions", "auth") . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</fieldset>';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
echo '<div style="text-align:center"><input type="submit" value="'.get_string('savechanges').'" /></div>';
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
+23
-21
@@ -2,13 +2,13 @@
|
||||
/**
|
||||
* Edit configuration for an individual auth plugin
|
||||
*/
|
||||
|
||||
|
||||
require_once '../config.php';
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('userauthentication', $adminroot);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
$auth = required_param('auth', PARAM_SAFEDIR);
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
$err = array();
|
||||
|
||||
@@ -19,9 +19,9 @@ if ($frm = data_submitted()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (method_exists($authplugin, 'validate_form')) {
|
||||
$authplugin->validate_form($frm, $err);
|
||||
}
|
||||
$frm = stripslashes_recursive($frm);
|
||||
|
||||
$authplugin->validate_form($frm, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
|
||||
@@ -33,19 +33,19 @@ if ($frm = data_submitted()) {
|
||||
if (preg_match('/^lockconfig_(.+?)$/', $name, $matches)) {
|
||||
$plugin = "auth/$auth";
|
||||
$name = $matches[1];
|
||||
if (!set_config($name, $value, $plugin)) {
|
||||
notify("Problem saving config $name as $value for plugin $plugin");
|
||||
if (!set_config($name, $value, $plugin)) {
|
||||
error("Problem saving config $name as $value for plugin $plugin");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect("auth.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
redirect("auth.php");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$frm = get_config("auth/$auth");
|
||||
}
|
||||
@@ -73,7 +73,7 @@ print_simple_box_start('center', '60%', '', 5, 'informationbox');
|
||||
print_string("auth_{$auth}description", 'auth');
|
||||
print_simple_box_end();
|
||||
echo "<hr />\n";
|
||||
$authplugin->config_form($frm, $err);
|
||||
$authplugin->config_form($frm, $err, $user_fields);
|
||||
print_simple_box_end();
|
||||
echo '<center><p><input type="submit" value="' . get_string("savechanges") . "\" /></p></center>\n";
|
||||
echo "</form>\n";
|
||||
@@ -86,7 +86,7 @@ exit;
|
||||
// Good enough for most auth plugins
|
||||
// but some may want a custom one if they are offering
|
||||
// other options
|
||||
// Note: lockconfig_ fields have special handling.
|
||||
// Note: lockconfig_ fields have special handling.
|
||||
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
|
||||
|
||||
echo '<tr><td colspan="3">';
|
||||
@@ -104,7 +104,7 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
|
||||
'onlogin' => get_string('update_onlogin', 'auth'));
|
||||
$updateextoptions = array('0' => get_string('update_never', 'auth'),
|
||||
'1' => get_string('update_onupdate', 'auth'));
|
||||
|
||||
|
||||
$pluginconfig = get_config("auth/$auth");
|
||||
|
||||
// helptext is on a field with rowspan
|
||||
@@ -138,30 +138,32 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
|
||||
$fieldname = get_string($fieldname);
|
||||
}
|
||||
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo $fieldname;
|
||||
echo '</td><td>';
|
||||
|
||||
if ($retrieveopts) {
|
||||
$varname = 'field_map_' . $field;
|
||||
|
||||
echo "<input name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\" />";
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="lockconfig_'.$varname.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
|
||||
echo "<input id=\"lockconfig_{$varname}\" name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\" />";
|
||||
echo '<div align="right">';
|
||||
echo get_string('auth_updatelocal', 'auth') . ' ';
|
||||
echo '<label for="menulockconfig_field_updatelocal_'.$field.'">'.get_string('auth_updatelocal', 'auth') . '</label> ';
|
||||
choose_from_menu($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, "");
|
||||
echo '<br />';
|
||||
if ($updateopts) {
|
||||
echo get_string('auth_updateremote', 'auth') . ' ';
|
||||
' ';
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
choose_from_menu($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, "");
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo get_string('auth_fieldlock', 'auth') . ' ';
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
+12
-9
@@ -17,7 +17,6 @@
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
@@ -29,6 +28,7 @@
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
@@ -165,11 +165,8 @@
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'multiple', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
foreach ($blockbyname as $blockname => $blockid) {
|
||||
@@ -184,6 +181,13 @@
|
||||
}
|
||||
|
||||
$count = count_records('block_instance', 'blockid', $blockid);
|
||||
if ($count>0) {
|
||||
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&sesskey={$USER->sesskey}\" ";
|
||||
$blocklist .= "title=\"$strshowblockcourse\" >$count</a>";
|
||||
}
|
||||
else {
|
||||
$blocklist = "$count";
|
||||
}
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if ($blocks[$blockid]->visible) {
|
||||
@@ -208,8 +212,8 @@
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$blockobject->get_title().'</span>',
|
||||
$count,
|
||||
$blockobject->get_version(),
|
||||
$blocklist,
|
||||
'<span'.$class.'>'.$blockobject->get_version().'</span>',
|
||||
$visible,
|
||||
$multiple,
|
||||
$delete,
|
||||
@@ -228,9 +232,8 @@
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'incompatible');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
$table->setup();
|
||||
|
||||
|
||||
+18
-5
@@ -133,13 +133,27 @@
|
||||
|
||||
}
|
||||
}
|
||||
mtrace("Finished blocks");
|
||||
mtrace('Finished blocks');
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages();
|
||||
}
|
||||
|
||||
mtrace('Removing expired enrolments ...', ''); // See MDL-8785
|
||||
$timenow = time();
|
||||
if ($oldenrolments = get_records_select('role_assignments', "timeend > 0 AND timeend < '$timenow'")) {
|
||||
mtrace(count($oldenrolments).' to delete');
|
||||
foreach ($oldenrolments as $oldenrolment) {
|
||||
if (role_unassign($oldenrolment->roleid, $oldenrolment->userid, 0, $oldenrolment->contextid)) {
|
||||
mtrace("Deleted expired role assignment $oldenrolment->roleid for user $oldenrolment->userid from context $oldenrolment->contextid");
|
||||
}
|
||||
}
|
||||
mtrace('Done');
|
||||
} else {
|
||||
mtrace('none found');
|
||||
}
|
||||
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
@@ -254,7 +268,7 @@
|
||||
//Execute backup's cron
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("196M");
|
||||
@raise_memory_limit("192M");
|
||||
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
|
||||
@@ -307,9 +321,8 @@
|
||||
}
|
||||
|
||||
/// Run the auth cron, if any
|
||||
if (!($auths = explode(',', $CFG->auth_plugins_enabled))) {
|
||||
$auths = array($user->auth);
|
||||
}
|
||||
$auths = get_enabled_auth_plugins();
|
||||
|
||||
mtrace("Running auth crons if required...");
|
||||
foreach ($auths as $auth) {
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
|
||||
+2
-2
@@ -59,10 +59,10 @@
|
||||
// run through submitted data
|
||||
// reject if does not start with filter_
|
||||
foreach ($config as $name => $value) {
|
||||
set_config( $name,$value );
|
||||
set_config($name, stripslashes($value));
|
||||
}
|
||||
}
|
||||
redirect( "$CFG->wwwroot/$CFG->admin/filters.php", get_string('changessaved'), 1);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/filters.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
+2
-7
@@ -182,15 +182,10 @@
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(FILTER_TABLE);
|
||||
$table->define_columns(array('name', 'hideshow', 'order', 'settings'));
|
||||
$table->column_style('hideshow', 'text-align', 'center');
|
||||
$table->column_style('order', 'text-align', 'center');
|
||||
$table->column_style('settings', 'text-align', 'center');
|
||||
$table->define_headers(array($txt->name, $txt->hideshow, $txt->updown, $txt->settings));
|
||||
$table->define_baseurl("$CFG->wwwroot/$CFG->admin/filters.php");
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'flexible generaltable generalbox');
|
||||
$table->set_attribute('style', 'margin:auto;');
|
||||
$table->set_attribute('cellpadding', '5');
|
||||
$table->set_attribute('id', 'filters');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// iterate through filters adding to display table
|
||||
|
||||
@@ -40,7 +40,7 @@ while(!feof($fd)) {
|
||||
|
||||
$user = get_record("user","id",$log->userid);
|
||||
$course = get_record("course","id",$log->course);
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
@@ -78,7 +78,7 @@ function notify_admins_unknown($file,$a) {
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',$site->fullname);
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
|
||||
+30
-17
@@ -136,17 +136,18 @@
|
||||
echo "<br />";
|
||||
notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1",
|
||||
"http://docs.moodle.org/en/License");
|
||||
print_footer('none');
|
||||
exit;
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
echo '<form action="index.php"><fieldset class="invisiblefieldset">';
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'generalbox boxaligncenter boxwidthwide');
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="agreelicense" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
@@ -207,6 +208,7 @@
|
||||
'enrol' => 'manual',
|
||||
'enrol_plugins_enabled' => 'manual',
|
||||
'guestloginbutton' => 1,
|
||||
'registerauth' => 'email',
|
||||
'style' => 'default',
|
||||
'template' => 'default',
|
||||
'theme' => 'standardwhite',
|
||||
@@ -270,13 +272,24 @@
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
echo '<form action="index.php"><fieldset class="invisiblefieldset">';
|
||||
echo '<input type="hidden" name="confirmupgrade" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</fieldset>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="0" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
print_heading(get_string('environment', 'admin'));
|
||||
if (!check_moodle_environment($release, $environment_results, true)) {
|
||||
notice_yesno(get_string('environmenterrorupgrade', 'admin'),
|
||||
'index.php?confirmupgrade=1&confirmrelease=1', 'index.php');
|
||||
} else {
|
||||
notify(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="confirmupgrade" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="0" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
print_footer('none');
|
||||
die;
|
||||
} else {
|
||||
@@ -519,7 +532,7 @@
|
||||
|
||||
/// Deprecated database! Warning!!
|
||||
if (!empty($CFG->migrated_to_new_db)) {
|
||||
print_box(print_string('dbmigrationdeprecateddb','admin'));
|
||||
print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Check for any special upgrades that might need to be run
|
||||
@@ -528,11 +541,11 @@
|
||||
}
|
||||
|
||||
if (ini_get_bool('register_globals') && !ini_get_bool('magic_quotes_gpc')) {
|
||||
print_box(get_string('globalsquoteswarning', 'admin'));
|
||||
print_box(get_string('globalsquoteswarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
if (is_dataroot_insecure()) {
|
||||
print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
|
||||
print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// If no recently cron run
|
||||
@@ -540,17 +553,17 @@
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
$strinstallation = get_string('installation', 'install');
|
||||
$helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
|
||||
print_box(get_string('cronwarning', 'admin')." ".$helpbutton);
|
||||
print_box(get_string('cronwarning', 'admin')." ".$helpbutton, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Print multilang upgrade notice if needed
|
||||
if (empty($CFG->filter_multilang_converted)) {
|
||||
print_box(get_string('multilangupgradenotice', 'admin'));
|
||||
print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Alert if we are currently in maintenance mode
|
||||
if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
|
||||
print_box(get_string('sitemaintenancewarning', 'admin'));
|
||||
print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +573,7 @@
|
||||
if (!isset($CFG->registered) || $CFG->registered < (time() - 3600*24*30*6)) {
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_box_start();
|
||||
print_box_start('generalbox adminwarning');
|
||||
print_string('pleaseregister', 'admin');
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
print_box_end();
|
||||
|
||||
+77
-7
@@ -57,17 +57,17 @@
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $strmissingstrings";
|
||||
$title = $strmissingstrings;
|
||||
$button = '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<fieldset class="invisiblefieldset">'.
|
||||
'<div>'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="submit" value="'.$streditstrings.'" /></fieldset></form>';
|
||||
'<input type="submit" value="'.$streditstrings.'" /></div></form>';
|
||||
break;
|
||||
case "compare":
|
||||
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $streditstrings";
|
||||
$title = $streditstrings;
|
||||
$button = '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<fieldset class="invisiblefieldset">'.
|
||||
'<div>'.
|
||||
'<input type="hidden" name="mode" value="missing" />'.
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></fieldset></form>';
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></div></form>';
|
||||
break;
|
||||
default:
|
||||
$title = $strlanguage;
|
||||
@@ -170,7 +170,7 @@
|
||||
$missinglinkend = '';
|
||||
}
|
||||
if (strlen($value) > LANG_MISSING_TEXT_MAX_LEN) {
|
||||
$value = substr($value, 0, LANG_MISSING_TEXT_MAX_LEN) . ' ...';
|
||||
$value = lang_xhtml_save_substr($value, 0, LANG_MISSING_TEXT_MAX_LEN) . ' ...'; // MDL-8852
|
||||
}
|
||||
$o .= "$"."string['".$missinglinkstart.$key.$missinglinkend."'] = \"$value\";<br />";
|
||||
}
|
||||
@@ -299,12 +299,12 @@
|
||||
helpbutton('langswitchstorage', $strfilestoredinhelp, 'moodle');
|
||||
|
||||
echo '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<fieldset class="invisiblefieldset">'.
|
||||
'<div>'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="hidden" name="currentfile" value="'.$currentfile.'" />'.
|
||||
'<input type="hidden" name="uselocal" value="'.(1 - $uselocal % 2).'" />'.
|
||||
'<input type="submit" value="'.$strswitchlang.'" />'.
|
||||
'</fieldset></form>';
|
||||
'</div></form>';
|
||||
print_box_end();
|
||||
|
||||
if ($currentfile <> '') {
|
||||
@@ -629,5 +629,75 @@ function lang_file_string_key($keyfromform) {
|
||||
return str_replace('##46#', '.', $keyfromform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the substring of the string and take care of XHTML compliance.
|
||||
*
|
||||
* There was a problem with pure substr() which could possibly produce XHTML parsing error:
|
||||
* substr('Marks & Spencer', 0, 9) -> 'Marks &am' ... is not XHTML compliance
|
||||
* This function takes care of these cases. Fixes MDL-8852.
|
||||
*
|
||||
* Thanks to kovacsendre, the author of the function at http://php.net/substr
|
||||
*
|
||||
* @param string $str The original string
|
||||
* @param int $start Start position in the $value string
|
||||
* @param int $length Optional length of the returned substring
|
||||
* @return string The substring as returned by substr() with XHTML compliance
|
||||
* @todo Seems the function does not work with negative $start together with $length being set
|
||||
*/
|
||||
function lang_xhtml_save_substr($str, $start, $length = NULL) {
|
||||
if ($length === 0) {
|
||||
//stop wasting our time ;)
|
||||
return "";
|
||||
}
|
||||
|
||||
//check if we can simply use the built-in functions
|
||||
if (strpos($str, '&') === false) {
|
||||
// No entities. Use built-in functions
|
||||
if ($length === NULL) {
|
||||
return substr($str, $start);
|
||||
} else {
|
||||
return substr($str, $start, $length);
|
||||
}
|
||||
}
|
||||
|
||||
// create our array of characters and html entities
|
||||
$chars = preg_split('/(&[^;\s]+;)|/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
|
||||
$html_length = count($chars);
|
||||
|
||||
// check if we can predict the return value and save some processing time, i.e.:
|
||||
// input string was empty OR
|
||||
// $start is longer than the input string OR
|
||||
// all characters would be omitted
|
||||
if (($html_length === 0) or ($start >= $html_length) or (isset($length) and ($length <= -$html_length))) {
|
||||
return '';
|
||||
}
|
||||
|
||||
//calculate start position
|
||||
if ($start >= 0) {
|
||||
$real_start = $chars[$start][1];
|
||||
} else {
|
||||
//start'th character from the end of string
|
||||
$start = max($start,-$html_length);
|
||||
$real_start = $chars[$html_length+$start][1];
|
||||
}
|
||||
|
||||
if (!isset($length)) {
|
||||
// no $length argument passed, return all remaining characters
|
||||
return substr($str, $real_start);
|
||||
} elseif ($length > 0) {
|
||||
// copy $length chars
|
||||
if ($start+$length >= $html_length) {
|
||||
// return all remaining characters
|
||||
return substr($str, $real_start);
|
||||
} else {
|
||||
//return $length characters
|
||||
return substr($str, $real_start, $chars[max($start,0)+$length][1] - $real_start);
|
||||
}
|
||||
} else {
|
||||
//negative $length. Omit $length characters from end
|
||||
return substr($str, $real_start, $chars[$html_length+$length][1] - $real_start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+15
-12
@@ -44,10 +44,10 @@
|
||||
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
|
||||
switch ($status) {
|
||||
|
||||
case ERROR:
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
case INSTALLED:
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack));
|
||||
redirect('langimport.php', get_string('langpackupdated','admin',$pack), -1, $adminroot);
|
||||
break;
|
||||
|
||||
case UPTODATE:
|
||||
@@ -185,7 +185,7 @@
|
||||
case ERROR:
|
||||
if ($cd->get_error() == 'remotedownloadnotallowed') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'zip';
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
@@ -208,9 +208,9 @@
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php');
|
||||
notice(get_string('langupdatecomplete','admin'), 'langimport.php', NULL, $adminroot);
|
||||
} else {
|
||||
notice(get_string('nolangupdateneeded','admin'), 'langimport.php');
|
||||
notice(get_string('nolangupdateneeded','admin'), 'langimport.php', NULL, $adminroot);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -262,9 +262,9 @@
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
echo '<form id="updateform" action="langimport.php?mode=5" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<div>';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
/// Display option to change site language
|
||||
@@ -368,13 +368,16 @@
|
||||
return false; //failed
|
||||
}
|
||||
fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
|
||||
$i = 0;
|
||||
while(!feof($proxy_fp)) {
|
||||
|
||||
$headers_done = false;
|
||||
while(!feof($proxy_fp)) {
|
||||
$string = fgets($proxy_fp, 1024);
|
||||
if ($i > 11) { //12 lines of info skipped
|
||||
if(!$headers_done){
|
||||
// A new line indicates end of HTTP headers
|
||||
$headers_done = ("\r\n" == $string);
|
||||
} else {
|
||||
$availablelangs[] = split(',', $string);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
fclose($proxy_fp);
|
||||
|
||||
|
||||
@@ -127,15 +127,11 @@ $warn = '';
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
$warn = '<p>' . get_string('mnetdisabled','mnet') .'</p>';
|
||||
}
|
||||
if (empty($CFG->auth_plugins_enabled)) {
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
$warn .= '<p>' . get_string('authmnetdisabled','mnet').'</p>';
|
||||
} else {
|
||||
$auths = explode(',', $CFG->auth_plugins_enabled);
|
||||
if (!in_array('mnet', $auths)) {
|
||||
$warn .= '<p>' . get_string('authmnetdisabled','mnet').'</p>';
|
||||
}
|
||||
unset($auths);
|
||||
}
|
||||
|
||||
if (get_config('auth/mnet', 'auto_add_remote_users') != true) {
|
||||
$warn .= '<p>' . get_string('authmnetautoadddisabled','mnet').'</p>';
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ $strsearchresults = get_string('searchresults');
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
print_box('<strong>' . s($mnet_peer->name) . ' : '
|
||||
. s($course->shortname) .' '. s($course->fullname)
|
||||
. format_string($course->shortname) .' '. format_string($course->fullname)
|
||||
. '</strong><br />'
|
||||
. get_string("enrolcourseenrol_desc", "mnet"));
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@
|
||||
. "host={$mnethost}&courseid={$course->id}&sesskey={$USER->sesskey}";
|
||||
print ('<tr>'
|
||||
. "<td>$icon</td>"
|
||||
. "<td><a href=\"$link\">".s($course->fullname). "</a></td>"
|
||||
. "<td><a href=\"$link\">".format_string($course->fullname). "</a></td>"
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. '<td>'.s($course->shortname). ' - ' .s($course->cat_name).'</td>'
|
||||
. '<td>'.format_string($course->shortname). ' - ' .format_string($course->cat_name).'</td>'
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. "<td align=\"left\" >{$course->summary}</td>"
|
||||
|
||||
@@ -51,6 +51,13 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
// ensure we remove trailing slashes
|
||||
$form->wwwroot = preg_replace(':/$:', '', $form->wwwroot);
|
||||
}
|
||||
|
||||
if(!function_exists('xmlrpc_encode_request')) {
|
||||
trigger_error("You must have xml-rpc enabled in your PHP build to use this feature.");
|
||||
error(get_string('xmlrpc-missing', 'mnet'),'peers.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($form->updateregisterall)) {
|
||||
if (!empty($form->registerallhosts)) {
|
||||
set_config('mnet_register_allhosts',1);
|
||||
|
||||
+35
-13
@@ -2,10 +2,15 @@
|
||||
// Allows the admin to manage activity modules
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// defines
|
||||
define('MODULE_TABLE','module_administration_table');
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
admin_externalpage_setup('managemodules', $adminroot);
|
||||
require_once('../course/lib.php');
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
@@ -23,6 +28,7 @@
|
||||
$strsettings = get_string("settings");
|
||||
$stractivities = get_string("activities");
|
||||
$stractivitymodule = get_string("activitymodule");
|
||||
$strshowmodulecourse = get_string('showmodulecourse');
|
||||
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
@@ -149,12 +155,14 @@
|
||||
ksort($modulebyname);
|
||||
|
||||
/// Print the table of all modules
|
||||
|
||||
$table->head = array ($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings);
|
||||
$table->align = array ("left", "right", "left", "center", "center", "center");
|
||||
$table->wrap = array ("nowrap", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(MODULE_TABLE);
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
|
||||
$table->set_attribute('id', 'modules');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
foreach ($modulebyname as $modulename => $module) {
|
||||
|
||||
@@ -169,7 +177,14 @@
|
||||
$settings = "";
|
||||
}
|
||||
|
||||
$count = count_records("$module->name");
|
||||
$count = count_records_select("$module->name",'course<>0');
|
||||
if ($count>0) {
|
||||
$countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
|
||||
"&sesskey={$USER->sesskey}\" title=\"$strshowmodulecourse\">$count</a>";
|
||||
}
|
||||
else {
|
||||
$countlink = "$count";
|
||||
}
|
||||
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
@@ -178,18 +193,25 @@
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
$class = " class=\"dimmed_text\"";
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$table->data[] = array ("<span $class>$icon $modulename</span>", $count, $module->version, $visible, $delete, $settings);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
echo "<br /><br />";
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$icon.' '.$modulename.'</span>',
|
||||
$countlink,
|
||||
'<span'.$class.'>'.$module->version.'</span>',
|
||||
$visible,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
$courses = get_courses();
|
||||
$courses = get_records('course');
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
@@ -99,7 +99,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = get_record('course_sections', 'id', $newsection))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '.$course->fullname.'<br />';
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -116,11 +116,12 @@ class page_admin extends page_base {
|
||||
$this->init_full($section); // we're trusting that init_full() has already been called by now; it should have.
|
||||
// if not, print_header() has to be called with a $section parameter
|
||||
|
||||
if ($this->user_allowed_editing()) {
|
||||
// The search page currently doesn't handle block editing
|
||||
if ($this->section != 'search' and $this->user_allowed_editing()) {
|
||||
$buttons = '<div><form '.$CFG->frametarget.' method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<fieldset class="invisiblefieldset"><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<input type="hidden" name="section" value="'.$this->section.'" />'.
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></fieldset></form></div>';
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></div></form></div>';
|
||||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$subject = get_string('noreplybouncesubject','moodle',$site->fullname);
|
||||
$body = get_string('noreplybouncemessage','moodle',$site->fullname)."\n\n";
|
||||
$subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if ($fd) {
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@
|
||||
$strregistration = get_string("registration");
|
||||
$strregistrationinfo = get_string("registrationinfo");
|
||||
|
||||
print_header("$site->shortname: $strregistration", "$site->fullname",
|
||||
print_header("$site->shortname: $strregistration", $site->fullname,
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
|
||||
|
||||
print_heading($strregistration);
|
||||
@@ -72,7 +72,7 @@
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="sitename">'.get_string("fullsitename").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo '<input size="50" id="sitename" type="text" name="sitename" value="'.$site->fullname.'" />';
|
||||
echo '<input size="50" id="sitename" type="text" name="sitename" value="'.format_string($site->fullname).'" />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID)); // needed?
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'));
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3, $adminroot);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,4 +117,4 @@
|
||||
}
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time);
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time, '', 3, $adminroot);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
@@ -46,7 +46,7 @@
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'));
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3, $adminroot);
|
||||
}
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
echo '<form action="allowassign.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/></div>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '</form>';
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
echo '<form action="allowoverride.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/></div>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '</form>';
|
||||
|
||||
|
||||
+46
-35
@@ -15,25 +15,32 @@
|
||||
onfocus="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=false;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;">
|
||||
|
||||
|
||||
<?php
|
||||
foreach ($contextusers as $contextuser) {
|
||||
$fullname = fullname($contextuser, true);
|
||||
if ($contextuser->hidden) {
|
||||
$hidden=' ('.get_string('hiddenassign').') ';
|
||||
} else {
|
||||
$hidden="";
|
||||
}
|
||||
echo "<option value=\"$contextuser->id\">".$fullname.", ".$contextuser->email.$hidden."</option>\n";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($contextusers as $contextuser) {
|
||||
$fullname = fullname($contextuser, true);
|
||||
if ($contextuser->hidden) {
|
||||
$hidden=' ('.get_string('hiddenassign').') ';
|
||||
} else {
|
||||
$hidden="";
|
||||
}
|
||||
echo "<option value=\"$contextuser->id\">".$fullname.", ".$contextuser->email.$hidden."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
if ($i==0) {
|
||||
echo '<option/>'; // empty select breaks xhtml strict
|
||||
}
|
||||
?>
|
||||
<option/>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<label title="<?php print_string('hiddenassign') ?>">
|
||||
<input type="checkbox" name="hidden" value="1" />
|
||||
<img src="<?php echo $CFG->pixpath; ?>/t/hide.gif" alt="<?php print_string('hiddenassign') ?>" class="hide-show-image" />
|
||||
<img src="<?php echo $CFG->pixpath; ?>/t/hide.gif" alt="<?php print_string('hiddenassign') ?>" class="hide-show-image" /> <?
|
||||
helpbutton ('hiddenassign', get_string('hiddenassign'));
|
||||
?>
|
||||
</label>
|
||||
<?php check_theme_arrows(); ?>
|
||||
<p class="arrow_button">
|
||||
@@ -50,32 +57,36 @@
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
$i=0;
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($contextusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($contextusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
|
||||
} else {
|
||||
if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
} else {
|
||||
if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($contextusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($contextusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($i==0) {
|
||||
echo '<option/>'; // empty select breaks xhtml strict
|
||||
}
|
||||
?>
|
||||
<option/>
|
||||
</select>
|
||||
<br />
|
||||
<label for="searchtext" class="accesshide"><?php p($strsearch) ?></label>
|
||||
|
||||
+20
-12
@@ -19,7 +19,7 @@
|
||||
$timeend = optional_param('timened', 0, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
|
||||
|
||||
$errors = array();
|
||||
|
||||
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
|
||||
@@ -50,9 +50,11 @@
|
||||
}
|
||||
} else {
|
||||
$courseid = SITEID;
|
||||
$course = get_site();
|
||||
$course = clone($SITE);
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
require_login($context->instanceid);
|
||||
} else {
|
||||
@@ -61,7 +63,10 @@
|
||||
|
||||
require_capability('moodle/role:assign', $context);
|
||||
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
/// needed for tabs.php
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
$strassignusers = get_string('assignusers', 'role');
|
||||
@@ -103,7 +108,7 @@
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
print_header("$course->fullname: $fullname", "$course->fullname",
|
||||
print_header("$course->fullname: $fullname", $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">$fullname</a> -> $straction", "", "", true, " ", navmenu($course));
|
||||
}
|
||||
|
||||
@@ -163,7 +168,7 @@
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$topleveladmin = false;
|
||||
|
||||
|
||||
// we only worry about this if the role has doanything capability at site level
|
||||
if ($context->id == $sitecontext->id && $adminroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext)) {
|
||||
foreach ($adminroles as $adminrole) {
|
||||
@@ -172,7 +177,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
|
||||
@@ -205,6 +210,10 @@
|
||||
print_heading_with_help(get_string('assignroles', 'role'), 'assignroles');
|
||||
}
|
||||
|
||||
if ($context->contextlevel==CONTEXT_SYSTEM) {
|
||||
print_box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
if ($roleid) { /// prints a form to swap roles
|
||||
|
||||
/// Get all existing participants in this context.
|
||||
@@ -215,7 +224,7 @@
|
||||
}
|
||||
|
||||
$select = "username <> 'guest' AND deleted = 0 AND confirmed = 1";
|
||||
|
||||
|
||||
$usercount = count_records_select('user', $select) - count($contextusers);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
@@ -227,18 +236,17 @@
|
||||
$select .= " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
}
|
||||
|
||||
$availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user
|
||||
$availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user
|
||||
WHERE '.$select.'
|
||||
ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
/// In the .html file below we loop through these results and exclude any in $contextusers
|
||||
|
||||
echo '<div style="text-align:center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
echo '<label>'.$strroletoassign.'</label>: ';
|
||||
$assignableroles = array('0'=>get_string('listallroles', 'role').'...') + $assignableroles;
|
||||
$assignableroles = array('0'=>get_string('listallroles', 'role').'...') + $assignableroles;
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/roles/assign.php?userid=$userid&courseid=$courseid&contextid=$contextid&roleid=",
|
||||
$assignableroles, 'switchrole', $roleid, '');
|
||||
$assignableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletoassign);
|
||||
echo '</div>';
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
+107
-55
@@ -4,58 +4,89 @@
|
||||
case 'add':
|
||||
$submitlabel = get_string('addrole', 'role');
|
||||
break;
|
||||
case 'view':
|
||||
$submitlabel = get_string('listallroles', 'role');
|
||||
break;
|
||||
case 'edit':
|
||||
default:
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
|
||||
if ($action == 'view') {
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div align="right">
|
||||
<a href="manage.php?roleid=<?php p($roleid); ?>&action=duplicate"><?php print_string('duplicaterole'); ?></a>
|
||||
</div>
|
||||
<form id="rolesform" action="manage.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="action" value="<?php if ($action != 'view') { echo p($action); } ?>" />
|
||||
|
||||
<table cellpadding="9" cellspacing="0" align="center">
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('name') ?>:</td>
|
||||
<td><?php
|
||||
if ($action == 'view') {
|
||||
p($role->name);
|
||||
} else {
|
||||
echo '<input type="text" name="name" maxlength="254" size="50" value="'.s($role->name).'" />';
|
||||
if (isset($errors["name"])) formerr($errors["name"]);
|
||||
} ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('shortname') ?>:</td>
|
||||
<td><?php
|
||||
if ($action == 'view') {
|
||||
p($role->shortname);
|
||||
} else {
|
||||
echo '<input type="text" name="shortname" maxlength="20" size="15" value="'.s($role->shortname).'" />';
|
||||
if (isset($errors["shortname"])) formerr($errors["shortname"]);
|
||||
} ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('description') ?>:</td>
|
||||
<td><?php
|
||||
if ($action == 'view') {
|
||||
p($role->description);
|
||||
$usehtmleditor = false;
|
||||
} else {
|
||||
print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
|
||||
} ?></td>
|
||||
</tr>
|
||||
</fieldset>
|
||||
<table class="roledesc" cellpadding="9" cellspacing="0">
|
||||
<?php if ($action == 'view') { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('name') ?>:</td>
|
||||
<td><?php p($role->name); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('shortname') ?>:</td>
|
||||
<td><?php p($role->shortname); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('description') ?>:</td>
|
||||
<td><?php p($role->description); $usehtmleditor = false; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('legacytype', 'role') ?>:</td>
|
||||
<td><?php
|
||||
$usehtmleditor = false;
|
||||
if (empty($role->legacytype)) {
|
||||
print_string('none');
|
||||
} else {
|
||||
print_string('legacy:'.$role->legacytype, 'role');
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="name"><?php print_string('name') ?></label></td>
|
||||
<td><?php
|
||||
echo '<input type="text" id="name" name="name" maxlength="254" size="50" value="'.s($role->name).'" />';
|
||||
if (isset($errors["name"])) formerr($errors["name"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="shortname"><?php print_string('shortname') ?></label></td>
|
||||
<td><?php
|
||||
echo '<input type="text" id="shortname" name="shortname" maxlength="20" size="15" value="'.s($role->shortname).'" />';
|
||||
if (isset($errors["shortname"])) formerr($errors["shortname"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="edit-description"><?php print_string('description') ?></label></td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menulegacytype"><?php print_string('legacytype', 'role') ?></label></td>
|
||||
<td><?php
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
$legacyroles = get_legacy_roles();
|
||||
foreach($legacyroles as $ltype=>$lcap) {
|
||||
$options[$ltype] = get_string('legacy:'.$ltype, 'role');
|
||||
}
|
||||
choose_from_menu($options, 'legacytype', $role->legacytype, '');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
print_heading_with_help(get_string('permissions','role'), 'permissions');
|
||||
|
||||
$strinherit = get_string('inherit','role');
|
||||
@@ -64,7 +95,7 @@
|
||||
$strprohibit = get_string('prohibit','role');
|
||||
?>
|
||||
|
||||
<table class="rolecap" align="center">
|
||||
<table class="rolecap">
|
||||
|
||||
<tr>
|
||||
<th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
|
||||
@@ -84,7 +115,20 @@ $component = '';
|
||||
$strrisks = s(get_string('risks', 'role'));
|
||||
$strcapabilities = s(get_string('capabilities', 'role'));
|
||||
|
||||
// prepare legacy defaults
|
||||
if (!empty($role->legacytype)) {
|
||||
$defaultcaps = get_default_capabilities($role->legacytype);
|
||||
} else {
|
||||
$defaultcaps = false;
|
||||
}
|
||||
|
||||
foreach ($capabilities as $capability) {
|
||||
|
||||
//legacy caps have their own selector
|
||||
if (islegacy($capability->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prints a breaker if component or name or context level
|
||||
if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
|
||||
@@ -97,7 +141,6 @@ foreach ($capabilities as $capability) {
|
||||
|
||||
if (empty($errors)) {
|
||||
// check the capability override for this cap, this role in this context
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
$localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
|
||||
} else {
|
||||
$localoverride = new object();
|
||||
@@ -109,44 +152,53 @@ foreach ($capabilities as $capability) {
|
||||
$riskinfo = '<td class="risk managetrust">';
|
||||
$rowclasses = '';
|
||||
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskmanagetrust';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk config">';
|
||||
if (RISK_CONFIG & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskconfig';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk xss">';
|
||||
if (RISK_XSS & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskxss';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk personal">';
|
||||
if (RISK_PERSONAL & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskpersonal';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk spam">';
|
||||
if (RISK_SPAM & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
$riskinfo .= '</td>';
|
||||
|
||||
$isinherit = (!isset($defaultcaps[$capability->name]) or $defaultcaps[$capability->name] == CAP_INHERIT) ? 'capdefault' : '';
|
||||
$isallow = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_ALLOW) ? 'capdefault' : '';
|
||||
$isprevent = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PREVENT) ? 'capdefault' : '';
|
||||
$isprohibit = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PROHIBIT) ? 'capdefault' : '';
|
||||
|
||||
?>
|
||||
|
||||
<tr class="rolecap <?php echo $rowclasses; ?>">
|
||||
<td class="name"><span class="cap-desc"><a target="docspopup" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
<td class="inherit"><input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_INHERIT ?>" <?php if (!isset($localoverride->permission) || $localoverride->permission==CAP_INHERIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="allow"><input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_ALLOW ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_ALLOW){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prevent" ><input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PREVENT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PREVENT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prohibit" ><input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PROHIBIT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PROHIBIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
<td class="inherit <?php echo $isinherit ?>">
|
||||
<input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_INHERIT ?>" <?php if (!isset($localoverride->permission) || $localoverride->permission==CAP_INHERIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="allow <?php echo $isallow ?>">
|
||||
<input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_ALLOW ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_ALLOW){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prevent <?php echo $isprevent ?>" >
|
||||
<input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PREVENT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PREVENT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prohibit <?php echo $isprohibit ?>" >
|
||||
<input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PROHIBIT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PROHIBIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
|
||||
<?php echo $riskinfo; ?>
|
||||
|
||||
@@ -155,11 +207,11 @@ foreach ($capabilities as $capability) {
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<div class="submit" align="center">
|
||||
<input type="submit" value="<?php p($submitlabel) ?>" />
|
||||
<?php if ($action != 'view') { ?>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" value="<?php p($submitlabel) ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
|
||||
+143
-30
@@ -15,7 +15,9 @@
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
if ($cancel) {
|
||||
redirect('manage.php');
|
||||
@@ -55,6 +57,12 @@
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$shortname = moodle_strtolower(clean_param(clean_filename($shortname), PARAM_SAFEDIR)); // only lowercase safe ASCII characters
|
||||
$legacytype = required_param('legacytype', PARAM_RAW);
|
||||
|
||||
$legacyroles = get_legacy_roles();
|
||||
if (!array_key_exists($legacytype, $legacyroles)) {
|
||||
$legacytype = '';
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = get_string('errorbadrolename', 'role');
|
||||
@@ -69,12 +77,19 @@
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
$newrole = create_role($name, $shortname, $description);
|
||||
$newroleid = create_role($name, $shortname, $description);
|
||||
|
||||
// set proper legacy type
|
||||
if (!empty($legacytype)) {
|
||||
assign_capability($legacyroles[$legacytype], CAP_ALLOW, $newroleid, $sitecontext->id);
|
||||
}
|
||||
|
||||
} else {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
@@ -84,6 +99,12 @@
|
||||
if (!isset($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// legacy caps have their own selector
|
||||
if (islegacy($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
@@ -91,11 +112,12 @@
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
assign_capability($capname, $value, $newrole, $sitecontext->id);
|
||||
assign_capability($capname, $value, $newroleid, $sitecontext->id);
|
||||
} else {
|
||||
$newrole->$capname = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
@@ -106,6 +128,12 @@
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$shortname = moodle_strtolower(clean_param(clean_filename($shortname), PARAM_SAFEDIR)); // only lowercase safe ASCII characters
|
||||
$legacytype = required_param('legacytype', PARAM_RAW);
|
||||
|
||||
$legacyroles = get_legacy_roles();
|
||||
if (!array_key_exists($legacytype, $legacyroles)) {
|
||||
$legacytype = '';
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = get_string('errorbadrolename', 'role');
|
||||
@@ -126,9 +154,10 @@
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
@@ -138,6 +167,12 @@
|
||||
if (!isset($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// legacy caps have their own selector
|
||||
if (islegacy($data->{$cap->name}) === 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
@@ -171,6 +206,7 @@
|
||||
assign_capability($capname, $value, $roleid, $sitecontext->id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
@@ -183,6 +219,16 @@
|
||||
if (!update_record('role', $role)) {
|
||||
error('Could not update role!');
|
||||
}
|
||||
|
||||
// set proper legacy type
|
||||
foreach($legacyroles as $ltype=>$lcap) {
|
||||
if ($ltype == $legacytype) {
|
||||
assign_capability($lcap, CAP_ALLOW, $roleid, $sitecontext->id);
|
||||
} else {
|
||||
unassign_capability($lcap, $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
}
|
||||
}
|
||||
@@ -190,7 +236,7 @@
|
||||
|
||||
case 'delete':
|
||||
if (in_array($roleid, $defaultroles)) {
|
||||
error('This role is used as one of the default system roles, it can not be deleted');
|
||||
error('This role is used as one of the default system roles, it can not be deleted');
|
||||
}
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
if (!delete_role($roleid)) {
|
||||
@@ -243,17 +289,38 @@
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'duplicate':
|
||||
if (!array_key_exists($roleid, $roles)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
//ok - lets duplicate!
|
||||
} else {
|
||||
// show confirmation
|
||||
admin_externalpage_print_header($adminroot);
|
||||
$optionsyes = array('action'=>'duplicate', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
notice_yesno(get_string('duplicaterolesure', 'role', $a), 'manage.php', 'manage.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
die;
|
||||
}
|
||||
|
||||
// duplicate current role
|
||||
$sourcerole = get_record('role','id',$roleid);
|
||||
|
||||
|
||||
$fullname = $sourcerole->name;
|
||||
$shortname = $sourcerole->shortname;
|
||||
$currentfullname = "";
|
||||
$currentshortname = "";
|
||||
$counter = 0;
|
||||
|
||||
// find a name for the duplicated role
|
||||
|
||||
// find a name for the duplicated role
|
||||
do {
|
||||
if ($counter) {
|
||||
$suffixfull = " ".get_string("copyasnoun")." ".$counter;
|
||||
@@ -269,14 +336,46 @@
|
||||
$courseshort = get_record("role","shortname",addslashes($currentshortname));
|
||||
$counter++;
|
||||
} while ($coursefull || $courseshort);
|
||||
|
||||
$description = 'duplicate of '.$fullname;
|
||||
|
||||
$description = 'duplicate of '.$fullname;
|
||||
if ($newrole = create_role($currentfullname, $currentshortname, $description)) {
|
||||
// dupilcate all the capabilities
|
||||
role_cap_duplicate($sourcerole, $newrole);
|
||||
}
|
||||
}
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'reset':
|
||||
if (!array_key_exists($roleid, $roles)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
reset_role_capabilities($roleid);
|
||||
redirect('manage.php?action=view&roleid='.$roleid);
|
||||
|
||||
} else {
|
||||
// show confirmation
|
||||
admin_externalpage_print_header($adminroot);
|
||||
$optionsyes = array('action'=>'reset', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->legacytype = get_legacy_type($roleid);
|
||||
if (empty($a->legacytype)) {
|
||||
$warning = get_string('resetrolesurenolegacy', 'role', $a);
|
||||
} else {
|
||||
$warning = get_string('resetrolesure', 'role', $a);
|
||||
}
|
||||
notice_yesno($warning, 'manage.php', 'manage.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
die;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -294,9 +393,10 @@
|
||||
$roleid = 0;
|
||||
if (empty($errors) or empty($newrole)) {
|
||||
$role = new object();
|
||||
$role->name='';
|
||||
$role->shortname='';
|
||||
$role->description='';
|
||||
$role->name = '';
|
||||
$role->shortname = '';
|
||||
$role->description = '';
|
||||
$role->legacytype = '';
|
||||
} else {
|
||||
$role = stripslashes_safe($newrole);
|
||||
}
|
||||
@@ -306,6 +406,7 @@
|
||||
if(!$role = get_record('role', 'id', $roleid)) {
|
||||
error('Incorrect role ID!');
|
||||
}
|
||||
$role->legacytype = get_legacy_type($role->id);
|
||||
}
|
||||
|
||||
foreach ($roles as $rolex) {
|
||||
@@ -332,18 +433,28 @@
|
||||
break;
|
||||
}
|
||||
|
||||
echo '<div align="center" class="selector">';
|
||||
echo '<div class="selector">';
|
||||
if ($action == 'view') {
|
||||
echo get_string('selectrole', 'role').': ';
|
||||
echo '<form style="display:inline;" id="switchrole" action="manage.php" method="get">';
|
||||
echo '<input type="hidden" name="action" value="view" />';
|
||||
choose_from_menu ($roleoptions, 'roleid', $roleid, get_string('listallroles', 'role').'...', $script='switchrole.submit()');
|
||||
echo '</form>';
|
||||
echo '<form style="display:inline;" id="editrole" action="manage.php" method="get">';
|
||||
echo '<input type="hidden" name="roleid" value="'.$roleid.'" />';
|
||||
echo '<input type="hidden" name="action" value="edit" />';
|
||||
echo '<input type="submit" value="'.get_string('edit').'" />';
|
||||
echo '</form>';
|
||||
popup_form('manage.php?action=view&roleid=', $roleoptions, 'switchrole', $roleid, '', '', '',
|
||||
false, 'self', get_string('selectrole', 'role'));
|
||||
|
||||
echo '<div class="buttons">';
|
||||
|
||||
$legacytype = get_legacy_type($roleid);
|
||||
$options = array();
|
||||
$options['roleid'] = $roleid;
|
||||
$options['action'] = 'edit';
|
||||
print_single_button('manage.php', $options, get_string('edit'));
|
||||
$options['action'] = 'reset';
|
||||
if (empty($legacytype)) {
|
||||
print_single_button('manage.php', $options, get_string('resetrolenolegacy', 'role'));
|
||||
} else {
|
||||
print_single_button('manage.php', $options, get_string('resetrole', 'role'));
|
||||
}
|
||||
$options['action'] = 'duplicate';
|
||||
print_single_button('manage.php', $options, get_string('duplicaterole', 'role'));
|
||||
print_single_button('manage.php', null, get_string('listallroles', 'role'));
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
@@ -419,7 +530,9 @@
|
||||
|
||||
$options = new object();
|
||||
$options->action = 'add';
|
||||
echo '<div class="buttons">';
|
||||
print_single_button('manage.php', $options, get_string('addrole', 'role'), 'get');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
@@ -468,12 +581,12 @@ function role_cap_duplicate($sourcerole, $targetrole) {
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$caps = get_records_sql("SELECT * FROM {$CFG->prefix}role_capabilities
|
||||
WHERE roleid = $sourcerole->id
|
||||
AND contextid = $systemcontext->id");
|
||||
AND contextid = $systemcontext->id");
|
||||
// adding capabilities
|
||||
foreach ($caps as $cap) {
|
||||
unset($cap->id);
|
||||
$cap->roleid = $targetrole;
|
||||
insert_record('role_capabilities', $cap);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
// this page deals with the 2 tabs for manage.php and grant.php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$toprow = array();
|
||||
|
||||
$toprow[] = new tabobject('manage', $CFG->wwwroot.'/'.$CFG->admin.'/roles/manage.php', get_string('manageroles', 'role'),'', true);
|
||||
|
||||
$toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allowassign.php', get_string('allowassign', 'role'));
|
||||
|
||||
+16
-15
@@ -6,11 +6,13 @@
|
||||
?>
|
||||
|
||||
<form id="overrideform" action="override.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="userid" value="<?php p($userid) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
</fieldset>
|
||||
|
||||
<table class="rolecap">
|
||||
<tr>
|
||||
@@ -31,6 +33,12 @@
|
||||
$strcapabilities = s(get_string('capabilities', 'role'));
|
||||
|
||||
foreach ($capabilities as $capability) {
|
||||
|
||||
// legacy caps should not be overriden - we must use proper capabilities if needed
|
||||
if (islegacy($capability->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prints a breaker if component or name or context level
|
||||
if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
|
||||
@@ -57,36 +65,36 @@
|
||||
$isprohibit = 0;
|
||||
}
|
||||
|
||||
$isdisabled = $isprohibit || islegacy($capability->name);
|
||||
$isdisabled = $isprohibit;
|
||||
|
||||
$riskinfo = '<td class="risk managetrust">';
|
||||
$rowclasses = '';
|
||||
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskmanagetrust';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk config">';
|
||||
if (RISK_CONFIG & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskconfig';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk xss">';
|
||||
if (RISK_XSS & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskxss';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk personal">';
|
||||
if (RISK_PERSONAL & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskpersonal';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk spam">';
|
||||
if (RISK_SPAM & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a target="docspopup" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
@@ -96,13 +104,7 @@
|
||||
?>
|
||||
|
||||
<tr class="rolecap <?php echo $rowclasses; ?>">
|
||||
<td class="name">
|
||||
<span class="cap-desc">
|
||||
<a target="docspopup" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>">
|
||||
<?php echo get_capability_string($capability->name); ?></a>
|
||||
</span>
|
||||
<span class="cap-name"><?php echo $capability->name ?></span>
|
||||
</td>
|
||||
<td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
|
||||
<td class="inherit">
|
||||
<input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="0"
|
||||
@@ -136,8 +138,7 @@
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
<br />
|
||||
<div align="center">
|
||||
<div class="submit buttons">
|
||||
<input type="submit" value="<?php print_string('savechanges') ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
|
||||
+33
-16
@@ -2,7 +2,7 @@
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
$contextid = required_param('contextid',PARAM_INT); // context id
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // requested role id
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
@@ -12,29 +12,34 @@
|
||||
error('Bad context ID');
|
||||
}
|
||||
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID)) {
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
|
||||
error('No site ID');
|
||||
}
|
||||
|
||||
if ($context->id == $sitecontext->id) {
|
||||
error ('Can not override base role capabilities');
|
||||
error('Can not override base role capabilities');
|
||||
}
|
||||
|
||||
require_capability('moodle/role:override', $context); // Just to make sure
|
||||
if (!has_capability('moodle/role:override', $context)) {
|
||||
error('You do not have permission to change overrides in this context!');
|
||||
}
|
||||
|
||||
if ($courseid) {
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Bad course ID');
|
||||
}
|
||||
} else {
|
||||
$course = $SITE;
|
||||
$course = clone($SITE);
|
||||
$courseid = SITEID;
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$baseurl = 'override.php?contextid='.$context->id;
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
if (!empty($courseid)) {
|
||||
if ($courseid != SITEID) {
|
||||
$baseurl .= '&courseid='.$courseid;
|
||||
}
|
||||
|
||||
@@ -42,6 +47,9 @@
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
/// needed for tabs.php
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
@@ -53,6 +61,7 @@
|
||||
$strparticipants = get_string('participants');
|
||||
|
||||
/// Make sure this user can override that role
|
||||
|
||||
if ($roleid) {
|
||||
if (!user_can_override($context, $roleid)) {
|
||||
error ('you can not override this role in this context');
|
||||
@@ -64,18 +73,27 @@
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
}
|
||||
|
||||
/// get all cababilities
|
||||
$capabilities = fetch_context_capabilities($context);
|
||||
|
||||
/// Process incoming role override
|
||||
if ($data = data_submitted() and $roleid and confirm_sesskey()) {
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
$capabilities = fetch_context_capabilities($context); // capabilities applicable in this context
|
||||
|
||||
$localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
|
||||
'', 'capability, permission, id');
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
|
||||
if (!isset($data->{$cap->name})) {
|
||||
//cap not specified in form
|
||||
continue;
|
||||
}
|
||||
|
||||
if (islegacy($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
@@ -129,7 +147,7 @@
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
print_header("$course->fullname: $fullname", "$course->fullname",
|
||||
print_header("$course->fullname: $fullname", $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/user/view.php?id=$userid&course=$course->id\">$fullname</a> -> $straction", "", "", true, " ", navmenu($course));
|
||||
}
|
||||
$showroles = 1;
|
||||
@@ -151,15 +169,13 @@
|
||||
|
||||
print_heading_with_help(get_string('overrides', 'role'), 'overrides');
|
||||
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
|
||||
if ($roleid) {
|
||||
/// prints a form to swap roles
|
||||
echo '<div align="center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
echo $strroletooverride.': ';
|
||||
$overridableroles = array('0'=>get_string('listallroles', 'role').'...') + $overridableroles;
|
||||
echo '<div class="selector">';
|
||||
echo $strcurrentcontext.': '.print_context_name($context).'<br/>';
|
||||
$overridableroles = array('0'=>get_string('listallroles', 'role').'...') + $overridableroles;
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/roles/override.php?userid=$userid&courseid=$courseid&contextid=$contextid&roleid=",
|
||||
$overridableroles, 'switchrole', $roleid, '');
|
||||
$overridableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletooverride);
|
||||
echo '</div>';
|
||||
|
||||
$parentcontexts = get_parent_contexts($context);
|
||||
@@ -177,11 +193,12 @@
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
// Get the capabilities overrideable in this context
|
||||
if ($capabilities = fetch_context_capabilities($context)) {
|
||||
if (!empty($capabilities)) {
|
||||
// Print the capabilities overrideable in this context
|
||||
print_simple_box_start('center');
|
||||
include_once('override.html');
|
||||
print_simple_box_end();
|
||||
|
||||
} else {
|
||||
notice(get_string('nocapabilitiesincontext', 'role'),
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/'.$baseurl);
|
||||
|
||||
+18
-13
@@ -1,6 +1,11 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Handles headers and tabs for the roles control at any level apart from SYSTEM level
|
||||
// We also assume that $currenttab, $assignableroles and $overridableroles are defined
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if ($currenttab != 'update') {
|
||||
switch ($context->contextlevel) {
|
||||
@@ -29,11 +34,14 @@ if ($currenttab != 'update') {
|
||||
case CONTEXT_COURSE:
|
||||
if ($context->instanceid != SITEID) {
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
|
||||
|
||||
$course = get_record('course', 'id', $context->instanceid);
|
||||
print_header($streditcoursesettings, "$course->fullname",
|
||||
|
||||
require_login($course);
|
||||
|
||||
print_header($streditcoursesettings, $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $straction");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CONTEXT_GROUP:
|
||||
@@ -54,6 +62,8 @@ if ($currenttab != 'update') {
|
||||
error("The required instance of this module doesn't exist");
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">$instance->name</a> ->";
|
||||
$fullmodulename = get_string("modulename", $module->name);
|
||||
$streditinga = get_string("editinga", "moodle", $fullmodulename);
|
||||
@@ -65,7 +75,6 @@ if ($currenttab != 'update') {
|
||||
$focuscursor = "form.name";
|
||||
}
|
||||
|
||||
$COURSE = $course;
|
||||
print_header_simple($streditinga, '',
|
||||
"<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
|
||||
$strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
|
||||
@@ -81,6 +90,9 @@ if ($currenttab != 'update') {
|
||||
switch ($blockinstance->pagetype) {
|
||||
case 'course-view':
|
||||
if ($course = get_record('course', 'id', $blockinstance->pageid)) {
|
||||
|
||||
require_login($course);
|
||||
|
||||
if ($course->id != SITEID) {
|
||||
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $navigation";
|
||||
}
|
||||
@@ -104,7 +116,7 @@ if ($currenttab != 'update') {
|
||||
break;
|
||||
|
||||
default:
|
||||
error ('This is an unknown context!');
|
||||
error ('This is an unknown context (' . $context->contextlevel . ') in admin/roles/tabs.php!');
|
||||
return false;
|
||||
|
||||
}
|
||||
@@ -123,14 +135,7 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex
|
||||
$toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.
|
||||
$context->id, get_string('roles'));
|
||||
|
||||
if (isset($tabsmode)) {
|
||||
|
||||
if (!isset($assignableroles)) {
|
||||
$assignableroles = get_assignable_roles($context);
|
||||
}
|
||||
if (!isset($overridableroles)) {
|
||||
$overridableroles = get_overridable_roles($context);
|
||||
}
|
||||
if (!empty($tabsmode)) {
|
||||
|
||||
if (!empty($assignableroles)) {
|
||||
$secondrow[] = new tabobject('assign',
|
||||
|
||||
@@ -59,8 +59,10 @@ if ($statusmsg != '') {
|
||||
$resultshtml = search_settings_html(admin_get_root(), $query);
|
||||
|
||||
echo '<form action="search.php" method="post" id="adminsettings">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
echo '<input type="hidden" name="query" value="' . s($query) . '" />';
|
||||
echo '</div>';
|
||||
echo '<fieldset>';
|
||||
echo '<div class="clearer"><!-- --></div>';
|
||||
if ($resultshtml != '') {
|
||||
@@ -112,6 +114,11 @@ function search_settings(&$node, $query) {
|
||||
function search_settings_html(&$node, $query) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($query == ''){
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_a($node, 'admin_category')) {
|
||||
$entries = array_keys($node->children);
|
||||
$return = '';
|
||||
|
||||
@@ -10,14 +10,20 @@ $temp->add(new admin_setting_configcheckbox('allowuserthemes', get_string('allow
|
||||
$temp->add(new admin_setting_configcheckbox('allowcoursethemes', get_string('allowcoursethemes', 'admin'), get_string('configallowcoursethemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('showblocksonmodpages', get_string('showblocksonmodpages', 'admin'), get_string('configshowblocksonmodpages', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('tabselectedtofront', get_string('tabselectedtofronttext', 'admin'), get_string('tabselectedtofront', 'admin'), 0));
|
||||
$ADMIN->add('themes', $temp);
|
||||
$ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php'));
|
||||
|
||||
# for CALENDAR_TF_12 and CALENDAR_TF_24 ...
|
||||
require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
|
||||
// calendar
|
||||
$temp = new admin_settingpage('calendar', get_string('calendarsettings','admin'));
|
||||
$temp->add(new admin_setting_special_adminseesall());
|
||||
$temp->add(new admin_setting_configselect('calendar_site_timeformat', get_string('pref_timeformat', 'calendar'), get_string('explain_site_timeformat', 'calendar'), '0',
|
||||
array( 0 => get_string('default', 'calendar'),
|
||||
CALENDAR_TF_12 => get_string('timeformat_12', 'calendar'),
|
||||
CALENDAR_TF_24 => get_string('timeformat_24', 'calendar')
|
||||
)));
|
||||
$temp->add(new admin_setting_configselect('calendar_startwday', get_string('configstartwday', 'admin'), get_string('helpstartofweek', 'admin'), 0,
|
||||
array(
|
||||
0 => get_string('sunday', 'calendar'),
|
||||
|
||||
@@ -9,10 +9,13 @@ $temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', '
|
||||
$temp->add(new admin_setting_configtext('langlist', get_string('langlist', 'admin'), get_string('configlanglist', 'admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE));
|
||||
|
||||
// new CFG variable for excel encoding
|
||||
$temp->add(new admin_setting_configselect('latinexcelexport', get_string('latinexcelexport', 'admin'), get_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin')));
|
||||
|
||||
|
||||
$ADMIN->add('language', $temp);
|
||||
|
||||
|
||||
|
||||
$ADMIN->add('language', new admin_externalpage('langedit', get_string('langedit', 'admin'), "$CFG->wwwroot/$CFG->admin/lang.php"));
|
||||
$ADMIN->add('language', new admin_externalpage('langimport', get_string('langpacks', 'admin'), "$CFG->wwwroot/$CFG->admin/langimport.php"));
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ $temp->add(new admin_setting_configselect('digestmailtime', get_string('digestma
|
||||
'22' => '22',
|
||||
'23' => '23')));
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']); // not needed here
|
||||
$options = array();
|
||||
$options['0'] = get_string('none');
|
||||
$options = array_merge($options, $charsets);
|
||||
@@ -85,6 +86,7 @@ $ADMIN->add('server', $temp);
|
||||
$temp = new admin_settingpage('debugging', get_string('debugging', 'admin'));
|
||||
$temp->add(new admin_setting_special_debug());
|
||||
$temp->add(new admin_setting_special_debugdisplay());
|
||||
$temp->add(new admin_setting_configcheckbox('debugsmtp', get_string('debugsmtp', 'admin'), get_string('configdebugsmtp', 'admin'), 0));
|
||||
$temp->add(new admin_setting_special_perfdebug());
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('prof
|
||||
$ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
|
||||
$ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php"));
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $sitecontext->id));
|
||||
$ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $sitecontext->id));
|
||||
|
||||
|
||||
// "userpolicies" settingpage
|
||||
@@ -43,6 +43,14 @@ if ($userroles = get_roles_with_capability('moodle/legacy:user', CAP_ALLOW)) {
|
||||
} else {
|
||||
$userrole->id = 0;
|
||||
}
|
||||
if (empty($CFG->creatornewroleid)) {
|
||||
if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, $context)) {
|
||||
$teachereditrole = array_shift($teacherroles);
|
||||
set_config('creatornewroleid', $teachereditrole->id);
|
||||
} else {
|
||||
set_config('creatornewroleid', 0);
|
||||
}
|
||||
}
|
||||
// we must not use assignable roles here:
|
||||
// 1/ unsetting roles as assignable for admin might bork the settings!
|
||||
// 2/ default user role should not be assignable anyway
|
||||
@@ -61,6 +69,8 @@ $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defau
|
||||
get_string('configdefaultuserroleid', 'admin'), $userrole->id, $allroles));
|
||||
$temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
|
||||
get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles));
|
||||
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
|
||||
get_string('configcreatornewroleid', 'admin'), $CFG->creatornewroleid, $allroles));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
// that we'll take longer, and that the process should be recycled soon
|
||||
// to free up memory.
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("196M");
|
||||
@raise_memory_limit("192M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
@apache_child_terminate();
|
||||
}
|
||||
@@ -131,10 +131,10 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
// check for valid field names
|
||||
foreach ($header as $i => $h) {
|
||||
$h = trim($h); $header[$i] = $h; // remove whitespace
|
||||
if (!($required[$h] or $optionalDefaults[$h] or $optional[$h])) {
|
||||
if (!(isset($required[$h]) or isset($optionalDefaults[$h]) or isset($optional[$h]))) {
|
||||
error(get_string('invalidfieldname', 'error', $h), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
}
|
||||
if ($required[$h]) {
|
||||
if (isset($required[$h])) {
|
||||
$required[$h] = 0;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
// add fields to object $user
|
||||
foreach ($record as $name => $value) {
|
||||
// check for required values
|
||||
if ($required[$name] and !$value) {
|
||||
if (isset($required[$name]) and !$value) {
|
||||
error(get_string('missingfield', 'error', $name). " ".
|
||||
get_string('erroronline', 'error', $linenum) .". ".
|
||||
get_string('processingstops', 'error'),
|
||||
|
||||
+9
-6
@@ -104,12 +104,13 @@
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
die;
|
||||
} else if (data_submitted() and !$user->deleted) {
|
||||
//following code is also used in auth sync scripts
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time()); // Remember it just in case
|
||||
$updateuser->email = ''; // Clear this field to free it up
|
||||
$updateuser->idnumber = ''; // Clear this field to free it up
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time()); // Remember it just in case
|
||||
$updateuser->email = ''; // Clear this field to free it up
|
||||
$updateuser->idnumber = ''; // Clear this field to free it up
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record('user', $updateuser)) {
|
||||
// not sure if this is needed. unenrol_student($user->id); // From all courses
|
||||
@@ -354,7 +355,9 @@
|
||||
. get_string($changeaccessto, 'mnet') . " access</a>)";
|
||||
}
|
||||
// mnet info in edit column
|
||||
$editbutton = $mnethosts[$user->mnethostid]->name;
|
||||
if (isset($mnethosts[$user->mnethostid])) {
|
||||
$editbutton = $mnethosts[$user->mnethostid]->name;
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->lastaccess) {
|
||||
|
||||
@@ -112,7 +112,7 @@ class edit_index extends XMLDBAction {
|
||||
if ($structure->getIndexUses($table->getName(), $index->getName())) {
|
||||
$disabled = ' disabled="disabled " ';
|
||||
}
|
||||
$o.= ' <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . 'value="' . s($index->getName()) . '" /></td></tr>';
|
||||
$o.= ' <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . ' value="' . s($index->getName()) . '" /></td></tr>';
|
||||
/// XMLDB key comment
|
||||
$o.= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($index->getComment()) . '</textarea></td></tr>';
|
||||
/// XMLDBIndex Type
|
||||
|
||||
@@ -112,7 +112,7 @@ class edit_key extends XMLDBAction {
|
||||
if ($structure->getKeyUses($table->getName(), $key->getName())) {
|
||||
$disabled = ' disabled="disabled " ';
|
||||
}
|
||||
$o.= ' <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . 'value="' . s($key->getName()) . '" /></td></tr>';
|
||||
$o.= ' <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . ' value="' . s($key->getName()) . '" /></td></tr>';
|
||||
/// XMLDB key comment
|
||||
$o.= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($key->getComment()) . '</textarea></td></tr>';
|
||||
/// XMLDBKey Type
|
||||
|
||||
@@ -81,6 +81,9 @@ class load_xml_file extends XMLDBAction {
|
||||
return false;
|
||||
}
|
||||
$xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
|
||||
///Set the XML DTD and schema
|
||||
$xmldb_file->setDTD($CFG->dirroot . '/lib/xmldb/xmldb.dtd');
|
||||
$xmldb_file->setSchema($CFG->dirroot . '/lib/xmldb/xmldb.xsd');
|
||||
/// Set dbdir as necessary
|
||||
if ($xmldb_file->fileExists()) {
|
||||
$dbdir->xml_exists = true;
|
||||
@@ -92,6 +95,7 @@ class load_xml_file extends XMLDBAction {
|
||||
$loaded = $xmldb_file->loadXMLStructure();
|
||||
if ($loaded && $xmldb_file->isLoaded()) {
|
||||
$dbdir->xml_loaded = true;
|
||||
$dbdir->filemtime = filemtime($dbdir->path . '/install.xml');
|
||||
}
|
||||
$dbdir->xml_file = $xmldb_file;
|
||||
} else {
|
||||
|
||||
@@ -157,6 +157,13 @@ class main_view extends XMLDBAction {
|
||||
!empty($dbdir->xml_loaded) &&
|
||||
!empty($dbdir->xml_changed)) {
|
||||
$b .= '<a href="index.php?action=save_xml_file&dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&time=' . time() . '&postaction=main_view#lastused">[' . $this->str['save'] . ']</a>';
|
||||
/// Check if the file has been manually edited while being modified in the editor
|
||||
if ($dbdir->filemtime != filemtime($key . '/install.xml')) {
|
||||
/// File manually modified. Add to errors.
|
||||
if ($structure =& $dbdir->xml_file->getStructure()) {
|
||||
$structure->errormsg = 'Warning: File locally modified while using the XMLDB Editor. Saving will overwrite local changes';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$b .= '[' . $this->str['save'] . ']';
|
||||
}
|
||||
|
||||
@@ -114,6 +114,8 @@ class test extends XMLDBAction {
|
||||
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
|
||||
$table->addIndexInfo('rsstype', XMLDB_INDEX_UNIQUE, array('rsstype'));
|
||||
|
||||
$table->setComment("This is a test'n drop table. You can drop it safely");
|
||||
|
||||
/// Get SQL code and execute it
|
||||
$test = new stdClass;
|
||||
$test->sql = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, true);
|
||||
@@ -275,7 +277,7 @@ class test extends XMLDBAction {
|
||||
/// Get SQL code and execute it
|
||||
$test = new stdClass;
|
||||
$field = new XMLDBField('grade');
|
||||
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test');
|
||||
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, "test'n drop");
|
||||
|
||||
$test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
|
||||
$test->status = change_field_type($table, $field, false, false);
|
||||
|
||||
+34
-168
@@ -1,15 +1,16 @@
|
||||
This directory contains authentication modules.
|
||||
|
||||
Each of these modules describes a different way to
|
||||
check that a user has provided a correct
|
||||
Each of these modules describes a different way to
|
||||
check that a user has provided a correct
|
||||
|
||||
- username, and
|
||||
- username, and
|
||||
- password.
|
||||
|
||||
Even when external forms of authentication are being used, Moodle still
|
||||
maintains the internal "user" table with all the associated information about
|
||||
that user such as name, email address and so on.
|
||||
|
||||
|
||||
Multiauthentication in Moodle 1.8
|
||||
-------------------------------------
|
||||
|
||||
@@ -22,20 +23,26 @@ part of the enabled plugin sequence).
|
||||
email - authentication by email (DEFAULT METHOD)
|
||||
|
||||
- user fills out form with email address
|
||||
- email sent to user with link
|
||||
- email sent to user with link
|
||||
- user clicks on link in email to confirm
|
||||
- user account is created
|
||||
- user can log in
|
||||
|
||||
|
||||
none - no authentication at all .. very insecure!!
|
||||
|
||||
|
||||
- user logs in using ANY username and password
|
||||
- if the username doesn't already exist then
|
||||
a new account is created
|
||||
- when user tries to access a course they
|
||||
- when user tries to access a course they
|
||||
are forced to set up their account details
|
||||
|
||||
|
||||
nologin - user can not log in, login as is possible
|
||||
|
||||
- this plugin can be used to prevent normal user login
|
||||
|
||||
|
||||
manual - internal authentication only
|
||||
|
||||
- user logs in using username and password
|
||||
@@ -81,7 +88,7 @@ nntp - Uses an external NNTP server
|
||||
|
||||
|
||||
db - Uses an external database to check username/password
|
||||
|
||||
|
||||
- user logs in using username and password
|
||||
- these are checked against an external database
|
||||
- if correct, user is logged in
|
||||
@@ -94,6 +101,9 @@ db - Uses an external database to check username/password
|
||||
Authentication API
|
||||
------------------
|
||||
|
||||
|
||||
AUTHENTICATION PLUGINS
|
||||
----------------------
|
||||
Each authentication plugin is now contained in a subfolder as a class definition
|
||||
in the auth.php file. For instance, the LDAP authentication plugin is the class
|
||||
called auth_plugin_ldap defined in:
|
||||
@@ -105,13 +115,17 @@ get_auth_plugin() that does the work for you:
|
||||
|
||||
$ldapauth = get_auth_plugin('ldap');
|
||||
|
||||
If an auth is not specified, get_auth_plugin() will return you the auth plugin
|
||||
defined in the $CFG->auth variable.
|
||||
Auth plugin classes are pretty basic and should be extending auth_plugin_base class.
|
||||
They contain the same functions that were previously in each plugin's lib.php file,
|
||||
but refactored to become class methods, and tweaked to reference the plugin's instantiated
|
||||
config to get at the settings, rather than the global $CFG variable.
|
||||
|
||||
Auth plugin classes are pretty basic. They contain the same functions that were
|
||||
previously in each plugin's lib.php file, but refactored to become class
|
||||
methods, and tweaked to reference the plugin's instantiated config to get at the
|
||||
settings, rather than the global $CFG variable.
|
||||
When creating new plugins you can either extend the abstract auth_plugin_base class
|
||||
(defined in lib/authlib.php) or create a new one and implement all methods from
|
||||
auth_plugin_base.
|
||||
|
||||
The new plugin architecture allows creating of more advanced types such as custom SSO
|
||||
without the need to patch login and logout pages (see *_hook() methods in existing plugins).
|
||||
|
||||
Configuration
|
||||
-----------------
|
||||
@@ -130,12 +144,6 @@ is now accessed as
|
||||
Authentication settings have been moved to the config_plugins database table,
|
||||
with the plugin field set to "auth/foo" (for instance, "auth/ldap").
|
||||
|
||||
Upgrading from Moodle 1.7
|
||||
-----------------------------
|
||||
|
||||
Moodle will upgrade the old auth settings (in $CFG->auth_foobar where foo is the
|
||||
auth plugin and bar is the setting) to the new style in the config_plugin
|
||||
database table.
|
||||
|
||||
Method Names
|
||||
-----------------
|
||||
@@ -153,155 +161,13 @@ this also avoids having to worry about which auth/lib file to include since
|
||||
Moodle takes care of it for you when you create an instance with
|
||||
get_auth_plugin().
|
||||
|
||||
Code Usage
|
||||
-----------------
|
||||
|
||||
Code calling auth plugins can use method_exists() to determine plugin
|
||||
functionality, much in the same way that function_exists() was used until now.
|
||||
In addition, auth plugins provide some methods by default that can be called:
|
||||
|
||||
user_login($username, $password)
|
||||
This is the primary method that is used by the authenticate_user_login()
|
||||
function in moodlelib.php. This method should return a boolean indicating
|
||||
whether or not the username and password authenticate successfully.
|
||||
|
||||
is_internal()
|
||||
Returns true if this authentication plugin is "internal" (which means that
|
||||
Moodle stores the users' passwords and other details in the local Moodle
|
||||
database).
|
||||
|
||||
can_change_password()
|
||||
Returns true if the plugin can change the users' passwords.
|
||||
|
||||
change_password_url()
|
||||
Returns the URL for changing the users' passwords, or false if the default
|
||||
URL can be used.
|
||||
|
||||
user_update_password($user, $newpassword)
|
||||
Updates the user's password. In previous versions of Moodle, the function
|
||||
auth_user_update_password accepted a username as the first parameter. The
|
||||
revised function expects a user object.
|
||||
|
||||
config_form()
|
||||
Displays the configuration form for the auth plugin, for use in the admin
|
||||
pages.
|
||||
|
||||
process_config()
|
||||
Saves the auth plugin's configuration to the database.
|
||||
|
||||
Other Methods
|
||||
------------------
|
||||
|
||||
Most of functions are from ldap-authentication module and are not implemented
|
||||
(yet?) on other modules. Please feel free to extend other modules to support
|
||||
same features or roll your own module.
|
||||
|
||||
Some of the new functions are still to be tested and are not documented here
|
||||
yet.
|
||||
|
||||
AUTHENTICATION
|
||||
|
||||
Basic fuctions to authenticate users with external db.
|
||||
|
||||
Mandatory:
|
||||
|
||||
auth_plugin_foo()
|
||||
|
||||
Constructor. At the least, it populates config member variable with settings
|
||||
from the Moodle database. It makes sense to put other startup code here.
|
||||
|
||||
user_login($username, $password)
|
||||
|
||||
Authenticate username, password with userdatabase.
|
||||
|
||||
Returns:
|
||||
true if the username and password work
|
||||
and false if they don't
|
||||
|
||||
Optional:
|
||||
|
||||
get_userinfo($username)
|
||||
|
||||
Query other userinformation from database.
|
||||
|
||||
Returns:
|
||||
Userinformation in array ( name => value, ....
|
||||
or false in case of error
|
||||
The basic class defines all applicable methods that moodle uses, you can find
|
||||
more information in lib/authlib.php file.
|
||||
|
||||
|
||||
validate_form(&$form, &$err)
|
||||
|
||||
Validate form data.
|
||||
|
||||
Returns:
|
||||
Bool. Manipulates $form and $err arrays in place
|
||||
|
||||
|
||||
COURSE CREATING
|
||||
|
||||
iscreator($username)
|
||||
|
||||
should user have rights to create courses
|
||||
|
||||
Returns:
|
||||
True if user have rights to crete cources otherwise false
|
||||
|
||||
|
||||
USER CREATION
|
||||
|
||||
Functions that enable usercreation, activation and deactivation
|
||||
from moodle to external database
|
||||
|
||||
|
||||
user_exists ($username)
|
||||
|
||||
Checks if given username exist on external db
|
||||
|
||||
Returns:
|
||||
true if given usernname exist or false
|
||||
|
||||
|
||||
user_create ($userobject,$plainpass)
|
||||
|
||||
Creates new user to external db. User should be created
|
||||
in inactive stage until confirmed by email.
|
||||
|
||||
Returns:
|
||||
True on success otherwise false
|
||||
|
||||
|
||||
user_activate ($username)
|
||||
|
||||
activate new user after email-address is confirmed
|
||||
|
||||
Returns:
|
||||
True on success otherwise false
|
||||
|
||||
|
||||
user_disable ($username) {
|
||||
|
||||
deactivate user in external db.
|
||||
|
||||
Returns:
|
||||
True on success otherwise false
|
||||
|
||||
|
||||
|
||||
USER INFORMATION AND SYNCRONIZATION
|
||||
|
||||
get_userlist ()
|
||||
|
||||
Get list of usernames in external db.
|
||||
|
||||
Returns:
|
||||
All usernames in array or false on error.
|
||||
|
||||
|
||||
get_users($filter='*')
|
||||
|
||||
Get ALL USEROBJECTS FROM EXTERNAL DB.
|
||||
|
||||
Returns:
|
||||
Array of all users as objects from external db
|
||||
|
||||
Upgrading from Moodle 1.7
|
||||
-----------------------------
|
||||
|
||||
Moodle will upgrade the old auth settings (in $CFG->auth_foobar where foo is the
|
||||
auth plugin and bar is the setting) to the new style in the config_plugin
|
||||
database table.
|
||||
@@ -1,92 +0,0 @@
|
||||
AUTHENTICATION PLUGINS
|
||||
----------------------
|
||||
Each authentication plugin is now contained in a subfolder as a class definition
|
||||
in the auth.php file. For instance, the LDAP authentication plugin is the class
|
||||
called auth_plugin_ldap defined in:
|
||||
|
||||
/auth/ldap/auth.php
|
||||
|
||||
To instantiate the class, there is a function in lib/moodlelib called
|
||||
get_auth_plugin() that does the work for you:
|
||||
|
||||
$ldapauth = get_auth_plugin('ldap');
|
||||
|
||||
If an auth is not specified, get_auth_plugin() will return you the auth plugin
|
||||
defined in the $CFG->auth variable.
|
||||
|
||||
Auth plugin classes are pretty basic. They contain the same functions that were
|
||||
previously in each plugin's lib.php file, but refactored to become class
|
||||
methods, and tweaked to reference the plugin's instantiated config to get at the
|
||||
settings, rather than the global $CFG variable.
|
||||
|
||||
Configuration
|
||||
-----------------
|
||||
|
||||
All auth plugins must have a config property that contains the name value pairs
|
||||
from the config_plugins table. This is populated using the get_config() function
|
||||
in the constructor. The settings keys have also had the "auth_" prefix, as well
|
||||
as the auth plugin name, trimmed. For instance, what used to be
|
||||
|
||||
echo $CFG->auth_ldapversion;
|
||||
|
||||
is now accessed as
|
||||
|
||||
echo $ldapauth->config->version;
|
||||
|
||||
Authentication settings have been moved to the config_plugins database table,
|
||||
with the plugin field set to "auth/foo" (for instance, "auth/ldap").
|
||||
|
||||
Method Names
|
||||
-----------------
|
||||
|
||||
When the functions from lib.php were ported to methods in auth.php, the "auth_"
|
||||
prefix was dropped. For instance, calls to
|
||||
|
||||
auth_user_login($user, $pass);
|
||||
|
||||
now become
|
||||
|
||||
$ldapauth->user_login($user, $pass);
|
||||
|
||||
this also avoids having to worry about which auth/lib file to include since
|
||||
Moodle takes care of it for you when you create an instance with
|
||||
get_auth_plugin().
|
||||
|
||||
Code Use
|
||||
-----------------
|
||||
|
||||
Code calling auth plugins can use method_exists() to determine plugin
|
||||
functionality, much in the same way that function_exists() was used until now.
|
||||
In addition, auth plugins provide some methods by default that can be called:
|
||||
|
||||
user_login($username, $password)
|
||||
This is the primary method that is used by the authenticate_user_login()
|
||||
function in moodlelib.php. This method should return a boolean indicating
|
||||
whether or not the username and password authenticate successfully.
|
||||
|
||||
is_internal()
|
||||
Returns true if this authentication plugin is "internal" (which means that
|
||||
Moodle stores the users' passwords and other details in the local Moodle
|
||||
database).
|
||||
|
||||
can_change_password()
|
||||
Returns true if the plugin can change the users' passwords.
|
||||
|
||||
change_password_url()
|
||||
Returns the URL for changing the users' passwords, or false if the default
|
||||
URL can be used.
|
||||
|
||||
Other Methods
|
||||
-----------------
|
||||
|
||||
get_userinfo()
|
||||
This method should return an array of fields from the authentication source
|
||||
for the given username.
|
||||
|
||||
Upgrading from Moodle 1.7
|
||||
-----------------------------
|
||||
|
||||
Moodle will upgrade the old auth settings (in $CFG->auth_foobar where foo is the
|
||||
auth plugin and bar is the setting) to the new style in the config_plugin
|
||||
database table.
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package moodle multiauth
|
||||
*
|
||||
* Multiple plugin authentication
|
||||
* Support library
|
||||
*
|
||||
* 2006-08-28 File created, AUTH return values defined.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returned when the login was successful.
|
||||
*/
|
||||
define('AUTH_OK', 0);
|
||||
|
||||
/**
|
||||
* Returned when the login was unsuccessful.
|
||||
*/
|
||||
define('AUTH_FAIL', 1);
|
||||
|
||||
/**
|
||||
* Returned when the login was denied (a reason for AUTH_FAIL).
|
||||
*/
|
||||
define('AUTH_DENIED', 2);
|
||||
|
||||
/**
|
||||
* Returned when some error occurred (a reason for AUTH_FAIL).
|
||||
*/
|
||||
define('AUTH_ERROR', 4);
|
||||
|
||||
?>
|
||||
+1
-1
@@ -2,6 +2,6 @@ CAS-module README
|
||||
|
||||
Please read comments from lib.php for auth/cas module
|
||||
The auth/cas module is using part of the /auth/ldap module. The /auth/ldap directory should exist.
|
||||
The auth/cas use the PHPCAS project from http://esup-phpcas.sourceforge.net
|
||||
The auth/cas use the PHPCAS project from http://esup-phpcas.sourceforge.net
|
||||
|
||||
|
||||
|
||||
+34
-19
@@ -11,23 +11,22 @@
|
||||
* 2006-08-28 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* CAS authentication plugin.
|
||||
*/
|
||||
class auth_plugin_cas {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_cas extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_cas() {
|
||||
$this->authtype = 'cas';
|
||||
$this->config = get_config('auth/cas');
|
||||
}
|
||||
|
||||
@@ -38,21 +37,21 @@ class auth_plugin_cas {
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
if (! function_exists('ldap_connect')) {
|
||||
print_error('auth_casnotinstalled','mnet');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
global $CFG;
|
||||
|
||||
// don't allow blank usernames or passwords
|
||||
if (!$username or !$password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// CAS specific
|
||||
if ($CFG->auth == "cas" and !empty($this->config->enabled)) {
|
||||
if ($this->config->create_user == '0') {
|
||||
@@ -72,7 +71,7 @@ class auth_plugin_cas {
|
||||
|
||||
if ($ldap_connection) {
|
||||
$ldap_user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
|
||||
// if ldap_user_dn is empty, user does not exist
|
||||
if (!$ldap_user_dn) {
|
||||
ldap_close($ldap_connection);
|
||||
@@ -205,7 +204,7 @@ class auth_plugin_cas {
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -215,10 +214,26 @@ class auth_plugin_cas {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
return !empty($this->config->changepasswordurl);
|
||||
}
|
||||
|
||||
function loginpage_hook() {
|
||||
// Load alternative login screens if necessary
|
||||
// TODO: fix the cas login screen
|
||||
return;
|
||||
|
||||
if(!empty($CFG->cas_enabled)) {
|
||||
require($CFG->dirroot.'/auth/cas/login.php');
|
||||
}
|
||||
}
|
||||
|
||||
function prelogout_hook() {
|
||||
global $CFG;
|
||||
|
||||
require($CFG->dirroot.'/auth/cas/logout.php');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,15 +244,15 @@ class auth_plugin_cas {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include 'config.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* Returns the URL for changing the user's pw, or empty if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return string
|
||||
*/
|
||||
function change_password_url() {
|
||||
return $this->config->changepasswordurl;
|
||||
@@ -288,7 +303,7 @@ class auth_plugin_cas {
|
||||
set_config('changepasswordurl', $config->changepasswordurl, 'auth/cas');
|
||||
|
||||
// save LDAP settings
|
||||
// TODO: Do we want the CAS LDAP settings to be separate from the LDAP settings?
|
||||
// TODO: settings must be separated now that we have multiauth!
|
||||
$ldapauth = get_auth_plugin('ldap');
|
||||
$ldapauth->process_config($config);
|
||||
|
||||
|
||||
@@ -2,31 +2,33 @@
|
||||
/** auth_ldap_sync_users.php
|
||||
* Modified for cas Module
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* backend in those setups where the LDAP backend acts as 'master'.
|
||||
*
|
||||
*
|
||||
* Recommended cron entry:
|
||||
* # 5 minutes past 4am
|
||||
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* Notes:
|
||||
* - If you have a large number of users, you may want to raise the memory limits
|
||||
* by passing -d momory_limit=256M
|
||||
* - For debugging & better logging, you are encouraged to use in the command line:
|
||||
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
|
||||
*
|
||||
*
|
||||
* Performance notes:
|
||||
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if (!empty($_SERVER['GATEWAY_INTERFACE'])) {
|
||||
error_log("should not be called from apache!");
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
error_log("should not be called from web server!");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nomoodlecookie = true; // cookie not needed
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
@@ -34,7 +36,12 @@ require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/moodlelib.php');
|
||||
$CFG->debug=10;
|
||||
|
||||
if (!is_enabled_auth('cas')) {
|
||||
echo "Plugin not enabled!";
|
||||
die;
|
||||
}
|
||||
|
||||
$casauth = get_auth_plugin('cas');
|
||||
$casauth->sync_users(1000, true);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
unset($options);
|
||||
$options[1] = get_string('yes');
|
||||
choose_from_menu ($options, 'use_cas', $config->use_cas, get_string('no'), '', '');
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_cas_enabled', 'auth') ?></td>
|
||||
@@ -63,11 +63,11 @@
|
||||
<td>
|
||||
<input name="hostname" type="text" size="30" value="<?php echo $config->hostname ?>" />
|
||||
<?php
|
||||
|
||||
|
||||
if (isset($err['hostname'])) {
|
||||
formerr($err['hostname']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_cas_hostname', 'auth') ?></td>
|
||||
@@ -78,11 +78,11 @@
|
||||
<td>
|
||||
<input name="baseuri" type="text" size="30" value="<?php echo $config->baseuri ?>" />
|
||||
<?php
|
||||
|
||||
|
||||
if (isset($err['baseuri'])) {
|
||||
formerr($err['baseuri']);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_cas_baseuri', 'auth') ?></td>
|
||||
@@ -93,11 +93,11 @@
|
||||
<td>
|
||||
<input name="port" type="text" size="30" value="<?php echo $config->port ?>" />
|
||||
<?php
|
||||
|
||||
|
||||
if (isset($err['port'])) {
|
||||
formerr($err['port']);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_cas_port', 'auth') ?></td>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
$loginsite = get_string("loginsite");
|
||||
$errormsg = get_string("auth_cas_invalidcaslogin", "auth");
|
||||
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite);
|
||||
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite);
|
||||
include("forbidden.html");
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<tr>
|
||||
<td width="50%" align="center" valign="top" class="generalbox">
|
||||
<p><?php print_string("loginusing") ?>:<br />
|
||||
(<?php print_string("cookiesenabled");?>)
|
||||
(<?php print_string("cookiesenabled");?>)
|
||||
<?php helpbutton("cookies", get_string("cookiesenabled"))?><br /><?php formerr($errormsg) ?>
|
||||
</p>
|
||||
<form action="index.php" method="post" id="login">
|
||||
@@ -41,7 +41,7 @@
|
||||
$changebuttonname = get_string("senddetails");
|
||||
?>
|
||||
<hr width="80%" />
|
||||
<p><?php print_string("forgotten") ?></p>
|
||||
<p><?php print_string("forgotten") ?></p>
|
||||
<form action="<?php p($changepassword) ?>" method="get" id="changepassword">
|
||||
<input type="submit" value="<?php p($changebuttonname) ?>" />
|
||||
</form>
|
||||
|
||||
+21
-21
@@ -70,8 +70,8 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
update_login_count();
|
||||
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
@@ -91,7 +91,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
$USER->firstname = get_string("guestuser"); // Name always in current language
|
||||
$USER->lastname = " ";
|
||||
}
|
||||
|
||||
|
||||
if (!update_user_login_times()) {
|
||||
error("Wierd error: could not update login records");
|
||||
}
|
||||
@@ -111,7 +111,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
$userauth = get_auth_plugin($USER->auth);
|
||||
if (method_exists($userauth, 'can_change_password') and $userauth->can_change_password()) {
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
}
|
||||
}
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)) {
|
||||
@@ -122,7 +122,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
@@ -143,12 +143,12 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
if ($ldapauth->config->expiration == 1) {
|
||||
$days2expire = $ldapauth->password_expire($USER->username);
|
||||
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
} elseif (intval($days2expire) < 0 ) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
@@ -162,7 +162,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
redirect($urltogo);
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
} else {
|
||||
if ($CFG->auth == "cas" ) { /// CAS error login
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
@@ -174,8 +174,8 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
}
|
||||
$user = $casauth->automatic_authenticate($user);
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
@@ -226,7 +226,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
@@ -247,12 +247,12 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
if ($ldapauth->config->expiration == 1) {
|
||||
$days2expire = $ldapauth->password_expire($USER->username);
|
||||
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div class=\"langmenu\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div class=\"langmenu\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
} elseif (intval($days2expire) < 0 ) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div class=\"langmenu\">$langmenu</div>");
|
||||
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div class=\"langmenu\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
@@ -278,18 +278,18 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
if (empty($SESSION->wantsurl)) {
|
||||
$SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot.'/';
|
||||
$SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot.'/';
|
||||
}
|
||||
|
||||
if (get_moodle_cookie() == '') {
|
||||
if (get_moodle_cookie() == '') {
|
||||
set_moodle_cookie('nobody'); // To help search for cookies
|
||||
}
|
||||
|
||||
|
||||
if (empty($frm->username)) {
|
||||
$frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
|
||||
$frm->password = "";
|
||||
}
|
||||
|
||||
|
||||
if (!empty($frm->username)) {
|
||||
$focus = "login.password";
|
||||
} else {
|
||||
@@ -301,8 +301,8 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
} else {
|
||||
$show_instructions = false;
|
||||
}
|
||||
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
|
||||
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
include($CFG->dirroot.'/auth/cas/index_form.html');
|
||||
print_footer();
|
||||
|
||||
|
||||
+324
-201
@@ -12,56 +12,60 @@
|
||||
* 2006-08-28 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* External database authentication plugin.
|
||||
*/
|
||||
class auth_plugin_db {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_db extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_db() {
|
||||
$this->authtype = 'db';
|
||||
$this->config = get_config('auth/db');
|
||||
if (empty($this->config->extencoding)) {
|
||||
$this->config->extencoding = 'utf-8';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
*
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
function user_login($username, $password) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
// Connect to the external database (forcing new connection)
|
||||
$authdb = &ADONewConnection($this->config->type);
|
||||
$authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
|
||||
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
$textlib = textlib_get_instance();
|
||||
$extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding);
|
||||
$extpassword = $textlib->convert(stripslashes($password), 'utf-8', $this->config->extencoding);
|
||||
|
||||
if ($this->config->passtype === 'internal') {
|
||||
$authdb = $this->db_init();
|
||||
|
||||
if ($this->config->passtype === 'internal') {
|
||||
// lookup username externally, but resolve
|
||||
// password locally -- to support backend that
|
||||
// don't track passwords
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '$username' ");
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' ");
|
||||
$authdb->Close();
|
||||
|
||||
if (!$rs) {
|
||||
print_error('auth_dbcantconnect','auth');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
// user exists exterally
|
||||
// check username/password internally
|
||||
@@ -71,60 +75,90 @@ class auth_plugin_db {
|
||||
} else {
|
||||
// user does not exist externally
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
// normal case: use external db for passwords
|
||||
|
||||
if ($this->config->passtype === 'md5') { // Re-format password accordingly
|
||||
$password = md5($password);
|
||||
$extpassword = md5($extpassword);
|
||||
} else if ($this->config->passtype === 'sha1') {
|
||||
$extpassword = sha1($extpassword);
|
||||
}
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '$username'
|
||||
AND {$this->config->fieldpass} = '$password' ");
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'
|
||||
AND {$this->config->fieldpass} = '".$this->ext_addslashes($extpassword)."' ");
|
||||
$authdb->Close();
|
||||
|
||||
|
||||
if (!$rs) {
|
||||
print_error('auth_dbcantconnect','auth');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
|
||||
if ($rs->RecordCount()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function db_init() {
|
||||
// Connect to the external database (forcing new connection)
|
||||
$authdb = &ADONewConnection($this->config->type);
|
||||
if (!empty($this->config->debugauthdb)) {
|
||||
$authdb->debug = true;
|
||||
ob_start();//start output buffer to allow later use of the page headers
|
||||
}
|
||||
$authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
|
||||
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
if (!empty($this->config->setupsql)) {
|
||||
$authdb->Execute($this->config->setupsql);
|
||||
}
|
||||
|
||||
return $authdb;
|
||||
}
|
||||
/**
|
||||
* retuns user attribute mappings between moodle and ldap
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function db_attributes() {
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang" );
|
||||
$moodleattributes = array();
|
||||
foreach ($fields as $field) {
|
||||
if (!empty($this->config->{"field_map_$field"})) {
|
||||
$moodleattributes[$field] = $this->config->{"field_map_$field"};
|
||||
}
|
||||
}
|
||||
$moodleattributes['username'] = $this->config->fielduser;
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads any other information for a user from external database,
|
||||
* then returns it in an array
|
||||
*
|
||||
* @param string $username (with system magic quotes)
|
||||
*
|
||||
* @return array without magic quotes
|
||||
*/
|
||||
function get_userinfo($username) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
// Connect to the external database (forcing new connection)
|
||||
$authdb = &ADONewConnection($this->config->type);
|
||||
$authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
|
||||
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang");
|
||||
$textlib = textlib_get_instance();
|
||||
$extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding);
|
||||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
//Array to map local fieldnames we want, to external fieldnames
|
||||
$selectfields = array();
|
||||
foreach ($fields as $field) {
|
||||
if (!empty($this->config->{'field_map_' . $field})) {
|
||||
$selectfields[$field] = $this->config->{'field_map_' . $field};
|
||||
}
|
||||
}
|
||||
$selectfields = $this->db_attributes();
|
||||
|
||||
$result = array();
|
||||
//If at least one field is mapped from external db, get that mapped data:
|
||||
if ($selectfields) {
|
||||
@@ -135,22 +169,18 @@ class auth_plugin_db {
|
||||
$select = 'SELECT ' . substr($select,1);
|
||||
$sql = $select .
|
||||
" FROM {$this->config->table}" .
|
||||
" WHERE {$this->config->fielduser} = '$username'";
|
||||
" WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'";
|
||||
if ($rs = $authdb->Execute($sql)) {
|
||||
if ( $rs->RecordCount() == 1 ) {
|
||||
$fields_obj = rs_fetch_record($rs);
|
||||
foreach ($selectfields as $localname=>$externalname) {
|
||||
if (empty($CFG->unicodedb)) {
|
||||
$fields_obj->{$localname} = utf8_decode($fields_obj->{$localname});
|
||||
}
|
||||
$result[$localname] = addslashes(stripslashes($fields_obj->{$localname}));
|
||||
$result[$localname] = $textlib->convert($fields_obj->{$localname}, $this->config->extencoding, 'utf-8');
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
}
|
||||
$authdb->Close();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -158,15 +188,16 @@ class auth_plugin_db {
|
||||
/**
|
||||
* Change a user's password
|
||||
*
|
||||
* @param object $user The user to update
|
||||
* @param string $newpassword The new password
|
||||
* @param object $user User table object (with system magic quotes)
|
||||
* @param string $newpassword Plaintext password (with system magic quotes)
|
||||
*
|
||||
* @return bool True on success
|
||||
*/
|
||||
function user_update_password($user, $newpassword) {
|
||||
|
||||
global $CFG;
|
||||
if ($this->config->passtype === 'internal') {
|
||||
return set_field('user', 'password', md5($newpassword), 'id', $user->id, 'mnethostid', $CFG->mnet_localhost_id);
|
||||
update_internal_user_password($user, $newpassword);
|
||||
} else {
|
||||
// we should have never been called!
|
||||
return false;
|
||||
@@ -179,69 +210,77 @@ class auth_plugin_db {
|
||||
* 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.
|
||||
*
|
||||
* 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 sync_users ($do_updates=0) {
|
||||
|
||||
function sync_users($do_updates=false) {
|
||||
|
||||
global $CFG;
|
||||
$pcfg = get_config('auth/db');
|
||||
|
||||
///
|
||||
/// list external users
|
||||
///
|
||||
/// list external users
|
||||
$userlist = $this->get_userlist();
|
||||
$quoteduserlist = implode("', '", $userlist);
|
||||
$quoteduserlist = implode("', '", addslashes_recursive($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);
|
||||
/// delete obsolete internal users
|
||||
if (!empty($this->config->removeuser)) {
|
||||
|
||||
if (!empty($remove_users)) {
|
||||
print_string('auth_dbuserstoremove','auth', count($remove_users));
|
||||
echo "\n";
|
||||
// find obsolete users
|
||||
if (count($userlist)) {
|
||||
$sql = "SELECT u.id, u.username, u.email
|
||||
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, u.email
|
||||
FROM {$CFG->prefix}user u
|
||||
WHERE u.auth='db' AND u.deleted=0";
|
||||
}
|
||||
$remove_users = get_records_sql($sql);
|
||||
|
||||
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
|
||||
$updateuser = new stdClass();
|
||||
$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);
|
||||
delete_records('role_assignments', 'userid', $user->id); // unassign all roles
|
||||
notify(get_string("deletedactivity", "", fullname($user, true)) );
|
||||
} else {
|
||||
notify(get_string("deletednot", "", fullname($user, true)));
|
||||
if (!empty($remove_users)) {
|
||||
print_string('auth_dbuserstoremove','auth', count($remove_users)); echo "\n";
|
||||
|
||||
begin_sql();
|
||||
foreach ($remove_users as $user) {
|
||||
if ($this->config->removeuser == 2) {
|
||||
//following is copy pasted from admin/user.php
|
||||
//maybe this should moved to function in lib/datalib.php
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = 1;
|
||||
$updateuser->username = addslashes("$user->email.".time()); // Remember it just in case
|
||||
$updateuser->email = ''; // Clear this field to free it up
|
||||
$updateuser->idnumber = ''; // Clear this field to free it up
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record('user', $updateuser)) {
|
||||
delete_records('role_assignments', 'userid', $user->id); // unassign all roles
|
||||
//copy pasted part ends
|
||||
echo "\t"; print_string('auth_dbdeleteuser', 'auth', array($user->username, $user->id)); echo "\n";
|
||||
} else {
|
||||
echo "\t"; print_string('auth_dbdeleteusererror', 'auth', $user->username); echo "\n";
|
||||
}
|
||||
} else if ($this->config->removeuser == 1) {
|
||||
$updateuser = new object();
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->auth = 'nologin';
|
||||
if (update_record('user', $updateuser)) {
|
||||
echo "\t"; print_string('auth_dbsuspenduser', 'auth', array($user->username, $user->id)); echo "\n";
|
||||
} else {
|
||||
echo "\t"; print_string('auth_dbsuspendusererror', 'auth', $user->username); echo "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
//copy pasted part ends
|
||||
}
|
||||
commit_sql();
|
||||
}
|
||||
unset($remove_users); // free mem!
|
||||
commit_sql();
|
||||
}
|
||||
unset($remove_users); // free mem!
|
||||
}
|
||||
|
||||
if (!count($userlist)) {
|
||||
// exit right here
|
||||
@@ -269,15 +308,21 @@ class auth_plugin_db {
|
||||
// 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
|
||||
$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) {
|
||||
$this->db_update_user_record($user->username, $updatekeys);
|
||||
if ($update_users = get_records_sql($sql)) {
|
||||
print "User entries to update: ". count($update_users). "\n";
|
||||
|
||||
foreach ($update_users as $user) {
|
||||
echo "\t"; print_string('auth_dbupdatinguser', 'auth', array($user->username, $user->id));
|
||||
if (!$this->update_user_record(addslashes($user->username), $updatekeys)) {
|
||||
echo " - ".get_string('skipped');
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
unset($update_users); // free memory
|
||||
}
|
||||
unset($update_users); // free memory
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,12 +332,12 @@ class auth_plugin_db {
|
||||
///
|
||||
// NOTE: this is very memory intensive
|
||||
// and generally inefficient
|
||||
$sql = 'SELECT u.id, u.username
|
||||
FROM ' . $CFG->prefix .'user u
|
||||
$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) {
|
||||
@@ -304,44 +349,38 @@ class auth_plugin_db {
|
||||
unset($usernames);
|
||||
|
||||
if (!empty($add_users)) {
|
||||
print_string('auth_dbuserstoadd','auth',count($add_users));
|
||||
echo "\n";
|
||||
print_string('auth_dbuserstoadd','auth',count($add_users)); echo "\n";
|
||||
begin_sql();
|
||||
foreach($add_users as $user) {
|
||||
$username = $user;
|
||||
$user = $this->get_userinfo_asobj($user);
|
||||
|
||||
|
||||
// prep a few params
|
||||
$user->username = $username;
|
||||
$user->modified = time();
|
||||
$user->confirmed = 1;
|
||||
$user->auth = 'db';
|
||||
$user->mnethostid = $CFG->mnet_localhost_id;
|
||||
|
||||
// insert it
|
||||
$old_debug=$CFG->debug;
|
||||
$CFG->debug=10;
|
||||
|
||||
if (empty($user->lang)) {
|
||||
$user->lang = $CFG->lang;
|
||||
}
|
||||
|
||||
$user = addslashes_object($user);
|
||||
// maybe the user has been deleted before
|
||||
if ($old_user = get_record('user', 'username', $user->username, 'deleted', 1, 'mnethostid', $user->mnethostid)) {
|
||||
$user->id = $old_user->id;
|
||||
set_field('user', 'deleted', 0, 'username', $user->username);
|
||||
print_string('auth_dbrevive','auth',array($user->username, $user->id));
|
||||
echo "\n";
|
||||
} elseif ($id=insert_record ('user',$user)) { // it is truly a new user
|
||||
print_string('auth_dbinsertuser','auth',array($user->username, $id));
|
||||
echo "\n";
|
||||
$user->id = $id;
|
||||
echo "\t"; print_string('auth_dbreviveuser', 'auth', array(stripslashes($user->username), $user->id)); echo "\n";
|
||||
} elseif ($id = insert_record ('user',$user)) { // it is truly a new user
|
||||
echo "\t"; print_string('auth_dbinsertuser','auth',array(stripslashes($user->username), $id)); echo "\n";
|
||||
// if relevant, tag for password generation
|
||||
if ($this->config->passtype === 'internal') {
|
||||
set_user_preference('auth_forcepasswordchange', 1, $id);
|
||||
set_user_preference('create_password', 1, $id);
|
||||
}
|
||||
} else {
|
||||
print_string('auth_dbinsertusererror', 'auth', $user->username);
|
||||
echo "\n";
|
||||
echo "\t"; print_string('auth_dbinsertusererror', 'auth', $user->username); echo "\n";
|
||||
}
|
||||
$CFG->debug=$old_debug;
|
||||
}
|
||||
commit_sql();
|
||||
unset($add_users); // free mem
|
||||
@@ -349,43 +388,35 @@ class auth_plugin_db {
|
||||
return true;
|
||||
}
|
||||
|
||||
function user_exists ($username) {
|
||||
function user_exists($username) {
|
||||
|
||||
// Connect to the external database (forcing new connection)
|
||||
$authdb = &ADONewConnection($this->config->type);
|
||||
$authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
|
||||
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
$textlib = textlib_get_instance();
|
||||
$extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding);
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '$username' ");
|
||||
$authdb = $this->db_init();
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' ");
|
||||
$authdb->Close();
|
||||
|
||||
if (!$rs) {
|
||||
print_error('auth_dbcantconnect','auth');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
// user exists exterally
|
||||
// check username/password internally
|
||||
// ?? there is no $password variable, so why??
|
||||
/*if ($user = get_record('user', 'username', $username)) {
|
||||
return ($user->password == md5($password));
|
||||
}*/
|
||||
return $rs->RecordCount();
|
||||
} else {
|
||||
// user does not exist externally
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_userlist() {
|
||||
|
||||
// Connect to the external database (forcing new connection)
|
||||
$authdb = &ADONewConnection($this->config->type);
|
||||
$authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
|
||||
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
$authdb = $this->db_init();
|
||||
|
||||
// fetch userlist
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fielduser} AS username
|
||||
@@ -396,7 +427,7 @@ class auth_plugin_db {
|
||||
print_error('auth_dbcantconnect','auth');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ( $rs->RecordCount() ) {
|
||||
$userlist = array();
|
||||
while ($rec = rs_fetch_next_record($rs)) {
|
||||
@@ -405,40 +436,40 @@ class auth_plugin_db {
|
||||
return $userlist;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* reads userinformation from DB and return it in an object
|
||||
*
|
||||
* @param string $username username
|
||||
* @param string $username username (with system magic quotes)
|
||||
* @return array
|
||||
*/
|
||||
function get_userinfo_asobj($username) {
|
||||
$user_array = truncate_userinfo($this->get_userinfo($username));
|
||||
$user = new object;
|
||||
$user = new object();
|
||||
foreach($user_array as $key=>$value) {
|
||||
$user->{$key} = $value;
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
/*
|
||||
* will update a local user record from an external source.
|
||||
* is a lighter version of the one in moodlelib -- won't do
|
||||
/**
|
||||
* 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
|
||||
* If you don't pass $updatekeys, there is a performance hit and
|
||||
* values removed from DB won't be removed from moodle.
|
||||
*
|
||||
* @param string $username username (with system magic quotes)
|
||||
*/
|
||||
function db_update_user_record($username, $updatekeys=false) {
|
||||
function update_user_record($username, $updatekeys=false) {
|
||||
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, 'mnethostid', $CFG->mnet_localhost_id);
|
||||
if (empty($user)) { // trouble
|
||||
@@ -450,46 +481,101 @@ class auth_plugin_db {
|
||||
// Ensure userid is not overwritten
|
||||
$userid = $user->id;
|
||||
|
||||
// TODO: this had a function_exists() - now we have a $this
|
||||
if ($newinfo = $this->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($this->config->{'field_updatelocal_' . $key})) {
|
||||
if ($user->{$key} != $value) { // only update if it's changed
|
||||
set_field('user', $key, $value, 'id', $userid);
|
||||
}
|
||||
|
||||
if (!empty($this->config->{'field_updatelocal_' . $key})) {
|
||||
if ($user->{$key} != $value) { // only update if it's changed
|
||||
set_field('user', $key, addslashes($value), 'id', $userid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return get_record_select("user", "id = '$userid' AND deleted <> '1'");
|
||||
return get_record_select('user', "id = $userid AND deleted = 0");
|
||||
}
|
||||
|
||||
// A chance to validate form data, and last chance to
|
||||
// do stuff before it is inserted in config_plugin
|
||||
function validate_form(&$form, &$err) {
|
||||
/**
|
||||
* Called when the user record is updated.
|
||||
* Modifies user in external database. It takes olduser (before changes) and newuser (after changes)
|
||||
* conpares information saved modified information to external db.
|
||||
*
|
||||
* @param mixed $olduser Userobject before modifications (without system magic quotes)
|
||||
* @param mixed $newuser Userobject new modified userobject (without system magic quotes)
|
||||
* @return boolean result
|
||||
*
|
||||
*/
|
||||
function user_update($olduser, $newuser) {
|
||||
if (isset($olduser->username) and isset($newuser->username) and $olduser->username != $newuser->username) {
|
||||
error_log("ERROR:User renaming not allowed in ext db");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($olduser->auth) and $olduser->auth != 'db') {
|
||||
return true; // just change auth and skip update
|
||||
}
|
||||
|
||||
$curruser = $this->get_userinfo($olduser->username);
|
||||
if (empty($curruser)) {
|
||||
error_log("ERROR:User $olduser->username found in ext db");
|
||||
return false;
|
||||
}
|
||||
|
||||
$textlib = textlib_get_instance();
|
||||
$extusername = $textlib->convert($olduser->username, 'utf-8', $this->config->extencoding);
|
||||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
$update = array();
|
||||
foreach($curruser as $key=>$value) {
|
||||
if ($key == 'username') {
|
||||
continue; // skip this
|
||||
}
|
||||
if (empty($this->config->{"field_updateremote_$key"})) {
|
||||
continue; // remote update not requested
|
||||
}
|
||||
if (!isset($newuser->$key)) {
|
||||
continue;
|
||||
}
|
||||
$nuvalue = stripslashes($newuser->$key);
|
||||
if ($nuvalue != $value) {
|
||||
$update[] = $this->config->{"field_map_$key"}."='".$this->ext_addslashes($textlib->convert($nuvalue, 'utf-8', $this->config->extencoding))."'";
|
||||
}
|
||||
}
|
||||
if (!empty($update)) {
|
||||
$authdb->Execute("UPDATE {$this->config->table}
|
||||
SET ".implode(',', $update)."
|
||||
WHERE {$this->config->fielduser}='".$this->ext_addslashes($extusername)."'");
|
||||
}
|
||||
$authdb->Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A chance to validate form data, and last chance to
|
||||
* do stuff before it is inserted in config_plugin
|
||||
*/
|
||||
function validate_form(&$form, &$err) {
|
||||
if ($form->passtype === 'internal') {
|
||||
$this->config->changepasswordurl = '';
|
||||
set_config('changepasswordurl', '', 'auth/db');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -499,20 +585,26 @@ class auth_plugin_db {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return ($this->config->passtype === 'internal');
|
||||
return ($this->config->passtype == 'internal' or !empty($this->config->changepasswordurl));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* Returns the URL for changing the user's pw, or empty if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return string
|
||||
*/
|
||||
function change_password_url() {
|
||||
return $this->config->changepasswordurl;
|
||||
if ($this->config->passtype == 'internal') {
|
||||
// standard form
|
||||
return '';
|
||||
} else {
|
||||
// use custom url
|
||||
return $this->config->changepasswordurl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,8 +615,8 @@ class auth_plugin_db {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
include "config.html";
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include 'config.html';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,51 +625,82 @@ class auth_plugin_db {
|
||||
function process_config($config) {
|
||||
// set to defaults if undefined
|
||||
if (!isset($config->host)) {
|
||||
$config->host = "localhost";
|
||||
$config->host = 'localhost';
|
||||
}
|
||||
if (!isset($config->type)) {
|
||||
$config->type = "mysql";
|
||||
$config->type = 'mysql';
|
||||
}
|
||||
if (!isset($config->sybasequoting)) {
|
||||
$config->sybasequoting = 0;
|
||||
}
|
||||
if (!isset($config->name)) {
|
||||
$config->name = "";
|
||||
$config->name = '';
|
||||
}
|
||||
if (!isset($config->user)) {
|
||||
$config->user = "";
|
||||
$config->user = '';
|
||||
}
|
||||
if (!isset($config->pass)) {
|
||||
$config->pass = "";
|
||||
$config->pass = '';
|
||||
}
|
||||
if (!isset($config->table)) {
|
||||
$config->table = "";
|
||||
$config->table = '';
|
||||
}
|
||||
if (!isset($config->fielduser)) {
|
||||
$config->fielduser = "";
|
||||
$config->fielduser = '';
|
||||
}
|
||||
if (!isset($config->fieldpass)) {
|
||||
$config->fieldpass = "";
|
||||
$config->fieldpass = '';
|
||||
}
|
||||
if (!isset($config->passtype)) {
|
||||
$config->passtype = "plaintext";
|
||||
$config->passtype = 'plaintext';
|
||||
}
|
||||
if (!isset($config->extencoding)) {
|
||||
$config->extencoding = 'utf-8';
|
||||
}
|
||||
if (!isset($config->setupsql)) {
|
||||
$config->setupsql = '';
|
||||
}
|
||||
if (!isset($config->debugauthdb)) {
|
||||
$config->debugauthdb = 0;
|
||||
}
|
||||
if (!isset($config->removeuser)) {
|
||||
$config->removeuser = 0;
|
||||
}
|
||||
if (!isset($config->changepasswordurl)) {
|
||||
$config->changepasswordurl = '';
|
||||
}
|
||||
|
||||
$config = stripslashes_recursive($config);
|
||||
// save settings
|
||||
set_config('host', $config->host, 'auth/db');
|
||||
set_config('type', $config->type, 'auth/db');
|
||||
set_config('name', $config->name, 'auth/db');
|
||||
set_config('user', $config->user, 'auth/db');
|
||||
set_config('pass', $config->pass, 'auth/db');
|
||||
set_config('table', $config->table, 'auth/db');
|
||||
set_config('fielduser', $config->fielduser, 'auth/db');
|
||||
set_config('fieldpass', $config->fieldpass, 'auth/db');
|
||||
set_config('passtype', $config->passtype, 'auth/db');
|
||||
set_config('changepasswordurl', $config->changepasswordurl, 'auth/db');
|
||||
|
||||
set_config('host', $config->host, 'auth/db');
|
||||
set_config('type', $config->type, 'auth/db');
|
||||
set_config('sybasequoting', $config->sybasequoting, 'auth/db');
|
||||
set_config('name', $config->name, 'auth/db');
|
||||
set_config('user', $config->user, 'auth/db');
|
||||
set_config('pass', $config->pass, 'auth/db');
|
||||
set_config('table', $config->table, 'auth/db');
|
||||
set_config('fielduser', $config->fielduser, 'auth/db');
|
||||
set_config('fieldpass', $config->fieldpass, 'auth/db');
|
||||
set_config('passtype', $config->passtype, 'auth/db');
|
||||
set_config('extencoding', trim($config->extencoding), 'auth/db');
|
||||
set_config('setupsql', trim($config->setupsql),'auth/db');
|
||||
set_config('debugauthdb', $config->debugauthdb, 'auth/db');
|
||||
set_config('removeuser', $config->removeuser, 'auth/db');
|
||||
set_config('changepasswordurl', trim($config->changepasswordurl), 'auth/db');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ext_addslashes($text) {
|
||||
// using custom made function for now
|
||||
if (empty($this->config->sybasequoting)) {
|
||||
$text = str_replace('\\', '\\\\', $text);
|
||||
$text = str_replace(array('\'', '"', "\0"), array('\\\'', '\\"', '\\0'), $text);
|
||||
} else {
|
||||
$text = str_replace("'", "''", $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,39 +1,46 @@
|
||||
<?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'.
|
||||
*
|
||||
*
|
||||
* This script is meant to be called from a system cronjob to
|
||||
* sync moodle user accounts with external database.
|
||||
* It is required when using internal passwords (== passwords not defined in external database).
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* + 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!");
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
error_log("should not be called from web server!");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nomoodlecookie = true; // cookie not needed
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
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.'/lib/moodlelib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
$CFG->debug=10;
|
||||
|
||||
if (!is_enabled_auth('db')) {
|
||||
echo "Plugin not enabled!";
|
||||
die;
|
||||
}
|
||||
|
||||
$dbauth = get_auth_plugin('db');
|
||||
$dbauth->sync_users(true);
|
||||
|
||||
|
||||
+116
-39
@@ -2,91 +2,114 @@
|
||||
|
||||
// set to defaults if undefined
|
||||
if (!isset($config->host)) {
|
||||
$config->host = "localhost";
|
||||
$config->host = 'localhost';
|
||||
}
|
||||
if (!isset($config->type)) {
|
||||
$config->type = "mysql";
|
||||
$config->type = 'mysql';
|
||||
}
|
||||
if (!isset($config->sybasequoting)) {
|
||||
$config->sybasequoting = 0;
|
||||
}
|
||||
if (!isset($config->name)) {
|
||||
$config->name = "";
|
||||
$config->name = '';
|
||||
}
|
||||
if (!isset($config->user)) {
|
||||
$config->user = "";
|
||||
$config->user = '';
|
||||
}
|
||||
if (!isset($config->pass)) {
|
||||
$config->pass = "";
|
||||
$config->pass = '';
|
||||
}
|
||||
if (!isset($config->table)) {
|
||||
$config->table = "";
|
||||
$config->table = '';
|
||||
}
|
||||
if (!isset($config->fielduser)) {
|
||||
$config->fielduser = "";
|
||||
$config->fielduser = '';
|
||||
}
|
||||
if (!isset($config->fieldpass)) {
|
||||
$config->fieldpass = "";
|
||||
$config->fieldpass = '';
|
||||
}
|
||||
if (!isset($config->passtype)) {
|
||||
$config->passtype = "plaintext";
|
||||
$config->passtype = 'plaintext';
|
||||
}
|
||||
if (!isset($config->changepasswordurl)) {
|
||||
$config->changepasswordurl = '';
|
||||
}
|
||||
if (empty($config->extencoding)) {
|
||||
$config->extencoding = 'utf-8';
|
||||
}
|
||||
if (empty($config->debugauthdb)) {
|
||||
$config->debugauthdb = 0;
|
||||
}
|
||||
if (!isset($config->setupsql)) {
|
||||
$config->setupsql = '';
|
||||
}
|
||||
if (!isset($config->removeuser)) {
|
||||
$config->removeuser = 0;
|
||||
}
|
||||
|
||||
$pluginconfig = get_config('auth/db');
|
||||
$yesno = array( get_string('no'), get_string('yes') );
|
||||
|
||||
?>
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbhost_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="host"><?php print_string("auth_dbhost_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host?>" />
|
||||
<input id="host" name="host" type="text" size="30" value="<?php echo $config->host?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["host"])) {
|
||||
formerr($err["host"]);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string("auth_dbhost", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbtype_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="menutype"><?php print_string("auth_dbtype_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<?php $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mssql_n", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
|
||||
<?php $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mssql_n", "mysql", "mysqli", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
|
||||
foreach ($dbtypes as $dbtype) {
|
||||
$dboptions[$dbtype] = $dbtype;
|
||||
}
|
||||
choose_from_menu($dboptions, "type", $config->type, "");
|
||||
?>
|
||||
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_dbtype","auth") ?>
|
||||
<?php print_string("auth_dbtype","auth") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbname_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="menusybasequoting"><?php print_string("auth_dbsybasequoting", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="name" type="text" size="30" value="<?php echo $config->name?>" />
|
||||
<?php choose_from_menu($yesno, 'sybasequoting', $config->sybasequoting, ''); ?>
|
||||
</td>
|
||||
<td><?php print_string("auth_dbsybasequotinghelp", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="name"><?php print_string("auth_dbname_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input id="name" name="name" type="text" size="30" value="<?php echo $config->name?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["name"])) {
|
||||
formerr($err["name"]);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string("auth_dbname", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbuser_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="user"><?php print_string("auth_dbuser_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="user" type="text" size="30" value="<?php echo $config->user?>" />
|
||||
<input id="user" name="user" type="text" size="30" value="<?php echo $config->user?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["user"])) {
|
||||
@@ -99,9 +122,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbpass_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="pass"><?php print_string("auth_dbpass_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="pass" type="text" size="30" value="<?php echo $config->pass?>" />
|
||||
<input id="pass" name="pass" type="text" size="30" value="<?php echo $config->pass?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["pass"])) {
|
||||
@@ -116,9 +139,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbtable_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="table"><?php print_string("auth_dbtable_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="table" type="text" size="30" value="<?php echo $config->table?>" />
|
||||
<input id="table" name="table" type="text" size="30" value="<?php echo $config->table?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["table"])) {
|
||||
@@ -131,9 +154,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbfielduser_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="fielduser"><?php print_string("auth_dbfielduser_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="fielduser" type="text" size="30" value="<?php echo $config->fielduser?>" />
|
||||
<input id="fielduser" name="fielduser" type="text" size="30" value="<?php echo $config->fielduser?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["fielduser"])) {
|
||||
@@ -146,9 +169,9 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbfieldpass_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="fieldpass"><?php print_string("auth_dbfieldpass_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="fieldpass" type="text" size="30" value="<?php echo $config->fieldpass?>" />
|
||||
<input id="fieldpass" name="fieldpass" type="text" size="30" value="<?php echo $config->fieldpass?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err["fieldpass"])) {
|
||||
@@ -161,12 +184,13 @@
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("auth_dbpasstype_key", "auth") ?>: </td>
|
||||
<td align="right"><label for="menupasstype"><?php print_string("auth_dbpasstype_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
$passtype = array();
|
||||
$passtype["plaintext"] = get_string("plaintext", "auth");
|
||||
$passtype["md5"] = get_string("md5", "auth");
|
||||
$passtype["sha1"] = get_string("sha1", "auth");
|
||||
$passtype["internal"] = get_string("internal", "auth");
|
||||
choose_from_menu($passtype, "passtype", $config->passtype, "");
|
||||
|
||||
@@ -175,10 +199,41 @@
|
||||
<td><?php print_string("auth_dbpasstype", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_dbchangepasswordurl_key", "auth") ?>: </td>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="extencoding"><?php print_string("auth_dbextencoding", "auth") ?></label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<input id="extencoding" name="extencoding" type="text" value="<?php echo $config->extencoding ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['extencoding'])) {
|
||||
formerr($err['extencoding']);
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_dbextencodinghelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="setupsql"><?php print_string("auth_dbsetupsql", "auth") ?></label></td>
|
||||
<td>
|
||||
<input id="setupsql" name="setupsql" type="text" value="<?php echo $config->setupsql ?>" />
|
||||
</td>
|
||||
<td><?php print_string('auth_dbsetupsqlhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menudebugauthdb"><?php print_string("auth_dbdebugauthdb", "auth") ?></label></td>
|
||||
<td>
|
||||
<?php choose_from_menu($yesno, 'debugauthdb', $config->debugauthdb, ''); ?>
|
||||
</td>
|
||||
<td><?php print_string("auth_dbdebugauthdbhelp", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string("auth_dbchangepasswordurl_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input id="changepasswordurl" name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
@@ -189,10 +244,32 @@
|
||||
</td>
|
||||
<td><?php print_string('changepasswordhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('db', $user_fields, get_string('auth_dbextrafields', 'auth'), true, false);
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string('auth_sync_script', 'auth') ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menuremoveuser"><?php print_string('auth_remove_user_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$deleteopt = array();
|
||||
$deleteopt['0'] = get_string('auth_remove_keep','auth');
|
||||
$deleteopt['1'] = get_string('auth_remove_suspend','auth');
|
||||
$deleteopt['2'] = get_string('auth_remove_delete','auth');
|
||||
choose_from_menu($deleteopt, 'removeuser', $config->removeuser, '');
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_remove_user','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
print_auth_lock_options('db', $user_fields, get_string('auth_dbextrafields', 'auth'), true, true);
|
||||
|
||||
?>
|
||||
</table>
|
||||
|
||||
+63
-36
@@ -12,33 +12,22 @@
|
||||
* 2006-08-28 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
|
||||
/**
|
||||
* Error codes for user confirm
|
||||
*/
|
||||
define('AUTH_CONFIRM_FAIL', 0);
|
||||
define('AUTH_CONFIRM_OK', 1);
|
||||
define('AUTH_CONFIRM_ALREADY', 2);
|
||||
define('AUTH_CONFIRM_ERROR', 3);
|
||||
// TODO: instead of integers these could be the language keys?
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* Email authentication plugin.
|
||||
*/
|
||||
class auth_plugin_email {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_email extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_email() {
|
||||
$this->authtype = 'email';
|
||||
$this->config = get_config('auth/email');
|
||||
}
|
||||
|
||||
@@ -48,7 +37,7 @@ class auth_plugin_email {
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
global $CFG;
|
||||
@@ -63,8 +52,8 @@ class auth_plugin_email {
|
||||
*
|
||||
* called when the user password is updated.
|
||||
*
|
||||
* @param object $user User
|
||||
* @param string $newpassword Plaintext password
|
||||
* @param object $user User table object (with system magic quotes)
|
||||
* @param string $newpassword Plaintext password (with system magic quotes)
|
||||
* @return boolean result
|
||||
*
|
||||
*/
|
||||
@@ -73,10 +62,20 @@ class auth_plugin_email {
|
||||
return update_internal_user_password($user, $newpassword);
|
||||
}
|
||||
|
||||
/*
|
||||
function can_signup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign up a new user ready for confirmation.
|
||||
* Password is passed in plaintext.
|
||||
*
|
||||
* @param object $user new user object (with system magic quotes)
|
||||
* @param boolean $notify print notice with link and terminate
|
||||
*/
|
||||
function user_signup($user, $notify = true) {
|
||||
function user_signup($user, $notify=true) {
|
||||
$user->password = hash_internal_user_password($user->password);
|
||||
|
||||
if (! ($user->id = insert_record('user', $user)) ) {
|
||||
print_error('auth_emailnoinsert','auth');
|
||||
}
|
||||
@@ -89,11 +88,25 @@ class auth_plugin_email {
|
||||
$emailconfirm = get_string('emailconfirm');
|
||||
print_header($emailconfirm, $emailconfirm, $emailconfirm);
|
||||
notice(get_string('emailconfirmsent', '', $user->email), "$CFG->wwwroot/index.php");
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true if plugin allows confirming of new users.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function can_confirm() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the new user as registered.
|
||||
*
|
||||
* @param string $username (with system magic quotes)
|
||||
* @param string $confirmsecret (with system magic quotes)
|
||||
*/
|
||||
function user_confirm($username, $confirmsecret) {
|
||||
$user = get_complete_user_data('username', $username);
|
||||
@@ -101,8 +114,11 @@ class auth_plugin_email {
|
||||
if (!empty($user)) {
|
||||
if ($user->confirmed) {
|
||||
return AUTH_CONFIRM_ALREADY;
|
||||
}
|
||||
if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
|
||||
|
||||
} else if ($user->auth != 'email') {
|
||||
return AUTH_CONFIRM_ERROR;
|
||||
|
||||
} else if ($user->secret == stripslashes($confirmsecret)) { // They have provided the secret key to get in
|
||||
if (!set_field("user", "confirmed", 1, "id", $user->id)) {
|
||||
return AUTH_CONFIRM_FAIL;
|
||||
}
|
||||
@@ -111,38 +127,49 @@ class auth_plugin_email {
|
||||
}
|
||||
return AUTH_CONFIRM_OK;
|
||||
}
|
||||
} else {
|
||||
return AUTH_CONFIRM_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* Returns the URL for changing the user's pw, or empty if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return mixed
|
||||
*/
|
||||
function change_password_url() {
|
||||
return false;
|
||||
return ''; // use dafult internal method
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if plugin allows resetting of internal password.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function can_reset_password() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -151,7 +178,7 @@ class auth_plugin_email {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
@@ -161,7 +188,7 @@ class auth_plugin_email {
|
||||
function process_config($config) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
<div align="center"><?php print_string('none'); ?></div>
|
||||
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('email', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
Moodle - FirstClass authentication module
|
||||
-----------------------------------------
|
||||
This module uses the FirstClass Flexible Provisining Protocol (FPP) to communicate between the FirstClass server
|
||||
and the Moodle host.
|
||||
and the Moodle host.
|
||||
|
||||
Installation
|
||||
------------
|
||||
@@ -9,7 +9,7 @@ Installation
|
||||
1. Enable FPP on the FirstClass server
|
||||
FPP is not doumented in the FirstClass documentation and is not enable by default.
|
||||
To enable the protocol you need to edit the file \FCPO\Server\Netinfo. Open the file and insert the
|
||||
following lines.
|
||||
following lines.
|
||||
|
||||
// TCP port for Flexible Provisioning Protocol (FPP).
|
||||
TCPFPPPORT = 3333
|
||||
@@ -23,7 +23,7 @@ Default account name is "fcMoodle".
|
||||
|
||||
|
||||
3. Check that the FPP protocoll is working by running a Telnet session. If everyting is working you
|
||||
should get a "+0" answer from the server.
|
||||
should get a "+0" answer from the server.
|
||||
|
||||
> telnet yourhost.domain.com 3333
|
||||
+0
|
||||
@@ -47,7 +47,7 @@ Get user some_user_id 1201
|
||||
|
||||
4. On the Moodle host go to the directory where you have installed Moodle.
|
||||
Open the folder "auth", where all other authentication modules are installed,
|
||||
and create a new directory with the name "fc".
|
||||
and create a new directory with the name "fc".
|
||||
|
||||
Copy the files "config.html", "fcFPP.php" and "lib.php" to the "auth" directory.
|
||||
|
||||
|
||||
+53
-33
@@ -11,25 +11,24 @@
|
||||
* 2006-08-28 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once 'fcFPP.php';
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
require_once 'fcFPP.php';
|
||||
|
||||
/**
|
||||
* FirstClass authentication plugin.
|
||||
*/
|
||||
class auth_plugin_fc {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_fc extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_fc() {
|
||||
$this->authtype = 'fc';
|
||||
$this->config = get_config('auth/fc');
|
||||
}
|
||||
|
||||
@@ -39,7 +38,7 @@ class auth_plugin_fc {
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
global $CFG;
|
||||
@@ -57,7 +56,7 @@ class auth_plugin_fc {
|
||||
}
|
||||
}
|
||||
$fpp->close();
|
||||
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@@ -82,13 +81,13 @@ class auth_plugin_fc {
|
||||
country -
|
||||
lang -
|
||||
timezone 8030 (Not used yet. Need to figure out how FC codes timezones)
|
||||
|
||||
|
||||
description Get data from users resume. Pictures will be removed.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
$userinfo = array();
|
||||
|
||||
|
||||
$fpp = new fcFPP($this->config->host, $this->config->port);
|
||||
if ($fpp->open()) {
|
||||
if ($fpp->login($this->config->userid, $this->config->passwd)) {
|
||||
@@ -101,7 +100,7 @@ class auth_plugin_fc {
|
||||
}
|
||||
}
|
||||
$fpp->close();
|
||||
|
||||
|
||||
foreach($userinfo as $key => $value) {
|
||||
if (!$value) {
|
||||
unset($userinfo[$key]);
|
||||
@@ -110,23 +109,18 @@ class auth_plugin_fc {
|
||||
|
||||
return $userinfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get users group membership from the FirstClass server user and check if
|
||||
* user is member of one of the groups of creators.
|
||||
*/
|
||||
function iscreator($username = 0) {
|
||||
global $USER;
|
||||
|
||||
function iscreator($username) {
|
||||
if (! $this->config->creators) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
if (! $username) {
|
||||
$username = $USER->username;
|
||||
}
|
||||
|
||||
|
||||
$fcgroups = array();
|
||||
|
||||
|
||||
$fpp = new fcFPP($this->config->host, $this->config->port);
|
||||
if ($fpp->open()) {
|
||||
if ($fpp->login($this->config->userid, $this->config->passwd)) {
|
||||
@@ -134,24 +128,26 @@ class auth_plugin_fc {
|
||||
}
|
||||
}
|
||||
$fpp->close();
|
||||
|
||||
|
||||
if ((! $fcgroups)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$creators = explode(";", $this->config->creators);
|
||||
|
||||
|
||||
foreach($creators as $creator) {
|
||||
If (in_array($creator, $fcgroups)) return true;
|
||||
if (in_array($creator, $fcgroups)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -161,12 +157,36 @@ class auth_plugin_fc {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync roles for this user
|
||||
*
|
||||
* @param $user object user object (without system magic quotes)
|
||||
*/
|
||||
function sync_roles($user) {
|
||||
$iscreator = $this->iscreator($user->username);
|
||||
if ($iscreator === null) {
|
||||
return; //nothing to sync - creators not configured
|
||||
}
|
||||
|
||||
if ($roles = get_roles_with_capability('moodle/legacy:coursecreator', CAP_ALLOW)) {
|
||||
$creatorrole = array_shift($roles); // We can only use one, let's use the first one
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
if ($iscreator) { // Following calls will not create duplicates
|
||||
role_assign($creatorrole->id, $user->id, 0, $systemcontext->id, 0, 0, 0, 'fc');
|
||||
} else {
|
||||
//unassign only if previously assigned by this plugin!
|
||||
role_unassign($creatorrole->id, $user->id, 0, $systemcontext->id, 'fc');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -175,7 +195,7 @@ class auth_plugin_fc {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -15,10 +15,10 @@
|
||||
}
|
||||
if (!isset($config->creators)) {
|
||||
$config->creators = "";
|
||||
}
|
||||
}
|
||||
if (!isset($config->changepasswordurl)) {
|
||||
$config->changepasswordurl = '';
|
||||
}
|
||||
}
|
||||
if (!isset($config->changepasswordurl)) {
|
||||
$config->changepasswordurl = '';
|
||||
}
|
||||
@@ -95,9 +95,8 @@
|
||||
<td><?php print_string('changepasswordhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('fc', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+35
-35
@@ -22,21 +22,21 @@
|
||||
*/
|
||||
|
||||
class fcFPP
|
||||
{
|
||||
{
|
||||
var $_hostname; // hostname of FirstClass server we are connection to
|
||||
var $_port; // port on which fpp is running
|
||||
var $_conn = 0; // socket we are connecting on
|
||||
var $_debug = FALSE; // set to true to see some debug info
|
||||
|
||||
|
||||
// class constructor
|
||||
function fcFPP($host="localhost", $port="3333")
|
||||
{
|
||||
$this->_hostname = $host;
|
||||
$this->_port = $port;
|
||||
$this->_user = "";
|
||||
$this->_pwd = "";
|
||||
$this->_pwd = "";
|
||||
}
|
||||
|
||||
|
||||
// open a connection to the FirstClass server
|
||||
function open()
|
||||
{
|
||||
@@ -53,10 +53,10 @@ class fcFPP
|
||||
print_error('auth_fcconnfail','auth', array($errno, $errstr));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// We are connected
|
||||
if ($this->_debug) echo "connected!";
|
||||
|
||||
|
||||
// Read connection message.
|
||||
$line = fgets ($conn); //+0
|
||||
$line = fgets ($conn); //new line
|
||||
@@ -69,7 +69,7 @@ class fcFPP
|
||||
|
||||
// close any open connections
|
||||
function close()
|
||||
{
|
||||
{
|
||||
// get the current connection
|
||||
$conn = &$this->_conn;
|
||||
|
||||
@@ -84,8 +84,8 @@ class fcFPP
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Authenticate to the FirstClass server
|
||||
function login($userid, $passwd)
|
||||
{
|
||||
@@ -98,37 +98,37 @@ class fcFPP
|
||||
$line = fgets ($this->_conn); //new line
|
||||
$line = fgets ($this->_conn); //+0
|
||||
$line = fgets ($this->_conn); //new line
|
||||
|
||||
|
||||
# Send password
|
||||
fputs($this->_conn,"$passwd\r\n");
|
||||
$line = fgets ($this->_conn); //new line
|
||||
$line = fgets ($this->_conn); //+0
|
||||
$line = fgets ($this->_conn); //+0 or message
|
||||
|
||||
|
||||
if ($this->_debug) echo $line;
|
||||
|
||||
|
||||
if (preg_match ("/^\+0/", $line)) { //+0, user with subadmin privileges
|
||||
$this->_user = $userid;
|
||||
$this->_pwd = $passwd;
|
||||
return TRUE;
|
||||
$this->_pwd = $passwd;
|
||||
return TRUE;
|
||||
} elseif (strpos($line, 'You are not allowed')) { // Denied access but a valid user and password
|
||||
// "Sorry. You are not allowed to login with the FPP interface"
|
||||
return TRUE;
|
||||
} else { //Invalid user or password
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get the list of groups the user is a member of
|
||||
// Get the list of groups the user is a member of
|
||||
function getGroups($userid) {
|
||||
|
||||
|
||||
$groups = array();
|
||||
|
||||
// we must be logged in as a user with subadmin privileges
|
||||
|
||||
// we must be logged in as a user with subadmin privileges
|
||||
if ($this->_conn AND $this->_user) {
|
||||
# Send BA-command to get groups
|
||||
fputs($this->_conn,"GET USER '" . $userid . "' 4 -1\r");
|
||||
@@ -143,29 +143,29 @@ class fcFPP
|
||||
}
|
||||
if ($this->_debug) echo "getGroups:" . implode(",",$groups);
|
||||
}
|
||||
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
// Check if the user is member of any of the groups.
|
||||
// Return the list of groups the user is member of.
|
||||
function isMemberOf($userid, $groups) {
|
||||
|
||||
|
||||
$usergroups = array_map("strtolower",$this->getGroups($userid));
|
||||
$groups = array_map("strtolower",$groups);
|
||||
|
||||
|
||||
$result = array_intersect($groups,$usergroups);
|
||||
|
||||
|
||||
if ($this->_debug) echo "isMemberOf:" . implode(",",$result);
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getUserInfo($userid, $field) {
|
||||
|
||||
|
||||
$userinfo = "";
|
||||
|
||||
|
||||
if ($this->_conn AND $this->_user) {
|
||||
# Send BA-command to get data
|
||||
fputs($this->_conn,"GET USER '" . $userid . "' " . $field . "\r");
|
||||
@@ -180,17 +180,17 @@ class fcFPP
|
||||
}
|
||||
if ($this->_debug) echo "getUserInfo:" . $userinfo;
|
||||
}
|
||||
|
||||
|
||||
return str_replace('\r',' ',trim($userinfo,'"'));
|
||||
|
||||
}
|
||||
|
||||
function getResume($userid) {
|
||||
|
||||
|
||||
$resume = "";
|
||||
|
||||
$pattern = "/\[.+:.+\..+\]/"; // Remove references to pictures in resumes
|
||||
|
||||
|
||||
if ($this->_conn AND $this->_user) {
|
||||
# Send BA-command to get data
|
||||
fputs($this->_conn,"GET RESUME '" . $userid . "' 6\r");
|
||||
@@ -203,17 +203,17 @@ class fcFPP
|
||||
$resume .= preg_replace($pattern,"",str_replace('\r',"\n",trim($line,'6 ')));
|
||||
$line = trim(fgets ($this->_conn));
|
||||
//print $line;
|
||||
|
||||
|
||||
}
|
||||
if ($this->_debug) echo "getResume:" . $resume;
|
||||
}
|
||||
|
||||
|
||||
return $resume;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+25
-27
@@ -12,23 +12,22 @@
|
||||
* 2006-08-31 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* IMAP authentication plugin.
|
||||
*/
|
||||
class auth_plugin_imap {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_imap extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_imap() {
|
||||
$this->authtype = 'imap';
|
||||
$this->config = get_config('auth/imap');
|
||||
}
|
||||
|
||||
@@ -36,16 +35,16 @@ class auth_plugin_imap {
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
if (! function_exists('imap_open')) {
|
||||
print_error('auth_imapnotinstalled','mnet');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
global $CFG;
|
||||
$hosts = split(';', $this->config->host); // Could be multiple hosts
|
||||
|
||||
@@ -56,22 +55,22 @@ class auth_plugin_imap {
|
||||
case 'imapssl':
|
||||
$host = '{'.$host.":{$this->config->port}/imap/ssl}";
|
||||
break;
|
||||
|
||||
|
||||
case 'imapcert':
|
||||
$host = '{'.$host.":{$this->config->port}/imap/ssl/novalidate-cert}";
|
||||
break;
|
||||
|
||||
|
||||
case 'imaptls':
|
||||
$host = '{'.$host.":{$this->config->port}/imap/tls}";
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$host = '{'.$host.":{$this->config->port}/imap}";
|
||||
}
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
||||
error_reporting($CFG->debug);
|
||||
$connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
imap_close($connection);
|
||||
@@ -85,7 +84,7 @@ class auth_plugin_imap {
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -95,23 +94,22 @@ class auth_plugin_imap {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
return !empty($this->config->changepasswordurl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* Returns the URL for changing the user's pw, or empty if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return string
|
||||
*/
|
||||
function change_password_url() {
|
||||
return $CFG->changepasswordurl; // TODO: will this be global?
|
||||
//return $this->config->changepasswordurl;
|
||||
return $this->config->changepasswordurl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -120,7 +118,7 @@ class auth_plugin_imap {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,8 @@ if (!isset($config->changepasswordurl)) {
|
||||
<td><?php print_string('changepasswordhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('imap', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
LDAP-module README
|
||||
|
||||
Please read comments from lib.php
|
||||
Please read comments from lib.php
|
||||
|
||||
+703
-671
File diff suppressed because it is too large
Load Diff
@@ -1,40 +1,45 @@
|
||||
<?php
|
||||
/** auth_ldap_sync_users.php
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* backend in those setups where the LDAP backend acts as 'master'.
|
||||
*
|
||||
*
|
||||
* Recommended cron entry:
|
||||
* # 5 minutes past 4am
|
||||
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* Notes:
|
||||
* - If you have a large number of users, you may want to raise the memory limits
|
||||
* by passing -d momory_limit=256M
|
||||
* - For debugging & better logging, you are encouraged to use in the command line:
|
||||
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
|
||||
*
|
||||
*
|
||||
* Performance notes:
|
||||
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if (!empty($_SERVER['GATEWAY_INTERFACE'])) {
|
||||
error_log("should not be called from apache!");
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
error_log("should not be called from web server!");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nomoodlecookie = true; // cookie not needed
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
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.'/mod/forum/lib.php');
|
||||
$CFG->debug=10;
|
||||
|
||||
require_once($CFG->dirroot.'/lib/moodlelib.php');
|
||||
if (!is_enabled_auth('ldap')) {
|
||||
echo "Plugin not enabled!";
|
||||
die;
|
||||
}
|
||||
|
||||
$ldapauth = get_auth_plugin('ldap');
|
||||
$ldapauth->sync_users(1000, true);
|
||||
|
||||
|
||||
+176
-143
@@ -1,62 +1,67 @@
|
||||
<?php
|
||||
|
||||
$createoptions[0] = get_string("no");
|
||||
$createoptions[1] = get_string("yes");
|
||||
|
||||
// set to defaults if undefined
|
||||
if (!isset($config->host_url))
|
||||
if (!isset($config->host_url))
|
||||
{ $config->host_url = ''; }
|
||||
if (!isset($config->contexts))
|
||||
if (empty($config->ldapencoding))
|
||||
{ $config->ldapencoding = 'utf-8'; }
|
||||
if (!isset($config->contexts))
|
||||
{ $config->contexts = ''; }
|
||||
if (!isset($config->user_type))
|
||||
{ $config->user_type = ''; }
|
||||
if (!isset($config->user_attribute))
|
||||
if (!isset($config->user_type))
|
||||
{ $config->user_type = 'default'; }
|
||||
if (!isset($config->user_attribute))
|
||||
{ $config->user_attribute = ''; }
|
||||
if (!isset($config->search_sub))
|
||||
if (!isset($config->search_sub))
|
||||
{ $config->search_sub = ''; }
|
||||
if (!isset($config->opt_deref))
|
||||
{ $config->opt_deref = ''; }
|
||||
if (!isset($config->preventpassindb))
|
||||
{ $config->preventpassindb = 0; }
|
||||
if (!isset($config->bind_dn))
|
||||
if (!isset($config->opt_deref))
|
||||
{ $config->opt_deref = LDAP_DEREF_NEVER; }
|
||||
if (!isset($config->preventpassindb))
|
||||
{ $config->preventpassindb = 0; }
|
||||
if (!isset($config->bind_dn))
|
||||
{$config->bind_dn = ''; }
|
||||
if (!isset($config->bind_pw))
|
||||
if (!isset($config->bind_pw))
|
||||
{$config->bind_pw = ''; }
|
||||
if (!isset($config->version))
|
||||
if (!isset($config->version))
|
||||
{$config->version = '2'; }
|
||||
if (!isset($config->objectclass))
|
||||
if (!isset($config->objectclass))
|
||||
{$config->objectclass = ''; }
|
||||
if (!isset($config->memberattribute))
|
||||
if (!isset($config->memberattribute))
|
||||
{$config->memberattribute = ''; }
|
||||
if (!isset($config->creators))
|
||||
if (!isset($config->memberattribute_isdn))
|
||||
{$config->memberattribute_isdn = ''; }
|
||||
if (!isset($config->creators))
|
||||
{$config->creators = ''; }
|
||||
if (!isset($config->create_context))
|
||||
if (!isset($config->create_context))
|
||||
{$config->create_context = ''; }
|
||||
if (!isset($config->expiration))
|
||||
if (!isset($config->expiration))
|
||||
{$config->expiration = ''; }
|
||||
if (!isset($config->expiration_warning))
|
||||
if (!isset($config->expiration_warning))
|
||||
{$config->expiration_warning = '10'; }
|
||||
if (!isset($config->expireattr))
|
||||
if (!isset($config->expireattr))
|
||||
{$config->expireattr = ''; }
|
||||
if (!isset($config->gracelogins))
|
||||
if (!isset($config->gracelogins))
|
||||
{$config->gracelogins = ''; }
|
||||
if (!isset($config->graceattr))
|
||||
if (!isset($config->graceattr))
|
||||
{$config->graceattr = ''; }
|
||||
if (!isset($config->auth_user_create))
|
||||
if (!isset($config->auth_user_create))
|
||||
{$config->auth_user_create = ''; }
|
||||
if (!isset($config->forcechangepassword))
|
||||
{$config->forcechangepassword = false; }
|
||||
if (!isset($config->forcechangepassword))
|
||||
{$config->forcechangepassword = 0; }
|
||||
if (!isset($config->stdchangepassword))
|
||||
{$config->stdchangepassword = false; }
|
||||
{$config->stdchangepassword = 0; }
|
||||
if (!isset($config->passtype))
|
||||
{$config->passtype = 'plaintext';}
|
||||
if (!isset($config->changepasswordurl))
|
||||
{$config->changepasswordurl = ''; }
|
||||
if (!isset($config->removeuser))
|
||||
{$config->removeuser = 0; }
|
||||
|
||||
$yesno = array( get_string('no'), get_string('yes') );
|
||||
|
||||
|
||||
if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
notify(get_string('auth_ldap_noextension','auth'));
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
|
||||
@@ -67,31 +72,47 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_host_url_key','auth') ?>:</td>
|
||||
<td align="right"><label for="host_url"><?php print_string('auth_ldap_host_url_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="host_url" type="text" size="30" value="<?php echo $config->host_url?>" />
|
||||
<input name="host_url" id="host_url" type="text" size="30" value="<?php echo $config->host_url?>" />
|
||||
<?php if (isset($err['host_url'])) formerr($err['host_url']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_host_url','auth') ?>
|
||||
<?php print_string('auth_ldap_host_url','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_version_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menuversion"><?php print_string('auth_ldap_version_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$varsions = array();
|
||||
$versions[2] = '2';
|
||||
$versions[3] = '3';
|
||||
choose_from_menu($versions, 'version', $config->version, '');
|
||||
if (isset($err['version'])) formerr($err['version']);
|
||||
if (isset($err['version'])) formerr($err['version']);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_version','auth') ?>
|
||||
<?php print_string('auth_ldap_version','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="ldapencoding"><?php print_string("auth_ldap_ldap_encoding_key", "auth") ?></label></td>
|
||||
<td>
|
||||
<input id="ldapencoding" name="ldapencoding" type="text" value="<?php echo $config->ldapencoding ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['ldapencoding'])) {
|
||||
formerr($err['ldapencoding']);
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_ldap_ldap_encoding', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string('auth_ldap_bind_settings', 'auth') ?> </h4>
|
||||
@@ -99,36 +120,31 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_preventpassindb_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menupreventpassindb"><?php print_string('auth_ldap_preventpassindb_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$choices = array();
|
||||
$choices['0'] = get_string('no');
|
||||
$choices['1'] = get_string('yes');
|
||||
choose_from_menu ($choices, 'preventpassindb', $config->preventpassindb, '');
|
||||
?>
|
||||
<?php choose_from_menu($yesno, 'preventpassindb', $config->preventpassindb, ''); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_preventpassindb','auth') ?>
|
||||
<?php print_string('auth_ldap_preventpassindb','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_bind_dn_key','auth') ?>:</td>
|
||||
<td align="right"><label for="bind_dn"><?php print_string('auth_ldap_bind_dn_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="bind_dn" type="text" size="30" value="<?php echo $config->bind_dn?>" />
|
||||
<input name="bind_dn" id="bind_dn" type="text" size="30" value="<?php echo $config->bind_dn?>" />
|
||||
<?php if (isset($err['bind_dn'])) formerr($err['bind_dn']); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_bind_dn','auth') ?>
|
||||
<?php print_string('auth_ldap_bind_dn','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_bind_pw_key','auth') ?>:</td>
|
||||
<td align="right"><label for="bind_pw"><?php print_string('auth_ldap_bind_pw_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="bind_pw" type="password" size="30" value="<?php echo $config->bind_pw?>" />
|
||||
<input name="bind_pw" id="bind_pw" type="password" size="30" value="<?php echo $config->bind_pw?>" />
|
||||
<?php if (isset($err['bind_pw'])) formerr($err['bind_pw']); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_bind_pw','auth') ?>
|
||||
<?php print_string('auth_ldap_bind_pw','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -139,88 +155,94 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_user_type_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menuuser_type"><?php print_string('auth_ldap_user_type_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php choose_from_menu($this->ldap_suppported_usertypes(), 'user_type', $config->user_type, ''); ?>
|
||||
<?php if (isset($err['user_type'])) formerr($err['user_type']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_user_type', 'auth') ?>
|
||||
<?php print_string('auth_ldap_user_type', 'auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_contexts_key','auth') ?>:</td>
|
||||
<td align="right"><label for="contexts"><?php print_string('auth_ldap_contexts_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="contexts" type="text" size="30" value="<?php echo $config->contexts?>" />
|
||||
<input name="contexts" id="contexts" type="text" size="30" value="<?php echo $config->contexts?>" />
|
||||
<?php if (isset($err['contexts'])) formerr($err['contexts']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_contexts', 'auth') ?>
|
||||
<?php print_string('auth_ldap_contexts', 'auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_search_sub_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menusearch_sub"><?php print_string('auth_ldap_search_sub_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$choices = array();
|
||||
$choices['0'] = get_string('no');
|
||||
$choices['1'] = get_string('yes');
|
||||
choose_from_menu ($choices, 'search_sub', $config->search_sub, '');
|
||||
?>
|
||||
<?php if (isset($err['search_sub'])) formerr($err['search_sub']); ?>
|
||||
<?php choose_from_menu($yesno, 'search_sub', $config->search_sub, ''); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_search_sub','auth') ?>
|
||||
<?php print_string('auth_ldap_search_sub','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_opt_deref_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menuopt_deref"><?php print_string('auth_ldap_opt_deref_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$opt_deref = array();
|
||||
$opt_deref[LDAP_DEREF_NEVER] = get_string('no');
|
||||
$opt_deref[LDAP_DEREF_ALWAYS] = get_string('yes');
|
||||
choose_from_menu($opt_deref, 'opt_deref', $config->opt_deref, LDAP_DEREF_NEVER);
|
||||
if (isset($err['opt_deref'])) formerr($err['opt_deref']);
|
||||
choose_from_menu($opt_deref, 'opt_deref', $config->opt_deref, LDAP_DEREF_NEVER, '');
|
||||
if (isset($err['opt_deref'])) formerr($err['opt_deref']);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_opt_deref','auth') ?>
|
||||
<?php print_string('auth_ldap_opt_deref','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_user_attribute_key','auth') ?>:</td>
|
||||
<td align="right"><label for="user_attribute"><?php print_string('auth_ldap_user_attribute_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute?>" />
|
||||
<input name="user_attribute" id="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute?>" />
|
||||
<?php if (isset($err['user_attribute'])) formerr($err['user_attribute']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_user_attribute','auth') ?>
|
||||
<?php print_string('auth_ldap_user_attribute','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_memberattribute_key','auth') ?>:</td>
|
||||
<td align="right"><label for="memberattribute"><?php print_string('auth_ldap_memberattribute_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="memberattribute" type="text" size="30" value="<?php echo $config->memberattribute?>" />
|
||||
<input name="memberattribute" id="memberattribute" type="text" size="30" value="<?php echo $config->memberattribute?>" />
|
||||
<?php if (isset($err['memberattribute'])) formerr($err['memberattribute']); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_memberattribute','auth') ?>
|
||||
<?php print_string('auth_ldap_memberattribute','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_objectclass_key','auth') ?>:</td>
|
||||
<td align="right"><label for="memberattribute_isdn"><?php print_string('auth_ldap_memberattribute_isdn_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="memberattribute" id="memberattribute_isdn" type="text" size="30" value="<?php echo $config->memberattribute_isdn?>" />
|
||||
<?php if (isset($err['memberattribute_isdn'])) formerr($err['memberattribute_isdn']); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_memberattribute_isdn','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="objectclass"><?php print_string('auth_ldap_objectclass_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="objectclass" type="text" size="30" value="<?php echo $config->objectclass?>" />
|
||||
<input name="objectclass" id="objectclass" type="text" size="30" value="<?php echo $config->objectclass?>" />
|
||||
<?php if (isset($err['objectclass'])) formerr($err['objectclass']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_objectclass','auth') ?>
|
||||
<?php print_string('auth_ldap_objectclass','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -231,44 +253,45 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right" valign="top"><?php print_string('forcechangepassword', 'auth') ?>:</td>
|
||||
<td align="right" valign="top"><label for="menuforcechangepassword"><?php print_string('forcechangepassword', 'auth') ?></label></td>
|
||||
<td>
|
||||
|
||||
<select name="forcechangepassword">
|
||||
<option value="0" <?php echo ($config->forcechangepassword ? '' : 'selected="yes"') ?> >
|
||||
<?php print_string('no') ?></option>
|
||||
<option value="1" <?php echo ($config->forcechangepassword ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string('yes') ?></option>
|
||||
</select><br />
|
||||
|
||||
<?php choose_from_menu($yesno, 'forcechangepassword', $config->forcechangepassword, ''); ?>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<p><?php print_string('forcechangepasswordfirst_help', 'auth') ?></p>
|
||||
<p><?php print_string('forcechangepasswordfirst_help', 'auth') ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right" valign="top"><?php print_string('stdchangepassword', 'auth') ?>:</td>
|
||||
<td align="right" valign="top"><label for="menustdchangepassword"><?php print_string('stdchangepassword', 'auth') ?></label></td>
|
||||
<td>
|
||||
|
||||
<select name="stdchangepassword">
|
||||
<option value='0' <?php echo ($config->stdchangepassword ? '' : 'selected="yes"') ?> >
|
||||
<?php print_string('no') ?></option>
|
||||
<option value='1' <?php echo ($config->stdchangepassword ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string('yes') ?></option>
|
||||
</select><br />
|
||||
|
||||
<?php choose_from_menu($yesno, 'stdchangepassword', $config->stdchangepassword, ''); ?>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<p><?php print_string('stdchangepassword_expl', 'auth') ?></p>
|
||||
<p><?php print_string('stdchangepassword_explldap', 'auth') ?></p>
|
||||
<p><?php print_string('stdchangepassword_expl', 'auth') ?></p>
|
||||
<p><?php print_string('stdchangepassword_explldap', 'auth') ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_ldap_changepasswordurl_key','auth') ?>: </td>
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="menupasstype"><?php print_string('auth_ldap_passtype_key', 'auth') ?></label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
$passtype = array();
|
||||
$passtype['plaintext'] = get_string('plaintext', 'auth');
|
||||
$passtype['md5'] = get_string('md5', 'auth');
|
||||
$passtype['sha1'] = get_string('sha1', 'auth');
|
||||
choose_from_menu($passtype, 'passtype', $config->passtype, '');
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_ldap_passtype', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="changepasswordurl"><?php print_string('auth_ldap_changepasswordurl_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
|
||||
<?php
|
||||
|
||||
if (isset($err['changepasswordurl'])) {
|
||||
@@ -287,69 +310,65 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_expiration_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menuexpiration"><?php print_string('auth_ldap_expiration_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$expiration = array();
|
||||
$expiration['0'] = 'no';
|
||||
$expiration['1'] = 'LDAP';
|
||||
choose_from_menu($expiration, 'expiration', $config->expiration, '');
|
||||
if (isset($err['expiration'])) formerr($err['expiration']);
|
||||
if (isset($err['expiration'])) formerr($err['expiration']);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_expiration_desc','auth') ?>
|
||||
<?php print_string('auth_ldap_expiration_desc','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_expiration_warning_key','auth') ?>:</td>
|
||||
<td align="right"><label for="expiration_warning"><?php print_string('auth_ldap_expiration_warning_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="expiration_warning" type="text" size="2" value="<?php echo $config->expiration_warning?>" />
|
||||
<?php if (isset($err['expiration_warning'])) formerr($err['expiration_warning']);
|
||||
<input name="expiration_warning" id="expiration_warning" type="text" size="2" value="<?php echo $config->expiration_warning?>" />
|
||||
<?php if (isset($err['expiration_warning'])) formerr($err['expiration_warning']);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_expiration_warning_desc','auth') ?>
|
||||
<?php print_string('auth_ldap_expiration_warning_desc','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_expireattr_key','auth') ?>:</td>
|
||||
<td align="right"><label for="expireattr"><?php print_string('auth_ldap_expireattr_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="expireattr" type="text" size="30" value="<?php echo $config->expireattr?>" />
|
||||
<?php if (isset($err['expireattr'])) formerr($err['expireattr']);
|
||||
<input name="expireattr" id="expireattr" type="text" size="30" value="<?php echo $config->expireattr?>" />
|
||||
<?php if (isset($err['expireattr'])) formerr($err['expireattr']);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_expireattr_desc','auth') ?>
|
||||
<?php print_string('auth_ldap_expireattr_desc','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_gracelogins_key','auth') ?>:</td>
|
||||
<td align="right"><label for="menugracelogins"><?php print_string('auth_ldap_gracelogins_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$grace['0'] = get_string('no');
|
||||
$grace['1'] = get_string('yes');
|
||||
choose_from_menu($grace, 'gracelogins', $config->gracelogins, '');
|
||||
if (isset($err['expiration'])) formerr($err['expiration']);
|
||||
?>
|
||||
<?php choose_from_menu($yesno, 'gracelogins', $config->gracelogins, ''); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_gracelogins_desc','auth') ?>
|
||||
<?php print_string('auth_ldap_gracelogins_desc','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_gracelogin_key','auth') ?>:</td>
|
||||
<td align="right"><label for="graceattr"><?php print_string('auth_ldap_gracelogin_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="graceattr" type="text" size="30" value="<?php echo $config->graceattr?>" />
|
||||
<?php if (isset($err['graceattr'])) formerr($err['graceattr']);
|
||||
<input name="graceattr" id="graceattr" type="text" size="30" value="<?php echo $config->graceattr?>" />
|
||||
<?php if (isset($err['graceattr'])) formerr($err['graceattr']);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_ldap_graceattr_desc','auth') ?>
|
||||
<?php print_string('auth_ldap_graceattr_desc','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -362,16 +381,9 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_ldap_auth_user_create_key','auth') ?>: </td>
|
||||
<td align="right"><label for="menuauth_user_create"><?php print_string('auth_ldap_auth_user_create_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
choose_from_menu($createoptions, 'auth_user_create', $config->auth_user_create, '');
|
||||
if (isset($err['auth_user_create'])) {
|
||||
formerr($err['auth_user_create']);
|
||||
}
|
||||
|
||||
?>
|
||||
<?php choose_from_menu($yesno, 'auth_user_create', $config->auth_user_create, ''); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("auth_user_creation","auth"); ?>
|
||||
@@ -379,12 +391,12 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_create_context_key','auth') ?>:</td>
|
||||
<td align="right"><label for="create_context"><?php print_string('auth_ldap_create_context_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="create_context" type="text" size="30" value="<?php echo $config->create_context?>" />
|
||||
<input name="create_context" id="create_context" type="text" size="30" value="<?php echo $config->create_context?>" />
|
||||
<?php if (isset($err['create_context'])) formerr($err['create_context']); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_create_context','auth') ?>
|
||||
<?php print_string('auth_ldap_create_context','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -396,16 +408,38 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
|
||||
</tr>
|
||||
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string('auth_ldap_creators_key','auth') ?>:</td>
|
||||
<td align="right"><label for="creators"><?php print_string('auth_ldap_creators_key','auth') ?></label></td>
|
||||
<td>
|
||||
<input name="creators" type="text" size="30" value="<?php echo $config->creators?>" />
|
||||
<input name="creators" id="creators" type="text" size="30" value="<?php echo $config->creators?>" />
|
||||
<?php if (isset($err['creators'])) formerr($err['creators']); ?>
|
||||
</td><td>
|
||||
<?php print_string('auth_ldap_creators','auth') ?>
|
||||
<?php print_string('auth_ldap_creators','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<h4><?php print_string('auth_sync_script', 'auth') ?> </h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menuremoveuser"><?php print_string('auth_remove_user_key','auth') ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
$deleteopt = array();
|
||||
$deleteopt['0'] = get_string('auth_remove_keep','auth');
|
||||
$deleteopt['1'] = get_string('auth_remove_suspend','auth');
|
||||
$deleteopt['2'] = get_string('auth_remove_delete','auth');
|
||||
choose_from_menu($deleteopt, 'removeuser', $config->removeuser, '');
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_remove_user','auth') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$help = get_string('auth_ldapextrafields','auth');
|
||||
$help .= get_string('auth_updatelocal_expl','auth');
|
||||
@@ -414,8 +448,7 @@ $help .= get_string('auth_updateremote_expl','auth');
|
||||
$help .= '<hr />';
|
||||
$help .= get_string('auth_updateremote_ldap','auth');
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('ldap', $user_fields, $help, true, true);
|
||||
print_auth_lock_options('ldap', $user_fields, $help, true, true);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
+33
-27
@@ -11,26 +11,22 @@
|
||||
* 2006-08-28 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* Manual authentication plugin.
|
||||
*/
|
||||
class auth_plugin_manual
|
||||
{
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
|
||||
var $canchangepassword = true;
|
||||
var $isinternal = true;
|
||||
class auth_plugin_manual extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_manual() {
|
||||
$this->authtype = 'manual';
|
||||
$this->config = get_config('auth/manual');
|
||||
}
|
||||
|
||||
@@ -38,9 +34,10 @@ class auth_plugin_manual
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
*
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
global $CFG;
|
||||
@@ -55,8 +52,8 @@ class auth_plugin_manual
|
||||
*
|
||||
* called when the user password is updated.
|
||||
*
|
||||
* @param object $user User
|
||||
* @param string $newpassword Plaintext password
|
||||
* @param object $user User table object (with system magic quotes)
|
||||
* @param string $newpassword Plaintext password (with system magic quotes)
|
||||
* @return boolean result
|
||||
*
|
||||
*/
|
||||
@@ -68,32 +65,41 @@ class auth_plugin_manual
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* Returns the URL for changing the user's pw, or empty if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return string
|
||||
*/
|
||||
function change_password_url() {
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if plugin allows resetting of internal password.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function can_reset_password() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -102,8 +108,8 @@ class auth_plugin_manual
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
include "config.html";
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include 'config.html';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +118,7 @@ class auth_plugin_manual
|
||||
function process_config($config) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
<div align="center"><?php print_string('none'); ?></div>
|
||||
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('manual', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+60
-49
@@ -12,26 +12,22 @@
|
||||
* 2006-11-01 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) {
|
||||
exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* Moodle Network authentication plugin.
|
||||
*/
|
||||
class auth_plugin_mnet
|
||||
{
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_mnet extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_mnet() {
|
||||
$this->authtype = 'mnet';
|
||||
$this->config = get_config('auth/mnet');
|
||||
}
|
||||
|
||||
@@ -44,8 +40,8 @@ class auth_plugin_mnet
|
||||
$sso_idp = array();
|
||||
$sso_idp['name'] = 'sso_idp'; // Name & Description go in lang file
|
||||
$sso_idp['apiversion'] = 1;
|
||||
$sso_idp['methods'] = array('user_authorise','keepalive_server', 'kill_children',
|
||||
'refresh_log', 'fetch_user_image', 'fetch_theme_info',
|
||||
$sso_idp['methods'] = array('user_authorise','keepalive_server', 'kill_children',
|
||||
'refresh_log', 'fetch_user_image', 'fetch_theme_info',
|
||||
'update_enrolments');
|
||||
|
||||
$sso_sp = array();
|
||||
@@ -63,7 +59,7 @@ class auth_plugin_mnet
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login($username, $password) {
|
||||
return false; // error("Remote MNET users cannot login locally.");
|
||||
@@ -136,7 +132,7 @@ class auth_plugin_mnet
|
||||
h.wwwroot,
|
||||
h.id as hostid,
|
||||
count(c.id) as count
|
||||
FROM
|
||||
FROM
|
||||
{$CFG->prefix}mnet_enrol_course c,
|
||||
{$CFG->prefix}mnet_enrol_assignments a,
|
||||
{$CFG->prefix}mnet_host h
|
||||
@@ -198,9 +194,9 @@ class auth_plugin_mnet
|
||||
$mnet_peer->set_id($mnethostid);
|
||||
|
||||
// set up the session
|
||||
$mnet_session = get_record('mnet_session',
|
||||
'userid', $USER->id,
|
||||
'mnethostid', $mnethostid,
|
||||
$mnet_session = get_record('mnet_session',
|
||||
'userid', $USER->id,
|
||||
'mnethostid', $mnethostid,
|
||||
'useragent', sha1($_SERVER['HTTP_USER_AGENT']));
|
||||
if ($mnet_session == false) {
|
||||
$mnet_session = new object();
|
||||
@@ -241,7 +237,7 @@ class auth_plugin_mnet
|
||||
*
|
||||
* @param string $token The random session token.
|
||||
* @param string $remotewwwroot The ID provider wwwroot.
|
||||
* @returns array The local user record.
|
||||
* @return array The local user record.
|
||||
*/
|
||||
function confirm_mnet_session($token, $remotewwwroot) {
|
||||
global $CFG, $MNET, $SESSION;
|
||||
@@ -272,7 +268,7 @@ class auth_plugin_mnet
|
||||
list($code, $message) = array_map('trim',explode(':', $errormessage, 2));
|
||||
if($code == 702) {
|
||||
$site = get_site();
|
||||
print_error('mnet_session_prohibited','mnet', $remotewwwroot, $site->fullname);
|
||||
print_error('mnet_session_prohibited','mnet', $remotewwwroot, format_string($site->fullname));
|
||||
exit;
|
||||
}
|
||||
$message .= "ERROR $code:<br/>$errormessage<br/>";
|
||||
@@ -359,8 +355,8 @@ class auth_plugin_mnet
|
||||
$count = clean_param($rhost['count'], PARAM_INT);
|
||||
$url_is_local = stristr($url , $CFG->wwwroot);
|
||||
if (!empty($name) && !empty($count) && empty($url_is_local)) {
|
||||
$localuser->mnet_foreign_host_array[] = array('name' => $name,
|
||||
'url' => $url,
|
||||
$localuser->mnet_foreign_host_array[] = array('name' => $name,
|
||||
'url' => $url,
|
||||
'count' => $count);
|
||||
}
|
||||
}
|
||||
@@ -379,9 +375,9 @@ class auth_plugin_mnet
|
||||
}
|
||||
|
||||
// set up the session
|
||||
$mnet_session = get_record('mnet_session',
|
||||
'userid', $localuser->id,
|
||||
'mnethostid', $remotepeer->id,
|
||||
$mnet_session = get_record('mnet_session',
|
||||
'userid', $localuser->id,
|
||||
'mnethostid', $remotepeer->id,
|
||||
'useragent', sha1($_SERVER['HTTP_USER_AGENT']));
|
||||
if ($mnet_session == false) {
|
||||
$mnet_session = new object();
|
||||
@@ -404,7 +400,7 @@ class auth_plugin_mnet
|
||||
|
||||
if (!$firsttime) {
|
||||
// repeat customer! let the IDP know about enrolments
|
||||
// we have for this user.
|
||||
// we have for this user.
|
||||
// set up the RPC request
|
||||
$mnetrequest = new mnet_xmlrpc_client();
|
||||
$mnetrequest->set_method('auth/mnet/auth.php/update_enrolments');
|
||||
@@ -412,13 +408,13 @@ class auth_plugin_mnet
|
||||
// pass username and an assoc array of "my courses"
|
||||
// with info so that the IDP can maintain mnet_enrol_assignments
|
||||
$mnetrequest->add_param($remoteuser->username);
|
||||
$fields = 'id, category, sortorder, fullname, shortname, idnumber, summary,
|
||||
$fields = 'id, category, sortorder, fullname, shortname, idnumber, summary,
|
||||
startdate, cost, currency, defaultrole, visible';
|
||||
$courses = get_my_courses($localuser->id, 'visible DESC,sortorder ASC', $fields);
|
||||
if (is_array($courses) && !empty($courses)) {
|
||||
// Second request to do the JOINs that we'd have done
|
||||
// inside get_my_courses() if we had been allowed
|
||||
$sql = "SELECT c.id,
|
||||
$sql = "SELECT c.id,
|
||||
cc.name AS cat_name, cc.description AS cat_description,
|
||||
r.shortname as defaultrolename
|
||||
FROM {$CFG->prefix}course c
|
||||
@@ -453,7 +449,7 @@ class auth_plugin_mnet
|
||||
} else {
|
||||
// if the array is empty, send it anyway
|
||||
// we may be clearing out stale entries
|
||||
$courses = array();
|
||||
$courses = array();
|
||||
}
|
||||
$mnetrequest->add_param($courses);
|
||||
|
||||
@@ -475,7 +471,7 @@ class auth_plugin_mnet
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $courses Assoc array of courses following the structure of mnet_enrol_course
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function update_enrolments($username, $courses) {
|
||||
global $MNET_REMOTE_CLIENT, $CFG;
|
||||
@@ -485,15 +481,15 @@ class auth_plugin_mnet
|
||||
}
|
||||
// make sure it is a user we have an in active session
|
||||
// with that host...
|
||||
$userid = get_field('mnet_session', 'userid',
|
||||
'username', addslashes($username),
|
||||
$userid = get_field('mnet_session', 'userid',
|
||||
'username', addslashes($username),
|
||||
'mnethostid', (int)$MNET_REMOTE_CLIENT->id);
|
||||
if (!$userid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($courses)) { // no courses? clear out quickly
|
||||
delete_records('mnet_enrol_assignments',
|
||||
delete_records('mnet_enrol_assignments',
|
||||
'hostid', (int)$MNET_REMOTE_CLIENT->id,
|
||||
'userid', $userid);
|
||||
return true;
|
||||
@@ -563,7 +559,7 @@ class auth_plugin_mnet
|
||||
if ($saveflag) {
|
||||
update_record('mnet_enrol_course', $currentcourse);
|
||||
}
|
||||
|
||||
|
||||
if (isset($currentcourse->assignmentid) && is_numeric($currentcourse->assignmentid)) {
|
||||
$userisregd = true;
|
||||
}
|
||||
@@ -597,7 +593,7 @@ class auth_plugin_mnet
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -607,9 +603,10 @@ class auth_plugin_mnet
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
//TODO: it should be able to redirect, right?
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -617,10 +614,10 @@ class auth_plugin_mnet
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return string
|
||||
*/
|
||||
function change_password_url() {
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -631,7 +628,7 @@ class auth_plugin_mnet
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
global $CFG;
|
||||
|
||||
$query = "
|
||||
@@ -687,7 +684,7 @@ class auth_plugin_mnet
|
||||
$id_providers[]= array('id' => $hostservice->id, 'name' => $hostservice->hostname, 'wwwroot' => $hostservice->wwwroot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
@@ -763,13 +760,13 @@ class auth_plugin_mnet
|
||||
} elseif ($mnet_request->response['code'] > 0) {
|
||||
debugging($mnet_request->response['message']);
|
||||
}
|
||||
|
||||
|
||||
if (!isset($mnet_request->response['last log id'])) {
|
||||
debugging("Server side error has occured on host $mnethostid\nNo log ID was received.");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
debugging("Server side error has occured on host $mnethostid: " .
|
||||
debugging("Server side error has occured on host $mnethostid: " .
|
||||
join("\n", $mnet_request->error));
|
||||
break;
|
||||
}
|
||||
@@ -1006,8 +1003,12 @@ class auth_plugin_mnet
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function logout() {
|
||||
function prelogout_hook() {
|
||||
global $MNET, $CFG, $USER;
|
||||
if ($USER->auth != 'mnet') {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
|
||||
|
||||
// If the user is local to this Moodle:
|
||||
@@ -1043,9 +1044,9 @@ class auth_plugin_mnet
|
||||
|
||||
$mnetsessions = get_records_sql($sql);
|
||||
|
||||
$ignore = delete_records('mnet_session',
|
||||
'username', $username,
|
||||
'useragent', $useragent,
|
||||
$ignore = delete_records('mnet_session',
|
||||
'username', $username,
|
||||
'useragent', $useragent,
|
||||
'mnethostid', $USER->mnethostid);
|
||||
|
||||
if (false != $mnetsessions) {
|
||||
@@ -1060,7 +1061,7 @@ class auth_plugin_mnet
|
||||
$mnet_request->add_param($useragent);
|
||||
if ($mnet_request->send($mnet_peer) === false) {
|
||||
debugging(join("\n", $mnet_request->error));
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1121,13 +1122,13 @@ class auth_plugin_mnet
|
||||
$mnet_request->add_param($username);
|
||||
$mnet_request->add_param($useragent);
|
||||
if ($mnet_request->send($mnet_peer) === false) {
|
||||
debugging("Server side error has occured on host $mnethostid: " .
|
||||
debugging("Server side error has occured on host $mnethostid: " .
|
||||
join("\n", $mnet_request->error));
|
||||
}
|
||||
}
|
||||
|
||||
$ignore = delete_records('mnet_session',
|
||||
'useragent', $useragent,
|
||||
$ignore = delete_records('mnet_session',
|
||||
'useragent', $useragent,
|
||||
'userid', $userid);
|
||||
|
||||
if (isset($MNET_REMOTE_CLIENT) && isset($MNET_REMOTE_CLIENT->id)) {
|
||||
@@ -1336,6 +1337,16 @@ class auth_plugin_mnet
|
||||
}
|
||||
return $accessctrl == 'allow';
|
||||
}
|
||||
|
||||
function logoutpage_hook() {
|
||||
global $USER, $CFG, $redirect;
|
||||
|
||||
if (!empty($USER->mnethostid) and $USER->mnethostid != $CFG->mnet_localhost_id) {
|
||||
$host = get_record('mnet_host', 'id', $USER->mnethostid);
|
||||
$redirect = $host->wwwroot.'/';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -65,7 +65,7 @@ foreach($id_providers as $host):
|
||||
<td align="right"><?php echo $host['name']; ?>: </td>
|
||||
<td colspan="2"><?php echo $host['wwwroot']; ?> </td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
<tr valign="top" class="required">
|
||||
@@ -78,10 +78,9 @@ foreach($service_providers as $host):
|
||||
<td align="right"><?php echo $host['name']; ?>: </td>
|
||||
<td colspan="2"><?php echo $host['wwwroot']; ?> </td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
endforeach;
|
||||
|
||||
// global $user_fields;
|
||||
// print_auth_lock_options('mnet', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+5
-1
@@ -14,10 +14,14 @@
|
||||
|
||||
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
error('mnet is disabled');
|
||||
}
|
||||
|
||||
// grab the GET params - wantsurl could be anything - take it
|
||||
// with PARAM_RAW
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$wantsurl = optional_param('wantsurl', '/', PARAM_RAW);
|
||||
$wantsurl = optional_param('wantsurl', '/', PARAM_RAW);
|
||||
|
||||
// start the mnet session and redirect browser to remote URL
|
||||
$mnetauth = get_auth_plugin('mnet');
|
||||
|
||||
+3
-1
@@ -19,6 +19,9 @@ if (!$site = get_site()) {
|
||||
print_error('mnet_session_prohibited', 'mnet', '', '');
|
||||
}
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
error('mnet is disabled');
|
||||
}
|
||||
// grab the GET params
|
||||
$token = required_param('token', PARAM_BASE64);
|
||||
$remotewwwroot = required_param('idp', PARAM_URL);
|
||||
@@ -29,7 +32,6 @@ $mnetauth = get_auth_plugin('mnet');
|
||||
$localuser = $mnetauth->confirm_mnet_session($token, $remotewwwroot);
|
||||
|
||||
// log in
|
||||
$CFG->auth = 'mnet';
|
||||
$USER = get_complete_user_data('id', $localuser->id, $localuser->mnethostid);
|
||||
load_all_capabilities();
|
||||
|
||||
|
||||
+18
-19
@@ -12,23 +12,22 @@
|
||||
* 2006-08-31 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* NNTP authentication plugin.
|
||||
*/
|
||||
class auth_plugin_nntp {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_nntp extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_nntp() {
|
||||
$this->authtype = 'nntp';
|
||||
$this->config = get_config('auth/nntp');
|
||||
}
|
||||
|
||||
@@ -36,26 +35,26 @@ class auth_plugin_nntp {
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
if (! function_exists('imap_open')) {
|
||||
print_error('auth_nntpnotinstalled','auth');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
global $CFG;
|
||||
|
||||
|
||||
// try each multiple host
|
||||
$hosts = split(';', $this->config->host);
|
||||
foreach ($hosts as $host) {
|
||||
$host = '{' . trim($host) . ':' . $this->config->port . '/nntp}';
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
||||
error_reporting($CFG->debug);
|
||||
$connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
imap_close($connection);
|
||||
@@ -68,7 +67,7 @@ class auth_plugin_nntp {
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -78,12 +77,12 @@ class auth_plugin_nntp {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -92,7 +91,7 @@ class auth_plugin_nntp {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@ if (!isset($config->changepasswordurl)) {
|
||||
<td>
|
||||
<input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
|
||||
<?php
|
||||
|
||||
|
||||
if (isset($err["host"])) {
|
||||
formerr($err["host"]);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
|
||||
print_string("auth_nntphost", "auth");
|
||||
print_string("auth_multiplehosts", "auth");
|
||||
|
||||
@@ -45,7 +45,7 @@ if (!isset($config->changepasswordurl)) {
|
||||
if (isset($err["port"])) {
|
||||
formerr($err["port"]);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string("auth_nntpport", "auth") ?></td>
|
||||
@@ -66,9 +66,8 @@ if (!isset($config->changepasswordurl)) {
|
||||
<td><?php print_string('changepasswordhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('nntp', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package moodle multiauth
|
||||
*
|
||||
* Authentication Plugin: No Authentication
|
||||
*
|
||||
* No authentication at all. This method approves everything!
|
||||
*
|
||||
* 2007-02-18 File created.
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* Plugin for no authentication - disabled user.
|
||||
*/
|
||||
class auth_plugin_nologin extends auth_plugin_base {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_nologin() {
|
||||
$this->authtype = 'nologin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not allow any login.
|
||||
*
|
||||
*/
|
||||
function user_login($username, $password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* No password updates.
|
||||
*/
|
||||
function user_update_password($user, $newpassword) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* No external data sync.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
//we do not know if it was internal or external originally
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* No changing of password.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* No password resetting.
|
||||
*/
|
||||
function can_reset_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+28
-23
@@ -12,26 +12,22 @@
|
||||
* 2006-08-31 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* Plugin for no authentication.
|
||||
*/
|
||||
class auth_plugin_none {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
|
||||
var $canchangepassword = true;
|
||||
var $isinternal = true;
|
||||
class auth_plugin_none extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_none() {
|
||||
$this->authtype = 'none';
|
||||
$this->config = get_config('auth/none');
|
||||
}
|
||||
|
||||
@@ -41,14 +37,14 @@ class auth_plugin_none {
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
global $CFG;
|
||||
if ($user = get_record('user', 'username', $username, 'mnethostid', $CFG->mnet_localhost_id)) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,8 +52,8 @@ class auth_plugin_none {
|
||||
*
|
||||
* called when the user password is updated.
|
||||
*
|
||||
* @param object $user User
|
||||
* @param string $newpassword Plaintext password
|
||||
* @param object $user User table object (with system magic quotes)
|
||||
* @param string $newpassword Plaintext password (with system magic quotes)
|
||||
* @return boolean result
|
||||
*
|
||||
*/
|
||||
@@ -69,7 +65,7 @@ class auth_plugin_none {
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return true;
|
||||
@@ -79,22 +75,31 @@ class auth_plugin_none {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* Returns the URL for changing the user's pw, or empty if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return string
|
||||
*/
|
||||
function change_password_url() {
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if plugin allows resetting of internal password.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function can_reset_password() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -103,7 +108,7 @@ class auth_plugin_none {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
<div align="center"><?php print_string('none'); ?></div>
|
||||
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('none', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+21
-22
@@ -7,16 +7,16 @@
|
||||
*
|
||||
* Authentication Plugin: PAM Authentication
|
||||
*
|
||||
* PAM (Pluggable Authentication Modules) for Moodle
|
||||
*
|
||||
* PAM (Pluggable Authentication Modules) for Moodle
|
||||
*
|
||||
* Description:
|
||||
* Authentication by using the PHP4 PAM module:
|
||||
* http://www.math.ohio-state.edu/~ccunning/pam_auth/
|
||||
*
|
||||
*
|
||||
* Version 0.3 2006/09/07 by Jonathan Harker (plugin class)
|
||||
* Version 0.2: 2004/09/01 by Martin V�geli (stable version)
|
||||
* Version 0.1: 2004/08/30 by Martin V�geli (first draft)
|
||||
*
|
||||
*
|
||||
* Contact: martinvoegeli@gmx.ch
|
||||
* Website 1: http://elearning.zhwin.ch/
|
||||
* Website 2: http://birdy1976.com/
|
||||
@@ -26,19 +26,17 @@
|
||||
* 2006-08-31 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* PAM authentication plugin.
|
||||
*/
|
||||
class auth_plugin_pam {
|
||||
class auth_plugin_pam extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
|
||||
/**
|
||||
* Store error messages from pam authentication attempts.
|
||||
*/
|
||||
@@ -48,6 +46,7 @@ class auth_plugin_pam {
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_pam() {
|
||||
$this->authtype = 'pam';
|
||||
$this->config = get_config('auth/pam');
|
||||
$this->errormessage = '';
|
||||
}
|
||||
@@ -56,32 +55,32 @@ class auth_plugin_pam {
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
// variable to store possible errors during authentication
|
||||
$errormessage = str_repeat(' ', 2048);
|
||||
|
||||
|
||||
// just for testing and debugging
|
||||
// error_reporting(E_ALL);
|
||||
|
||||
// call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth
|
||||
//if (pam_auth($username, $password, &$errormessage)) {
|
||||
if (pam_auth($username, $password)) {
|
||||
if (pam_auth(stripslashes($username), strislashes($password))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$this->lasterror = $errormessage;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -91,12 +90,12 @@ class auth_plugin_pam {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -105,7 +104,7 @@ class auth_plugin_pam {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
<div align="center"><?php print_string('none'); ?></div>
|
||||
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('pam', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+24
-26
@@ -12,23 +12,22 @@
|
||||
* 2006-08-31 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* POP3 authentication plugin.
|
||||
*/
|
||||
class auth_plugin_pop3 {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_pop3 extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_pop3() {
|
||||
$this->authtype = 'pop3';
|
||||
$this->config = get_config('auth/pop3');
|
||||
}
|
||||
|
||||
@@ -36,16 +35,16 @@ class auth_plugin_pop3 {
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login($username, $password) {
|
||||
if (! function_exists('imap_open')) {
|
||||
print_error('auth_pop3notinstalled','auth');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
global $CFG;
|
||||
$hosts = split(';', $this->config->host); // Could be multiple hosts
|
||||
foreach ($hosts as $host) { // Try each host in turn
|
||||
@@ -71,9 +70,9 @@ class auth_plugin_pop3 {
|
||||
}
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
$connection = imap_open($host, stripslashes($username), stripslashes($password));
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
imap_close($connection);
|
||||
return true;
|
||||
@@ -85,7 +84,7 @@ class auth_plugin_pop3 {
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -95,23 +94,22 @@ class auth_plugin_pop3 {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
return !empty($this->config->changepasswordurl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the URL for changing the user's pw, or false if the default can
|
||||
* be used.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function change_password_url() {
|
||||
return $CFG->changepasswordurl; // TODO: will this be global?
|
||||
//return $this->config->changepasswordurl;
|
||||
return $this->config->changepasswordurl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -120,7 +118,7 @@ class auth_plugin_pop3 {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
@@ -146,8 +144,8 @@ class auth_plugin_pop3 {
|
||||
}
|
||||
|
||||
// save settings
|
||||
set_config('host', $config->host, 'auth/pop3');
|
||||
set_config('type', $config->type, 'auth/pop3');
|
||||
set_config('host', $config->host, 'auth/pop3');
|
||||
set_config('type', $config->type, 'auth/pop3');
|
||||
set_config('port', $config->port, 'auth/pop3');
|
||||
set_config('mailbox', $config->mailbox, 'auth/pop3');
|
||||
set_config('changepasswordurl', $config->changepasswordurl, 'auth/pop3');
|
||||
|
||||
@@ -34,10 +34,10 @@ if (!isset($config->changepasswordurl)) {
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
|
||||
print_string('auth_pop3host', 'auth');
|
||||
print_string('auth_multiplehosts', 'auth');
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -103,9 +103,8 @@ if (!isset($config->changepasswordurl)) {
|
||||
<td><?php print_string('changepasswordhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('pop3', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);
|
||||
|
||||
?>
|
||||
|
||||
+21
-22
@@ -13,23 +13,22 @@
|
||||
* 2006-08-31 File created.
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* RADIUS authentication plugin.
|
||||
*/
|
||||
class auth_plugin_radius {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_radius extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_radius() {
|
||||
$this->authtype = 'radius';
|
||||
$this->config = get_config('auth/radius');
|
||||
}
|
||||
|
||||
@@ -37,28 +36,28 @@ class auth_plugin_radius {
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login ($username, $password) {
|
||||
require_once 'Auth/RADIUS.php';
|
||||
|
||||
|
||||
// Added by Clive on 7th May for test purposes
|
||||
// printf("Username: $username <br/>");
|
||||
// printf("Password: $password <br/>");
|
||||
// printf("host: $this->config->host <br/>");
|
||||
// printf("nasport: $this->config->nasport <br/>");
|
||||
// printf("secret: $this->config->secret <br/>");
|
||||
|
||||
$rauth = new Auth_RADIUS_PAP($username, $password);
|
||||
|
||||
$rauth = new Auth_RADIUS_PAP(stripslashes($username), stripslashes($password));
|
||||
$rauth->addServer($this->config->host, $this->config->nasport, $this->config->secret);
|
||||
|
||||
|
||||
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());
|
||||
@@ -70,21 +69,21 @@ class auth_plugin_radius {
|
||||
// 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -94,12 +93,12 @@ class auth_plugin_radius {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -108,7 +107,7 @@ class auth_plugin_radius {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Is Auth/RADIUS really there?
|
||||
if ((!include_once('Auth/RADIUS.php')) or (!class_exists(Auth_RADIUS_PAP))) {
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
// set to defaults if undefined
|
||||
if (!isset($config->host)) {
|
||||
@@ -44,11 +44,11 @@ if (!isset($config->changepasswordurl)) {
|
||||
<td>
|
||||
<input name="nasport" type="text" size="6" value="<?php echo $config->nasport ?>" />
|
||||
<?php
|
||||
|
||||
|
||||
if (isset($err['nasport'])) {
|
||||
formerr($err['nasport']);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td><?php print_string('auth_radiusnasport', 'auth') ?></td>
|
||||
@@ -59,7 +59,7 @@ if (!isset($config->changepasswordurl)) {
|
||||
<td>
|
||||
<input name="secret" type="text" size="6" value="<?php echo $config->secret ?>" />
|
||||
<?php
|
||||
|
||||
|
||||
if (isset($err['secret'])) {
|
||||
formerr($err['secret']);
|
||||
}
|
||||
|
||||
+57
-56
@@ -2,7 +2,7 @@ Shibboleth Authentication for Moodle
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Requirements:
|
||||
- Shibboleth target 1.1 or later. See documentation for your Shibboleth
|
||||
- Shibboleth target 1.1 or later. See documentation for your Shibboleth
|
||||
federation on how to set up Shibboleth.
|
||||
|
||||
Changes:
|
||||
@@ -15,12 +15,12 @@ Changes:
|
||||
- 02. 2006: Simplified authentication so that authorization works properly
|
||||
Added instructions for IIS
|
||||
- 11. 2006: User capabilities are now loaded properly as of Moodle 1.7+
|
||||
|
||||
- 03. 2007: Adapted authentication method to Moodle 1.8
|
||||
|
||||
Moodle Configuration with Dual login
|
||||
-------------------------------------------------------------------------------
|
||||
1. Protect the directory moodle/auth/shibboleth/ with Shibboleth.
|
||||
The page index.php in that directory actually logs in a Shibboleth user.
|
||||
The page index.php in that directory actually logs in a Shibboleth user.
|
||||
For Apache you have to define a rule like the following in the Apache config:
|
||||
|
||||
--
|
||||
@@ -31,25 +31,26 @@ Moodle Configuration with Dual login
|
||||
</Location>
|
||||
--
|
||||
|
||||
To restrict access to Moodle, replace the access rule 'require valid-user'
|
||||
To restrict access to Moodle, replace the access rule 'require valid-user'
|
||||
with something that fits your needs, e.g. 'require affiliation student'.
|
||||
|
||||
For IIS you have protect the auth/shibboleth directory directly in the
|
||||
For IIS you have protect the auth/shibboleth directory directly in the
|
||||
RequestMap of the Shibboleth configuration file (shibboleth.xml). See
|
||||
https://authdev.it.ohio-state.edu/twiki/bin/view/Shibboleth/xmlaccesscontrol?topic=XMLAccessControl
|
||||
|
||||
2. As Moodle admin, go to the 'Administrations >> Users >> Authentication
|
||||
Options' and select the 'Shibboleth' authentication method from the pop-up.
|
||||
|
||||
3. Fill in the fields of the form. The fields 'Username', 'First name',
|
||||
'Surname', etc should contain the name of the environment variables of the
|
||||
Shibboleth attributes that you want to map onto the corresponding Moodle
|
||||
variable (e.g. 'HTTP_SHIB_PERSON_SURNAME' for the person's last name, refer
|
||||
https://spaces.internet2.edu/display/SHIB/xmlaccesscontrol?topic=XMLAccessControl
|
||||
|
||||
2. As Moodle admin, go to the 'Administrations >> Users >> Authentication
|
||||
Options' and click on the the 'Shibboleth' settings.
|
||||
|
||||
3. Fill in the fields of the form. The fields 'Username', 'First name',
|
||||
'Surname', etc should contain the name of the environment variables of the
|
||||
Shibboleth attributes that you want to map onto the corresponding Moodle
|
||||
variable (e.g. 'HTTP_SHIB_PERSON_SURNAME' for the person's last name, refer
|
||||
the Shibboleth documentation or the documentation of your Shibboleth
|
||||
federation for information on which attributes are available).
|
||||
Especially the 'Username' field is of great importance because
|
||||
Especially the 'Username' field is of great importance because
|
||||
this attribute is used for the Moodle authentication of Shibboleth users.
|
||||
|
||||
|
||||
#############################################################################
|
||||
Shibboleth Attributes needed by Moodle:
|
||||
For Moodle to work properly Shibboleth should at least provide the attributes
|
||||
@@ -60,57 +61,57 @@ Moodle Configuration with Dual login
|
||||
lengths for each field in the user profile.
|
||||
#############################################################################
|
||||
|
||||
4. The large text field 'Instructions' must contain a link to the
|
||||
moodle/auth/shibboleth/index.php file which is protected by
|
||||
Shibboleth (see step 1) and causes the Shibboleth login procedure to start.
|
||||
You could also use HTML code in that field, e.g. to create your own
|
||||
Shibboleth login button.
|
||||
4. Save the changes for the 'Shibboleth settings'.
|
||||
|
||||
5. Save the changes for the Shibboleth authentication method.
|
||||
5.a If you want Shibboleth as your only authentication method, set the
|
||||
'Alternate Login URL' in the 'Common settings' in
|
||||
'Administrations >> Users >> Authentication Options' to the the URL of the
|
||||
file 'moodle/auth/shibboleth/index.php'. This will enforce Shibboleth login.
|
||||
|
||||
Moodle Configuration with Shibboleth only login
|
||||
-------------------------------------------------------------------------------
|
||||
If you want Shibboleth as your only authentication method, configure Moodle as
|
||||
described in the dual login section above and do the following steps:
|
||||
6.b If you want to use another authentication method together with Shibboleth,
|
||||
in parallel, change the 'Instructions' in the 'Common settings' of the
|
||||
'Administrations >> Users >> Authentication Options' to contain a link to the
|
||||
moodle/auth/shibboleth/index.php file which is protected by
|
||||
Shibboleth (see step 1) and causes the Shibboleth login procedure to start.
|
||||
You can also use HTML code in that field, e.g. to include an image as a
|
||||
Shibboleth login button.
|
||||
|
||||
4.a On the Moodle Shibboleth settings page, set the 'Alternate Login URL' to
|
||||
the URL of the file 'moodle/auth/shibboleth/index.php'
|
||||
This will enforce Shibboleth login.
|
||||
7. Save the changes for the 'Common settings'.
|
||||
|
||||
How the Shibboleth authentication works
|
||||
--------------------------------------------------------------------------------
|
||||
To get Shibboleth authenticated in Moodle a user basically must access the
|
||||
Shibboleth-protected page /auth/shibboleth/index.php. If Shibboleth is the only
|
||||
authentication method (see 4.a), this happens automatically when a user wants to
|
||||
login in Moodle. Otherwise, the user has to click on the link on the login page
|
||||
you provided in step 4.
|
||||
To get Shibboleth authenticated in Moodle a user basically must access the
|
||||
Shibboleth-protected page /auth/shibboleth/index.php. If Shibboleth is the only
|
||||
authentication method (see 5.a), this happens automatically when a user wants to
|
||||
login in Moodle. Otherwise, the user has to click on the link on the login page
|
||||
you provided in step 5.b.
|
||||
|
||||
Moodle basically checks whether the Shibboleth attribute that you mapped
|
||||
as the username is present. This attribute should only be present if a user is
|
||||
as the username is present. This attribute should only be present if a user is
|
||||
Shibboleth authenticated.
|
||||
|
||||
If the user's Moodle account has not existed yet, it gets automatically created.
|
||||
|
||||
To prevent that every Shibboleth user can access your Moodle site you have to
|
||||
adapt the 'require valid-user' line in your webserver's config (see step 1) to
|
||||
adapt the 'require valid-user' line in your webserver's config (see step 1) to
|
||||
allow only specific users. If you defined some authorization rules in step 1,
|
||||
these are checked by Shibboleth itself. Only users who met these rules
|
||||
these are checked by Shibboleth itself. Only users who met these rules
|
||||
actually can access /auth/shibboleth/index.php and get logged in.
|
||||
|
||||
You can use Shibboleth AND another authentication method (it was tested with
|
||||
manual login). So, if there are a few users that don't have a Shibboleth
|
||||
login, you could create manual accounts for them and they could use the manual
|
||||
login. For other authentication methods you first have to configure them and
|
||||
then set Shibboleth as your authentication method. Users can log in only via one
|
||||
You can use Shibboleth AND another authentication method (it was tested with
|
||||
manual login). So, if there are a few users that don't have a Shibboleth
|
||||
login, you could create manual accounts for them and they could use the manual
|
||||
login. For other authentication methods you first have to configure them and
|
||||
then set Shibboleth as your authentication method. Users can log in only via one
|
||||
authentication method unless they have two accounts in Moodle.
|
||||
|
||||
Shibboleth dual login with custom login page
|
||||
--------------------------------------------------------------------------------
|
||||
Of course you can create a dual login page that better fits your needs. For this
|
||||
to work, you have to set up the two authentication methods (e.g. 'Manual' and
|
||||
'Shibboleth') and specify an alternate login link to your own dual login page.
|
||||
Of course you can create a dual login page that better fits your needs. For this
|
||||
to work, you have to set up the two authentication methods (e.g. 'Manual' and
|
||||
'Shibboleth') and specify an alternate login link to your own dual login page.
|
||||
On that page you basically need a link to the Shibboleth-protected page
|
||||
('/auth/shibboleth/index.php') for the Shibboleth login and a
|
||||
('/auth/shibboleth/index.php') for the Shibboleth login and a
|
||||
form that sends 'username' and 'password' to moodle/login/index.php.
|
||||
Consult the Moodle documentation for further instructions and requirements.
|
||||
|
||||
@@ -119,21 +120,21 @@ How to customize the way the Shibboleth user data is used in Moodle
|
||||
Among the Shibboleth settings in Moodle there is a field that should contain a
|
||||
path to a php file that can be used as data manipulation hook.
|
||||
You can use this if you want to further process the way your Shibboleth
|
||||
attributes are used in Moodle.
|
||||
attributes are used in Moodle.
|
||||
|
||||
Example 1: Your Shibboleth federation uses an attribute that specifies the
|
||||
Example 1: Your Shibboleth federation uses an attribute that specifies the
|
||||
user's preferred language, but the content of this attribute is not
|
||||
compatible with the Moodle data representation, e.g. the Shibboleth
|
||||
attribute contains 'German' but Moodle needs a two letter value like
|
||||
attribute contains 'German' but Moodle needs a two letter value like
|
||||
'de'.
|
||||
Example 2: The country, city and street are provided in one Shibboleth attribute
|
||||
and you want these values to be used in the Moodle user profile. So
|
||||
You have to parse the corresponding attribute to fill the user fields.
|
||||
|
||||
If you want to use this hook you have to be a skilled PHP programmer. It is
|
||||
strongly recommended that you take a look at the file
|
||||
moodle/auth/shibboleth/auth.php, especially the function 'get_userinfo'
|
||||
where this file is included.
|
||||
If you want to use this hook you have to be a skilled PHP programmer. It is
|
||||
strongly recommended that you take a look at the file
|
||||
moodle/auth/shibboleth/auth.php, especially the function 'get_userinfo'
|
||||
where this file is included.
|
||||
The context of the file is the same as within this login function. So you
|
||||
can directly edit the object $result.
|
||||
|
||||
@@ -146,16 +147,16 @@ Example file:
|
||||
if ($_SERVER[$pluginconfig->field_map_address] != '')
|
||||
{
|
||||
// $address contains something like 'SWITCH$Limmatquai 138$CH-8021 Zurich'
|
||||
// We want to split this up to get:
|
||||
// We want to split this up to get:
|
||||
// institution, street, zipcode, city and country
|
||||
$address = $_SERVER[$pluginconfig->field_map_address];
|
||||
list($institution, $street, $zip_city) = split('\$', $address);
|
||||
ereg(' (.+)',$zip_city, $regs);
|
||||
$city = $regs[1];
|
||||
|
||||
|
||||
ereg('(.+)-',$zip_city, $regs);
|
||||
$country = $regs[1];
|
||||
|
||||
|
||||
$result["address"] = $street;
|
||||
$result["city"] = $city;
|
||||
$result["country"] = $country;
|
||||
@@ -165,5 +166,5 @@ Example file:
|
||||
--
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
In case of problems and questions with Shibboleth authentication, contact
|
||||
In case of problems and questions with Shibboleth authentication, contact
|
||||
Lukas Haemmerle <haemmerle@switch.ch> or Markus Hagman <hagman@hytti.uku.fi>
|
||||
|
||||
+73
-41
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Martin Dougiamas
|
||||
* @author Lukas Haemmerle
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package moodle multiauth
|
||||
*
|
||||
@@ -8,33 +9,33 @@
|
||||
*
|
||||
* Authentication using Shibboleth.
|
||||
*
|
||||
* 10.2004 SHIBBOLETH Authentication functions v.0.1
|
||||
* 05.2005 Various extensions and fixes by Lukas Haemmerle
|
||||
* 10.2005 Added better error messags
|
||||
* 05.2006 Added better handling of mutli-valued attributes
|
||||
* Distributed under GPL (c)Markus Hagman 2004-2006
|
||||
*
|
||||
* 10.2004 SHIBBOLETH Authentication functions v.0.1
|
||||
* 05.2005 Various extensions and fixes by Lukas Haemmerle
|
||||
* 10.2005 Added better error messags
|
||||
* 05.2006 Added better handling of mutli-valued attributes
|
||||
* 2006-08-28 File created, code imported from lib.php
|
||||
* 2006-10-27 Upstream 1.7 changes merged in, added above credits from lib.php :-)
|
||||
* 2007-03-09 Fixed authentication but may need some other changes
|
||||
*/
|
||||
|
||||
// This page cannot be called directly
|
||||
if (!isset($CFG)) exit;
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
|
||||
/**
|
||||
* Shibboleth authentication plugin.
|
||||
*/
|
||||
class auth_plugin_shibboleth {
|
||||
|
||||
/**
|
||||
* The configuration details for the plugin.
|
||||
*/
|
||||
var $config;
|
||||
class auth_plugin_shibboleth extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function auth_plugin_shibboleth() {
|
||||
$this->authtype = 'shibboleth';
|
||||
$this->config = get_config('auth/shibboleth');
|
||||
}
|
||||
|
||||
@@ -42,14 +43,15 @@ class auth_plugin_shibboleth {
|
||||
* Returns true if the username and password work and false if they are
|
||||
* wrong or don't exist.
|
||||
*
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @returns bool Authentication success or failure.
|
||||
* @param string $username The username (with system magic quotes)
|
||||
* @param string $password The password (with system magic quotes)
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login($username, $password) {
|
||||
|
||||
// If we are in the shibboleth directory then we trust the server var
|
||||
if (!empty($_SERVER[$config->user_attribute])) {
|
||||
return ($_SERVER[$config->user_attribute] == $username);
|
||||
if (!empty($_SERVER[$this->config->user_attribute])) {
|
||||
return ($_SERVER[$this->config->user_attribute] == $username);
|
||||
} else {
|
||||
// If we are not, the user has used the manual login and the login name is
|
||||
// unknown, so we return false.
|
||||
@@ -57,46 +59,50 @@ class auth_plugin_shibboleth {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the user information for 'external' users. In this case the
|
||||
* attributes provided by Shibboleth
|
||||
*
|
||||
* @return array $result Associative array of user data
|
||||
*/
|
||||
function get_userinfo($username) {
|
||||
// reads user information from shibboleth attributes and return it in array()
|
||||
global $CFG;
|
||||
|
||||
// Check whether we have got all the essential attributes
|
||||
if (
|
||||
empty($_SERVER[$config->user_attribute])
|
||||
|| empty($_SERVER[$config->field_map_firstname])
|
||||
|| empty($_SERVER[$config->field_map_lastname])
|
||||
|| empty($_SERVER[$config->field_map_email])
|
||||
empty($_SERVER[$this->config->user_attribute])
|
||||
|| empty($_SERVER[$this->config->field_map_firstname])
|
||||
|| empty($_SERVER[$this->config->field_map_lastname])
|
||||
|| empty($_SERVER[$this->config->field_map_email])
|
||||
) {
|
||||
error(get_string( 'shib_not_all_attributes_error', 'auth' , "'".$config->user_attribute."' ('".$_SERVER[$config->user_attribute]."'), '".$config->field_map_firstname."' ('".$_SERVER[$config->field_map_firstname]."'), '".$config->field_map_lastname."' ('".$_SERVER[$config->field_map_lastname]."') and '".$config->field_map_email."' ('".$_SERVER[$config->field_map_email]."')"));
|
||||
error(get_string( 'shib_not_all_attributes_error', 'auth' , "'".$this->config->user_attribute."' ('".$_SERVER[$this->config->user_attribute]."'), '".$this->config->field_map_firstname."' ('".$_SERVER[$this->config->field_map_firstname]."'), '".$this->config->field_map_lastname."' ('".$_SERVER[$this->config->field_map_lastname]."') and '".$this->config->field_map_email."' ('".$_SERVER[$this->config->field_map_email]."')"));
|
||||
}
|
||||
|
||||
$attrmap = $this->get_attributes();
|
||||
|
||||
$result = array();
|
||||
$search_attribs = array();
|
||||
|
||||
|
||||
foreach ($attrmap as $key=>$value) {
|
||||
if (!empty($CFG->unicodedb)) {
|
||||
$result[$key] = $this->get_first_string($_SERVER[$value]);
|
||||
} else {
|
||||
$result[$key] = $this->get_first_string(utf8_decode($_SERVER[$value]));
|
||||
}
|
||||
$result[$key] = $this->get_first_string($_SERVER[$value]);
|
||||
}
|
||||
|
||||
// Provide an API to modify the information to fit the Moodle internal
|
||||
// data representation
|
||||
if (
|
||||
$config->convert_data
|
||||
&& $config->convert_data != ''
|
||||
&& is_readable($config->convert_data)
|
||||
if (
|
||||
$this->config->convert_data
|
||||
&& $this->config->convert_data != ''
|
||||
&& is_readable($this->config->convert_data)
|
||||
) {
|
||||
|
||||
|
||||
// Include a custom file outside the Moodle dir to
|
||||
// modify the variable $moodleattributes
|
||||
include($config->convert_data);
|
||||
include($this->config->convert_data);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -106,8 +112,8 @@ class auth_plugin_shibboleth {
|
||||
function get_attributes() {
|
||||
$configarray = (array) $this->config;
|
||||
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang", "guid");
|
||||
|
||||
$moodleattributes = array();
|
||||
@@ -124,7 +130,7 @@ class auth_plugin_shibboleth {
|
||||
/**
|
||||
* Returns true if this authentication plugin is 'internal'.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function is_internal() {
|
||||
return false;
|
||||
@@ -134,12 +140,28 @@ class auth_plugin_shibboleth {
|
||||
* Returns true if this authentication plugin can change the user's
|
||||
* password.
|
||||
*
|
||||
* @returns bool
|
||||
* @return bool
|
||||
*/
|
||||
function can_change_password() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function loginpage_hook() {
|
||||
global $SESSION, $CFG;
|
||||
|
||||
//TODO: fix the code
|
||||
return;
|
||||
|
||||
// See http://moodle.org/mod/forum/discuss.php?d=39918#187611
|
||||
// if ($CFG->auth == 'shibboleth') {
|
||||
// if (!empty($SESSION->shibboleth_checked) ) { // Just come from there
|
||||
// unset($SESSION->shibboleth_checked);
|
||||
// } else if (empty($_POST)) { // No incoming data, so redirect
|
||||
// redirect($CFG->wwwroot.'/auth/shibboleth/index.php');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a form for configuring this authentication plugin.
|
||||
*
|
||||
@@ -148,12 +170,15 @@ class auth_plugin_shibboleth {
|
||||
*
|
||||
* @param array $page An object containing all the data for this page.
|
||||
*/
|
||||
function config_form($config, $err) {
|
||||
function config_form($config, $err, $user_fields) {
|
||||
include "config.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and stores configuration data for this authentication plugin.
|
||||
*
|
||||
*
|
||||
* @param object $config Configuration object
|
||||
*/
|
||||
function process_config($config) {
|
||||
// set to defaults if undefined
|
||||
@@ -176,11 +201,18 @@ class auth_plugin_shibboleth {
|
||||
set_config('auth_instructions', $config->auth_instructions, 'auth/shibboleth');
|
||||
set_config('changepasswordurl', $config->changepasswordurl, 'auth/shibboleth');
|
||||
|
||||
// Check values and return false if something is wrong
|
||||
if (!file_exists($config->convert_data) || !is_readable($config->convert_data)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans and returns first of potential many values (multi-valued attributes)
|
||||
*
|
||||
* @param string $string Possibly multi-valued attribute from Shibboleth
|
||||
*/
|
||||
function get_first_string($string) {
|
||||
$list = split( ';', $string);
|
||||
|
||||
@@ -22,31 +22,38 @@
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("username") ?>:</td>
|
||||
<td>
|
||||
<input name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute ?>">
|
||||
<input name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute ?>" />
|
||||
</td>
|
||||
<td><?php print_string("auth_shib_username_description", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
<!--
|
||||
This is kind of obsolete because the login instructions are now centralized
|
||||
On the other hand it would be great for Shibboleth to have seperate login
|
||||
instructions
|
||||
-->
|
||||
<!--
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
|
||||
<td>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
|
||||
print_string("auth_shib_instructions_help", "auth", htmlspecialchars($CFG->wwwroot.'/auth/shibboleth/index.php'));
|
||||
helpbutton("text", get_string("helptext"));
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_convert_data", "auth") ?>:</td>
|
||||
<td>
|
||||
<input name="convert_data" type="text" size="30" value="<?php echo $config->convert_data?>">
|
||||
<?php
|
||||
<input name="convert_data" type="text" size="30" value="<?php echo $config->convert_data?>" />
|
||||
<?php
|
||||
|
||||
if ($config->convert_data and $config->convert_data != '' and !is_readable($config->convert_data)) {
|
||||
echo '<br/><font color="red">';
|
||||
@@ -59,6 +66,7 @@
|
||||
<td><?php print_string("auth_shib_convert_data_description", "auth") ?></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('auth_shib_changepasswordurl', 'auth') ?>: </td>
|
||||
<td>
|
||||
@@ -74,9 +82,8 @@
|
||||
<td><?php print_string('changepasswordhelp', 'auth') ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
|
||||
global $user_fields;
|
||||
print_auth_lock_options('shibboleth', $user_fields, '<!-- empty help -->', true, false);
|
||||
|
||||
?>
|
||||
|
||||
+27
-16
@@ -2,7 +2,6 @@
|
||||
// Designed to be redirected from moodle/login/index.php
|
||||
|
||||
require('../../config.php');
|
||||
require('lib.php');
|
||||
|
||||
if (isloggedin() && $USER->username != 'guest') { // Nothing to do
|
||||
if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
@@ -13,12 +12,13 @@
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
|
||||
redirect($urltogo);
|
||||
}
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
$shibbolethauth = get_auth_plugin('shibboleth');
|
||||
|
||||
// Check whether Shibboleth is configured properly
|
||||
if (empty($pluginconfig->user_attribute)) {
|
||||
error(get_string( 'shib_not_set_up_error', 'auth'));
|
||||
@@ -29,21 +29,26 @@
|
||||
$frm->username = $_SERVER[$pluginconfig->user_attribute];
|
||||
$frm->password = substr(base64_encode($_SERVER[$pluginconfig->user_attribute]),0,8);
|
||||
// The random password consists of the first 8 letters of the base 64 encoded user ID
|
||||
// This password is never used unless the user account is converted to manual
|
||||
// This password is never used unless the user account is converted to manual
|
||||
|
||||
/// Check if the user has actually submitted login data to us
|
||||
|
||||
if ($user = authenticate_user_login($frm->username, $frm->password)) {
|
||||
|
||||
// Let's get them all set up.
|
||||
$USER = $user;
|
||||
|
||||
add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $USER->id, 0, $USER->id);
|
||||
|
||||
if ($shibbolethauth->user_login($frm->username, $frm->password)) {
|
||||
|
||||
$USER = authenticate_user_login($frm->username, $frm->password);
|
||||
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security, store the site in the
|
||||
|
||||
update_user_login_times();
|
||||
set_moodle_cookie($USER->username);
|
||||
set_login_session_preferences();
|
||||
|
||||
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $USER->id, 0, $USER->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.SITEID;
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
@@ -56,21 +61,27 @@
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
|
||||
/// Go to my-moodle page instead of homepage if mymoodleredirect enabled
|
||||
if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM, SITEID)) and !empty($CFG->mymoodleredirect) and !isguest()) {
|
||||
if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') {
|
||||
$urltogo = $CFG->wwwroot.'/my/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
load_all_capabilities(); /// This is what lets the user do anything on the site :-)
|
||||
|
||||
redirect($urltogo);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
else {
|
||||
// For some weird reason the Shibboleth user couldn't be authenticated
|
||||
}
|
||||
}
|
||||
|
||||
// If we can find any (user independent) Shibboleth attributes but no user
|
||||
|
||||
// If we can find any (user independent) Shibboleth attributes but no user
|
||||
// attributes we probably didn't receive any user attributes
|
||||
elseif (!empty($_SERVER['HTTP_SHIB_APPLICATION_ID'])) {
|
||||
error(get_string( 'shib_no_attributes_error', 'auth' , '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\''));
|
||||
|
||||
+3
-3
@@ -78,7 +78,7 @@
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("center");
|
||||
foreach ($courses as $course) {
|
||||
echo '<a href="backup.php?id='.$course->id.'">'.s($course->fullname).' ('.s($course->shortname).')</a><br />'."\n";
|
||||
echo '<a href="backup.php?id='.$course->id.'">'.format_string($course->fullname).' ('.format_string($course->shortname).')</a><br />'."\n";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
@@ -106,12 +106,12 @@
|
||||
}
|
||||
|
||||
//Print form
|
||||
print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
|
||||
print_heading(format_string("$strcoursebackup: $course->fullname ($course->shortname)"));
|
||||
print_simple_box_start("center");
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("196M");
|
||||
raise_memory_limit("192M");
|
||||
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
|
||||
+20
-3
@@ -213,9 +213,10 @@
|
||||
//Extracts user id from file path
|
||||
$tok = strtok($dir,"/");
|
||||
if ($tok) {
|
||||
$userid = $tok;
|
||||
$userid = $tok;
|
||||
} else {
|
||||
$tok = "";
|
||||
//We were getting $dir='0', so continue (WAS: $tok = "";)
|
||||
continue;
|
||||
}
|
||||
//Look it is a backupable user
|
||||
$data = get_record ("backup_ids","backup_code","$backup_unique_code",
|
||||
@@ -1842,6 +1843,16 @@
|
||||
|
||||
global $CFG,$preferences;
|
||||
|
||||
//Use one static variable to cache all the require_once calls that,
|
||||
//under PHP5 seems to increase load too much, and we are requiring
|
||||
//them here thousands of times (one per content). MDL-8700.
|
||||
//Once fixed by PHP, we'll delete this hack
|
||||
|
||||
static $includedfiles;
|
||||
if (!isset($includedfiles)) {
|
||||
$includedfiles = array();
|
||||
}
|
||||
|
||||
//Check if preferences is ok. If it isn't set, we are
|
||||
//in a scheduled_backup to we are able to get a copy
|
||||
//from CFG->backup_preferences
|
||||
@@ -1861,8 +1872,14 @@
|
||||
$result = str_replace($search,$replace,$content);
|
||||
|
||||
foreach ($mypreferences->mods as $name => $info) {
|
||||
/// We only include the corresponding backuplib.php if it hasn't been included before
|
||||
/// This will save some load under PHP5. MDL-8700.
|
||||
/// Once fixed by PHP, we'll delete this hack
|
||||
if (!in_array($name, $includedfiles)) {
|
||||
include_once("$CFG->dirroot/mod/$name/backuplib.php");
|
||||
$includedfiles[] = $name;
|
||||
}
|
||||
//Check if the xxxx_encode_content_links exists
|
||||
include_once("$CFG->dirroot/mod/$name/backuplib.php");
|
||||
$function_name = $name."_encode_content_links";
|
||||
if (function_exists($function_name)) {
|
||||
$result = $function_name($result,$mypreferences);
|
||||
|
||||
+4
-3
@@ -7,10 +7,11 @@
|
||||
//Sets a name/value pair in backup_config table
|
||||
function backup_set_config($name, $value) {
|
||||
if (get_field("backup_config", "name", "name", $name)) {
|
||||
return set_field("backup_config", "value", $value, "name", $name);
|
||||
return set_field("backup_config", "value", addslashes($value), "name", $name);
|
||||
} else {
|
||||
$config = new object();
|
||||
$config->name = $name;
|
||||
$config->value = $value;
|
||||
$config->value = addslashes($value);
|
||||
return insert_record("backup_config", $config);
|
||||
}
|
||||
}
|
||||
@@ -658,7 +659,7 @@
|
||||
}
|
||||
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("196M");
|
||||
raise_memory_limit("192M");
|
||||
|
||||
if (!$backup_unique_code = restore_precheck($destinationcourse,$pathtofile,$errorstr,true)) {
|
||||
mtrace($debuginfo.'Failed restore_precheck (error was '.$errorstr.')');
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("196M");
|
||||
raise_memory_limit("192M");
|
||||
|
||||
//Call the form, depending the step we are
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
$restore->course_startdateoffset = $coursestartdatedateoffset; //change to restore
|
||||
}
|
||||
|
||||
///Enforce SESSION->course_header rewrite (PHP 4.x needed because assigns are by value) MDL-8298
|
||||
$SESSION->course_header = $course_header;
|
||||
|
||||
//If restore session info exists, but we are coming from the form
|
||||
//it has prioriry
|
||||
if (isset($restore) and !empty($fromform)) {
|
||||
@@ -219,7 +222,7 @@
|
||||
} else {
|
||||
$optdimmed = '';
|
||||
}
|
||||
echo "<a $optdimmed href=\"restore.php?course_id=$course->id&launch=check&id=$id&file=$file\">".s($course->fullname).' ('.s($course->shortname).')</a><br />'."\n";
|
||||
echo "<a $optdimmed href=\"restore.php?course_id=$course->id&launch=check&id=$id&file=$file\">".format_string($course->fullname).' ('.format_string($course->shortname).')</a><br />'."\n";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
@@ -260,7 +263,7 @@
|
||||
if ($show_continue_button) {
|
||||
//Print the continue button to execute the restore NOW !!!!
|
||||
//All is prepared !!!
|
||||
echo "<center>";
|
||||
echo "<div style='text-align:center'>";
|
||||
$hidden["launch"] = "execute";
|
||||
$hidden["file"] = $file;
|
||||
$hidden["id"] = $id;
|
||||
@@ -275,7 +278,7 @@
|
||||
}
|
||||
}
|
||||
print_single_button("restore.php", $hidden, get_string("restorecoursenow"),"post");
|
||||
echo "</center>";
|
||||
echo "</div>";
|
||||
} else {
|
||||
//Show error
|
||||
error ("Something was wrong checking restore preferences");
|
||||
|
||||
@@ -54,6 +54,15 @@
|
||||
print_simple_box(get_string("restorefinished"),"center");
|
||||
} else {
|
||||
print_simple_box(get_string("importdatafinished"),"center");
|
||||
$file = $CFG->dataroot . '/'
|
||||
. $SESSION->import_preferences->backup_course
|
||||
. '/backupdata/' . $SESSION->import_preferences->backup_name;
|
||||
if (is_readable($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
else {
|
||||
error_log("import course data: couldn't unlink $file");
|
||||
}
|
||||
unset($SESSION->restore);
|
||||
}
|
||||
print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
|
||||
|
||||
+17
-19
@@ -160,7 +160,8 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
</script>
|
||||
|
||||
<form id="form1" method="post" action="restore.php">
|
||||
<table cellpadding="5">
|
||||
<div>
|
||||
<table cellpadding="5" class="boxaligncenter">
|
||||
<?php
|
||||
|
||||
//First, course destination
|
||||
@@ -291,23 +292,23 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
}
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
$nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
$nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
}
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
$nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
$nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
}
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
$nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
|
||||
$nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
|
||||
}
|
||||
$currentrow = ($currentrow + 1) % 2;
|
||||
}
|
||||
//Line
|
||||
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
|
||||
echo "<tr><td colspan=\"4\">$nonrestmod<hr /></td></tr>";
|
||||
|
||||
//Now print the Metacourse tr
|
||||
echo "<tr>";
|
||||
@@ -415,7 +416,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
echo "</td></tr>";
|
||||
}
|
||||
?>
|
||||
</td></tr></table>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<?php
|
||||
@@ -425,16 +426,12 @@ $xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml";
|
||||
|
||||
$info = restore_read_xml_info($xml_file);
|
||||
|
||||
if ($course->id == SITEID) {
|
||||
$siterolesarray = get_assignable_roles (get_context_instance(CONTEXT_SYSTEM, SITEID), "shortname");
|
||||
$siterolesnamearray = get_assignable_roles (get_context_instance(CONTEXT_SYSTEM, SITEID), "name");
|
||||
} else {
|
||||
$siterolesarray = get_assignable_roles (get_context_instance(CONTEXT_COURSE, $course->id), "shortname");
|
||||
$siterolesnamearray = get_assignable_roles (get_context_instance(CONTEXT_COURSE, $course->id), "name");
|
||||
}
|
||||
// fix for MDL-9068, front page course is just a normal course
|
||||
$siterolesarray = get_assignable_roles (get_context_instance(CONTEXT_COURSE, $course->id), "shortname");
|
||||
$siterolesnamearray = get_assignable_roles (get_context_instance(CONTEXT_COURSE, $course->id), "name");
|
||||
|
||||
echo ('<table width="100%" class="restore-form-instances">');
|
||||
echo ('<tr><td align="right"><b>'.get_string('sourcerole').'</b></td><td align="left"><b>'.get_string('targetrole').'</b></td></tr>');
|
||||
echo ('<tr><td align="right" style="width:50%"><b>'.get_string('sourcerole').'</b></td><td align="left" style="width:50%"><b>'.get_string('targetrole').'</b></td></tr>');
|
||||
|
||||
if ($info->backup_moodle_version < 2006092801) {
|
||||
// 1.6 and below backup
|
||||
@@ -510,11 +507,12 @@ echo ('</table>'); // end of role mappings table
|
||||
|
||||
?>
|
||||
<br />
|
||||
<center>
|
||||
<div style="text-align:center">
|
||||
<input type="hidden" name="id" value="<?php p($id) ?>" />
|
||||
<input type="hidden" name="launch" value="check" />
|
||||
<input type="hidden" name="fromform" value="1" />
|
||||
<input type="submit" value="<?php print_string("continue") ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
+72
-45
@@ -79,9 +79,11 @@
|
||||
if (function_exists($function_name)) {
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "<li>".get_string ("from")." ".get_string("modulenameplural",$name);
|
||||
echo '</li>';
|
||||
}
|
||||
$status = $function_name($restore);
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1462,7 +1464,7 @@
|
||||
//user_course_creators and user_admins
|
||||
if (!empty($info->users)) {
|
||||
// Grab mnethosts keyed by wwwroot, to map to id
|
||||
$mnethosts = get_records('mnethost', '', '',
|
||||
$mnethosts = get_records('mnet_host', '', '',
|
||||
'wwwroot', 'wwwroot, id');
|
||||
|
||||
$languages = get_list_of_languages();
|
||||
@@ -1561,14 +1563,14 @@
|
||||
|
||||
//We need to analyse the AUTH field to recode it:
|
||||
// - if the field isn't set, we are in a pre 1.4 backup and we'll
|
||||
// use $CFG->auth
|
||||
// - if the destination site has any kind of INTERNAL authentication,
|
||||
// then apply it to the new user.
|
||||
// - if the destination site has any kind of EXTERNAL authentication,
|
||||
// then leave the original authentication of the user.
|
||||
// use manual
|
||||
|
||||
if ((! isset($user->auth)) || is_internal_auth($CFG->auth)) {
|
||||
$user->auth = $CFG->auth;
|
||||
if (empty($user->auth)) {
|
||||
if ($CFG->registerauth == 'email') {
|
||||
$user->auth = 'email';
|
||||
} else {
|
||||
$user->auth = 'manual';
|
||||
}
|
||||
}
|
||||
|
||||
//We need to process the POLICYAGREED field to recalculate it:
|
||||
@@ -1995,14 +1997,7 @@
|
||||
foreach ($info as $category) {
|
||||
//Skip empty categories (some backups can contain them)
|
||||
if (!empty($category->id)) {
|
||||
$catrestore = "restore_question_categories";
|
||||
if (function_exists($catrestore)) {
|
||||
//print_object ($category); //Debug
|
||||
$status = $catrestore($category,$restore);
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
}
|
||||
$status = restore_question_categories($category,$restore);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2229,6 +2224,10 @@
|
||||
|
||||
$status = true;
|
||||
|
||||
if (! isset($info['GROUP']['#']['MEMBERS']['0']['#']['MEMBER'])) {
|
||||
//OK, some groups have no members.
|
||||
return $status;
|
||||
}
|
||||
//Get the members array
|
||||
$members = $info['GROUP']['#']['MEMBERS']['0']['#']['MEMBER'];
|
||||
|
||||
@@ -4692,7 +4691,7 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($this->level == 6 && $this->tree[5]!="ROLE_ASSIGNMENTS" && $this->tree[5]!="ROLE_OVERRIDES") {
|
||||
if ($this->level == 6 && $this->tree[5]!="ROLES_ASSIGNMENTS" && $this->tree[5]!="ROLES_OVERRIDES") {
|
||||
switch ($tagName) {
|
||||
case "ROLE":
|
||||
//We've finalized a role, get it
|
||||
@@ -4707,7 +4706,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->level == 7 && $this->tree[5]!="ROLE_ASSIGNMENTS" && $this->tree[5]!="ROLE_OVERRIDES") {
|
||||
if ($this->level == 7) {
|
||||
switch ($tagName) {
|
||||
case "TYPE":
|
||||
$this->info->temprole->type = $this->getContents();
|
||||
@@ -5521,7 +5520,7 @@
|
||||
if ($status){
|
||||
require_once("$CFG->dirroot/backup/bb/restore_bb.php");
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "<li>".get_string("checkingforbbexport");
|
||||
echo "<li>".get_string("checkingforbbexport").'</li>';
|
||||
}
|
||||
$status = blackboard_convert($CFG->dataroot."/temp/backup/".$backup_unique_code);
|
||||
}
|
||||
@@ -5562,7 +5561,7 @@
|
||||
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
//End the main ul
|
||||
echo "</li></ul>";
|
||||
echo "</ul>\n";
|
||||
|
||||
//End the main table
|
||||
echo "</td></tr>";
|
||||
@@ -5603,13 +5602,13 @@
|
||||
//with some hidden fields
|
||||
if ($status) {
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "<br /><center>";
|
||||
echo "<br /><div style='text-align:center'>";
|
||||
$hidden["backup_unique_code"] = $backup_unique_code;
|
||||
$hidden["launch"] = "form";
|
||||
$hidden["file"] = $file;
|
||||
$hidden["id"] = $id;
|
||||
print_single_button("restore.php", $hidden, get_string("continue"),"post");
|
||||
echo "</center>";
|
||||
echo "</div>";
|
||||
}
|
||||
else {
|
||||
if (empty($noredirect)) {
|
||||
@@ -5758,7 +5757,7 @@
|
||||
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>';
|
||||
echo "<li>".get_string("to").": ". format_string($course->fullname) ." (".format_string($course->shortname).")".'</li>';
|
||||
if (($restore->deleting)) {
|
||||
echo "<li>".get_string("deletingexistingcoursedata").'</li>';
|
||||
} else {
|
||||
@@ -5910,6 +5909,10 @@
|
||||
} // no need to return false here, it's recoverable.
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "</li>";
|
||||
}
|
||||
}
|
||||
|
||||
//Now create metacourse info
|
||||
@@ -5917,7 +5920,7 @@
|
||||
//Only to new courses!
|
||||
if ($restore->restoreto == 2) {
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "</li><li>".get_string("creatingmetacoursedata");
|
||||
echo "<li>".get_string("creatingmetacoursedata");
|
||||
}
|
||||
if (!$status = restore_create_metacourse($restore,$xml_file)) {
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
@@ -5984,7 +5987,7 @@
|
||||
//Now create course files as needed
|
||||
if ($status and ($restore->course_files)) {
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "<li>".get_string("copyingcoursefiles")."</li>";
|
||||
echo "<li>".get_string("copyingcoursefiles");
|
||||
}
|
||||
if (!$status = restore_course_files($restore)) {
|
||||
if (empty($status)) {
|
||||
@@ -6003,6 +6006,9 @@
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo "</li>";
|
||||
}
|
||||
}
|
||||
|
||||
//Now create messages as needed
|
||||
@@ -6268,7 +6274,6 @@
|
||||
/*******************************************************************************
|
||||
************* Restore of Roles and Capabilities happens here ******************
|
||||
*******************************************************************************/
|
||||
|
||||
$status = restore_create_roles($restore, $xml_file);
|
||||
$status = restore_roles_settings($restore, $xml_file);
|
||||
|
||||
@@ -6291,12 +6296,17 @@
|
||||
// fix for MDL-6831
|
||||
$newcontext = get_context_instance(CONTEXT_COURSE, $restore->course_id);
|
||||
if (!has_capability('moodle/course:manageactivities', $newcontext)) {
|
||||
if ($legacyteachers = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if ($legacyteacher = array_shift($legacyteachers)) {
|
||||
role_assign($legacyteacher->id, $USER->id, 0, $newcontext->id);
|
||||
}
|
||||
// fix for MDL-9065, use the new config setting if exists
|
||||
if ($CFG->creatornewroleid) {
|
||||
role_assign($CFG->creatornewroleid, $USER->id, 0, $newcontext->id);
|
||||
} else {
|
||||
notify('Could not find a legacy teacher role. You might need your moodle admin to assign a role with editing privilages to this course.');
|
||||
if ($legacyteachers = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if ($legacyteacher = array_shift($legacyteachers)) {
|
||||
role_assign($legacyteacher->id, $USER->id, 0, $newcontext->id);
|
||||
}
|
||||
} else {
|
||||
notify('Could not find a legacy teacher role. You might need your moodle admin to assign a role with editing privilages to this course.');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
@@ -6357,9 +6367,8 @@
|
||||
$stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
|
||||
}
|
||||
///Accessibility: added the 'lang' attribute to $direction, used in theme <html> tag.
|
||||
$language = str_replace('_utf8','',$CFG->lang);
|
||||
$languagehtml = '';
|
||||
$languagehtml .= ' lang="'.$language.'" xml:lang="'.$language.'"';
|
||||
$languagehtml = get_html_lang($dir=true);
|
||||
|
||||
//Write the header in the new logging file
|
||||
fwrite ($restorelog_file,"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
|
||||
fwrite ($restorelog_file," \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> ");
|
||||
@@ -6439,10 +6448,19 @@
|
||||
if (!empty($restore->rolesmapping)) {
|
||||
$rolemappings = $restore->rolesmapping;
|
||||
}
|
||||
// $info->roles will be empty for backups pre 1.7
|
||||
if (isset($info->roles) && $info->roles) {
|
||||
foreach ($info->roles as $oldroleid=>$roledata) {
|
||||
|
||||
/// first we check if the roles are in the mappings
|
||||
foreach ($info->roles as $oldroleid=>$roledata) {
|
||||
if (empty($restore->rolesmapping)) {
|
||||
// if this is empty altogether, we came from import or there's no roles used in course at all
|
||||
// in this case, write the same oldid as this is the same site
|
||||
// no need to do mapping
|
||||
$status = backup_putid($restore->backup_unique_code,"role",$oldroleid,
|
||||
$oldroleid); // adding a new id
|
||||
continue; // do not create additonal roles;
|
||||
}
|
||||
// first we check if the roles are in the mappings
|
||||
// if so, we just do a mapping i.e. update oldids table
|
||||
if (isset($rolemappings[$oldroleid]) && $rolemappings[$oldroleid]) {
|
||||
$status = backup_putid($restore->backup_unique_code,"role",$oldroleid,
|
||||
@@ -6513,7 +6531,13 @@
|
||||
}
|
||||
$course = restore_read_xml_course_header($xmlfile);
|
||||
|
||||
if (!empty($course->roleassignments)) {
|
||||
if (!isset($restore->rolesmapping)) {
|
||||
$isimport = true; // course import from another course, or course with no role assignments
|
||||
} else {
|
||||
$isimport = false; // course restore with role assignments
|
||||
}
|
||||
|
||||
if (!empty($course->roleassignments) && !$isimport) {
|
||||
$courseassignments = $course->roleassignments;
|
||||
|
||||
foreach ($courseassignments as $oldroleid => $courseassignment) {
|
||||
@@ -6524,7 +6548,7 @@
|
||||
* Restoring from course level overrides *
|
||||
*****************************************************/
|
||||
|
||||
if (!empty($course->roleoverrides)) {
|
||||
if (!empty($course->roleoverrides) && !$isimport) {
|
||||
$courseoverrides = $course->roleoverrides;
|
||||
foreach ($courseoverrides as $oldroleid => $courseoverride) {
|
||||
// if not importing into exiting course, or creating new role, we are ok
|
||||
@@ -6549,11 +6573,12 @@
|
||||
foreach ($secs as $section) {
|
||||
if (isset($section->mods)) {
|
||||
foreach ($section->mods as $modid=>$mod) {
|
||||
if (isset($mod->roleassignments)) {
|
||||
if (isset($mod->roleassignments) && !$isimport) {
|
||||
foreach ($mod->roleassignments as $oldroleid=>$modassignment) {
|
||||
restore_write_roleassignments($restore, $modassignment->assignments, "course_modules", CONTEXT_MODULE, $modid, $oldroleid);
|
||||
}
|
||||
}
|
||||
// role overrides always applies, in import or backup/restore
|
||||
if (isset($mod->roleoverrides)) {
|
||||
foreach ($mod->roleoverrides as $oldroleid=>$modoverride) {
|
||||
restore_write_roleoverrides($restore, $modoverride->overrides, "course_modules", CONTEXT_MODULE, $modid, $oldroleid);
|
||||
@@ -6575,13 +6600,14 @@
|
||||
$blocks = restore_read_xml_blocks($xmlfile);
|
||||
if (isset($blocks->instances)) {
|
||||
foreach ($blocks->instances as $instance) {
|
||||
if (isset($instance->roleassignments)) {
|
||||
if (isset($instance->roleassignments) && !$isimport) {
|
||||
foreach ($instance->roleassignments as $oldroleid=>$blockassignment) {
|
||||
restore_write_roleassignments($restore, $blockassignment->assignments, "block_instance", CONTEXT_BLOCK, $instance->id, $oldroleid);
|
||||
|
||||
}
|
||||
}
|
||||
if (isset($instance->roleoverrides)) {
|
||||
// likewise block overrides should always be restored like mods
|
||||
if (isset($instance->roleoverrides)) {
|
||||
foreach ($instance->roleoverrides as $oldroleid=>$blockoverride) {
|
||||
restore_write_roleoverrides($restore, $blockoverride->overrides, "block_instance", CONTEXT_BLOCK, $instance->id, $oldroleid);
|
||||
}
|
||||
@@ -6597,7 +6623,7 @@
|
||||
echo "<li>".get_string("creatinguserroles").'</li>';
|
||||
}
|
||||
$info = restore_read_xml_users($restore, $xmlfile);
|
||||
if (!empty($info->users)) {
|
||||
if (!empty($info->users) && !$isimport) { // no need to restore user assignments for imports (same course)
|
||||
//For each user, take its info from backup_ids
|
||||
foreach ($info->users as $userid) {
|
||||
$rec = backup_getid($restore->backup_unique_code,"user",$userid);
|
||||
@@ -6625,7 +6651,8 @@
|
||||
foreach ($assignments as $assignment) {
|
||||
|
||||
$olduser = backup_getid($restore->backup_unique_code,"user",$assignment->userid);
|
||||
if (!$olduser || $olduser->info == "notincourse") { // it's possible that user is not in the course
|
||||
//Oh dear, $olduser... can be an object, $obj->string or bool!
|
||||
if (!$olduser || (is_string($olduser->info) && $olduser->info == "notincourse")) { // it's possible that user is not in the course
|
||||
continue;
|
||||
}
|
||||
$assignment->userid = $olduser->new_id; // new userid here
|
||||
@@ -6738,4 +6765,4 @@
|
||||
fclose($restorelog);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("196M");
|
||||
raise_memory_limit("192M");
|
||||
|
||||
echo "<pre>\n";
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
|
||||
$courses = get_records("course");
|
||||
foreach ($courses as $course) {
|
||||
echo "Start course ".$course->fullname;
|
||||
echo "Start course ". format_string($course->fullname);
|
||||
$preferences = schedule_backup_course_configure($course);
|
||||
if ($preferences && $status) {
|
||||
$status = schedule_backup_course_execute($preferences);
|
||||
}
|
||||
if ($status && $preferences) {
|
||||
echo "End course ".$course->fullname." OK\n\n";
|
||||
echo "End course ". format_string($course->fullname)." OK\n\n";
|
||||
} else {
|
||||
echo "End course ".$course->fullname." FAIL\n\n";
|
||||
echo "End course ". format_string($course->fullname)." FAIL\n\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
/// database (backup_version) to determine whether upgrades should
|
||||
/// be performed (see db/backup_*.php)
|
||||
|
||||
$backup_version = 2006082304; // The current version is a date (YYYYMMDDXX)
|
||||
$backup_release = "1.8dev"; // User-friendly version number
|
||||
$backup_version = 2007022100; // The current version is a date (YYYYMMDDXX)
|
||||
$backup_release = "1.8Beta"; // User-friendly version number
|
||||
|
||||
?>
|
||||
|
||||
-1232
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user