Compare commits
1345 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 81716d0d33 | |||
| 658bf42b26 | |||
| 3ee8f1715f | |||
| 2334e9083c | |||
| 4a6a574f2a | |||
| a205123f06 | |||
| a6ee2f5e7d | |||
| 8590fd913d | |||
| e7f72d1658 | |||
| 64eed73fa2 | |||
| 381ae36075 | |||
| 1bdeb2ca8e | |||
| 8af2a809fb | |||
| 5d224d17b6 | |||
| f001154b33 | |||
| bca7452938 | |||
| b366308091 | |||
| f38485140c | |||
| 258be26525 | |||
| 5f4c712ea8 | |||
| 6d9aa82c99 | |||
| 4c5686d97f | |||
| d688c342ad | |||
| 3f676beac0 | |||
| 978962c8bb | |||
| 87cc153beb | |||
| 7647e09126 | |||
| 0fcd21c3bc | |||
| b09069a4c7 | |||
| 576fd161a0 | |||
| 16cba4cf88 | |||
| fc55b4e900 | |||
| ab8c78b03a | |||
| ba6c4a8701 | |||
| 6337086aca | |||
| 111bfff48a | |||
| 31d7714a84 | |||
| 68225f50b4 | |||
| b9f0af5fb0 | |||
| 7fe2220fc0 | |||
| a26d994d2b | |||
| e7d1f700d9 | |||
| 9fc3e0ebef | |||
| cee7b95a10 | |||
| f933b27c32 | |||
| 16ba73512e | |||
| 84a8415baf | |||
| f6590fb484 | |||
| 3662bce5b4 | |||
| 1dd2451954 | |||
| 8d2accb64c | |||
| 02e44e7cf4 | |||
| 8df45f47bd | |||
| 399266ce40 | |||
| 03fa434bb3 | |||
| 644f6213f1 | |||
| 8fad496688 | |||
| c451c1f6bd | |||
| c8ddb345b9 | |||
| 05c7ec6f2b | |||
| f7a6049e57 | |||
| ff27a09eca | |||
| a166e72e43 | |||
| 4848d55a9e | |||
| 0be7c25ebe | |||
| 2f6c832d5c | |||
| a2c7397c42 | |||
| 4565e9cc0a | |||
| b1106eb5ba | |||
| 5f6604b578 | |||
| 018dcb996d | |||
| 131f438648 | |||
| bbc2e4226a | |||
| ab34a057ed | |||
| 092c819e68 | |||
| 20598e0da3 | |||
| 06e9af99e7 | |||
| df415fbf08 | |||
| 8bcabc74e2 | |||
| 57bcdda9f5 | |||
| d03e4db1b8 | |||
| 8a600d7d1d | |||
| 3926deafe1 | |||
| c4ad9158e3 | |||
| aa140aabfd | |||
| 0535cadae5 | |||
| a5eb9f335f | |||
| b391b14bda | |||
| 09026b19d9 | |||
| 893e0c5c0b | |||
| eefa6d6e06 | |||
| 3c382acc28 | |||
| bf442dc9d6 | |||
| 0c59a23c67 | |||
| 7a6112792c | |||
| 6a602d47e0 | |||
| 5881bb7e3c | |||
| 40343df7fd | |||
| 783da26290 | |||
| 73fafc3886 | |||
| 522f608d02 | |||
| 12c55f3cd4 | |||
| bb515027b5 | |||
| fe3b0f3a2f | |||
| 5c0567b4cd | |||
| 8fdd5ab2b3 | |||
| 7ba7461530 | |||
| 47e9035598 | |||
| 7134ebc80b | |||
| feffd1dffe | |||
| 0aa35815c4 | |||
| f897f346a3 | |||
| ac722cc42b | |||
| 219633ea2b | |||
| 5325f8b8cf | |||
| b39cadbfe7 | |||
| 020181047d | |||
| a3152e449d | |||
| 02997ce175 | |||
| 499c23e8fc | |||
| d8e2e28044 | |||
| 1cb2266ef7 | |||
| 40e5eb1b33 | |||
| 7f2a3e678e | |||
| 4b2b7a7110 | |||
| 6687be174a | |||
| f5ca7ebe1a | |||
| f698f3f394 | |||
| 6157b82c7b | |||
| 7c934d06ed | |||
| b088919164 | |||
| 849f614bd1 | |||
| dec96d4f2c | |||
| b2878fc5ae | |||
| ab48c1bb53 | |||
| ec3db5a310 | |||
| 31861ff29c | |||
| 7a1205eea9 | |||
| 70d9c95acf | |||
| 0e3e960a33 | |||
| d805c3462e | |||
| c3219da409 | |||
| c7ba7904cb | |||
| be23a53ca9 | |||
| 79da6d8717 | |||
| 931ade40e3 | |||
| f64fb7b192 | |||
| 353d033843 | |||
| 35d606e6fa | |||
| 11697b48ea | |||
| 60ffb53a7d | |||
| b5987b0f49 | |||
| b1f505771e | |||
| 91d7f813e5 | |||
| 304d7785ca | |||
| 7e092fdaed | |||
| 3f50cab58d | |||
| 8d5b052f35 | |||
| 844bad05a9 | |||
| ad03ae446e | |||
| 043b94f66d | |||
| b95c3ab896 | |||
| 779a4a8da4 | |||
| 54242af0d6 | |||
| e9564a5a80 | |||
| 240aca4b34 | |||
| 5d0f5a599b | |||
| 3ee236820a | |||
| 17ec8eb684 | |||
| 8c5b0c41bb | |||
| 730cb6bac3 | |||
| 6a6681294a | |||
| 96376e9a4f | |||
| 96112b5224 | |||
| f2deadb30c | |||
| 87d8623181 | |||
| 4c94c21b11 | |||
| fd2f02d4cd | |||
| 775f689b0f | |||
| c563a9a0d1 | |||
| cc7fa0dc05 | |||
| 729035fdaa | |||
| 76bf541df8 | |||
| 41a03b45f0 | |||
| d41947c6be | |||
| c525b27592 | |||
| 713386aadb | |||
| fd43f7d026 | |||
| 48cbf566bb | |||
| cd86c938b2 | |||
| ca2129424f | |||
| a4ad03f175 | |||
| 8b50d2a76e | |||
| 06cffaf0bb | |||
| bbf9b1624d | |||
| 2563c5ef7b | |||
| 6879123761 | |||
| eab79dc13d | |||
| 958facf055 | |||
| 14159d0960 | |||
| 07b586eaa3 | |||
| 7170501293 | |||
| 4d01ada343 | |||
| a6ccb416f1 | |||
| fcb12a1e0c | |||
| c39c66a5e8 | |||
| 785ae439eb | |||
| d348c53f1f | |||
| 880fd2146c | |||
| b9846a9b9e | |||
| 7641819df0 | |||
| 740aa005dc | |||
| c061b8d2a5 | |||
| 9ba291e88d | |||
| 67d5ab6dc1 | |||
| 05c1cfba93 | |||
| 71f64e123b | |||
| bf2919bf84 | |||
| 30739c3daf | |||
| bfe42924da | |||
| 67fb6d3aaf | |||
| 69ec0a8b1d | |||
| 5c219ea46d | |||
| 60a60432a1 | |||
| 3a4c2fd089 | |||
| 610603be4d | |||
| 7adf67875d | |||
| cf565fd7cf | |||
| 33de9f7bdc | |||
| 17df1ae4bd | |||
| 455d308f5d | |||
| ae384ef160 | |||
| 6bebcf8d72 | |||
| c6a0f9d5bf | |||
| e48feed988 | |||
| 3e54b808bc | |||
| 0817d5cac0 | |||
| ce729f49c8 | |||
| 0f192e2cd6 | |||
| 01a16f7e5e | |||
| 5aca97a20a | |||
| 476fd9c716 | |||
| 52376d940f | |||
| d288fa5255 | |||
| a53cef7e80 | |||
| d8eece23c9 | |||
| 46a244605d | |||
| e808d25f56 | |||
| ada728e24d | |||
| 5a74165523 | |||
| 9a2efc9fb0 | |||
| 76c1650d02 | |||
| b086c2b527 | |||
| edea91f37b | |||
| b13f7b84ec | |||
| ce3b1d1f7d | |||
| 4f446b2e36 | |||
| 21951923a5 | |||
| 16a0e6f05c | |||
| e9d3eca323 | |||
| 72a2547d05 | |||
| daec2fede2 | |||
| ae078a9809 | |||
| 0a9f61b55f | |||
| ac4f6d455f | |||
| fa6a30b75c | |||
| 4bcc7ebfd6 | |||
| 56a800aac5 | |||
| 6cdbd5d52a | |||
| 64900c048e | |||
| fe930cf3ca | |||
| a0deb5db60 | |||
| 6a7ce0c1ab | |||
| 170a9c4612 | |||
| 393c9b4ff4 | |||
| 3551966092 | |||
| f11d6df519 | |||
| af478c0b2b | |||
| 9025fec405 | |||
| 05b2871dfa | |||
| d06863d95f | |||
| df52003fb1 | |||
| 14014fb7e1 | |||
| 4784696533 | |||
| b294bc4b1d | |||
| 543009a54d | |||
| 667d2f2a86 | |||
| 23e3e468aa | |||
| d0ef834745 | |||
| 4f6ae69e0e | |||
| efead3b909 | |||
| 2f518143de | |||
| be912538fa | |||
| 232d36dffa | |||
| 215e628dcf | |||
| 32ad57746b | |||
| 54157606e0 | |||
| a3a4cd3ed6 | |||
| 537718f85a | |||
| 9d85990f62 | |||
| 6d3566f8d5 | |||
| 5867bfb50e | |||
| cfb9c52577 | |||
| 7e6b0b3b6e | |||
| 767141c19e | |||
| 92ce3481fc | |||
| de1a5345cb | |||
| d6be31eeed | |||
| 6afe855886 | |||
| 98a792faaf | |||
| bbc0d9abbf | |||
| 9f71c9e713 | |||
| 6c8e8b5ed4 | |||
| 3d9f0f81d6 | |||
| 9b09f7d0cd | |||
| 319b375ecc | |||
| 5c2ba38c45 | |||
| 5f94c13b6b | |||
| e825f27967 | |||
| a9c2c8fd8f | |||
| eb7ec77d68 | |||
| ac6e435422 | |||
| a414246dc9 | |||
| 729fbeee94 | |||
| 1f49a7b780 | |||
| 0915679c36 | |||
| 52b538621e | |||
| ea6e952d88 | |||
| 95f6c01b03 | |||
| e51de1e846 | |||
| ab74168b2d | |||
| d94dc588ab | |||
| d6513bbb0c | |||
| 0f4f911059 | |||
| e865ded4ba | |||
| 0cb29cc411 | |||
| 4f5dbd132c | |||
| f5fb84cee7 | |||
| 7aab220e4b | |||
| fdcdc04730 | |||
| 3b8bad6ff0 | |||
| 000969becd | |||
| 2fb7c49f17 | |||
| 1f33691c86 | |||
| 49543158f7 | |||
| 851a89ff1b | |||
| 813ec7ad65 | |||
| fce1ce13c8 | |||
| 266fbe1a8a | |||
| 5f350e8f6d | |||
| 01d799665d | |||
| b879effb4a | |||
| a918234e91 | |||
| 11a876e1b6 | |||
| 4105fe9dd2 | |||
| 581d7b4959 | |||
| bb19372c0f | |||
| 068be67d83 | |||
| 1e2fedeef0 | |||
| ea23100a02 | |||
| 2bc269fd7b | |||
| be4c89b86a | |||
| 674b30f5f7 | |||
| 39c4f15a40 | |||
| b0778a76c3 | |||
| a615cc7bb6 | |||
| 3868b9c666 | |||
| 465fd00e04 | |||
| 8a230a7d96 | |||
| 1215e52299 | |||
| d15cbab76f | |||
| 93d64ea469 | |||
| 1ea7c62794 | |||
| b37eb1bf00 | |||
| f50f74f6e4 | |||
| ff82802366 | |||
| 3bb49201b1 | |||
| 2fe2985a53 | |||
| 8140c67e45 | |||
| a6d71a2199 | |||
| c0ba103ca7 | |||
| cda45e5506 | |||
| 5ade559e8e | |||
| 4fc61176b9 | |||
| dfec7b013f | |||
| 592188b42c | |||
| ffb71387cb | |||
| 59345eb4ec | |||
| b2a47e2052 | |||
| 228b823898 | |||
| 59cd767a99 | |||
| 46772d8c60 | |||
| 7d99d6959e | |||
| 81ed361792 | |||
| 2627a658f8 | |||
| d342c76370 | |||
| d7c8a46bc5 | |||
| 9f0b8269ac | |||
| eb347b6b68 | |||
| 1b502431a8 | |||
| dfe5f88b3b | |||
| b4bee933da | |||
| afbe3de8cf | |||
| 04aa5b2de1 | |||
| c4c8f73c4a | |||
| 8cc242516e | |||
| 8980a4e8db | |||
| 24a39b1761 | |||
| 984a8bf349 | |||
| 107b010b43 | |||
| ea563f8f99 | |||
| 3565715c76 | |||
| 005103e0bc | |||
| 141097ff80 | |||
| d6545aefbc | |||
| c6bcd06aba | |||
| 02fee14e28 | |||
| 82e8e7f569 | |||
| 75da62deee | |||
| 519bd9342a | |||
| 61ae5d36ca | |||
| b1834f2dde | |||
| 6f40f198d2 | |||
| e6622eda6a | |||
| c45855e551 | |||
| 7db29e6783 | |||
| 10332943ca | |||
| d67257815d | |||
| c53987bbb8 | |||
| aa0959690c | |||
| 890a2cfeea | |||
| c5be7d8e8e | |||
| 737c4885be | |||
| 3fe1c56cdd | |||
| b3afe8244a | |||
| 52ff6a7f44 | |||
| d22d31c659 | |||
| edffca1558 | |||
| 28408ed2ac | |||
| d4ccfc2a2b | |||
| 5f5ea8cc4c | |||
| a36175db4c | |||
| 6db95aa730 | |||
| 3e9ca9fbc5 | |||
| bf32194357 | |||
| 3b777608ac | |||
| 3920667ee3 | |||
| ea914a66ae | |||
| d565341a2f | |||
| ea65b07cdd | |||
| 6b14fdcb1d | |||
| 482fa9f6c6 | |||
| ca16eaeb31 | |||
| f855f6062b | |||
| 5d0d5d5ac5 | |||
| 31d6331615 | |||
| dc95f4a11b | |||
| 9d6f5d42eb | |||
| 6d41991acc | |||
| 46956de552 | |||
| a273084d7a | |||
| 81f186b47a | |||
| df48be741a | |||
| 8de14dc72b | |||
| 28ba0d55cc | |||
| 8809fee944 | |||
| b86fc0e2a6 | |||
| 9655b654a5 | |||
| 6492992616 | |||
| 9a652ddb2b | |||
| f343161392 | |||
| b72c80db7e | |||
| 95abee03e6 | |||
| 028677d7b2 | |||
| 9d2dda0f85 | |||
| e313ef4476 | |||
| d14c1e0687 | |||
| dc0dc7d5dd | |||
| 2b83b7f98b | |||
| f0eec3b641 | |||
| e8a0fc9a4f | |||
| e9ececbb1e | |||
| 5352ceba67 | |||
| dc2590e587 | |||
| e13d05801c | |||
| 16aefd75fb | |||
| 667e2e0293 | |||
| 7716babeb2 | |||
| 6d21fd37f2 | |||
| 6901fa7955 | |||
| e209e0b09e | |||
| f5e82bc7f4 | |||
| 026bcf8ce1 | |||
| 7aaedff8de | |||
| 2656b1351f | |||
| 81a383ca7a | |||
| f8bccb148a | |||
| 540bab47d4 | |||
| 30f89d6833 | |||
| f9d5fd3b3c | |||
| f9ce68ee7f | |||
| c0605295bd | |||
| 85093cf4f9 | |||
| 0830bae4d7 | |||
| 1ba3960285 | |||
| 6459f225b8 | |||
| 1b5910c4a5 | |||
| a54b8dd3af | |||
| 667ab3252b | |||
| b1992e65cf | |||
| 10a95b432c | |||
| ad08fdc277 | |||
| 38e5dbf319 | |||
| ec2a28a607 | |||
| 278a229c25 | |||
| 3d89198946 | |||
| 78e0146055 | |||
| 6eb6cd8753 | |||
| fbca88e692 | |||
| 2953d5e865 | |||
| 86e6076b3b | |||
| c3357723de | |||
| 09368e3938 | |||
| a95ae47bdf | |||
| 50d673157b | |||
| 65eed52ded | |||
| d1db7bee92 | |||
| 39b5b3fa2a | |||
| e317d04919 | |||
| dff0db9ad5 | |||
| 746546a8f8 | |||
| b3cc742cf9 | |||
| c4c575979e | |||
| 3399a22c9f | |||
| 4dd0497164 | |||
| 826293c75b | |||
| 5a9126f75a | |||
| a2f1ef3067 | |||
| 266cc04fe7 | |||
| b328523cc1 | |||
| a5c411d4c2 | |||
| 583a7283e9 | |||
| fc613dff69 | |||
| 4d4267739c | |||
| a282d0ffda | |||
| 87b490dfc6 | |||
| 580f2fbc07 | |||
| 047d30d1eb | |||
| 1e22bc9c04 | |||
| e40488f80c | |||
| c37053ea2f | |||
| e6c136e1bf | |||
| 1dea7ebb04 | |||
| f99d236832 | |||
| dbe0be0059 | |||
| 3b0fb381ea | |||
| 61367e6417 | |||
| 719e7b04f8 | |||
| 5094d166b7 | |||
| dd8d521d91 | |||
| 81cdaada93 | |||
| 7cfb83477c | |||
| 638f95b1ff | |||
| 88478a664f | |||
| 67b0821af9 | |||
| e1c4617441 | |||
| 3395f2d67e | |||
| 41ab15fba5 | |||
| 1fc49f0019 | |||
| 2a40936834 | |||
| 13df5aeef3 | |||
| 7acaa63d09 | |||
| feffa4e695 | |||
| fec5a6a63f | |||
| cf055081ef | |||
| 00d26a208b | |||
| d4269e95c0 | |||
| 91162b4688 | |||
| a7eedb343c | |||
| f861185a4a | |||
| b7637a30d4 | |||
| c032b59db9 | |||
| 312447111c | |||
| 3af4a3653c | |||
| 847179dc91 | |||
| bc3df42048 | |||
| c7da6f7a8f | |||
| e6cf424727 | |||
| e05566015e | |||
| 3c7f99a447 | |||
| 7d6cac54f3 | |||
| 3ba2985594 | |||
| b369ff55fe | |||
| 718ad19f47 | |||
| 9dd0b37817 | |||
| 3269b238a7 | |||
| 6b708b9844 | |||
| 978704f095 | |||
| d2802df553 | |||
| 44a334d874 | |||
| d61bf02f18 | |||
| 4dddd64b5f | |||
| fe8bc4c9a5 | |||
| cefc7e817e | |||
| 2ab968e937 | |||
| 32dcc87484 | |||
| fc6a91994e | |||
| 02a7699f0d | |||
| 03aa0dfa10 | |||
| 9e0a08bd28 | |||
| c20b762a06 | |||
| 3c8a606d85 | |||
| 546be6dd89 | |||
| 96e301a7c9 | |||
| 9ddb00e600 | |||
| 29507631a9 | |||
| 801e1f0a3e | |||
| bf3bc898ac | |||
| a00283d6cd | |||
| c1d9daca3c | |||
| 7226ce02b1 | |||
| da63e99627 | |||
| 3abe21ab94 | |||
| e1122620b5 | |||
| 2408867e8c | |||
| 96192c4459 | |||
| 77cff58927 | |||
| eece3a331a | |||
| f24f17c5bb | |||
| 2386e97f89 | |||
| d6a6331129 | |||
| c9548d4a5d | |||
| de38e2621d | |||
| 1acfbce5b6 | |||
| 5a25f84d25 | |||
| 8b72b41bf9 | |||
| b610b4c2fd | |||
| dea49bdd6c | |||
| 99de5ed02b | |||
| cb77b5b67f | |||
| a625debc38 | |||
| 15c715211e | |||
| 980d545f4f | |||
| 9ecb1bd3a4 | |||
| c5b6666eaf | |||
| 63a77d2d39 | |||
| c76f49060f | |||
| 7c81b6e273 | |||
| 752e1c2b62 | |||
| 67b69ce15b | |||
| cdb0ca8315 | |||
| f475564878 | |||
| 0bf2925db8 | |||
| 5e776a02ad | |||
| c6eed09730 | |||
| 340191ded7 | |||
| 085e317dbf | |||
| be09831ac3 | |||
| dae73c05e9 | |||
| bc700e6559 | |||
| c05eca327c | |||
| da5fb074c3 | |||
| b1db099b7e | |||
| 44ce983d45 | |||
| 66a68c1739 | |||
| 1365bacde6 | |||
| 52c018a0b5 | |||
| 4b85b71712 | |||
| f5cbbecaf5 | |||
| 72e5815533 | |||
| 434802d5ce | |||
| 34d52ad7d2 | |||
| d62413e869 | |||
| 329f046798 | |||
| 29cbd93a45 | |||
| aa6fbca550 | |||
| 8daaf761c3 | |||
| 8f202463d5 | |||
| b4e3b12234 | |||
| e64984a0bb | |||
| 8ef3483b60 | |||
| f07e21dec4 | |||
| f561b68011 | |||
| 46d552b810 | |||
| e52c4f2231 | |||
| c4dfc485eb | |||
| ef49e5c301 | |||
| 8a205861e0 | |||
| 0305fe824d | |||
| ffb410df03 | |||
| b398d5ee2a | |||
| 73f131b7a6 | |||
| e4be3d5943 | |||
| 432d39026d | |||
| 54a67a5921 | |||
| 03fd6a965e | |||
| 0d0baabf2c | |||
| 2d0b30a028 | |||
| adaf39283c | |||
| 754786f1be | |||
| a3b0dbfa80 | |||
| 90707adb7f | |||
| b8a0fb13a3 | |||
| aa9f961b7d | |||
| bad357c414 | |||
| ea6003eb8a | |||
| b60aa549fc | |||
| b6f64be2a5 | |||
| 075a591656 | |||
| 0ece16e90c | |||
| 036d3c1f90 | |||
| 6eff984aee | |||
| 264d4e0b9a | |||
| 1495667946 | |||
| 8cc7286ccc | |||
| f5cdd4d133 | |||
| b2d0ca3b7c | |||
| 000cc405ba | |||
| e384fb7b73 | |||
| 49e16355c2 | |||
| c750592ac4 | |||
| 6a3461ad1c | |||
| 746665838a | |||
| f8430195d9 | |||
| ef4145f6ae | |||
| f2cc50f192 | |||
| 4c0e951049 | |||
| 0fdddefbaa | |||
| d4120c3d7c | |||
| 509139373e | |||
| 78e72ed16b | |||
| e6829515b0 | |||
| e582b65e30 | |||
| a2631c99d9 | |||
| 01cf7d2ebc | |||
| a4ef9df2d7 | |||
| 9d5b689c8a | |||
| b9287b2fba | |||
| d48f938420 | |||
| ddde5a8c82 | |||
| c0f728ba9e | |||
| 6908193151 | |||
| 617778f2d3 | |||
| 4c31e7cfba | |||
| d4be5253aa | |||
| 2d8cf6799a | |||
| c9082a8c2f | |||
| f82c2d428a | |||
| 2ea9027bc4 | |||
| 08b3606390 | |||
| 754b76fe65 | |||
| 3ac1dedc35 | |||
| 1e5a2bf584 | |||
| 8f6dcdbaa4 | |||
| 5c34d1e3a4 | |||
| 8fb2f0fa1e | |||
| ac234d0262 | |||
| fe32b83bbf | |||
| 76a359ba93 | |||
| 7563a073c3 | |||
| d106f1d9ae | |||
| 9a9a2907c2 | |||
| c605097983 | |||
| 25f3420857 | |||
| 5fcda72588 | |||
| e00f0f9f51 | |||
| 548daac7d9 | |||
| 19bbe230f6 | |||
| 66ea5000db | |||
| 706e019764 | |||
| 1b7f43a40a | |||
| 247612cfe7 | |||
| 049100796f | |||
| b1ca03e9cf | |||
| cdf198d345 | |||
| 70e5e91e9e | |||
| 7470fb3782 | |||
| d831f93c73 | |||
| 1862b9eb54 | |||
| 0d1a40f00a | |||
| 31ce4b538c | |||
| df103e8212 | |||
| c363d9d11f | |||
| 9314930280 | |||
| 43f2302fdf | |||
| c4eb7e254f | |||
| cd4b225bd0 | |||
| f84148d015 | |||
| d57d61e3a7 | |||
| b365072d7c | |||
| 687f38368e | |||
| 9eee5e0559 | |||
| 44ac5310a8 | |||
| 068e57cebc | |||
| b4b7572b9a | |||
| 14bdb2387a | |||
| 02986c8002 | |||
| 7169069bd5 | |||
| 45930f2db5 | |||
| 3e7542449b | |||
| 7a361c8b55 | |||
| 55271c3047 | |||
| 08c17336a7 | |||
| 4e94d2608b | |||
| ff20ee79f6 | |||
| d92a53d182 | |||
| c0f271aa5c | |||
| 12faa2684e | |||
| f8b8aa347b | |||
| 111f984300 | |||
| ab202116b9 | |||
| f02ca41cca | |||
| 06334957fa | |||
| 66d323459e | |||
| 7dd3b70b10 | |||
| 610b9de6f7 | |||
| d7466bdecb | |||
| 44996d00f9 | |||
| 38620c460b | |||
| 5b337cdf3b | |||
| 38972a40a4 | |||
| 8b2fc31ce0 | |||
| 2fdb54b819 | |||
| 0ca1825cab | |||
| ea81ca5f6d | |||
| 6c891932c0 | |||
| 9f9f92c6df | |||
| 1924074c76 | |||
| 38b68c5d6f | |||
| 86bce68fa8 | |||
| 95dbc030a8 | |||
| 2b051f1c8e | |||
| ee0e5d57e2 | |||
| 663f70777a | |||
| 8f8e4f01b0 | |||
| 652fd67246 | |||
| f9a14cc720 | |||
| 5f2c35db18 | |||
| 47623d4f8f | |||
| 5443a18b8f | |||
| 4c398dda96 | |||
| 79ba7581de | |||
| 5a4d292bca | |||
| c2a96d6b32 | |||
| e10ed4f09f | |||
| 14c7248d3c | |||
| a01b257195 | |||
| dc1dc6e973 | |||
| 035aa1848c | |||
| 734d2c9887 | |||
| 2f05b46ec9 | |||
| a59cbb7851 | |||
| 811c88b32f | |||
| 2a231ed650 | |||
| c4e78a1b60 | |||
| 68fefdbe14 | |||
| 49220fa70c | |||
| 4270bba267 | |||
| 01a660a583 | |||
| 3f3960656d | |||
| 434f33c00a | |||
| 402eb657a6 | |||
| 40f1246b14 | |||
| de2146b276 | |||
| 73f8658c36 | |||
| bcdfe14e02 | |||
| eaa50dbc83 | |||
| ac68f7ffc8 | |||
| acf0f21ab1 | |||
| ecc114ee3b | |||
| f879140423 | |||
| 08ffd31db1 | |||
| 49c4b1f779 | |||
| 498d403283 | |||
| 56a4ed732a | |||
| 33ff2cca85 | |||
| fced815cd7 | |||
| db11e52dec | |||
| b35e8568ff | |||
| 7750f58e0c | |||
| f2e19ba41d | |||
| d686bf500b | |||
| a09b86a693 | |||
| 0d3cbf4cca | |||
| 1b27d92ad4 | |||
| 89600ce15f | |||
| 34afe40fb5 | |||
| c74a276913 | |||
| a2da49f38b | |||
| 750ab759ed | |||
| b49d73511b | |||
| e79ddee2ad | |||
| 03f06a1412 | |||
| 9223049919 | |||
| 54d0590b47 | |||
| eb58acca4d | |||
| 7d8f674dea | |||
| f3e48e6ef0 | |||
| 66fef9f99f | |||
| 48d38fad63 | |||
| 878ece7eca | |||
| 04222f70a3 | |||
| 5ca400f257 | |||
| 071df54ffd | |||
| dd98f2e261 | |||
| 1042139455 | |||
| a42fcc51cb | |||
| 9f44d972c7 | |||
| 5c71840819 | |||
| 7ba3fb64c9 | |||
| cfe22ac921 | |||
| eca6a3b781 | |||
| 2d05c39303 | |||
| a43d392c69 | |||
| d60131c3c9 | |||
| f6e653e06a | |||
| bc43adf16d | |||
| b1e6dcb26c | |||
| ce9f2be2f9 | |||
| 86b32d51d9 | |||
| 7d2e5b6595 | |||
| 4e2767f8e0 | |||
| 17654e3845 | |||
| 63dddf351a | |||
| 2e6d42735f | |||
| 5a99c0de4d | |||
| de5aabd2d2 | |||
| 0f61744597 | |||
| 832ead4969 | |||
| 28e30091f0 | |||
| 25786a263a | |||
| caf7ccd44f | |||
| 2fafa4bf31 | |||
| a53f918172 | |||
| b9fcddd16d | |||
| 789a2500eb | |||
| 3e9b5d5a90 | |||
| 858156a995 | |||
| a38e24a544 | |||
| a5e3644bd2 | |||
| 0b949a6d0c | |||
| 1f3eb3191a | |||
| 4028fcb159 | |||
| 37208cd23a | |||
| dde4495df4 | |||
| dc8791f367 | |||
| 207190aa87 | |||
| c9d4e6da89 | |||
| 3db3acfb99 | |||
| 69ae05837c | |||
| ecb1e78aaf | |||
| a7e838796a | |||
| fe2874294c | |||
| 3c72e2f9c9 | |||
| e01b5c0e77 | |||
| b5fdd4c60a | |||
| 842b894b91 | |||
| 67c6f56f05 | |||
| 7fb92a3388 | |||
| 59e6addbc9 | |||
| 2e43b5d987 | |||
| 319aa49306 | |||
| 8f94fbcd4a | |||
| a9630e4f60 | |||
| ca791cb4a5 | |||
| cf194fc831 | |||
| fdf5a1e2fb | |||
| 41b95af210 | |||
| 536d3e22be | |||
| 722d4d1e14 | |||
| d57bc55729 | |||
| 83948780bc | |||
| 2e41586e07 | |||
| 7f43f576fc | |||
| 7684f1efcc | |||
| dcde9f020a | |||
| 9277dbd42d | |||
| 1c418003d7 | |||
| 7af6281f22 | |||
| 2c104c0152 | |||
| ac0ac75240 | |||
| c078c29bb2 | |||
| dfcfb72876 | |||
| a9a55d693e | |||
| ab387834ab | |||
| 9ae687afb0 | |||
| d98228e497 | |||
| 13770d0c36 | |||
| 11159c3c60 | |||
| 1063d08854 | |||
| bcb5c5095e | |||
| 94e3411897 | |||
| 03c17ddfec | |||
| 3fb5b92095 | |||
| 29f18614e2 | |||
| 6ed3da1da4 | |||
| 1685298e60 | |||
| 105afdcb2e | |||
| 353439a354 | |||
| 6b72b9a911 | |||
| 704ac9fe76 | |||
| bee00f48aa | |||
| 4738ab0d37 | |||
| f8c898243d | |||
| f978ad0acb | |||
| d96b410816 | |||
| 6c14c3948f | |||
| 61dcfc31e0 | |||
| 5af670da9a | |||
| 3db75c62fc | |||
| 39e018b338 | |||
| a6602862fb | |||
| c897eac5e4 | |||
| 1079c8a872 | |||
| 4e080c888a | |||
| cd8ecdb0b9 | |||
| af4542c29e | |||
| 7dba8c384f | |||
| 8375fe4f88 | |||
| 5cc1aff3db | |||
| ce78926df0 | |||
| 8af3e37948 | |||
| 5be03da1e8 | |||
| 0b963b9041 | |||
| 8d61f85e32 | |||
| df8dd5f479 | |||
| 432809b1d6 | |||
| 5674507b4d | |||
| 58d6d79145 | |||
| 042a64f050 | |||
| 72ae3a0eb4 | |||
| 20f47494ae | |||
| bfe89310ce | |||
| 1b73ea5799 | |||
| c4028ac12b | |||
| a657c48b96 | |||
| 57b0a28bfa | |||
| f24a9b78eb | |||
| d9a9064e27 | |||
| 3bd402300e | |||
| 6a738db7b5 | |||
| 654eddf086 | |||
| e2b5b53e46 | |||
| 25a3810f01 | |||
| 1ccee9fdc3 | |||
| d768dee320 | |||
| b20f74c94a | |||
| b0e3a92523 | |||
| af60ea8a86 | |||
| 8b3235f57f | |||
| bdd2e029a0 | |||
| c07e87c6ee | |||
| 6422da3570 | |||
| 92a419a25c | |||
| 5dc09fb6ee | |||
| 8bbba2486c | |||
| f5789d86aa | |||
| 7d0d7f4665 | |||
| ed5e0c04ae | |||
| f8b3c31f28 | |||
| 607809b3ba | |||
| 3b7c1de95e | |||
| 8556ae8641 | |||
| 087b81fc86 | |||
| da95fdd658 | |||
| fcbea507c4 | |||
| 0b9e04f07e | |||
| 70d4cf8267 | |||
| 89885b582d | |||
| 17e6df458d | |||
| 1d2603b1e3 | |||
| a2fe7cc0dc | |||
| a3fb1c450a | |||
| d2d7c864de | |||
| 3cc9937d3c | |||
| e53b0823ab | |||
| 8663bfdb08 | |||
| 15ac90653d | |||
| a86b60ddd9 | |||
| 3250c50889 | |||
| 5f55de1007 | |||
| 14217044a5 | |||
| 5422d75fcb | |||
| e1bf736ffa | |||
| 36b4f9852e | |||
| fb964e0c78 | |||
| ba79f7429e | |||
| fa3ba0f6c1 | |||
| c030ab7078 | |||
| 7adcd58f82 | |||
| 24cd45467f | |||
| 9c2c5c5bd0 | |||
| 51ba6ad642 | |||
| 42a986b23a | |||
| 61e96406df | |||
| ac5d88ebe9 | |||
| 819df380a3 | |||
| 5b4fd9c20a | |||
| 33e5f52c01 | |||
| 6846ee2da5 | |||
| a44d18e70e | |||
| 6af88ac7a2 | |||
| 106140f7d1 | |||
| b79f41cd42 | |||
| e18b68b0b6 | |||
| 8e6c87ccf3 | |||
| d78ab28640 | |||
| 8ac3158791 | |||
| 0c106cd3ab | |||
| fdb57a7473 | |||
| 2f7566090f | |||
| cb573b2647 | |||
| b6bae251a1 | |||
| 6fbf8d8fe8 | |||
| e29fa0c8e2 | |||
| 1c0200e074 | |||
| db70b54b62 | |||
| 14e4a496b4 | |||
| 30d6173ed6 | |||
| 7f7f2cca29 | |||
| 13469b820d | |||
| 1df0ab5d8d | |||
| b0cef1ec45 | |||
| c2045f3436 | |||
| d2cded302b | |||
| 346b1a2483 | |||
| f747744495 | |||
| 6d6c938999 | |||
| 366287b705 | |||
| a7514c09e6 | |||
| 50c4bd4145 | |||
| f53af9410c | |||
| 5eda92d0e2 | |||
| 814ada432c | |||
| 86d6449306 | |||
| 808a3baaf8 | |||
| 6dd38d4656 | |||
| 149f85f035 | |||
| bdece65d72 | |||
| 47f1da80d0 | |||
| c04c41c7d2 | |||
| b9b8ab696f | |||
| 0ae5e5ea2d | |||
| b3fa6684ea | |||
| 4fd7ccc0fe | |||
| 932e472fdc | |||
| 9c9f7d7790 | |||
| a900458749 | |||
| 18496c590b | |||
| cae7436602 | |||
| b01597c807 | |||
| d558a7b5d1 | |||
| 8c05e98c41 | |||
| 753db9ace7 | |||
| 3cae82fe52 | |||
| 235bb050c5 | |||
| 9bd2c8741c | |||
| f1dacb2ed0 | |||
| 4456254798 | |||
| ce0eedfc72 | |||
| 11e8f20ec4 | |||
| 9d378732e4 | |||
| 5c63e0c4ee | |||
| fa9ef12118 | |||
| 92a4b0f180 | |||
| 57117c20d5 | |||
| 05a6c03ed2 | |||
| 212f17dd08 | |||
| 8c8a471356 | |||
| 04fa59d015 | |||
| 5f7ed5ceb3 | |||
| f5ff25a482 | |||
| 47149b438d | |||
| d9843ab42d | |||
| 4fe04be0bd | |||
| 7185e073ed | |||
| c23f1c10ca | |||
| 29341af700 | |||
| f7a5c8fafd | |||
| 195ad21e96 | |||
| 7e5e076adf | |||
| e494038ecb | |||
| 1342d68a8a | |||
| 67fcf6818a | |||
| d51fb96e98 | |||
| abf90faf65 | |||
| 97485d0726 | |||
| 7f8dcc6c02 | |||
| 4e042a3ee9 | |||
| 99988d1a87 | |||
| 31fefa636d | |||
| a3eea09cc9 | |||
| 6aeec7f8f8 | |||
| b6c38cec93 | |||
| ebc3bd2b24 | |||
| 1f48942e7d | |||
| b0cc830305 | |||
| dcc4f0e83a | |||
| e323955db8 | |||
| 1d881d926b | |||
| e99f76e01d | |||
| bdc23be0ff | |||
| ba54c0b8ce | |||
| 9e12b88eb9 | |||
| 19801b2b21 | |||
| 1523be781f | |||
| d26d7ed0c3 | |||
| 62cdef7869 | |||
| 469c2cc7d1 | |||
| 9fa49e22ab | |||
| 03f13d2207 | |||
| bdce039ca5 | |||
| 5a8415734f | |||
| bfd5649fcc | |||
| 663a621c51 | |||
| d5f48b1619 | |||
| e310476ae9 | |||
| 45cbb10388 | |||
| 84275343bd | |||
| 5736c5fcf4 | |||
| 82fc646799 | |||
| df28d6c5e6 | |||
| 8caf7e0430 | |||
| 709c0cb359 | |||
| fd66477c7d | |||
| 72af127890 | |||
| a4064f5755 | |||
| af0aa10fc3 | |||
| 3ac5d94015 | |||
| 0b0260e7ba | |||
| aaa872a9ed | |||
| 090e6d1959 | |||
| 852b18ff2b | |||
| 1451da5eed | |||
| fdd417e212 | |||
| 342c546d99 | |||
| 323af31737 | |||
| ab430cfd3d | |||
| 5e22db9e23 | |||
| b75c36b802 | |||
| 393cc5088b | |||
| d2380ec365 | |||
| 035f8397db | |||
| 33b4ba655f | |||
| f6680cfa4a | |||
| 4181fce9f9 | |||
| fd790dfb55 | |||
| a3e175eea5 | |||
| ca3cf39ee1 | |||
| dee505a1c0 | |||
| 6d987a67cc | |||
| fa949b2b5c | |||
| 93f03cc436 | |||
| 778c28671a | |||
| b2a2171f22 | |||
| e28a6c7378 | |||
| 51e734b85f | |||
| ce3faff837 | |||
| 9c5b4e1587 | |||
| 8fc6971035 | |||
| 8c009049f4 | |||
| 50c5119d82 | |||
| e57e540ce1 | |||
| b0767657a6 | |||
| 7be475f601 | |||
| 2e9e77eba0 | |||
| 499ab3711e | |||
| bfca4cffdc | |||
| 541b602d61 | |||
| 51b578bc6e | |||
| 6176355393 | |||
| d8c0083240 | |||
| 2e91475518 | |||
| 9984fe99e4 | |||
| 45f21f94d7 | |||
| 8ab95b7186 | |||
| 6daa3c2329 | |||
| 02d35f5503 | |||
| c2246cbb1e | |||
| 2590de4ff4 | |||
| f1f3b874ce | |||
| 7a6ce5df4c | |||
| c21f835ac3 | |||
| 1d1b312890 | |||
| 7f9b57040e | |||
| 59b888d7fb | |||
| 150e92dcf1 | |||
| 55181cf5a8 | |||
| 06c0a76a1d | |||
| e3305cc5d9 | |||
| f830b324cf | |||
| 31313bfb98 | |||
| 2f99e65049 | |||
| 79e7f21a65 | |||
| ccddfeec89 | |||
| a23b08a360 | |||
| 91de0951af | |||
| a7c833d1dd | |||
| be2946c27c | |||
| c78a72fc5b | |||
| 836c3d0ed6 | |||
| fbea810cf4 | |||
| fd6fbbeb0b | |||
| 45b1adcf20 | |||
| df6384e2b8 | |||
| d7facad81e | |||
| cc2c8c6dc5 | |||
| 5186f85951 | |||
| e7a02c4c73 | |||
| 78774bae0d | |||
| ae481044f7 | |||
| a13975e028 | |||
| 21f34b5f67 | |||
| 795976b352 | |||
| 7434d21a90 | |||
| af554bec95 | |||
| fff61015b7 | |||
| 379e2dcbae | |||
| ad8aa0b9f3 | |||
| 5f16e54d33 | |||
| 5d0a3181b0 | |||
| cf3f6bcc2c | |||
| eac7c90291 | |||
| 9e2265f707 | |||
| bb55809320 | |||
| f1d2a92c85 | |||
| 8c6cdfc613 | |||
| 266873247f | |||
| 62c5a17de5 | |||
| e6f10ec582 | |||
| 1355a93af2 | |||
| 208307010c | |||
| 9c645ce06c | |||
| 53a290ba03 | |||
| 673ada543a | |||
| 2db0a31b69 | |||
| 0fa6f59fbd | |||
| 31861304ec | |||
| 913dbeb760 | |||
| adfd802f27 | |||
| 6ec3aaaf84 | |||
| f5f08e24c1 | |||
| 454259a62f | |||
| 8736d429d4 | |||
| 0c8106d326 |
+17
-5
@@ -1,13 +1,25 @@
|
||||
README $Id$
|
||||
------
|
||||
|
||||
I highly recommend you read the detailed help on
|
||||
installation, upgrading and use of Moodle, stored
|
||||
in the doc subdirectory of this installation, or
|
||||
read at:
|
||||
If you are installing the first time, then you
|
||||
should read the installation guide which is
|
||||
part of the Moodle documentation (along with
|
||||
information about upgrading etc):
|
||||
|
||||
http://moodle.com/doc/
|
||||
|
||||
There is a copy of all this documentation as part of
|
||||
this Moodle distribution. You can access your local
|
||||
copy of the installation guide here:
|
||||
|
||||
lang/en/docs/install.html
|
||||
|
||||
Once Moodle is installed on your machine, then
|
||||
you can also access a local copy of all this
|
||||
documentation (localised to your language) at:
|
||||
|
||||
http://yourmoodlesite.com/doc/
|
||||
|
||||
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
@@ -21,7 +33,7 @@ a few minutes:
|
||||
process.
|
||||
|
||||
3) Create a single database for Moodle to store all
|
||||
it's tables in.
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
4) Copy the file config-dist.php to config.php, and
|
||||
edit it with all your own settings.
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign administrative rights to users
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 30);
|
||||
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
optional_variable($search, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// If you want any administrator to have the ability to assign admin
|
||||
/// rights, then comment out the following if statement
|
||||
if ($primaryadmin->id != $USER->id) {
|
||||
error("You must be the primary administrator to use this page.");
|
||||
}
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
$stringstoload = array (
|
||||
"assignadmins",
|
||||
"administration",
|
||||
"existingadmins",
|
||||
"noexistingadmins",
|
||||
"potentialadmins",
|
||||
"nopotentialadmins",
|
||||
"addadmin",
|
||||
"removeadmin",
|
||||
"search",
|
||||
"searchagain",
|
||||
"toomanytoshow",
|
||||
"searchresults"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
$strstringtoload = "str" . $stringtoload;
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassignadmins",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> ->
|
||||
<a href=\"{$_SERVER['PHP_SELF']}\">$strassignadmins</a>", "");
|
||||
|
||||
/// Get all existing admins
|
||||
$admins = get_admins();
|
||||
|
||||
/// Add an admin if one is specified
|
||||
if ($add) {
|
||||
$user = @get_record("user", "id", $_REQUEST['add']) or
|
||||
error("That account (id = {$_REQUEST['add']}) doesn't exist");
|
||||
|
||||
if ($admins) {
|
||||
foreach ($admins as $aa) {
|
||||
if ($aa->id == $user->id) {
|
||||
error("That user is already an admin.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$admin->userid = $user->id;
|
||||
$admin->id = insert_record("user_admins", $admin);
|
||||
$admins[] = $user;
|
||||
}
|
||||
|
||||
/// Remove an admin if one is specified.
|
||||
if ($remove) {
|
||||
|
||||
$user = @get_record("user", "id", $_REQUEST['remove']) or
|
||||
error("That account (id = {$_REQUEST['remove']}) doesn't exist");
|
||||
|
||||
if ($admins) {
|
||||
foreach ($admins as $key => $aa) {
|
||||
if ($aa->id == $user->id) {
|
||||
/// make sure that we don't delete the primary admin
|
||||
/// account, so that there is always at least on admin
|
||||
if ($aa->id == $primaryadmin->id) {
|
||||
error("That user is the primary admin, and shouldn't be removed.");
|
||||
} else {
|
||||
remove_admin($user->id);
|
||||
unset($admins[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print the lists of existing and potential admins
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingadmins</th><th width=50%>$strpotentialadmins</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
/// First, show existing admins
|
||||
|
||||
if (! $admins) {
|
||||
echo "<p align=center>$strnoexistingadmins</a>";
|
||||
|
||||
$adminlist = "";
|
||||
|
||||
} else {
|
||||
$adminarray = array();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$adminarray[] = $admin->id;
|
||||
echo "<p align=right>$admin->firstname $admin->lastname,
|
||||
$admin->email ";
|
||||
if ($primaryadmin->id == $admin->id){
|
||||
print_spacer(10, 9, false);
|
||||
} else {
|
||||
echo "<a href=\"{$_SERVER['PHP_SELF']}?remove=$admin->id\"
|
||||
title=\"$strremoveadmin\"><img src=\"../pix/t/right.gif\"
|
||||
border=0></A>";
|
||||
}
|
||||
echo "</p>";
|
||||
}
|
||||
|
||||
$adminlist = implode(",",$adminarray);
|
||||
unset($adminarray);
|
||||
}
|
||||
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
/// Print list of potential admins
|
||||
|
||||
$usercount = get_users(false, $search, true, $adminlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialadmins</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow</p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $adminlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><a href=\"{$_SERVER['PHP_SELF']}?add=$user->id\"".
|
||||
"title=\"$straddadmin\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action={$_SERVER['PHP_SELF']} method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+47
-15
@@ -2,7 +2,6 @@
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
include("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
@@ -16,10 +15,9 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
|
||||
$config = (object)$HTTP_POST_VARS;
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
$config = (array)$config;
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
@@ -41,7 +39,7 @@
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (!isset($config)) {
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
}
|
||||
|
||||
@@ -55,13 +53,35 @@
|
||||
} else {
|
||||
$auth = $config->auth;
|
||||
}
|
||||
|
||||
require_once("$CFG->dirroot/auth/$auth/lib.php"); //just to make sure that current authentication functions are loaded
|
||||
if (! isset($config->guestloginbutton)) {
|
||||
$config->guestloginbutton = 1;
|
||||
}
|
||||
if (! isset($config->auth_instructions)) {
|
||||
$config->auth_instructions = "";
|
||||
}
|
||||
if (! isset($config->changepassword)) {
|
||||
$config->changepassword = "";
|
||||
}
|
||||
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
|
||||
foreach ($user_fields as $user_field) {
|
||||
$user_field = "auth_user_$user_field";
|
||||
if (! isset($config->$user_field)) {
|
||||
$config->$user_field = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
|
||||
$createoptions[0] = get_string("no");
|
||||
$createoptions[1] = get_string("yes");
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strauthentication = get_string("authentication");
|
||||
$strauthenticationoptions = get_string("authenticationoptions","auth");
|
||||
@@ -71,7 +91,7 @@
|
||||
"<A HREF=\"index.php\">$stradministration</A> -> $strauthenticationoptions", "$focus");
|
||||
|
||||
echo "<CENTER><P><B>";
|
||||
echo "<form TARGET=\"_top\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
echo "<form TARGET=\"{$CFG->framename}\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
print_string("chooseauthmethod","auth");
|
||||
|
||||
choose_from_menu ($options, "auth", $auth, "","top.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
@@ -81,17 +101,17 @@
|
||||
print_simple_box_start("center", "100%", "$THEME->cellheading");
|
||||
print_heading($options[$auth]);
|
||||
|
||||
echo "<BLOCKQUOTE><CENTER><P>";
|
||||
print_simple_box_start("center", "60%", "$THEME->cellcontent");
|
||||
print_string("auth_$auth"."description", "auth");
|
||||
echo "</P></CENTER></BLOCKQUOTE>";
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<HR>";
|
||||
echo "<hr>";
|
||||
|
||||
print_heading($strsettings);
|
||||
|
||||
echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
|
||||
|
||||
require("$CFG->dirroot/auth/$auth/config.html");
|
||||
require_once("$CFG->dirroot/auth/$auth/config.html");
|
||||
|
||||
if ($auth != "email" and $auth != "none") {
|
||||
echo "<tr valign=\"top\">";
|
||||
@@ -99,7 +119,7 @@
|
||||
print_string("changepassword", "auth");
|
||||
echo ":</p></td>";
|
||||
echo "<td>";
|
||||
echo "<INPUT TYPE=\"text\" NAME=\"changepassword\" SIZE=40 VALUE=\"$config->changepassword\">";
|
||||
echo "<input type=\"text\" name=\"changepassword\" size=40 value=\"$config->changepassword\">";
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("changepasswordhelp","auth");
|
||||
@@ -116,12 +136,24 @@
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("showguestlogin","auth");
|
||||
echo "</td></tr></table>";
|
||||
echo "</td></tr>";
|
||||
|
||||
if (function_exists('auth_user_create')){
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
print_string("auth_user_create", "auth");
|
||||
echo ":</p></td>";
|
||||
echo "<td>";
|
||||
choose_from_menu($createoptions, "auth_user_create", $config->auth_user_create, "");
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("auth_user_creation","auth");
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
echo "<CENTER><P><INPUT TYPE=\"submit\" VALUE=\"";
|
||||
echo "</table><center><p><input type=\"submit\" value=\"";
|
||||
print_string("savechanges");
|
||||
echo "\"></P></CENTER></FORM>";
|
||||
echo "\"></p></center></form>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
+265
-151
@@ -1,72 +1,100 @@
|
||||
<FORM METHOD="post" action="config.php" NAME="form">
|
||||
<form method="post" action="config.php" name="form">
|
||||
|
||||
<TABLE cellpadding=9 cellspacing=0 >
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>lang:</TD>
|
||||
<TD>
|
||||
<? choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", "");
|
||||
formerr($err["lang"]);
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configlang") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>langdir:</TD>
|
||||
<TD>
|
||||
<? unset($options);
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><p>lang:</td>
|
||||
<td>
|
||||
<?php choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", ""); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlang") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langdir:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options["LTR"] = get_string("langltr");
|
||||
$options["RTL"] = get_string("langrtl");
|
||||
|
||||
choose_from_menu ($options, "langdir", $config->langdir, "", "", "");
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configlangdir") ?>
|
||||
</TD>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlangdir") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langmenu:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "langmenu", $config->langmenu, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlangmenu") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langlist:</td>
|
||||
<td>
|
||||
<input name=langlist type=text size=40 value="<?php p($config->langlist) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlanglist") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>locale:</td>
|
||||
<td>
|
||||
<input name=locale type=text size=10 value="<?php p($config->locale) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlocale") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>country:</td>
|
||||
<td><?php choose_from_menu ($COUNTRIES, "country", $config->country, get_string("selectacountry"), "", "") ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configcountry") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtphosts:</td>
|
||||
<td>
|
||||
<input name=smtphosts type=text size=30 value="<?php p($config->smtphosts)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsmtphosts") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtpuser:</td>
|
||||
<td>
|
||||
<input name=smtpuser type=text size=10 value="<?php p($config->smtpuser)?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
<?php print_string("configsmtpuser") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtppass:</td>
|
||||
<td>
|
||||
<input name=smtppass type=text size=10 value="<?php p($config->smtppass)?>">
|
||||
</td>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>locale:</TD>
|
||||
<TD>
|
||||
<INPUT NAME=locale TYPE=text SIZE=10 VALUE="<?=$config->locale?>">
|
||||
<? formerr($err["locale"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configlocale") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>smtphosts:</TD>
|
||||
<TD>
|
||||
<INPUT NAME=smtphosts TYPE=text SIZE=30 VALUE="<?=$config->smtphosts?>">
|
||||
<? formerr($err["smtphosts"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configsmtphosts") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>smtpuser:</TD>
|
||||
<TD>
|
||||
<INPUT NAME=smtpuser TYPE=text SIZE=10 VALUE="<?=$config->smtpuser?>">
|
||||
<? formerr($err["smtpuser"]); ?>
|
||||
</TD>
|
||||
<TD ROWSPAN=2>
|
||||
<? print_string("configsmtpuser") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>smtppass:</TD>
|
||||
<TD>
|
||||
<INPUT NAME=smtppass TYPE=text SIZE=10 VALUE="<?=$config->smtppass?>">
|
||||
<? formerr($err["smtppass"]); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>gdversion:</TD>
|
||||
<TD>
|
||||
<? unset($options);
|
||||
<tr valign=top>
|
||||
<td align=right><p>gdversion:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("gdnot");
|
||||
$options[1] = get_string("gd1");
|
||||
$options[2] = get_string("gd2");
|
||||
@@ -75,29 +103,31 @@
|
||||
|
||||
choose_from_menu ($options, "gdversion", $installed, "", "", "");
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configgdversion") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>htmleditor:</TD>
|
||||
<TD>
|
||||
<? unset($options);
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configgdversion") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>htmleditor:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("allownot");
|
||||
$options[1] = get_string("allow");
|
||||
choose_from_menu ($options, "htmleditor", $config->htmleditor, "", "", "");
|
||||
formerr($err["htmleditor"]);
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("confightmleditor") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>maxeditingtime:</TD>
|
||||
<TD>
|
||||
<? $options[3600] = get_string("numminutes", "", 60);
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("confightmleditor") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxeditingtime:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[3600] = get_string("numminutes", "", 60);
|
||||
$options[2700] = get_string("numminutes", "", 45);
|
||||
$options[1800] = get_string("numminutes", "", 30);
|
||||
$options[900] = get_string("numminutes", "", 15);
|
||||
@@ -105,17 +135,18 @@
|
||||
$options[60] = get_string("numminutes", "", 1);
|
||||
|
||||
choose_from_menu ($options, "maxeditingtime", $config->maxeditingtime, "", "", "");
|
||||
unset($options);
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configmaxeditingtime") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>longtimenosee:</TD>
|
||||
<TD>
|
||||
<? $options[1000] = get_string("numdays", "", 1000);
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configmaxeditingtime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>longtimenosee:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[1000] = get_string("numdays", "", 1000);
|
||||
$options[365] = get_string("numdays", "", 365);
|
||||
$options[180] = get_string("numdays", "", 180);
|
||||
$options[150] = get_string("numdays", "", 150);
|
||||
@@ -123,75 +154,158 @@
|
||||
$options[90] = get_string("numdays", "", 90);
|
||||
$options[60] = get_string("numdays", "", 60);
|
||||
$options[30] = get_string("numdays", "", 30);
|
||||
$options[21] = get_string("numdays", "", 21);
|
||||
$options[14] = get_string("numdays", "", 14);
|
||||
$options[7] = get_string("numdays", "", 7);
|
||||
|
||||
choose_from_menu ($options, "longtimenosee", $config->longtimenosee, "", "", "");
|
||||
unset($options);
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configlongtimenosee") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>zip:</TD>
|
||||
<TD>
|
||||
<INPUT name=zip TYPE=text SIZE=30 VALUE="<?=$config->zip?>">
|
||||
<? formerr($err["zip"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configzip") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>unzip:</TD>
|
||||
<TD>
|
||||
<INPUT name=unzip TYPE=text SIZE=30 VALUE="<?=$config->unzip?>">
|
||||
<? formerr($err["unzip"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configunzip") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>slasharguments:</TD>
|
||||
<TD>
|
||||
<? $options[0] = "file.php?file=/pic.jpg";
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlongtimenosee") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>loglifetime:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("neverdeletelogs");
|
||||
$options[1000] = get_string("numdays", "", 1000);
|
||||
$options[365] = get_string("numdays", "", 365);
|
||||
$options[180] = get_string("numdays", "", 180);
|
||||
$options[150] = get_string("numdays", "", 150);
|
||||
$options[120] = get_string("numdays", "", 120);
|
||||
$options[90] = get_string("numdays", "", 90);
|
||||
$options[60] = get_string("numdays", "", 60);
|
||||
$options[30] = get_string("numdays", "", 30);
|
||||
|
||||
choose_from_menu ($options, "loglifetime", $config->loglifetime, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configloglifetime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessiontimeout:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[14400] = get_string("numhours", "", 4);
|
||||
$options[10800] = get_string("numhours", "", 3);
|
||||
$options[7200] = get_string("numhours", "", 2);
|
||||
$options[5400] = get_string("numhours", "", "1.5");
|
||||
$options[3600] = get_string("numminutes", "", 60);
|
||||
$options[2700] = get_string("numminutes", "", 45);
|
||||
$options[1800] = get_string("numminutes", "", 30);
|
||||
$options[900] = get_string("numminutes", "", 15);
|
||||
$options[300] = get_string("numminutes", "", 5);
|
||||
|
||||
choose_from_menu ($options, "sessiontimeout", $config->sessiontimeout, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsessiontimeout") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>zip:</td>
|
||||
<td>
|
||||
<input name=zip type=text size=30 value="<?php p($config->zip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configzip") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>unzip:</td>
|
||||
<td>
|
||||
<input name=unzip type=text size=30 value="<?php p($config->unzip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configunzip") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>slasharguments:</td>
|
||||
<td>
|
||||
<?php unset($options);
|
||||
$options[0] = "file.php?file=/pic.jpg";
|
||||
$options[1] = "file.php/pic.jpg";
|
||||
|
||||
$installed = check_gd_version();
|
||||
|
||||
choose_from_menu ($options, "slasharguments", $config->slasharguments, "", "", "");
|
||||
unset($options);
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("configslasharguments") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>proxyhost:</TD>
|
||||
<TD>
|
||||
<INPUT name=proxyhost TYPE=text SIZE=30 VALUE="<?=$config->proxyhost?>">
|
||||
<? formerr($err["proxyhost"]); ?>
|
||||
</TD>
|
||||
<TD ROWSPAN=2>
|
||||
<? print_string("configproxyhost") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P>proxyport:</TD>
|
||||
<TD>
|
||||
<INPUT name=proxyport TYPE=text SIZE=5 VALUE="<?=$config->proxyport?>">
|
||||
<? formerr($err["proxyport"]); ?>
|
||||
</TD>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configslasharguments") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyhost:</td>
|
||||
<td>
|
||||
<input name=proxyhost type=text size=30 value="<?php p($config->proxyhost) ?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
<?php print_string("configproxyhost") ?>
|
||||
</td>
|
||||
</TR>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyport:</td>
|
||||
<td>
|
||||
<input name=proxyport type=text size=5 value="<?php p($config->proxyport) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>debug:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[7] = get_string("no");
|
||||
$options[15] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "debug", $config->debug, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdebug") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>framename:</td>
|
||||
<td>
|
||||
<?php
|
||||
if (empty($config->framename)) {
|
||||
$config->framename = "_top";
|
||||
}
|
||||
?>
|
||||
<input name=framename type=text size=15 value="<?php p($config->framename)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configframename") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>secureforms:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "secureforms", $config->secureforms, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsecureforms") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<TR>
|
||||
<TD COLSPAN=3 ALIGN=CENTER>
|
||||
<INPUT TYPE="submit" VALUE="<? print_string("savechanges") ?>"></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<tr>
|
||||
<td colspan=3 align=center>
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</FORM>
|
||||
</form>
|
||||
|
||||
+20
-31
@@ -1,30 +1,9 @@
|
||||
<?PHP // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
include("../config.php");
|
||||
require_once("../config.php");
|
||||
require_once("../lib/countries.php");
|
||||
|
||||
if (isset($phpinfo)) { // For debugging purposes, protected by password
|
||||
if (md5($phpinfo) == "caf9b6b99962bf5c2264824231d7a40c") {
|
||||
if ($site = get_site()) {
|
||||
print_heading("$site->fullname");
|
||||
}
|
||||
phpinfo();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config)) { // For debugging purposes, protected by password
|
||||
if (md5($config) == "caf9b6b99962bf5c2264824231d7a40c") {
|
||||
if ($site = get_site()) {
|
||||
print_heading("$site->fullname");
|
||||
}
|
||||
$TEMPCFG = $CFG;
|
||||
unset($TEMPCFG->dbuser);
|
||||
unset($TEMPCFG->dbpass);
|
||||
print_object($TEMPCFG);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($site = get_site()) { // If false then this is a new installation
|
||||
require_login();
|
||||
@@ -33,12 +12,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// This is to overcome the "insecure forms paradox"
|
||||
if (isset($secureforms) and $secureforms == 0) {
|
||||
$match = "nomatch";
|
||||
} else {
|
||||
$match = "";
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
|
||||
$config = (object)$HTTP_POST_VARS;
|
||||
if ($config = data_submitted($match)) {
|
||||
|
||||
validate_form($config, $err);
|
||||
|
||||
@@ -71,28 +54,34 @@
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (!isset($config)) {
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
}
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfigvariables = get_string("configvariables");
|
||||
|
||||
if ($site) {
|
||||
print_header("$site->shortname: $strconfigvariables", "$site->fullname",
|
||||
"<A HREF=\"index.php\">$stradmin</A> -> $strconfigvariables", "$focus");
|
||||
print_header("$site->shortname: $strconfigvariables", $site->fullname,
|
||||
"<A HREF=\"index.php\">$stradmin</A> -> $strconfigvariables", $focus);
|
||||
print_heading($strconfigvariables);
|
||||
} else {
|
||||
print_header();
|
||||
print_heading($strconfigvariables);
|
||||
print_simple_box(get_string("configintro"), "center");
|
||||
echo "<BR>";
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("config.html");
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
|
||||
if ($site) {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
Executable
+165
@@ -0,0 +1,165 @@
|
||||
<?PHP // $Id$
|
||||
// Admin only script to assign course creator rights to users
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 30);
|
||||
|
||||
optional_variable($search, "");
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// If you want any administrator to have the ability to assign admin
|
||||
/// rights, then comment out the following if statement
|
||||
if ($primaryadmin->id != $USER->id) {
|
||||
error("You must be the primary administrator to use this page.");
|
||||
}
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
$stringstoload = array (
|
||||
"assigncreators",
|
||||
"administration",
|
||||
"existingcreators",
|
||||
"noexistingcreators",
|
||||
"potentialcreators",
|
||||
"nopotentialcreators",
|
||||
"addcreator",
|
||||
"removecreator",
|
||||
"search",
|
||||
"searchagain",
|
||||
"toomanytoshow",
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
$strstringtoload = "str" . $stringtoload;
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassigncreators",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> ->
|
||||
<a href=\"{$_SERVER['PHP_SELF']}\">$strassigncreators</a>", "");
|
||||
|
||||
/// Get all existing creators
|
||||
$creators = get_creators();
|
||||
|
||||
/// Add an creator if one is specified
|
||||
if ($add) {
|
||||
$user = @get_record("user", "id", $add) or
|
||||
error("That account (id = $add) doesn't exist");
|
||||
|
||||
if ($creators) {
|
||||
foreach ($creators as $aa) {
|
||||
if ($aa->id == $user->id) {
|
||||
error("That user is already a creator .");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$creator->userid = $user->id;
|
||||
$creator->id = insert_record("user_coursecreators", $creator);
|
||||
$creators[] = $user;
|
||||
}
|
||||
|
||||
/// Remove an creator if one is specified.
|
||||
if ($remove) {
|
||||
$user = @get_record("user", "id", $remove) or
|
||||
error("That account (id = $remove) doesn't exist");
|
||||
|
||||
if ($creators) {
|
||||
foreach ($creators as $key => $aa) {
|
||||
if ($aa->id == $user->id) {
|
||||
delete_records("user_coursecreators","userid",$user->id);
|
||||
unset($creators[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print the lists of existing and potential creators
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingcreators</th><th width=50%>$strpotentialcreators</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
/// First, show existing creators
|
||||
|
||||
if (! $creators) {
|
||||
echo "<p align=center>$strnoexistingcreators</a>";
|
||||
|
||||
$creatorlist = "";
|
||||
|
||||
} else {
|
||||
$creatorarray = array();
|
||||
foreach ($creators as $creator) {
|
||||
$creatorarray[] = $creator->id;
|
||||
echo "<p align=right>$creator->firstname $creator->lastname,
|
||||
$creator->email ";
|
||||
echo "<a href=\"{$_SERVER['PHP_SELF']}?remove=$creator->id\"
|
||||
title=\"$strremovecreator\"><img src=\"../pix/t/right.gif\"
|
||||
border=0></a>";
|
||||
echo "</p>";
|
||||
}
|
||||
$creatorlist = implode(",",$creatorarray);
|
||||
unset($creatorarray);
|
||||
}
|
||||
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
/// Print list of potential creators
|
||||
|
||||
$usercount = get_users(false, $search, true, $creatorlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialcreators</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow</p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $creatorlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><a href=\"{$_SERVER['PHP_SELF']}?add=$user->id\"".
|
||||
"title=\"$straddcreator\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action={$_SERVER['PHP_SELF']} method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+40
-25
@@ -1,25 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// This script looks through all the module directories for cron.php files
|
||||
// and runs them. These files can contain cleanup functions, email functions
|
||||
// or anything that needs to be run on a regular basis.
|
||||
//
|
||||
// This file is best run from cron on the host system (ie outside PHP).
|
||||
// The script can either be invoked via the web server or via a standalone
|
||||
// version of PHP compiled for CGI.
|
||||
//
|
||||
// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
|
||||
// or php /web/moodle/admin/cron.php
|
||||
/// This script looks through all the module directories for cron.php files
|
||||
/// and runs them. These files can contain cleanup functions, email functions
|
||||
/// or anything that needs to be run on a regular basis.
|
||||
///
|
||||
/// This file is best run from cron on the host system (ie outside PHP).
|
||||
/// The script can either be invoked via the web server or via a standalone
|
||||
/// version of PHP compiled for CGI.
|
||||
///
|
||||
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
|
||||
/// or php /web/moodle/admin/cron.php
|
||||
|
||||
require("../config.php");
|
||||
$FULLME = "cron";
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
echo "<PRE>\n";
|
||||
|
||||
$timenow = time();
|
||||
|
||||
// Run all cron jobs for each module
|
||||
/// Run all cron jobs for each module
|
||||
|
||||
if ($mods = get_records_sql("SELECT * FROM modules WHERE cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
foreach ($mods as $mod) {
|
||||
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
|
||||
if (file_exists($libfile)) {
|
||||
@@ -37,14 +41,11 @@
|
||||
}
|
||||
|
||||
|
||||
// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
/// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
if ($CFG->longtimenosee) { // value in days
|
||||
$cutofftime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
if ($users = get_records_sql("SELECT u.* FROM user u, user_students s
|
||||
WHERE lastaccess > '0' AND
|
||||
lastaccess < '$cutofftime' AND
|
||||
u.id = s.user GROUP BY u.id")) {
|
||||
$longtime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
if ($users = get_users_longtimenosee($longtime)) {
|
||||
foreach ($users as $user) {
|
||||
if (unenrol_student($user->id)) {
|
||||
echo "Deleted student enrolment for $user->firstname $user->lastname ($user->id)\n";
|
||||
@@ -54,13 +55,10 @@
|
||||
}
|
||||
|
||||
|
||||
// Delete users who haven't confirmed within seven days
|
||||
/// Delete users who haven't confirmed within seven days
|
||||
|
||||
$cutofftime = $timenow - (7 * 24 * 3600);
|
||||
if ($users = get_records_sql("SELECT * FROM user
|
||||
WHERE confirmed = '0' AND
|
||||
firstaccess > '0' AND
|
||||
firstaccess < '$cutofftime'")) {
|
||||
$oneweek = $timenow - (7 * 24 * 3600);
|
||||
if ($users = get_users_unconfirmed($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records("user", "id", $user->id)) {
|
||||
echo "Deleted unconfirmed user for $user->firstname $user->lastname ($user->id)\n";
|
||||
@@ -68,6 +66,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Delete old queued mail that didn't get sent within 30 minutes
|
||||
|
||||
$oldmailtime = $timenow - 1800;
|
||||
delete_records_select("mail_queue", "timecreated < '$oldmailtime'");
|
||||
|
||||
|
||||
/// Delete old logs to save space (this might need a timer to slow it down...)
|
||||
|
||||
if (!empty($CFG->loglifetime)) { // value in days
|
||||
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
|
||||
delete_records_select("log", "time < '$loglifetime'");
|
||||
}
|
||||
|
||||
echo "Cron script completed correctly\n";
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
echo "Execution took ".$difftime." seconds\n";
|
||||
|
||||
?>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Deletes the moodledata directory, COMPLETELY!!
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
|
||||
include("../config.php");
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require("../config.php");
|
||||
|
||||
/// Normally this file is never used.
|
||||
///
|
||||
/// It can be useful to jump-start a new moodle installation when
|
||||
/// it is being installed into a database that already contains
|
||||
/// some tables.
|
||||
///
|
||||
/// For this case you would call this script directly
|
||||
///
|
||||
/// Warning: this method ASSUMES that all existing tables with
|
||||
/// have different names to any Moodle tables, so make sure
|
||||
/// there aren't any Moodle-named tables in your database before
|
||||
/// using this script. See lib/db/mysql.sql and mod/*/db/mysql.sql
|
||||
|
||||
if ($CFG->version) { // To avoid this being used on a working site.
|
||||
echo "No need to use this";
|
||||
|
||||
} else {
|
||||
|
||||
$strdatabasesetup = get_string("databasesetup");
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup);
|
||||
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = true;
|
||||
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
notify($strdatabasesuccess);
|
||||
} else {
|
||||
$db->debug = false;
|
||||
error("Error: Main databases NOT set up successfully");
|
||||
}
|
||||
} else {
|
||||
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle.
|
||||
See the lib/db directory.");
|
||||
}
|
||||
print_continue("index.php");
|
||||
}
|
||||
|
||||
+183
-58
@@ -1,47 +1,132 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require("../config.php");
|
||||
/// Check that config.php exists
|
||||
if (!file_exists("../config.php")) {
|
||||
echo "<H2 align=center>You need to create a config.php.<BR>
|
||||
See the <A HREF=\"http://moodle.com/doc/?frame=install.html\">installation instructions</A>.</H2>";
|
||||
die;
|
||||
}
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
|
||||
/// Check that PHP is of a sufficient version
|
||||
|
||||
if ( ! check_php_version("4.1.0") ) {
|
||||
if (!check_php_version("4.1.0")) {
|
||||
$version = phpversion();
|
||||
print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)");
|
||||
die;
|
||||
}
|
||||
|
||||
/// Check some PHP server settings
|
||||
|
||||
$documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>";
|
||||
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
|
||||
}
|
||||
|
||||
if (ini_get_bool('magic_quotes_runtime')) {
|
||||
error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
|
||||
}
|
||||
|
||||
if (!ini_get_bool('magic_quotes_gpc')) {
|
||||
error("The PHP server variable 'magic_quotes_gpc' is not turned On - $documentationlink");
|
||||
}
|
||||
|
||||
if (!ini_get_bool('file_uploads')) {
|
||||
error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
|
||||
}
|
||||
|
||||
if (!ini_get_bool('short_open_tag')) {
|
||||
error("The PHP server variable 'short_open_tag' is not turned On - $documentationlink");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Check that sessions are supported
|
||||
|
||||
if (!is_readable(ini_get('session.save_path')) and !ini_get_bool('safe_mode')) {
|
||||
$sessionpath = ini_get('session.save_path');
|
||||
notify("Warning: It appears your server does not support sessions (session.save_path = '$sessionpath')");
|
||||
}
|
||||
|
||||
|
||||
/// Check that config.php has been edited
|
||||
|
||||
if ($CFG->wwwroot == "http://example.com/moodle") {
|
||||
error("Moodle has not been configured yet. You need to to edit config.php first.");
|
||||
}
|
||||
|
||||
/// Check databases and modules and install as needed.
|
||||
if (! $db->Metatables() ) {
|
||||
|
||||
if (!$agreelicence) {
|
||||
/// Check settings in config.php
|
||||
|
||||
$dirroot = dirname(realpath("../config.php"));
|
||||
if ($dirroot != $CFG->dirroot) {
|
||||
error("Please fix your settings in config.php:
|
||||
<P>You have:
|
||||
<P>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
|
||||
<P>but it should be:
|
||||
<P>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
|
||||
"./");
|
||||
}
|
||||
|
||||
/// Set some necessary variables during set-up to avoid PHP warnings later on this page
|
||||
if (!isset($CFG->framename)) {
|
||||
$CFG->framename = "_top";
|
||||
}
|
||||
if (!isset($CFG->release)) {
|
||||
$CFG->release = "";
|
||||
}
|
||||
if (!isset($CFG->version)) {
|
||||
$CFG->version = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Check if the main tables have been installed yet or not.
|
||||
|
||||
if (! $tables = $db->Metatables() ) { // No tables yet at all.
|
||||
$maintables = false;
|
||||
|
||||
} else { // Check for missing main tables
|
||||
$maintables = true;
|
||||
$mtables = array("config", "course", "course_categories", "course_modules",
|
||||
"course_sections", "log", "log_display", "modules",
|
||||
"user", "user_admins", "user_students", "user_teachers");
|
||||
foreach ($mtables as $mtable) {
|
||||
if (!in_array($CFG->prefix.$mtable, $tables)) {
|
||||
$maintables = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $maintables) {
|
||||
if (empty($agreelicence)) {
|
||||
$strlicense = get_string("license");
|
||||
print_header($strlicense, $strlicense, $strlicense);
|
||||
print_heading("<A HREF=\"http://moodle.com\">Moodle</A> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " ");
|
||||
print_heading("<A HREF=\"http://moodle.org\">Moodle</A> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_heading(get_string("copyrightnotice"));
|
||||
print_simple_box_start("CENTER");
|
||||
print_simple_box_start("center");
|
||||
echo text_to_html(get_string("gpl"));
|
||||
print_simple_box_end();
|
||||
echo "<BR>";
|
||||
echo "<br />";
|
||||
notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
|
||||
"http://www.gnu.org/copyleft/gpl.html");
|
||||
"http://moodle.org/doc/?frame=licence.html");
|
||||
exit;
|
||||
}
|
||||
|
||||
$strdatabasesetup = get_string("databasesetup");
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup);
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", "", false, " ", " ");
|
||||
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = true;
|
||||
set_time_limit(0); // To allow slow databases to complete the long SQL
|
||||
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
notify($strdatabasesuccess);
|
||||
notify($strdatabasesuccess, "green");
|
||||
} else {
|
||||
$db->debug = false;
|
||||
error("Error: Main databases NOT set up successfully");
|
||||
@@ -65,13 +150,14 @@
|
||||
$a->newversion = $version;
|
||||
$strdatabasechecking = get_string("databasechecking", "", $a);
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking);
|
||||
notify($strdatabasechecking);
|
||||
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
if (main_upgrade($CFG->version)) {
|
||||
$db->debug=false;
|
||||
if (set_config("version", $version)) {
|
||||
notify($strdatabasesuccess);
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("index.php");
|
||||
die;
|
||||
} else {
|
||||
@@ -86,11 +172,12 @@
|
||||
}
|
||||
|
||||
} else {
|
||||
$strdatabaseupgrades = get_string("databaseupgrades");
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades);
|
||||
$strcurrentversion = get_string("currentversion");
|
||||
print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
if (set_config("version", $version)) {
|
||||
notify("You are currently using Moodle version $version (Release $release)");
|
||||
print_heading("You are currently using Moodle version $version (Release $release)");
|
||||
print_continue("index.php");
|
||||
die;
|
||||
} else {
|
||||
@@ -107,15 +194,15 @@
|
||||
/// Updated human-readable release version if necessary
|
||||
|
||||
if ($release <> $CFG->release) { // Update the release version
|
||||
$strdatabaseupgrades = get_string("databaseupgrades");
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades);
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading($release);
|
||||
if (!set_config("release", $release)) {
|
||||
notify("ERROR: Could not update release version in database!!");
|
||||
}
|
||||
print_continue("index.php");
|
||||
print_simple_box_start("CENTER");
|
||||
include("$CFG->dirroot/doc/release.html");
|
||||
include("$CFG->dirroot/lang/en/docs/release.html");
|
||||
print_simple_box_end();
|
||||
print_continue("index.php");
|
||||
exit;
|
||||
@@ -129,12 +216,29 @@
|
||||
}
|
||||
|
||||
foreach ($mods as $mod) {
|
||||
|
||||
if ($mod == "NEWMODULE") { // Someone has unzipped the template, ignore it
|
||||
continue;
|
||||
}
|
||||
|
||||
$fullmod = "$CFG->dirroot/mod/$mod";
|
||||
|
||||
unset($module);
|
||||
|
||||
include_once("$fullmod/version.php"); # defines $module with version etc
|
||||
include_once("$fullmod/db/$CFG->dbtype.php"); # defines upgrading function
|
||||
if ( is_readable("$fullmod/version.php")) {
|
||||
include_once("$fullmod/version.php"); # defines $module with version etc
|
||||
} else {
|
||||
notify("Module $mod: $fullmod/version.php was not readable");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_readable("$fullmod/db/$CFG->dbtype.php")) {
|
||||
include_once("$fullmod/db/$CFG->dbtype.php"); # defines upgrading function
|
||||
} else {
|
||||
notify("Module $mod: $fullmod/db/$CFG->dbtype.php was not readable");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!isset($module)) {
|
||||
continue;
|
||||
@@ -146,7 +250,7 @@
|
||||
if ($currmodule->version == $module->version) {
|
||||
// do nothing
|
||||
} else if ($currmodule->version < $module->version) {
|
||||
notify("$module->name module needs upgrading");
|
||||
print_heading("$module->name module needs upgrading");
|
||||
$upgrade_function = $module->name."_upgrade";
|
||||
if (function_exists($upgrade_function)) {
|
||||
$db->debug=true;
|
||||
@@ -157,7 +261,8 @@
|
||||
if (! update_record("modules", $module)) {
|
||||
error("Could not update $module->name record in modules table!");
|
||||
}
|
||||
notify(get_string("modulesuccess", "", $module->name));
|
||||
notify(get_string("modulesuccess", "", $module->name), "green");
|
||||
echo "<HR>";
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrading $module->name from $currmodule->version to $module->version FAILED!");
|
||||
@@ -169,16 +274,19 @@
|
||||
}
|
||||
|
||||
} else { // module not installed yet, so install it
|
||||
if (!$updated_modules) {
|
||||
if (empty($updated_modules)) {
|
||||
$strmodulesetup = get_string("modulesetup");
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup);
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, " ", " ");
|
||||
}
|
||||
print_heading($module->name);
|
||||
$updated_modules = true;
|
||||
$db->debug = true;
|
||||
set_time_limit(0); // To allow slow databases to complete the long SQL
|
||||
if (modify_database("$fullmod/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
if ($module->id = insert_record("modules", $module)) {
|
||||
notify(get_string("modulesuccess", "", $module->name));
|
||||
notify(get_string("modulesuccess", "", $module->name), "green");
|
||||
echo "<HR>";
|
||||
} else {
|
||||
error("$module->name module could not be added to the module list!");
|
||||
}
|
||||
@@ -188,7 +296,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated_modules) {
|
||||
if (!empty($updated_modules)) {
|
||||
print_continue("index.php");
|
||||
die;
|
||||
}
|
||||
@@ -198,20 +306,18 @@
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
$CFG = (array)$CFG;
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG[$name])) {
|
||||
$config->name = $name;
|
||||
$config->value = $CFG[$name] = $value;
|
||||
insert_record("config", $config);
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
$CFG = (object)$CFG;
|
||||
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if ($configchange) {
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php");
|
||||
}
|
||||
|
||||
@@ -221,13 +327,13 @@
|
||||
}
|
||||
|
||||
/// Set up the admin user
|
||||
if (! record_exists_sql("SELECT * FROM user_admins")) { // No admin user yet
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
redirect("user.php");
|
||||
}
|
||||
|
||||
/// Check for valid admin user
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
if (!iscreator()) {
|
||||
error("You need to be an admin user or teacher to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
|
||||
@@ -235,27 +341,46 @@
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
print_header("$site->shortname: $stradministration","$site->fullname: $stradministration", "$stradministration");
|
||||
|
||||
$table->head = array (get_string("site"), get_string("courses"), get_string("users"));
|
||||
$table->align = array ("CENTER", "CENTER", "CENTER");
|
||||
$table->data[0][0] = "<P><A HREF=\"config.php\">".get_string("configvariables")."</A></P>".
|
||||
"<P><A HREF=\"site.php\">".get_string("sitesettings")."</A></P>".
|
||||
"<P><A HREF=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</A></P>".
|
||||
"<P><A HREF=\"../theme/index.php\">".get_string("choosetheme")."</A></P>".
|
||||
"<P><A HREF=\"lang.php\">".get_string("checklanguage")."</A></P>";
|
||||
if (file_exists("$CFG->dirroot/admin/$CFG->dbtype")) {
|
||||
$table->data[0][0] .= "<P><A HREF=\"$CFG->dbtype/\">".get_string("managedatabase")."</A></P>";
|
||||
}
|
||||
$table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
|
||||
"<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
|
||||
"<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>".
|
||||
"<P><A HREF=\"../course/categories.php\">".get_string("categories")."</A></P>";
|
||||
$table->data[0][2] = "<P><A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A></P>".
|
||||
"<P><A HREF=\"user.php\">".get_string("edituser")."</A></P>".
|
||||
"<P><A HREF=\"auth.php\">".get_string("authentication")."</A></P>";
|
||||
|
||||
if (isadmin()) {
|
||||
$table->head = array (get_string("site"), get_string("courses"), get_string("users"));
|
||||
$table->align = array ("CENTER", "CENTER", "CENTER");
|
||||
$table->data[0][0] = "<p><a href=\"config.php\">".get_string("configvariables")."</a></p>".
|
||||
"<p><a href=\"site.php\">".get_string("sitesettings")."</a></p>".
|
||||
"<p><a href=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</a></p>".
|
||||
"<p><a href=\"../theme/index.php\">".get_string("choosetheme")."</a></p>".
|
||||
"<p><a href=\"lang.php\">".get_string("checklanguage")."</a></p>".
|
||||
"<p><a href=\"modules.php\">".get_string("managemodules")."</a></p>";
|
||||
if (file_exists("$CFG->dirroot/admin/$CFG->dbtype")) {
|
||||
$table->data[0][0] .= "<p><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></p>";
|
||||
}
|
||||
$table->data[0][1] = "<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>".
|
||||
"<p><a href=\"teacher.php\">".get_string("assignteachers")."</a></p>".
|
||||
"<p><a href=\"../course/delete.php\">".get_string("deletecourse")."</a></p>".
|
||||
"<p><a href=\"../course/categories.php\">".get_string("categories")."</a></p>";
|
||||
if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual") {
|
||||
$table->data[0][2] = "<p><a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a></p>";
|
||||
}
|
||||
$table->data[0][2] .= "<p><a href=\"user.php\">".get_string("edituser")."</a></p>".
|
||||
"<p><a href=\"admin.php\">".get_string("assignadmins")."</a></p>".
|
||||
"<p><a href=\"creators.php\">".get_string("assigncreators")."</a></p>".
|
||||
"<p><a href=\"auth.php\">".get_string("authentication")."</a></p>";
|
||||
} else { /// user is coursecreator
|
||||
$table->head = array (get_string("courses"));
|
||||
$table->align = array ("CENTER");
|
||||
$table->data[0][1] = "<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>".
|
||||
"<p><a href=\"teacher.php\">".get_string("assignteachers")."</a></p>";
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
echo "<br><div align=center>";
|
||||
print_single_button("$CFG->wwwroot/doc", NULL, get_string("documentation"));
|
||||
echo "</div>";
|
||||
|
||||
echo "<br><div align=center>";
|
||||
print_single_button("register.php", NULL, get_string("registration"));
|
||||
echo "</div>";
|
||||
|
||||
print_heading("Moodle $CFG->release ($CFG->version)", "CENTER", 1);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
+42
-29
@@ -1,6 +1,6 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require("../config.php");
|
||||
require_once("../config.php");
|
||||
|
||||
optional_variable($mode, "");
|
||||
|
||||
@@ -36,19 +36,19 @@
|
||||
break;
|
||||
}
|
||||
|
||||
if ($USER->lang) {
|
||||
$currentlang = $USER->lang;
|
||||
} else {
|
||||
$currentlang = $CFG->lang;
|
||||
}
|
||||
$currentlang = current_language();
|
||||
|
||||
print_header("$site->shortname: $title", "$site->fullname",
|
||||
"<A HREF=\"index.php\">$stradministration</A> -> $navigation");
|
||||
"<a href=\"index.php\">$stradministration</a> -> $navigation");
|
||||
|
||||
if (!$mode) {
|
||||
print_heading("$strcurrentlanguage: $currentlang - ".get_string("thislanguage"));
|
||||
print_heading("<A HREF=\"lang.php?mode=missing\">$strmissingstrings</A>");
|
||||
print_heading("<A HREF=\"lang.php?mode=compare\">$strcomparelanguage</A>");
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare\">$strcomparelanguage</a>");
|
||||
echo "<center><hr noshade size=1>";
|
||||
$options["lang"] = $currentlang;
|
||||
print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||
echo "</center>";
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
@@ -63,7 +63,7 @@
|
||||
}
|
||||
|
||||
foreach ($stringfiles as $key => $file) {
|
||||
if ($file == "README" or $file == "help" or $file == "docs") {
|
||||
if ($file == "README" or $file == "help" or $file == "docs" or $file == "fonts") {
|
||||
unset($stringfiles[$key]);
|
||||
}
|
||||
}
|
||||
@@ -86,15 +86,16 @@
|
||||
|
||||
$first = true;
|
||||
foreach ($enstring as $key => $value) {
|
||||
if (!isset($string[$key])) {
|
||||
if (!isset($string[$key]) or $string[$key] == "") {
|
||||
$value = htmlspecialchars($value);
|
||||
$value = str_replace("$"."a", "\\$"."a", $value);
|
||||
$value = str_replace("%%","%",$value);
|
||||
if ($first) {
|
||||
echo "</PRE><HR><P><B>".get_string("stringsnotset","","$langdir/$file")."</B></P><PRE>";
|
||||
$first = false;
|
||||
$somethingfound = true;
|
||||
}
|
||||
echo "$"."string[$key] = \"$value\";<BR>";
|
||||
echo "$"."string['$key'] = \"$value\";<BR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +123,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($somethingfound) {
|
||||
if (!empty($somethingfound)) {
|
||||
print_continue("lang.php");
|
||||
} else {
|
||||
notice(get_string("languagegood"), "lang.php");
|
||||
@@ -130,8 +131,8 @@
|
||||
|
||||
} else if ($mode == "compare") {
|
||||
|
||||
if (isset($HTTP_POST_VARS['file'])){ // Save a file
|
||||
$newstrings = $HTTP_POST_VARS;
|
||||
if (isset($_POST['file'])){ // Save a file
|
||||
$newstrings = $_POST;
|
||||
$file = $newstrings['file'];
|
||||
unset($newstrings['file']);
|
||||
if (lang_save_file($langdir, $file, $newstrings)) {
|
||||
@@ -147,7 +148,7 @@
|
||||
echo "</CENTER>";
|
||||
|
||||
foreach ($stringfiles as $file) {
|
||||
|
||||
|
||||
print_heading("$file", "LEFT", 4);
|
||||
|
||||
if (!file_exists("$langdir/$file")) {
|
||||
@@ -180,17 +181,28 @@
|
||||
echo "<TABLE WIDTH=\"100%\" CELLPADDING=2 CELLSPACING=3 BORDER=0>";
|
||||
foreach ($enstring as $key => $envalue) {
|
||||
$envalue = nl2br(htmlspecialchars($envalue));
|
||||
$envalue = str_replace("\$a","<B>\$a</B>", $envalue); // Make variables bold
|
||||
// TODO: It would be nice if all the $a->something variables were bold too
|
||||
$envalue = preg_replace('/(\$a\-\>[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
|
||||
$envalue = str_replace("%%","%",$envalue);
|
||||
|
||||
echo "<TR>";
|
||||
echo "<TD WIDTH=20% BGCOLOR=\"$THEME->cellheading\" NOWRAP VALIGN=TOP>$key</TD>";
|
||||
echo "<TD WIDTH=40% BGCOLOR=\"$THEME->cellheading\" VALIGN=TOP>$envalue</TD>";
|
||||
|
||||
$value = str_replace("\\","",$string[$key]); // Delete all slashes
|
||||
$value = $string[$key];
|
||||
$value = str_replace("\r","",$value); // Bad character caused by Windows
|
||||
$value = str_replace("\n\n\n\n\n\n","\n",$value); // Collapse runs of blank lines
|
||||
$value = str_replace("\n\n\n\n\n","\n",$value);
|
||||
$value = str_replace("\n\n\n\n","\n",$value);
|
||||
$value = str_replace("\n\n\n","\n",$value);
|
||||
$value = str_replace("\n\n\n","\n",$value);
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
$value = str_replace("%%","%",$value);
|
||||
$value = htmlspecialchars($value);
|
||||
|
||||
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
|
||||
|
||||
if ($editable) {
|
||||
echo "<TD WIDTH=40% VALIGN=TOP>";
|
||||
echo "<TD WIDTH=40% BGCOLOR=\"$cellcolour\" VALIGN=TOP>";
|
||||
if (isset($string[$key])) {
|
||||
$valuelen = strlen($value);
|
||||
} else {
|
||||
@@ -201,17 +213,15 @@
|
||||
$rows = ceil($valuelen / $cols);
|
||||
echo "<TEXTAREA NAME=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</TEXTAREA>";
|
||||
} else {
|
||||
$cols = $valuelen + 2;
|
||||
if ($valuelen) {
|
||||
$cols = $valuelen + 2;
|
||||
}
|
||||
echo "<INPUT TYPE=\"TEXT\" NAME=\"string-$key\" VALUE=\"$value\" SIZE=\"$cols\"></TD>";
|
||||
}
|
||||
echo "</TD>";
|
||||
|
||||
} else {
|
||||
if (isset($string[$key])) {
|
||||
echo "<TD WIDTH=40% BGCOLOR=white VALIGN=TOP>$value</TD>";
|
||||
} else {
|
||||
echo "<TD WIDTH=40% BGCOLOR=white ALIGN=CENTER VALIGN=TOP>-</TD>";
|
||||
}
|
||||
echo "<TD WIDTH=40% BGCOLOR=\"$cellcolour\" VALIGN=TOP>$value</TD>";
|
||||
}
|
||||
}
|
||||
if ($editable) {
|
||||
@@ -257,10 +267,13 @@ function lang_save_file($path, $file, $strings) {
|
||||
|
||||
foreach ($strings as $key => $value) {
|
||||
list($id, $stringname) = explode("-",$key);
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
if ($CFG->lang != "zh_hk" and $CFG->lang != "zh_tw") { // Some MB languages include backslash bytes
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
}
|
||||
$value = str_replace("$"."a", "\\$"."a", $value); // Add slashes for $a
|
||||
$value = str_replace("\"", "\\\"", $value); // Add slashes for "
|
||||
if ($id == "string"){
|
||||
$value = str_replace("\"", "\\\\\\\"", $value); // Add slashes for "
|
||||
$value = str_replace("%","%%",$value); // Escape % characters
|
||||
if ($id == "string" and $value != ""){
|
||||
fwrite($f,"\$string['$stringname'] = \"$value\";\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("../course/lib.php");
|
||||
|
||||
optional_variable($disable);
|
||||
optional_variable($enable);
|
||||
optional_variable($delete);
|
||||
optional_variable($confirm);
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strmanagemodules = get_string("managemodules");
|
||||
$strdelete = get_string("delete");
|
||||
$strhide = get_string("hide");
|
||||
$strshow = get_string("show");
|
||||
$stractivitymodule = get_string("activitymodule");
|
||||
|
||||
print_header("$site->shortname: $strmanagemodules", "$site->fullname",
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strmanagemodules");
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide)) {
|
||||
if (!$module = get_record("modules", "name", $hide)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
set_field("course_modules", "visible", "0", "module", $module->id); // Hide all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($show)) {
|
||||
if (!$module = get_record("modules", "name", $show)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field("course_modules", "visible", "1", "module", $module->id); // Show all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($delete)) {
|
||||
|
||||
$strmodulename = get_string("modulename", "$delete");
|
||||
|
||||
if (empty($confirm)) {
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=$delete",
|
||||
"modules.php");
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "forum") {
|
||||
error("You can not delete the forum module!!");
|
||||
}
|
||||
|
||||
if (!$module = get_record("modules", "name", $delete)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
|
||||
// OK, first delete all the relevant instances from all course sections
|
||||
if ($coursemods = get_records("course_modules", "module", $module->id)) {
|
||||
foreach ($coursemods as $coursemod) {
|
||||
if (! delete_mod_from_section($coursemod->id, $coursemod->section)) {
|
||||
notify("Could not delete the $strmodulename with id = $coursemod->id from section $coursemod->section");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now delete all the course module records
|
||||
if (!delete_records("course_modules", "module", $module->id)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in course_modules table");
|
||||
}
|
||||
|
||||
// Then delete all the logs
|
||||
if (!delete_records("log", "module", $module->name)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in log table");
|
||||
}
|
||||
|
||||
// And log_display information
|
||||
if (!delete_records("log_display", "module", $module->name)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in log_display table");
|
||||
}
|
||||
|
||||
// And the module entry itself
|
||||
if (!delete_records("modules", "name", $module->name)) {
|
||||
notify("Error occurred while deleting the $strmodulename record from modules table");
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$module->name;
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table, $prefix) === 0) {
|
||||
if (!execute_sql("DROP TABLE $table", false)) {
|
||||
notify("ERROR: while trying to drop table $table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rebuild_course_cache(); // Because things have changed
|
||||
|
||||
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
notice(get_string("moduledeletefiles", "", $a), "modules.php");
|
||||
}
|
||||
}
|
||||
|
||||
/// Get and sort the existing modules
|
||||
|
||||
if (!$modules = get_records("modules")) {
|
||||
error("No modules found!!"); // Should never happen
|
||||
}
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$strmodulename = get_string("modulename", "$module->name");
|
||||
$modulebyname[$strmodulename] = $module;
|
||||
}
|
||||
ksort($modulebyname);
|
||||
|
||||
/// Print the table of all modules
|
||||
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = "../pix";
|
||||
$modpixpath = "../mod";
|
||||
} else {
|
||||
$pixpath = "../theme/$CFG->theme/pix";
|
||||
$modpixpath = "../theme/$CFG->theme/pix/mod";
|
||||
}
|
||||
|
||||
$table->head = array ($stractivitymodule, "$strhide/$strshow", $strdelete);
|
||||
$table->align = array ("LEFT", "CENTER", "CENTER");
|
||||
$table->wrap = array ("NOWRAP", "", "");
|
||||
$table->size = array ("100%", "10", "10");
|
||||
$table->width = "100";
|
||||
|
||||
foreach ($modulebyname as $modulename => $module) {
|
||||
|
||||
$icon = "<img src=\"$modpixpath/$module->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name\">$strdelete</a>";
|
||||
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name\" title=\"$strhide\">".
|
||||
"<img src=\"$pixpath/i/hide.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name\" title=\"$strshow\">".
|
||||
"<img src=\"$pixpath/i/show.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$table->data[] = array ("<p $class>$icon $modulename</p>", $visible, $delete);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
echo "<br /><br />";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?PHP // $Id$
|
||||
// phpinfo.php - shows phpinfo for the current server
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
print_header("$site->shortname: phpinfo", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> phpinfo");
|
||||
|
||||
phpinfo();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,138 @@
|
||||
<?PHP // $Id$
|
||||
// register.php - allows admin to register their site on moodle.org
|
||||
|
||||
include("../config.php");
|
||||
require_once("../lib/countries.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
error("No admins");
|
||||
}
|
||||
|
||||
if (!$admin->country and $CFG->country) {
|
||||
$admin->country = $CFG->country;
|
||||
}
|
||||
|
||||
if (!$admin->secret) { // secret field hasn't been set yet
|
||||
$admin->secret = random_string(15);
|
||||
|
||||
if (!set_field("user", "secret", $admin->secret, "id", $admin->id)) {
|
||||
error("Could not set admin's secret string!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strregistration = get_string("registration");
|
||||
$strregistrationinfo = get_string("registrationinfo");
|
||||
|
||||
print_header("$site->shortname: $strregistration", "$site->fullname",
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
print_simple_box($strregistrationinfo, "center", "70%");
|
||||
echo "<br />";
|
||||
|
||||
|
||||
/// Print the form
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
echo "<form name=\"form\" action=\"http://moodle.org/register/\" method=post>\n";
|
||||
echo "<table cellpadding=9 border=0>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>Moodle URL:</td>\n";
|
||||
echo "<td><p>$CFG->wwwroot</td>\n";
|
||||
echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
|
||||
echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
|
||||
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\">\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$admin->secret\">\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\">\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("currentversion").":</td>\n";
|
||||
echo "<td><p>$CFG->release ($CFG->version)</td>\n";
|
||||
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\">\n";
|
||||
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("fullsitename").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"sitename\" value=\"$site->fullname\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("country").":</td>\n";
|
||||
echo "<td><p>";
|
||||
choose_from_menu ($COUNTRIES, "country", $admin->country, get_string("selectacountry")."...", "", "");
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p><a href=\"http://moodle.org/sites\" title=\"See the current list of sites\" target=_blank>".get_string("publicdirectory")."</a>:</td>\n";
|
||||
echo "<td><p>";
|
||||
$options[0] = get_string("publicdirectory0");
|
||||
$options[1] = get_string("publicdirectory1");
|
||||
$options[2] = get_string("publicdirectory2");
|
||||
choose_from_menu ($options, "public", "2", "", "", "");
|
||||
unset($options);
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td colspan=2><hr size=1 noshade>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("administrator").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"adminname\" value=\"$admin->firstname $admin->lastname\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("email").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"adminemail\" value=\"$admin->email\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("registrationemail")."</a>:</td>\n";
|
||||
echo "<td><p>\n";
|
||||
$options[0] = get_string("registrationno");
|
||||
$options[1] = get_string("registrationyes");
|
||||
choose_from_menu ($options, "mailme", "1", "", "", "");
|
||||
unset($options);
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right> </td>\n";
|
||||
echo "<td><p><input type=\"submit\" value=\"".get_string("registrationsend")."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<br />\n";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+30
-28
@@ -1,28 +1,31 @@
|
||||
<FORM METHOD="post" action="site.php" NAME="form">
|
||||
<TABLE cellpadding=9 cellspacing=0 >
|
||||
<form method="post" action="site.php" name="form">
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><P><? print_string("fullsitename") ?>:</td>
|
||||
<td><input type="text" name="fullname" size=50 value="<? p($form->fullname) ?>">
|
||||
<? formerr($err["fullname"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><? print_string("shortsitename") ?>:</td>
|
||||
<td><input type="text" name="shortname" size=50 value="<? p($form->shortname) ?>">
|
||||
<? formerr($err["shortname"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><? print_string("frontpagedescription") ?>:</P><BR>
|
||||
<? helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
<td><TEXTAREA NAME=summary COLS=50 ROWS=10 WRAP=virtual><? p($form->summary) ?></TEXTAREA>
|
||||
<? formerr($err["summary"]) ?>
|
||||
<td align=right><P><?php print_string("fullsitename") ?>:</td>
|
||||
<td><input type="text" name="fullname" size=50 value="<?php p($form->fullname) ?>">
|
||||
<?php if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><? print_string("frontpageformat") ?>:</td>
|
||||
<td><?
|
||||
<td align=right><P><?php print_string("shortsitename") ?>:</td>
|
||||
<td><input type="text" name="shortname" size=50 value="<?php p($form->shortname) ?>">
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("frontpagedescription") ?>:</P><br />
|
||||
<font size=1>
|
||||
<?php helpbutton("writing", get_string("helpwriting"), "moodle", true, true) ?><br />
|
||||
<?php helpbutton("html", get_string("helphtml"), "moodle", true, true) ?><br />
|
||||
</font>
|
||||
</td>
|
||||
<td><textarea name=summary cols=50 rows=10 wrap=virtual><?php p($form->summary) ?></textarea>
|
||||
<?php if (isset($err["summary"])) formerr($err["summary"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("frontpageformat") ?>:</td>
|
||||
<td><?php
|
||||
$newsitem = get_string("newsitem");
|
||||
$newsitems = get_string("newsitems");
|
||||
$options = array("0" => get_string("showlistofcourses"),
|
||||
@@ -37,16 +40,15 @@
|
||||
"9" => "9 $newsitems",
|
||||
"10" => "10 $newsitems");
|
||||
choose_from_menu ($options, "newsitems", "$form->newsitems", "");
|
||||
formerr($err["newsitems"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<? print_string("savechanges") ?>"></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</TABLE>
|
||||
<INPUT type="hidden" name="id" value="<?=$form->id ?>">
|
||||
<INPUT type="hidden" name="category" value="<?=$form->category ?>">
|
||||
<INPUT type="hidden" name="format" value="<?=$form->format ?>">
|
||||
</FORM>
|
||||
</table>
|
||||
<input type="hidden" name="id" value="<?php p($form->id) ?>">
|
||||
<input type="hidden" name="category" value="<?php p($form->category) ?>">
|
||||
<input type="hidden" name="format" value="<?php p($form->format) ?>">
|
||||
</form>
|
||||
|
||||
+34
-15
@@ -1,19 +1,17 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require("../config.php");
|
||||
require_once("../config.php");
|
||||
|
||||
if ($site = get_site()) {
|
||||
if (!isadmin()) {
|
||||
error("You need to be admin to edit this page");
|
||||
}
|
||||
$site->format = "social"; // override
|
||||
}
|
||||
$site->format = "social"; // override
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
|
||||
$form = (object)$HTTP_POST_VARS;
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
validate_form($form, $err);
|
||||
|
||||
@@ -23,7 +21,7 @@
|
||||
|
||||
if ($form->id) {
|
||||
if (update_record("course", $form)) {
|
||||
redirect("index.php", get_string("changessaved"));
|
||||
redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"));
|
||||
} else {
|
||||
error("Serious Error! Could not update the site record! (id = $form->id)");
|
||||
}
|
||||
@@ -31,7 +29,7 @@
|
||||
if ($newid = insert_record("course", $form)) {
|
||||
$cat->name = get_string("miscellaneous");
|
||||
if (insert_record("course_categories", $cat)) {
|
||||
redirect("index.php", get_string("changessaved"), "1");
|
||||
redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"));
|
||||
} else {
|
||||
error("Serious Error! Could not set up a default course category!");
|
||||
}
|
||||
@@ -39,36 +37,57 @@
|
||||
error("Serious Error! Could not set up the site!");
|
||||
}
|
||||
}
|
||||
die;
|
||||
die;
|
||||
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if ($site && !$form) {
|
||||
if ($site and empty($form)) {
|
||||
$form = $site;
|
||||
$firsttime = false;
|
||||
} else {
|
||||
$form->fullname = "";
|
||||
$form->shortname = "";
|
||||
$form->summary = "";
|
||||
$form->newsitems = 0;
|
||||
$form->id = "";
|
||||
$form->category = 0;
|
||||
$form->format = "social";
|
||||
$form->newsitems = 0;
|
||||
$firsttime = true;
|
||||
}
|
||||
|
||||
if (empty($focus)) {
|
||||
$focus = "form.fullname";
|
||||
}
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strsitesettings = get_string("sitesettings");
|
||||
|
||||
print_header("$site->shortname: $strsitesettings", "$site->fullname",
|
||||
"<A HREF=\"index.php\">$stradmin</A> -> $strsitesettings", "$focus");
|
||||
if ($firsttime) {
|
||||
print_header();
|
||||
print_heading($strsitesettings);
|
||||
print_simple_box(get_string("configintrosite"), "center");
|
||||
echo "<br />";
|
||||
} else {
|
||||
print_header("$site->shortname: $strsitesettings", "$site->fullname",
|
||||
"<A HREF=\"index.php\">$stradmin</A> -> $strsitesettings", "$focus");
|
||||
print_heading($strsitesettings);
|
||||
}
|
||||
|
||||
print_heading($strsitesettings);
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("site.html");
|
||||
include("site.html");
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
|
||||
if (!$firsttime) {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign teachers to courses
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 30);
|
||||
|
||||
optional_variable($id); // course id
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
optional_variable($search, ""); // search string
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!iscreator()) {
|
||||
error("You must be an administrator or course creator to use this page.");
|
||||
}
|
||||
|
||||
$strassignteachers = get_string("assignteachers");
|
||||
$stradministration = get_string("administration");
|
||||
$strexistingteachers = get_string("existingteachers");
|
||||
$strnoexistingteachers = get_string("noexistingteachers");
|
||||
$strpotentialteachers = get_string("potentialteachers");
|
||||
$strnopotentialteachers = get_string("nopotentialteachers");
|
||||
$straddteacher = get_string("addteacher");
|
||||
$strremoveteacher = get_string("removeteacher");
|
||||
$strsearch = get_string("search");
|
||||
$strsearchresults = get_string("searchresults");
|
||||
$strsearchagain = get_string("searchagain");
|
||||
$strtoomanytoshow = get_string("toomanytoshow");
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
|
||||
if (!$id) {
|
||||
print_header("$site->shortname: $strassignteachers", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strassignteachers");
|
||||
|
||||
$isadmin = isadmin(); /// cache value
|
||||
$courses = get_courses();
|
||||
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("center");
|
||||
|
||||
foreach ($courses as $course) {
|
||||
if ($isadmin or isteacher($course->id, $USER->id)){
|
||||
echo "<a href=\"teacher.php?id=$course->id\">$course->fullname ($course->shortname)</a><br>\n";
|
||||
$coursesfound = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
if ($coursesfound == FALSE) {
|
||||
print_heading(get_string("nocoursesyet"));
|
||||
print_continue("../$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect (can't find it)");
|
||||
}
|
||||
|
||||
|
||||
print_header("$site->shortname: $course->shortname: $strassignteachers",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> ->
|
||||
<a href=\"teacher.php\">$strassignteachers</a> -> $course->shortname", "");
|
||||
|
||||
print_heading("<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname ($course->shortname)</a>");
|
||||
|
||||
|
||||
/// Get all existing teachers for this course.
|
||||
$teachers = get_course_teachers($course->id);
|
||||
|
||||
/// Add a teacher if one is specified
|
||||
|
||||
if (!empty($add)) {
|
||||
if (!isteacher($course->id)){
|
||||
error("You must be an administrator or teacher to modify this course.");
|
||||
}
|
||||
|
||||
if (! $user = get_record("user", "id", $add)) {
|
||||
error("That teacher (id = $add) doesn't exist", "teacher.php?id=$course->id");
|
||||
}
|
||||
|
||||
if (!empty($teachers)) {
|
||||
foreach ($teachers as $tt) {
|
||||
if ($tt->id == $user->id) {
|
||||
error("That user is already a teacher for this course.", "teacher.php?id=$course->id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$teacher->userid = $user->id;
|
||||
$teacher->course = $course->id;
|
||||
if (!empty($teachers)) {
|
||||
$teacher->authority = 2;
|
||||
} else {
|
||||
$teacher->authority = 1; // First teacher is the main teacher
|
||||
}
|
||||
$teacher->id = insert_record("user_teachers", $teacher);
|
||||
if (empty($teacher->id)) {
|
||||
error("Could not add that teacher to this course!");
|
||||
}
|
||||
$teachers[] = $user;
|
||||
}
|
||||
|
||||
/// Remove a teacher if one is specified.
|
||||
|
||||
if (!empty($remove)) {
|
||||
|
||||
if (!isteacher($course->id)){
|
||||
error("You must be an administrator or teacher to modify this course.");
|
||||
}
|
||||
if (! $user = get_record("user", "id", $remove)) {
|
||||
error("That teacher (id = $remove) doesn't exist", "teacher.php?id=$course->id");
|
||||
}
|
||||
if (!empty($teachers)) {
|
||||
foreach ($teachers as $key => $tt) {
|
||||
if ($tt->id == $user->id) {
|
||||
remove_teacher($user->id, $course->id);
|
||||
unset($teachers[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print the lists of existing and potential teachers
|
||||
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingteachers</th><th width=50%>$strpotentialteachers</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
/// First, show existing teachers for this course
|
||||
|
||||
if (empty($teachers)) {
|
||||
echo "<p align=center>$strnoexistingteachers</a>";
|
||||
$teacherlist = "";
|
||||
|
||||
} else {
|
||||
$teacherarray = array();
|
||||
foreach ($teachers as $teacher) {
|
||||
$teacherarray[] = $teacher->id;
|
||||
echo "<p align=right>$teacher->firstname $teacher->lastname, $teacher->email <a href=\"teacher.php?id=$course->id&remove=$teacher->id\" title=\"$strremoveteacher\"><img src=\"../pix/t/right.gif\" border=0></a></p>";
|
||||
}
|
||||
$teacherlist = implode(",",$teacherarray);
|
||||
unset($teacherarray);
|
||||
}
|
||||
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
/// Print list of potential teachers
|
||||
|
||||
$usercount = get_users(false, $search, true, $teacherlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialteachers</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow</p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $teacherlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><a href=\"{$_SERVER['PHP_SELF']}?id=$course->id&add=$user->id\"".
|
||||
"title=\"$straddteacher\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action={$_SERVER['PHP_SELF']} method=post>";
|
||||
echo "<input type=hidden name=id value=\"$course->id\">";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+114
-89
@@ -1,8 +1,8 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require("../config.php");
|
||||
require("../user/lib.php");
|
||||
require("../lib/countries.php");
|
||||
require_once("../config.php");
|
||||
require_once("../user/lib.php");
|
||||
require_once("../lib/countries.php");
|
||||
|
||||
$recordsperpage = 30;
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
optional_variable($sort, "name");
|
||||
optional_variable($dir, "ASC");
|
||||
optional_variable($page, 0);
|
||||
optional_variable($search, "");
|
||||
|
||||
if (! record_exists_sql("SELECT * FROM user_admins")) { // No admin user yet
|
||||
$user->firstname = "Admin";
|
||||
$user->lastname = "User";
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
$user->firstname = get_string("admin");
|
||||
$user->lastname = get_string("user");
|
||||
$user->username = "admin";
|
||||
$user->password = md5("admin");
|
||||
$user->email = "root@localhost";
|
||||
@@ -28,7 +29,7 @@
|
||||
error("SERIOUS ERROR: Could not create admin user record !!!");
|
||||
}
|
||||
|
||||
$admin->user = $user->id;
|
||||
$admin->userid = $user->id;
|
||||
|
||||
if (! insert_record("user_admins", $admin)) {
|
||||
error("Could not make user $user->id an admin !!!");
|
||||
@@ -42,7 +43,7 @@
|
||||
error("Could not find site-level course");
|
||||
}
|
||||
|
||||
$teacher->user = $user->id;
|
||||
$teacher->userid = $user->id;
|
||||
$teacher->course = $site->id;
|
||||
$teacher->authority = 1;
|
||||
if (! insert_record("user_teachers", $teacher)) {
|
||||
@@ -54,9 +55,10 @@
|
||||
$USER->site = $CFG->wwwroot;
|
||||
$USER->admin = true;
|
||||
$USER->teacher["$site->id"] = true;
|
||||
save_session("USER");
|
||||
$USER->newadminuser = true;
|
||||
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
exit;
|
||||
|
||||
} else {
|
||||
if (! $site = get_site()) {
|
||||
@@ -95,6 +97,8 @@
|
||||
$stredit = get_string("edit");
|
||||
$strdelete = get_string("delete");
|
||||
$strdeletecheck = get_string("deletecheck");
|
||||
$strsearch = get_string("search");
|
||||
$strshowallusers = get_string("showallusers");
|
||||
|
||||
print_header("$site->shortname: $stredituser", $site->fullname,
|
||||
"<A HREF=\"index.php\">$stradministration</A> -> $stredituser");
|
||||
@@ -126,11 +130,6 @@
|
||||
|
||||
// Carry on with the user listing
|
||||
|
||||
if (!$user = get_record_sql("SELECT count(*) as count FROM user WHERE username <> 'guest' AND deleted <> '1'")) {
|
||||
error("Could not search for users?");
|
||||
}
|
||||
|
||||
$usercount = $user->count;
|
||||
|
||||
$columns = array("name", "email", "city", "country", "lastaccess");
|
||||
|
||||
@@ -145,7 +144,7 @@
|
||||
if ($columnsort == $sort) {
|
||||
$$column = $string[$column];
|
||||
} else {
|
||||
$$column = "<A HREF=\"user.php?sort=$columnsort&dir=$columndir\">".$string[$column]."</A>";
|
||||
$$column = "<A HREF=\"user.php?sort=$columnsort&dir=$columndir&search=$search\">".$string[$column]."</A>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,91 +152,117 @@
|
||||
$sort = "firstname";
|
||||
}
|
||||
|
||||
if ($users = get_records_sql("SELECT id, username, email, firstname, lastname, city, country, lastaccess from user WHERE username <> 'guest'
|
||||
AND deleted <> '1' ORDER BY $sort $dir LIMIT $page,$recordsperpage")) {
|
||||
if (!$users = get_users_listing($sort, $dir, $page, $recordsperpage, $search)) {
|
||||
if (!$users = get_users_listing($sort, $dir, 0, $recordsperpage)) {
|
||||
error("No users found!");
|
||||
} else {
|
||||
notify(get_string("nousersmatching", "", $search));
|
||||
$search = "";
|
||||
}
|
||||
}
|
||||
|
||||
$usercount = get_users(false);
|
||||
|
||||
if ($search) {
|
||||
$usersearchcount = get_users(false, $search);
|
||||
print_heading("$usersearchcount / $usercount ".get_string("users"));
|
||||
$usercount = $usersearchcount;
|
||||
} else {
|
||||
print_heading("$usercount ".get_string("users"));
|
||||
}
|
||||
|
||||
$a->start = $page;
|
||||
$a->end = $page + $recordsperpage;
|
||||
if ($a->end > $usercount) {
|
||||
$a->end = $usercount;
|
||||
}
|
||||
echo "<TABLE align=center cellpadding=10><TR>";
|
||||
echo "<TD>";
|
||||
if ($page) {
|
||||
$prevpage = $page - $recordsperpage;
|
||||
if ($prevpage < 0) {
|
||||
$prevpage = 0;
|
||||
}
|
||||
$options["dir"] = $dir;
|
||||
$options["page"] = 0;
|
||||
$options["sort"] = $sort;
|
||||
print_single_button("user.php", $options, " << ");
|
||||
echo "</TD><TD>";
|
||||
$options["page"] = $prevpage;
|
||||
print_single_button("user.php", $options, " < ");
|
||||
$a->start = $page;
|
||||
$a->end = $page + $recordsperpage;
|
||||
if ($a->end > $usercount) {
|
||||
$a->end = $usercount;
|
||||
}
|
||||
echo "<TABLE align=center cellpadding=10><TR>";
|
||||
echo "<TD>";
|
||||
if ($page) {
|
||||
$prevpage = $page - $recordsperpage;
|
||||
if ($prevpage < 0) {
|
||||
$prevpage = 0;
|
||||
}
|
||||
$options["dir"] = $dir;
|
||||
$options["page"] = 0;
|
||||
$options["sort"] = $sort;
|
||||
$options["search"] = $search;
|
||||
print_single_button("user.php", $options, " << ");
|
||||
echo "</TD><TD>";
|
||||
print_heading(get_string("displayingusers", "", $a));
|
||||
$options["page"] = $prevpage;
|
||||
print_single_button("user.php", $options, " < ");
|
||||
}
|
||||
echo "</TD><TD>";
|
||||
print_heading(get_string("displayingusers", "", $a));
|
||||
echo "</TD><TD>";
|
||||
$nextpage = $page + $recordsperpage;
|
||||
if ($nextpage < $usercount) {
|
||||
$options["dir"] = $dir;
|
||||
$options["page"] = $nextpage;
|
||||
$options["sort"] = $sort;
|
||||
$options["search"] = $search;
|
||||
print_single_button("user.php", $options, " > ");
|
||||
echo "</TD><TD>";
|
||||
$nextpage = $page + $recordsperpage;
|
||||
if ($nextpage < $usercount) {
|
||||
$options["dir"] = $dir;
|
||||
$options["page"] = $nextpage;
|
||||
$options["sort"] = $sort;
|
||||
print_single_button("user.php", $options, " > ");
|
||||
echo "</TD><TD>";
|
||||
$options["page"] = $usercount-$recordsperpage;
|
||||
print_single_button("user.php", $options, " >> ");
|
||||
}
|
||||
echo "</TD></TR></TABLE>";
|
||||
$options["page"] = $usercount-$recordsperpage;
|
||||
print_single_button("user.php", $options, " >> ");
|
||||
}
|
||||
echo "</TD></TR></TABLE>";
|
||||
|
||||
flush();
|
||||
flush();
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
foreach ($users as $key => $user) {
|
||||
if (!empty($user->country)) {
|
||||
$users[$key]->country = $COUNTRIES[$user->country];
|
||||
}
|
||||
if ($sort == "country") { // Need to resort by full country name, not code
|
||||
foreach ($users as $user) {
|
||||
$susers[$user->id] = $user->country;
|
||||
}
|
||||
asort($susers);
|
||||
foreach ($susers as $key => $value) {
|
||||
$nusers[] = $users[$key];
|
||||
}
|
||||
$users = $nusers;
|
||||
}
|
||||
|
||||
$table->head = array ($name, $email, $city, $country, $lastaccess, "", "");
|
||||
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "CENTER", "CENTER");
|
||||
$table->width = "95%";
|
||||
foreach ($users as $user) {
|
||||
if ($user->id == $USER->id or $user->username == "changeme") {
|
||||
$deletebutton = "";
|
||||
} else {
|
||||
$deletebutton = "<A HREF=\"user.php?delete=$user->id\" TARGET=\"$strdeletecheck\">$strdelete</A>";
|
||||
}
|
||||
if ($user->lastaccess) {
|
||||
$strlastaccess = format_time(time() - $user->lastaccess);
|
||||
} else {
|
||||
$strlastaccess = get_string("never");
|
||||
}
|
||||
$table->data[] = array ("<A HREF=\"../user/view.php?id=$user->id&course=$site->id\">$user->firstname $user->lastname</A>",
|
||||
"$user->email",
|
||||
"$user->city",
|
||||
"$user->country",
|
||||
$strlastaccess,
|
||||
"<A HREF=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</A>",
|
||||
$deletebutton);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
print_heading("<A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A>");
|
||||
} else {
|
||||
error("No users found!");
|
||||
|
||||
}
|
||||
if ($sort == "country") { // Need to resort by full country name, not code
|
||||
foreach ($users as $user) {
|
||||
$susers[$user->id] = $user->country;
|
||||
}
|
||||
asort($susers);
|
||||
foreach ($susers as $key => $value) {
|
||||
$nusers[] = $users[$key];
|
||||
}
|
||||
$users = $nusers;
|
||||
}
|
||||
|
||||
$table->head = array ($name, $email, $city, $country, $lastaccess, "", "");
|
||||
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "CENTER", "CENTER");
|
||||
$table->width = "95%";
|
||||
foreach ($users as $user) {
|
||||
if ($user->id == $USER->id or $user->username == "changeme") {
|
||||
$deletebutton = "";
|
||||
} else {
|
||||
$deletebutton = "<A HREF=\"user.php?delete=$user->id\" TARGET=\"$strdeletecheck\">$strdelete</A>";
|
||||
}
|
||||
if ($user->lastaccess) {
|
||||
$strlastaccess = format_time(time() - $user->lastaccess);
|
||||
} else {
|
||||
$strlastaccess = get_string("never");
|
||||
}
|
||||
$table->data[] = array ("<A HREF=\"../user/view.php?id=$user->id&course=$site->id\">$user->firstname $user->lastname</A>",
|
||||
"$user->email",
|
||||
"$user->city",
|
||||
"$user->country",
|
||||
$strlastaccess,
|
||||
"<A HREF=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</A>",
|
||||
$deletebutton);
|
||||
}
|
||||
|
||||
echo "<TABLE align=center cellpadding=10><TR><TD>";
|
||||
echo "<FORM ACTION=user.php METHOD=POST>";
|
||||
echo "<INPUT TYPE=text NAME=search VALUE=\"$search\" SIZE=20>";
|
||||
echo "<INPUT TYPE=submit VALUE=\"$strsearch\">";
|
||||
if ($search) {
|
||||
echo "<INPUT type=\"button\" onClick=\"document.location='user.php';\" value=\"$strshowallusers\">";
|
||||
}
|
||||
echo "</FORM>";
|
||||
echo "</TD></TR></TABLE>";
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_heading("<A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A>");
|
||||
|
||||
print_footer();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ none - no authentication at all .. very insecure!!
|
||||
- when user tries to access a course they
|
||||
are forced to set up their account details
|
||||
|
||||
manual - internal authentication only
|
||||
|
||||
- user logs in using username and password
|
||||
- no way for user to make their own account
|
||||
|
||||
|
||||
ldap - Uses an external LDAP server
|
||||
|
||||
|
||||
+51
-7
@@ -1,8 +1,37 @@
|
||||
<?PHP
|
||||
if (!isset($config->auth_dbhost)) {
|
||||
$config->auth_dbhost = "localhost";
|
||||
}
|
||||
if (!isset($config->auth_dbtype)) {
|
||||
$config->auth_dbtype = "mysql";
|
||||
}
|
||||
if (!isset($config->auth_dbname)) {
|
||||
$config->auth_dbname = "";
|
||||
}
|
||||
if (!isset($config->auth_dbuser)) {
|
||||
$config->auth_dbuser = "";
|
||||
}
|
||||
if (!isset($config->auth_dbpass)) {
|
||||
$config->auth_dbpass = "";
|
||||
}
|
||||
if (!isset($config->auth_dbtable)) {
|
||||
$config->auth_dbtable = "";
|
||||
}
|
||||
if (!isset($config->auth_dbfielduser)) {
|
||||
$config->auth_dbfielduser = "";
|
||||
}
|
||||
if (!isset($config->auth_dbfieldpass)) {
|
||||
$config->auth_dbfieldpass = "";
|
||||
}
|
||||
if (!isset($config->auth_dbpasstype)) {
|
||||
$config->auth_dbpasstype = "plaintext";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbhost:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_dbhost TYPE=text SIZE=30 VALUE="<?=$config->auth_dbhost?>">
|
||||
<? formerr($err["auth_dbhost"]); ?>
|
||||
<? if (isset($err["auth_dbhost"])) formerr($err["auth_dbhost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbhost","auth") ?>
|
||||
@@ -29,7 +58,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_dbname:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_dbname TYPE=text SIZE=30 VALUE="<?=$config->auth_dbname?>">
|
||||
<? formerr($err["auth_dbname"]); ?>
|
||||
<? if (isset($err["auth_dbname"]))formerr($err["auth_dbname"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbname","auth") ?>
|
||||
@@ -40,7 +69,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_dbuser:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_dbuser TYPE=text SIZE=30 VALUE="<?=$config->auth_dbuser?>">
|
||||
<? formerr($err["auth_dbuser"]); ?>
|
||||
<? if (isset($err["auth_dbuser"])) formerr($err["auth_dbuser"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbuser","auth") ?>
|
||||
@@ -51,7 +80,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_dbpass:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbpass?>">
|
||||
<? formerr($err["auth_dbpass"]); ?>
|
||||
<? if (isset($err["auth_dbpass"])) formerr($err["auth_dbpass"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbpass","auth") ?>
|
||||
@@ -62,7 +91,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_dbtable:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbtable" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbtable?>">
|
||||
<? formerr($err["auth_dbtable"]); ?>
|
||||
<? if (isset($err["auth_dbtable"])) formerr($err["auth_dbtable"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbtable","auth") ?>
|
||||
@@ -73,7 +102,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_dbfielduser:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbfielduser" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfielduser?>">
|
||||
<? formerr($err["auth_dbfielduser"]); ?>
|
||||
<? if (isset($err["auth_dbfielduser"])) formerr($err["auth_dbfielduser"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbfielduser","auth") ?>
|
||||
@@ -84,13 +113,28 @@
|
||||
<TD ALIGN=RIGHT><P>auth_dbfieldpass:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_dbfieldpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfieldpass?>">
|
||||
<? formerr($err["auth_dbfieldpass"]); ?>
|
||||
<? if (isset($err["auth_dbfieldpass"])) formerr($err["auth_dbfieldpass"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbfieldpass","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_dbpasstype:</TD>
|
||||
<TD>
|
||||
<? $passtype["plaintext"] = get_string("plaintext", "auth");
|
||||
$passtype["md5"] = get_string("md5", "auth");
|
||||
choose_from_menu($passtype, "auth_dbpasstype", $config->auth_dbpasstype, "");
|
||||
?>
|
||||
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_dbpasstype","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT><P><? print_string("firstname") ?>:</TD>
|
||||
<TD>
|
||||
|
||||
+14
-5
@@ -1,9 +1,6 @@
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up an external database table
|
||||
|
||||
// This code is completely untested so far - IT NEEDS TESTERS!
|
||||
// Looks like it should work though ...
|
||||
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns true if the username and password work
|
||||
@@ -11,10 +8,21 @@ function auth_user_login ($username, $password) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
ADOLoadCode($CFG->auth_dbtype);
|
||||
$authdb = &ADONewConnection();
|
||||
// This is a hack to workaround what seems to be a bug in ADOdb with accessing
|
||||
// two databases of the same kind ... it seems to get confused when trying to access
|
||||
// the first database again, after having accessed the second.
|
||||
// The following hack will make the database explicit which keeps it happy
|
||||
$CFG->prefix = "$CFG->dbname.$CFG->prefix";
|
||||
|
||||
// Connect to the external database
|
||||
$authdb = &ADONewConnection($CFG->auth_dbtype);
|
||||
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
|
||||
|
||||
switch ($CFG->auth_dbpasstype) { // Re-format password accordingly
|
||||
case "md5":
|
||||
$password = md5($password);
|
||||
break;
|
||||
}
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username'
|
||||
@@ -37,6 +45,7 @@ function auth_get_userinfo($username){
|
||||
// then returns it in an array
|
||||
|
||||
global $CFG;
|
||||
|
||||
$config = (array) $CFG;
|
||||
|
||||
ADOLoadCode($CFG->auth_dbtype);
|
||||
|
||||
+13
-2
@@ -1,8 +1,19 @@
|
||||
<?PHP
|
||||
if (!isset($config->auth_imaphost)) {
|
||||
$config->auth_imaphost = "127.0.0.1";
|
||||
}
|
||||
if (!isset($config->auth_imaptype)) {
|
||||
$config->auth_imaptype = "imap";
|
||||
}
|
||||
if (!isset($config->auth_imapport)) {
|
||||
$config->auth_imapport = "143";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_imaphost:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_imaphost TYPE=text SIZE=30 VALUE="<?=$config->auth_imaphost?>">
|
||||
<? formerr($err["ldap_host_url"]); ?>
|
||||
<? if (isset($err["auth_imaphost"])) formerr($err["auth_imaphost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_imaphost","auth") ?>
|
||||
@@ -28,7 +39,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_imapport:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_imapport?>">
|
||||
<? formerr($err["auth_imapport"]); ?>
|
||||
<? if (isset($err["auth_imapport"])) formerr($err["auth_imapport"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_imapport","auth") ?>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ function auth_user_login ($username, $password) {
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
||||
error_reporting(7);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
imap_close($connection);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
LDAP-module README
|
||||
07.10.2002 Version 0.1, Petri Asikainen <paca@sci.fi>
|
||||
|
||||
Ldap-authetication module is work in progress.
|
||||
Please read comments from lib.php
|
||||
|
||||
+56
-8
@@ -1,8 +1,28 @@
|
||||
<?PHP
|
||||
if (!isset($config->ldap_host_url)) {
|
||||
$config->ldap_host_url = "";
|
||||
}
|
||||
if (!isset($config->ldap_contexts)) {
|
||||
$config->ldap_contexts = "";
|
||||
}
|
||||
if (!isset($config->ldap_user_attribute)) {
|
||||
$config->ldap_user_attribute = "";
|
||||
}
|
||||
if (!isset($config->ldap_search_sub)) {
|
||||
$config->ldap_search_sub = "";
|
||||
}
|
||||
if (!isset($config->ldap_bind_dn)) {
|
||||
$config->ldap_bind_dn = "";
|
||||
}
|
||||
if (!isset($config->ldap_bind_pw)) {
|
||||
$config->ldap_bind_pw = "";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_host_url:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?=$config->ldap_host_url?>">
|
||||
<? formerr($err["ldap_host_url"]); ?>
|
||||
<? if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_ldap_host_url","auth") ?>
|
||||
@@ -10,10 +30,10 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_user_context:</TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_contexts:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?=$config->ldap_contexts?>">
|
||||
<? formerr($err["ldap_contexts"]); ?>
|
||||
<? if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_ldap_contexts","auth") ?>
|
||||
@@ -24,7 +44,7 @@
|
||||
<TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?=$config->ldap_user_attribute?>">
|
||||
<? formerr($err["ldap_user_attribute"]); ?>
|
||||
<? if (isset($err["ldap_user_attribute"])) formerr($err["ldap_user_attribute"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_ldap_user_attribute","auth") ?>
|
||||
@@ -35,7 +55,7 @@
|
||||
<TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?=$config->ldap_search_sub?>">
|
||||
<? formerr($err["ldap_search_sub"]); ?>
|
||||
<? if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_ldap_search_sub","auth") ?>
|
||||
@@ -46,23 +66,51 @@
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?=$config->ldap_bind_dn?>">
|
||||
<? formerr($err["ldap_bind_dn"]); ?>
|
||||
<? if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
|
||||
</TD><TD>
|
||||
<? print_string("auth_ldap_bind_dn","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_password:</TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?=$config->ldap_bind_pw?>">
|
||||
<? formerr($err["ldap_bind_pw"]); ?>
|
||||
<? if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
|
||||
</TD><TD>
|
||||
<? print_string("auth_ldap_bind_pw","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_memberattribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_memberattribute TYPE=text SIZE=30 VALUE="<?=$config->ldap_memberattribute?>">
|
||||
<? if (isset($err["ldap_memberattribute"])) formerr($err["ldap_memberattribute"]); ?>
|
||||
</TD><TD>
|
||||
<? print_string("auth_ldap_memberattribute","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_creators:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_creators TYPE=text SIZE=30 VALUE="<?=$config->ldap_creators?>">
|
||||
<? if (isset($err["ldap_creators"])) formerr($err["ldap_creators"]); ?>
|
||||
</TD><TD>
|
||||
<? print_string("auth_ldap_creators","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_create_context:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_create_context TYPE=text SIZE=30 VALUE="<?=$config->ldap_create_context?>">
|
||||
<? if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
|
||||
</TD><TD>
|
||||
<? print_string("auth_ldap_create_context","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT><P><? print_string("firstname") ?>:</TD>
|
||||
|
||||
+330
-144
@@ -1,181 +1,367 @@
|
||||
<?PHP
|
||||
<?PHP // $Id$
|
||||
//CHANGELOG:
|
||||
//24.02.2003 Added support for coursecreators
|
||||
//20.02.2003 Added support for user creation
|
||||
//12.10.2002 Reformatted source for consistency
|
||||
//03.10.2002 First version to CVS
|
||||
//29.09.2002 Clean up and splitted code to functions v. 0.02
|
||||
//29.09.2002 LDAP authentication functions v. 0.01
|
||||
//Distributed under GPL (c)Petri Asikainen 2002
|
||||
|
||||
|
||||
//Distributed under GPL (c)Petri Asikainen 2002-2003
|
||||
|
||||
/* README!
|
||||
Module is quite complete and most functinality can be configured from
|
||||
configinterfave /admin/auth.php. Some of latest additions/features need to
|
||||
be configured by modifying source code.
|
||||
|
||||
If you plan to use user creation feature, look function auth_user_create
|
||||
and modify it for your needs.
|
||||
You have to change all hardcoded attribute values to fit your LDAP-server.
|
||||
User-creation makes posible that your current
|
||||
users can authenticate with existings usernames/password and new users can
|
||||
create own accounts to LDAP-directory. I'm using this feature and new users
|
||||
are created to LDAP different context, without rights to other system. When
|
||||
user-creation feature is set like that, there's no known security issues.
|
||||
I write ldap-module on Novell E-directory / Linux & Solaris ,
|
||||
so all default values are for it.
|
||||
|
||||
Any feedback is wellcome,
|
||||
|
||||
Petri Asikainen paca@sci.fi
|
||||
|
||||
|
||||
*/
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns true if the username and password work
|
||||
// and false if they don't
|
||||
/// Returns true if the username and password work
|
||||
/// and false if they don't
|
||||
|
||||
global $CFG;
|
||||
|
||||
if (!$username or !$password) { // Don't allow blank usernames or passwords
|
||||
return false;
|
||||
}
|
||||
|
||||
$ldap_connection = auth_ldap_connect();
|
||||
if($ldap_connection) {
|
||||
|
||||
if ($ldap_connection) {
|
||||
$ldap_user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
$ldap_user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
//if ldap_user_dn is empty, user does not exist
|
||||
if(!$ldap_user_dn){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to bind with current username and password
|
||||
$ldap_login = @ldap_bind($ldap_connection, $ldap_user_dn, $password);
|
||||
if ($ldap_login) {
|
||||
ldap_close($ldap_connection);
|
||||
return true;
|
||||
}
|
||||
//if ldap_user_dn is empty, user does not exist
|
||||
if(!$ldap_user_dn){
|
||||
ldap_close($ldap_connection);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to bind with current username and password
|
||||
$ldap_login = @ldap_bind($ldap_connection, $ldap_user_dn, $password);
|
||||
ldap_close($ldap_connection);
|
||||
if ($ldap_login) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@ldap_close($ldap_connection);
|
||||
error("LDAP-module cannot connect to server: $CFG->ldap_host_url");
|
||||
return false ;
|
||||
@ldap_close($ldap_connection);
|
||||
error("LDAP-module cannot connect to server: $CFG->ldap_host_url");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function auth_get_userinfo($username){
|
||||
global $CFG;
|
||||
//reads userinformation from ldap and return it in array()
|
||||
/// reads userinformation from ldap and return it in array()
|
||||
global $CFG;
|
||||
|
||||
$config = (array)$CFG;
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang");
|
||||
$config = (array)$CFG;
|
||||
$attrmap = auth_ldap_attributes();
|
||||
|
||||
$ldap_connection=auth_ldap_connect();
|
||||
|
||||
$moodleattributes = array();
|
||||
foreach ($fields as $field) {
|
||||
if ($config["auth_user_$field"]) {
|
||||
$moodleattributes[$field] = $config["auth_user_$field"];
|
||||
}
|
||||
}
|
||||
|
||||
$ldap_connection=auth_ldap_connect();
|
||||
|
||||
$result = array();
|
||||
$search_attribs = array();
|
||||
|
||||
foreach ($moodleattributes as $key=>$value) {
|
||||
array_push($search_attribs, $value);
|
||||
}
|
||||
|
||||
$user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
if (! isset($CFG->ldap_objectclass)) {
|
||||
$CFG->ldap_objectclass="objectClass=*";
|
||||
}
|
||||
$result = array();
|
||||
$search_attribs = array();
|
||||
|
||||
$user_info_result = ldap_read($ldap_connection,$user_dn,$CFG->ldap_objectclass, $search_attribs);
|
||||
if ($user_info_result) {
|
||||
$user_entry = ldap_get_entries($ldap_connection, $user_info_result);
|
||||
foreach ($moodleattributes as $key=>$value){
|
||||
if(isset($user_entry[0][$value][0])){
|
||||
$result[$key]=$user_entry[0][$value][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ldap_close($ldap_connection);
|
||||
foreach ($attrmap as $key=>$value) {
|
||||
array_push($search_attribs, $value);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
$user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
function auth_get_userlist() {
|
||||
//returns all users from ldap servers
|
||||
global $CFG;
|
||||
$fresult = array();
|
||||
$ldap_connection = auth_ldap_connect();
|
||||
auth_ldap_bind($ldap_connection);
|
||||
if (! isset($CFG->ldap_objectclass)) {
|
||||
if (! isset($CFG->ldap_objectclass)) {
|
||||
$CFG->ldap_objectclass="objectClass=*";
|
||||
}
|
||||
$contexts=explode(";",$CFG->ldap_contexts);
|
||||
foreach ($contexts as $context) {
|
||||
|
||||
if($CFG->ldap_search_sub){
|
||||
//use ldap_search to find first user from subtree
|
||||
$ldap_result = ldap_search($ldap_connection, $context, "(".$CFG->ldap_objectclass.")", array($CFG->ldap_user_attribute));
|
||||
} else {
|
||||
//search only in this context
|
||||
$ldap_result = ldap_list($ldap_connection, $context, "(".$CFG->ldap_objectclass.")", array($CFG->ldap_user_attribute));
|
||||
}
|
||||
}
|
||||
|
||||
$user_info_result = ldap_read($ldap_connection,$user_dn,$CFG->ldap_objectclass, $search_attribs);
|
||||
|
||||
if ($user_info_result) {
|
||||
$user_entry = ldap_get_entries($ldap_connection, $user_info_result);
|
||||
foreach ($attrmap as $key=>$value){
|
||||
if(isset($user_entry[0][$value][0])){
|
||||
$result[$key]=$user_entry[0][$value][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ldap_close($ldap_connection);
|
||||
|
||||
$users = ldap_get_entries($ldap_connection,$ldap_result);
|
||||
//add found users to list
|
||||
for ($i=0;$i<$users['count'];$i++) {
|
||||
array_push($fresult,($users[$i][$CFG->ldap_user_attribute][0]));
|
||||
}
|
||||
}
|
||||
return $fresult;
|
||||
|
||||
}
|
||||
function auth_ldap_connect(){
|
||||
//connects to ldap-server
|
||||
global $CFG;
|
||||
$result = ldap_connect($CFG->ldap_host_url);
|
||||
if ($result) {
|
||||
return $result;
|
||||
} else {
|
||||
error("LDAP-module cannot connect to server: $CFG->ldap_host_url");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function auth_get_userlist () {
|
||||
global $CFG;
|
||||
return auth_ldap_get_userlist("($CFG->ldap_user_attribute=*)");
|
||||
}
|
||||
function auth_user_exists ($username) {
|
||||
global $CFG;
|
||||
//returns true if given usernname exist on ldap
|
||||
$users = auth_ldap_get_userlist("($CFG->ldap_user_attribute=$username)");
|
||||
return count($users);
|
||||
}
|
||||
|
||||
function auth_user_create ($userobject,$plainpass) {
|
||||
//create new user to ldap
|
||||
//use auth_user_exists to prevent dublicate usernames
|
||||
//return true if user is created, false on error
|
||||
global $CFG;
|
||||
$attrmap = auth_ldap_attributes();
|
||||
$ldapconnect = auth_ldap_connect();
|
||||
$ldapbind = auth_ldap_bind($ldapconnect);
|
||||
|
||||
$newuser = array();
|
||||
|
||||
foreach ($attrmap as $key=>$value){
|
||||
if(isset($userobject->$key) ){
|
||||
$newuser[$value]=utf8_encode($userobject->$key);
|
||||
}
|
||||
}
|
||||
|
||||
//Following sets all mandatory and other forced attribute values
|
||||
//this should be moved to config inteface ASAP
|
||||
$newuser['objectClass']= array("inetOrgPerson","organizationalPerson","person","top");
|
||||
$newuser['uniqueId']= $userobject->username;
|
||||
$newuser['logindisabled']="TRUE";
|
||||
$newuser['userpassword']=$plainpass;
|
||||
unset($newuser[country]);
|
||||
|
||||
$uadd = ldap_add($ldapconnect, $CFG->ldap_user_attribute."=$userobject->username,".$CFG->ldap_create_context, $newuser);
|
||||
|
||||
ldap_close($ldapconnect);
|
||||
return $uadd;
|
||||
|
||||
}
|
||||
|
||||
function auth_user_activate ($username) {
|
||||
//activate new ldap-user after email-address is confirmed
|
||||
global $CFG;
|
||||
|
||||
$ldapconnect = auth_ldap_connect();
|
||||
$ldapbind = auth_ldap_bind($ldapconnect);
|
||||
|
||||
$userdn = auth_ldap_find_userdn($ldapconnect, $username);
|
||||
|
||||
$newinfo['loginDisabled']="FALSE";
|
||||
|
||||
$result = ldap_modify($ldapconnect, $userdn, $newinfo);
|
||||
ldap_close($ldapconnect);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function auth_user_disable ($username) {
|
||||
//activate new ldap-user after email-address is confirmed
|
||||
global $CFG;
|
||||
|
||||
$ldapconnect = auth_ldap_connect();
|
||||
$ldapbind = auth_ldap_bind($ldapconnect);
|
||||
|
||||
$userdn = auth_ldap_find_userdn($ldapconnect, $username);
|
||||
$newinfo['loginDisabled']="TRUE";
|
||||
|
||||
$result = ldap_modify($ldapconnect, $userdn, $newinfo);
|
||||
ldap_close($ldapconnect);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function auth_iscreator($username=0) {
|
||||
///if user is member of creator group return true
|
||||
global $CFG, $USER;
|
||||
|
||||
$ldapconnect = auth_ldap_connect();
|
||||
$ldapbind = auth_ldap_bind($ldapconnect);
|
||||
|
||||
if (! $username) {
|
||||
$username=$USER->username;
|
||||
}
|
||||
|
||||
if ((! $CFG->ldap_creators) OR (! $CFG->ldap_memberattribute)) {
|
||||
return false;
|
||||
} else {
|
||||
$groups = explode(";",$CFG->ldap_creators);
|
||||
}
|
||||
|
||||
|
||||
//build filter
|
||||
$filter = "(& ($CFG->ldap_user_attribute=$username)(|";
|
||||
foreach ($groups as $group){
|
||||
$filter .= "($CFG->ldap_memberattribute=$group)";
|
||||
}
|
||||
$filter .= "))";
|
||||
//search
|
||||
$result = auth_ldap_get_userlist($filter);
|
||||
|
||||
return count($result);
|
||||
|
||||
}
|
||||
|
||||
//PRIVATE FUNCTIONS starts
|
||||
//private functions are named as auth_ldap*
|
||||
|
||||
function auth_ldap_connect(){
|
||||
/// connects to ldap-server
|
||||
global $CFG;
|
||||
|
||||
$result = ldap_connect($CFG->ldap_host_url);
|
||||
|
||||
if ($result) {
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
error("LDAP-module cannot connect to server: $CFG->ldap_host_url");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function auth_ldap_bind($ldap_connection){
|
||||
//makes bind to ldap for searching users
|
||||
//uses ldap_bind_dn or anonymous bind
|
||||
global $CFG;
|
||||
/// makes bind to ldap for searching users
|
||||
/// uses ldap_bind_dn or anonymous bind
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($CFG->ldap_bind_dn){
|
||||
//bind with search-user
|
||||
if (!ldap_bind($ldap_connection, $CFG->ldap_bind_dn,$CFG->ldap_bind_pw)){
|
||||
error("Error: could not bind ldap with ldap_bind_dn/pw");
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
//bind anonymously
|
||||
if ( !ldap_bind($ldap_connection)){
|
||||
error("Error: could not bind ldap anonymously");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
//bind with search-user
|
||||
if (!ldap_bind($ldap_connection, $CFG->ldap_bind_dn,$CFG->ldap_bind_pw)){
|
||||
error("Error: could not bind ldap with ldap_bind_dn/pw");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function auth_ldap_find_userdn ($ldap_connection, $username){
|
||||
//return dn of username
|
||||
//like: cn=username,ou=suborg,o=org
|
||||
//or false if username not found
|
||||
global $CFG;
|
||||
//default return value
|
||||
$ldap_user_dn = FALSE;
|
||||
|
||||
auth_ldap_bind($ldap_connection);
|
||||
|
||||
//get all contexts and look for first matching user
|
||||
$ldap_contexts = explode(";",$CFG->ldap_contexts);
|
||||
|
||||
foreach($ldap_contexts as $context) {
|
||||
$context == trim($context);
|
||||
if($CFG->ldap_search_sub){
|
||||
//use ldap_search to find first user from subtree
|
||||
$ldap_result = ldap_search($ldap_connection, $context, "(".$CFG->ldap_user_attribute."=".$username.")");
|
||||
} else {
|
||||
//search only in this context
|
||||
$ldap_result = ldap_list($ldap_connection, $context, "(".$CFG->ldap_user_attribute."=".$username.")");
|
||||
//bind anonymously
|
||||
if ( !ldap_bind($ldap_connection)){
|
||||
error("Error: could not bind ldap anonymously");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$entry = ldap_first_entry($ldap_connection,$ldap_result);
|
||||
if ($entry){
|
||||
|
||||
$ldap_user_dn = ldap_get_dn($ldap_connection, $entry);
|
||||
break ;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function auth_ldap_find_userdn ($ldap_connection, $username){
|
||||
/// return dn of username
|
||||
/// like: cn=username,ou=suborg,o=org
|
||||
/// or false if username not found
|
||||
|
||||
global $CFG;
|
||||
|
||||
//default return value
|
||||
$ldap_user_dn = FALSE;
|
||||
|
||||
auth_ldap_bind($ldap_connection);
|
||||
|
||||
//get all contexts and look for first matching user
|
||||
$ldap_contexts = explode(";",$CFG->ldap_contexts);
|
||||
|
||||
if (!empty($CFG->ldap_create_context)){
|
||||
array_push($ldap_contexts, $CFG->ldap_create_context);
|
||||
}
|
||||
}
|
||||
return $ldap_user_dn;
|
||||
|
||||
foreach ($ldap_contexts as $context) {
|
||||
|
||||
$context == trim($context);
|
||||
|
||||
if ($CFG->ldap_search_sub){
|
||||
//use ldap_search to find first user from subtree
|
||||
$ldap_result = ldap_search($ldap_connection, $context, "(".$CFG->ldap_user_attribute."=".$username.")");
|
||||
|
||||
} else {
|
||||
//search only in this context
|
||||
$ldap_result = ldap_list($ldap_connection, $context, "(".$CFG->ldap_user_attribute."=".$username.")");
|
||||
}
|
||||
|
||||
$entry = ldap_first_entry($ldap_connection,$ldap_result);
|
||||
|
||||
if ($entry){
|
||||
$ldap_user_dn = ldap_get_dn($ldap_connection, $entry);
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
return $ldap_user_dn;
|
||||
}
|
||||
|
||||
function auth_ldap_attributes (){
|
||||
//returns array containg attribute mappings between Moodle and ldap
|
||||
global $CFG;
|
||||
|
||||
$config = (array)$CFG;
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang");
|
||||
|
||||
$moodleattributes = array();
|
||||
foreach ($fields as $field) {
|
||||
if ($config["auth_user_$field"]) {
|
||||
$moodleattributes[$field] = $config["auth_user_$field"];
|
||||
}
|
||||
}
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
function auth_ldap_get_userlist($filter="*") {
|
||||
/// returns all users from ldap servers
|
||||
global $CFG;
|
||||
|
||||
$fresult = array();
|
||||
$ldap_connection = auth_ldap_connect();
|
||||
|
||||
auth_ldap_bind($ldap_connection);
|
||||
|
||||
if (! isset($CFG->ldap_objectclass)) {
|
||||
$CFG->ldap_objectclass="objectClass=*";
|
||||
}
|
||||
|
||||
if ($filter=="*") {
|
||||
$filter = "(&(".$CFG->ldap_user_attribute."=*)(".$CFG->ldap_objectclass."))";
|
||||
}
|
||||
|
||||
$contexts = explode(";",$CFG->ldap_contexts);
|
||||
|
||||
if (!empty($CFG->ldap_create_context)){
|
||||
array_push($contexts, $CFG->ldap_create_context);
|
||||
}
|
||||
|
||||
foreach ($contexts as $context) {
|
||||
|
||||
if ($CFG->ldap_search_sub) {
|
||||
//use ldap_search to find first user from subtree
|
||||
$ldap_result = ldap_search($ldap_connection, $context,
|
||||
$filter,
|
||||
array($CFG->ldap_user_attribute));
|
||||
} else {
|
||||
//search only in this context
|
||||
$ldap_result = ldap_list($ldap_connection, $context,
|
||||
$filter,
|
||||
array($CFG->ldap_user_attribute));
|
||||
}
|
||||
|
||||
$users = ldap_get_entries($ldap_connection, $ldap_result);
|
||||
|
||||
//add found users to list
|
||||
for ($i=0;$i<$users['count'];$i++) {
|
||||
array_push($fresult, ($users[$i][$CFG->ldap_user_attribute][0]) );
|
||||
}
|
||||
}
|
||||
|
||||
return $fresult;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><? print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("authinstructions","auth") ?>
|
||||
<? helpbutton("text", get_string("helptext")) ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?PHP // $Id$
|
||||
// manual method - Just does a simple check against the database
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns false if the username doesn't exist yet
|
||||
// Returns true if the username and password work
|
||||
|
||||
if ($user = get_user_info_from_db("username", $username)) {
|
||||
return ($user->password == md5($password));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
+12
-3
@@ -1,8 +1,17 @@
|
||||
<?PHP
|
||||
if (!isset($config->auth_nntphost)) {
|
||||
$config->auth_nntphost = "127.0.0.1";
|
||||
}
|
||||
if (!isset($config->auth_nntpport)) {
|
||||
$config->auth_nntpport = "119";
|
||||
}
|
||||
?>
|
||||
|
||||
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_nntphost:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_nntphost" TYPE="text" SIZE=30 VALUE="<?=$config->auth_nntphost?>">
|
||||
<? formerr($err["ldap_nntphost"]); ?>
|
||||
<? if (isset($err["auth_nntphost"])) formerr($err["auth_nntphost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_nntphost","auth") ?>
|
||||
@@ -12,8 +21,8 @@
|
||||
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_nntpport:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_nntpport?>">
|
||||
<? formerr($err["auth_nntpport"]); ?>
|
||||
<INPUT name=auth_nntpport TYPE=text SIZE=6 VALUE="<?=$config->auth_nntpport?>">
|
||||
<? if (isset($err["auth_nntpport"])) formerr($err["auth_nntpport"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_nntpport","auth") ?>
|
||||
|
||||
+1
-4
@@ -1,9 +1,6 @@
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up an NNTP server
|
||||
|
||||
// This code is completely untested so far - IT NEEDS TESTERS!
|
||||
// Looks like it should work though ...
|
||||
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns true if the username and password work
|
||||
@@ -15,7 +12,7 @@ function auth_user_login ($username, $password) {
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
||||
error_reporting(7);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
imap_close($connection);
|
||||
|
||||
+13
-3
@@ -1,8 +1,19 @@
|
||||
<?PHP
|
||||
if (!isset($config->auth_pop3host)) {
|
||||
$config->auth_pop3host = "127.0.0.1";
|
||||
}
|
||||
if (!isset($config->auth_pop3type)) {
|
||||
$config->auth_pop3type = "pop3";
|
||||
}
|
||||
if (!isset($config->auth_pop3port)) {
|
||||
$config->auth_pop3port = "110";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3host:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_pop3host TYPE=text SIZE=30 VALUE="<?=$config->auth_pop3host?>">
|
||||
<? formerr($err["ldap_host_url"]); ?>
|
||||
<? if (isset($err["auth_pop3host"])) formerr($err["auth_pop3host"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_pop3host","auth") ?>
|
||||
@@ -18,7 +29,6 @@
|
||||
}
|
||||
choose_from_menu($pop3options, "auth_pop3type", $config->auth_pop3type, "");
|
||||
?>
|
||||
<? formerr($err["auth_pop3type"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_pop3type","auth") ?>
|
||||
@@ -29,7 +39,7 @@
|
||||
<TD ALIGN=RIGHT><P>auth_pop3port:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_pop3port TYPE=text SIZE=6 VALUE="<?=$config->auth_pop3port?>">
|
||||
<? formerr($err["auth_pop3port"]); ?>
|
||||
<? if (isset($err["auth_pop3port"])) formerr($err["auth_pop3port"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<? print_string("auth_pop3port","auth") ?>
|
||||
|
||||
+1
-4
@@ -1,9 +1,6 @@
|
||||
<?PHP // $Id$
|
||||
// Authentication by looking up a POP3 server
|
||||
|
||||
// This code is completely untested so far - IT NEEDS TESTERS!
|
||||
// Looks like it should work though ...
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
// Returns true if the username and password work
|
||||
// and false if they are wrong or don't exist.
|
||||
@@ -21,7 +18,7 @@ function auth_user_login ($username, $password) {
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
||||
error_reporting(7);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
imap_close($connection);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
README $Id$
|
||||
----------
|
||||
|
||||
This directory contains my try to create a backup/recover
|
||||
admin option to moodle. I don't know when and how it'll be
|
||||
finished, but I'going to try it, sure.
|
||||
|
||||
Some day, if this is fully functional, it could be integrated
|
||||
into the main Moodle distribution (ask uncle Martin). :-)
|
||||
|
||||
Code here may not be tested - so there are no guarantees as
|
||||
to the quality of the code in here, even if part of a stable
|
||||
Moodle release.
|
||||
|
||||
Please, for any comment about this option, do it in Moodle
|
||||
Developer Forum at:
|
||||
|
||||
http://moodle.org/mod/forum/view.php?id=55
|
||||
(searching an "backup" topic)
|
||||
|
||||
or you can put tour comments in Moodel Bugs at:
|
||||
|
||||
http://moodle.org/bugs/bug.php?op=show&bugid=84.
|
||||
|
||||
All comments will be welcome. TIA.
|
||||
|
||||
To see the general status of the utility, take a look to
|
||||
"STATUS.txt" in this directory.
|
||||
|
||||
And this is all, I start with it NOW.
|
||||
|
||||
Eloy (stronk7)
|
||||
29-04-2003
|
||||
@@ -0,0 +1,197 @@
|
||||
STATUS $Id$
|
||||
----------
|
||||
|
||||
This documment shows the current status of the backup/restore option.
|
||||
|
||||
Backup: WORKING. COMPLETED but only assignments, resources,
|
||||
choices and surveys.
|
||||
|
||||
Restore: WORKING. NOT COMPLETED. Only course, users, user_files and
|
||||
course_files. No logs, mods or final checks !!!!
|
||||
|
||||
|
||||
========== ========== ========== ========== ========== ==========
|
||||
|
||||
Now I show the specific detailed status of every item in the process:
|
||||
|
||||
Backup Details:
|
||||
===============
|
||||
- Backup FrontEnd............................................DONE
|
||||
- Check Security........................................DONE
|
||||
- Select Info to Backup.(from mods).....................DONE
|
||||
- Check (summary info)..................................DONE
|
||||
- Check mods.......................................DONE
|
||||
- Check logs.......................................DONE
|
||||
- Check users......................................DONE
|
||||
- Check User Files.................................DONE
|
||||
- Check Course Files...............................DONE
|
||||
- Launch Backup.........................................DONE
|
||||
- Show progress.........................................DONE
|
||||
- Determine Backup location.............................DONE
|
||||
- Delete old entries at backup startup..................DONE
|
||||
- From database....................................DONE
|
||||
- From filesystem..................................DONE
|
||||
- Backup Items:..............................................IN PROGRESS
|
||||
- Backup Info data......................................DONE
|
||||
- Course................................................IN PROGRESS
|
||||
- Course Summary Data................................DONE
|
||||
x course info.....................................DONE
|
||||
x sections info...................................DONE
|
||||
x mods info.......................................DONE
|
||||
- User Accounts Info.................................DONE
|
||||
x admins..........................................DONE
|
||||
- All..........................................DONE
|
||||
x course creators.................................DONE
|
||||
- All..........................................DONE
|
||||
x teachers........................................DONE
|
||||
- Course.......................................DONE
|
||||
- All..........................................DONE
|
||||
x students........................................DONE
|
||||
- Course.......................................DONE
|
||||
- All..........................................DONE
|
||||
- Logs...............................................DONE
|
||||
- Mods Info..........................................IN PROGRESS
|
||||
x assignments.....................................DONE
|
||||
+ course data..................................DONE
|
||||
+ user data....................................DONE
|
||||
+ files........................................DONE
|
||||
x choices.........................................DONE
|
||||
+ course data..................................DONE
|
||||
+ user data....................................DONE
|
||||
+ files.....(NOT EXISTS).......................DONE
|
||||
x forums..........................................IN PROGRESS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x journals........................................IN PROGRESS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x peer graded assignments.........................IN PROGRESS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x quizzes.........................................IN PROGRESS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x resources.......................................DONE
|
||||
+ course data..................................DONE
|
||||
+ user data....................................DONE
|
||||
+ files..(ARE COURSE FILES !!!)................DONE
|
||||
x surveys.........................................DONE
|
||||
+ course data..................................DONE
|
||||
+ user data....................................DONE
|
||||
+ files.....(NOT EXISTS).......................DONE
|
||||
x workshops.......................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x user files to temp..............................DONE
|
||||
x course files to temp............................DONE
|
||||
- Compress the backup (zip)..................................DONE. PROBLEMS PCLZIP/UNZIP
|
||||
- XML File................................................DONE. PROBLEMS PCLZIP/UNZIP
|
||||
- moddata files...........................................DONE. PROBLEMS PCLZIP/UNZIP
|
||||
- Course Files............................................DONE. PROBLEMS PCLZIP/UNZIP
|
||||
- User Files..............................................DONE. PROBLEMS PCLZIP/UNZIP
|
||||
- Copy finished file to browseable dir.......................DONE
|
||||
- Delete old entries at backup end...........................DONE
|
||||
- From database...........................................DONE
|
||||
- From filesystem.........................................DONE
|
||||
- Browse backup files........................................DONE
|
||||
- Download backup files......................................DONE
|
||||
- Delete backup files........................................DONE
|
||||
- Program automatic backups..................................NO EXISTS
|
||||
|
||||
Restore Details:
|
||||
===============
|
||||
- Delete old entries at restore start........................DONE
|
||||
- From database...........................................DONE
|
||||
- From filesystem.........................................DONE
|
||||
- Restore FrontEnd...........................................DONE
|
||||
- Check Security........................................DONE
|
||||
- Select File to Restore................................DONE
|
||||
- Uncompress the backup (unzip).........................DONE
|
||||
- XML File..........................................DONE
|
||||
- Course Files......................................DONE
|
||||
- User Files........................................DONE
|
||||
- Check file is a valid one.............................DONE
|
||||
- Load info from file...................................DONE
|
||||
- Load Backup Info......................................DONE
|
||||
- Load Course Header....................................DONE
|
||||
- Restore into feature..................................DONE
|
||||
- New course (restore)...............................DONE
|
||||
- Existing course (import)...........................DONE
|
||||
- Select Info to Restore (depending from backup)........DONE
|
||||
- Make decisions........................................DONE
|
||||
- About existing users...............................DONE
|
||||
- Launch Restore........................................DONE
|
||||
- Show progress.........................................DONE
|
||||
- Restore Items:.............................................IN PROGRESS
|
||||
- Course................................................DONE
|
||||
- Course Summary Data................................DONE
|
||||
- Course Table....................................DONE
|
||||
- Sections Table..................................DONE
|
||||
- Modules Table...................................DONE
|
||||
- User Accounts Info.................................DONE
|
||||
x teacheras. .....................................DONE
|
||||
- None .......................................DONE
|
||||
- Course.......................................DONE
|
||||
- All..........................................DONE
|
||||
x students........................................DONE
|
||||
- None.........................................DONE
|
||||
- Course.......................................DONE
|
||||
- All..........................................DONE
|
||||
x creators........................................DONE
|
||||
- None.........................................DONE
|
||||
- Course.......................................DONE
|
||||
- All..........................................DONE
|
||||
x admins..........................................DONE
|
||||
- None.........................................DONE
|
||||
- Course.......................................DONE
|
||||
- All..........................................DONE
|
||||
- Mods Info..........................................NO EXISTS
|
||||
x assignments.....................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x choices.........................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x forums..........................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x journals........................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x quizzes.........................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x resources.......................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
x surveys.........................................NO EXISTS
|
||||
+ course data..................................NO EXISTS
|
||||
+ user data....................................NO EXISTS
|
||||
+ files........................................NO EXISTS
|
||||
- User files from temp.......................................DONE
|
||||
- Course files from temp.....................................DONE
|
||||
- Log entries................................................NO EXISTS
|
||||
- Readjust instance in course_modules........................NO EXISTS
|
||||
- Readjust modinfo in course (serialize).....................NO EXISTS
|
||||
- Delete old entries at restore end. .......................NO EXISTS
|
||||
- From database...........................................NO EXISTS
|
||||
- From filesystem.........................................NO EXISTS
|
||||
- Upload backup files........................................DONE
|
||||
|
||||
========== ========== ========== =========== =========== =========== ===
|
||||
|
||||
This is all. It's no a little thing !!! :-)
|
||||
|
||||
Eloy (stronk7)
|
||||
29-04-2003
|
||||
@@ -0,0 +1,91 @@
|
||||
<?PHP //$Id$
|
||||
//This script is used to configure and execute the backup proccess.
|
||||
|
||||
//Define some globals for all the script
|
||||
|
||||
//MUST CHANGE WITH FINAL BACKUP LOCATION !! WITHOUT TRAILING SLASH !!
|
||||
//ALL RELATIVE FROM THE LOCATION OF THE backup.php SCRIPT !!!
|
||||
|
||||
$moodle_home = "../../..";
|
||||
$mods_home = "mod";
|
||||
|
||||
//END MUST CHANGE
|
||||
|
||||
//Units used
|
||||
require_once ("$moodle_home/config.php");
|
||||
require_once ("$moodle_home/version.php");
|
||||
require_once ("backup_version.php");
|
||||
require_once ("db/backup_$CFG->dbtype.php");
|
||||
require_once ("lib.php");
|
||||
require_once ("backuplib.php");
|
||||
|
||||
//Optional variables
|
||||
optional_variable($id); // course id
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Check backup_version
|
||||
upgrade_backup_db($backup_version,$backup_release,"backup.php");
|
||||
|
||||
//Get strings
|
||||
$strcoursebackup = get_string("coursebackup");
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
//If no course has been selected or cancel button pressed
|
||||
if (!$id or $cancel) {
|
||||
print_header("$site->shortname: $strcoursebackup", $site->fullname,
|
||||
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
|
||||
|
||||
if ($courses = get_courses()) {
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
foreach ($courses as $course) {
|
||||
echo "<A HREF=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
print_heading(get_string("nocoursesyet"));
|
||||
print_continue("$moodle_home/$CFG->admin/index.php");
|
||||
}
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Get and check course
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect (can't find it)");
|
||||
}
|
||||
//Print header
|
||||
print_header("$site->shortname: $strcoursebackup", $site->fullname,
|
||||
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> ->
|
||||
<A HREF=\"backup.php\">$strcoursebackup</A> -> $course->fullname ($course->shortname)");
|
||||
|
||||
//Print form
|
||||
print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
include_once("backup_form.html");
|
||||
} else if ($launch == "check") {
|
||||
include_once("backup_check.html");
|
||||
} else if ($launch == "execute") {
|
||||
include_once("backup_execute.html");
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
//Print footer
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
<?PHP //$Id$
|
||||
//This page prints the backup todo list to see everything
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Checks for the required files/functions to backup every mod
|
||||
//And check if there is data about it
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$mods_home/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
if (!isset($backup_users)) {
|
||||
$backup_users = 1;
|
||||
}
|
||||
|
||||
if (!isset($backup_logs)) {
|
||||
$backup_logs = 1;
|
||||
}
|
||||
|
||||
if (!isset($backup_user_files)) {
|
||||
$backup_user_files = 1;
|
||||
}
|
||||
|
||||
if (!isset($backup_course_files)) {
|
||||
$backup_course_files = 2;
|
||||
}
|
||||
|
||||
if ($count == 0) {
|
||||
notice("No backupable modules are installed!");
|
||||
}
|
||||
?>
|
||||
|
||||
<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?
|
||||
|
||||
//Now print the Backup Name tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("name").":";
|
||||
echo "</B></td><td>";
|
||||
//Calculate the backup string
|
||||
$backup_name = strtolower(get_string("backup"));
|
||||
//If non-translated, use "backup"
|
||||
if (substr($backup_name,0,1) == "[") {
|
||||
$backup_name = "backup";
|
||||
}
|
||||
//Calculate the format string
|
||||
$backup_name_format = get_string("backupnameformat");
|
||||
//If non-translated, use "%Y%m%d-%H%M"
|
||||
if (substr($backup_name_format,0,1) == "[") {
|
||||
$backup_name_format = "%%Y%%m%%d-%%H%%M";
|
||||
}
|
||||
$backup_name .= "-".strtolower($course->shortname)."-".userdate(time(),$backup_name_format,99,false).".zip";
|
||||
echo $backup_name;
|
||||
//Add as hidden name
|
||||
echo "<input type=\"hidden\" name=\"backup_name\" value=\"".$backup_name."\">";
|
||||
echo "</td></tr>";
|
||||
|
||||
//Calculate the backup unique code to allow simultaneus backups (to define
|
||||
//the temp-directory name and records in backup temp tables
|
||||
$backup_unique_code = time();
|
||||
//Add as hidden name
|
||||
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"".$backup_unique_code."\">";
|
||||
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
|
||||
//Now print the To Do list
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\" align=\"center\"><P><B>";
|
||||
echo get_string("backupdetails").":";
|
||||
echo "</td></tr>";
|
||||
|
||||
//This is tha align to every ingo table
|
||||
$table->align = array ("LEFT","RIGHT");
|
||||
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modbackup = $modname."_backup_mods";
|
||||
//If exists the lib & function
|
||||
$var = "exists_".$modname;
|
||||
if ($$var) {
|
||||
//Add hidden fields
|
||||
$var = "backup_".$modname;
|
||||
echo "<input type=\"hidden\" name=\"".$var."\" value=\"".$$var."\">";
|
||||
$var = "backup_user_info_".$modname;
|
||||
echo "<input type=\"hidden\" name=\"".$var."\" value=\"".$$var."\">";
|
||||
$var = "backup_".$modname;
|
||||
//Only if selected
|
||||
if ($$var == 1) {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><P><B>";
|
||||
//Print the mod name
|
||||
echo "<li>".get_string("include")." ".get_string("modulenameplural",$modname)." ";
|
||||
//Now look for user-data status
|
||||
$backup_user_options[0] = get_string("withoutuserdata");
|
||||
$backup_user_options[1] = get_string("withuserdata");
|
||||
$var = "backup_user_info_".$modname;
|
||||
//Print the user info
|
||||
echo $backup_user_options[$$var]."<P>";
|
||||
//Call the check function to show more info
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
$table->data = $modcheckbackup($id,$$var,$backup_unique_code);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
|
||||
//Now print the Users tr
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><P><B>";
|
||||
$user_options[0] = get_string("includeallusers");
|
||||
$user_options[1] = get_string("includecourseusers");
|
||||
///$user_options[2] = get_string("includeneededusers");--->NOT IMPLEMENTED
|
||||
echo "<li>".$user_options[$backup_users]."<P>";
|
||||
//Add as hidden name
|
||||
echo "<input type=\"hidden\" name=\"backup_users\" value=\"".$backup_users."\">";
|
||||
//Print info
|
||||
$table->data = user_check_backup($id,$backup_unique_code,$backup_users);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Logs tr conditionally
|
||||
if ($backup_logs) {
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><P><B>";
|
||||
echo "<li>".get_string("includelogentries")."<P>";
|
||||
//Print info
|
||||
$table->data = log_check_backup($id);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
//Add as hidden name
|
||||
echo "<input type=\"hidden\" name=\"backup_logs\" value=\"".$backup_logs."\">";
|
||||
|
||||
//Now print the User Files tr conditionally
|
||||
if ($backup_user_files) {
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><P><B>";
|
||||
echo "<li>".get_string("includeuserfiles")."<P>";
|
||||
//Print info
|
||||
$table->data = user_files_check_backup($id,$backup_unique_code);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
//Add as hidden name
|
||||
echo "<input type=\"hidden\" name=\"backup_user_files\" value=\"".$backup_user_files."\">";
|
||||
|
||||
//Now print the Course Files tr conditionally
|
||||
if ($backup_course_files) {
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\"><P><B>";
|
||||
echo "<li>".get_string("includecoursefiles")."<P>";
|
||||
//Print info
|
||||
$table->data = course_files_check_backup($id,$backup_unique_code);
|
||||
print_table($table);
|
||||
echo "</td></tr>";
|
||||
}
|
||||
//Add as hidden name
|
||||
echo "<input type=\"hidden\" name=\"backup_course_files\" value=\"".$backup_course_files."\">";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<BR>
|
||||
<CENTER>
|
||||
<input type="hidden" name=id value="<? p($id) ?>">
|
||||
<input type="hidden" name=launch value="execute">
|
||||
<input type="submit" value="<? print_string("continue") ?>">
|
||||
<input type="submit" name=cancel value="<? print_string("cancel") ?>">
|
||||
</CENTER>
|
||||
</FORM>
|
||||
@@ -0,0 +1,277 @@
|
||||
<?PHP //$Id$
|
||||
//This page prints the backup todo list to see everything
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Checks for the required files/functions to backup every mod
|
||||
//And check if there is data about it
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$mods_home/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
if (!isset($$var)) {
|
||||
//Every undefined backup_XXXX isn't exported
|
||||
$$var = 0;
|
||||
}
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->backup = $$var;
|
||||
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
//Now stores all the mods preferences into an array into preferences
|
||||
$preferences->mods[$modname]->userinfo = $$var;
|
||||
//And the name of the mod
|
||||
$preferences->mods[$modname]->name = $modname;
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
if (!isset($backup_users)) {
|
||||
$backup_users = 1;
|
||||
}
|
||||
$preferences->backup_users = $backup_users;
|
||||
|
||||
if (!isset($backup_logs)) {
|
||||
$backup_logs = 1;
|
||||
}
|
||||
$preferences->backup_logs = $backup_logs;
|
||||
|
||||
if (!isset($backup_user_files)) {
|
||||
$backup_user_files = 1;
|
||||
}
|
||||
$preferences->backup_user_files = $backup_user_files;
|
||||
|
||||
if (!isset($backup_course_files)) {
|
||||
$backup_course_files = 2;
|
||||
}
|
||||
$preferences->backup_course_files = $backup_course_files;
|
||||
|
||||
if (!isset($id)) {
|
||||
error ("Course not specified");
|
||||
}
|
||||
$preferences->backup_course = $id;
|
||||
|
||||
if (!isset($backup_name)) {
|
||||
error ("Backup name not specified");
|
||||
}
|
||||
$preferences->backup_name = $backup_name;
|
||||
|
||||
if (!isset($backup_unique_code)) {
|
||||
error ("Backup unique code not specified");
|
||||
}
|
||||
$preferences->backup_unique_code = $backup_unique_code;
|
||||
|
||||
//Another Info
|
||||
$preferences->moodle_version = $version;
|
||||
$preferences->moodle_release = $release;
|
||||
$preferences->backup_version = $backup_version;
|
||||
$preferences->backup_release = $backup_release;
|
||||
|
||||
if ($count == 0) {
|
||||
notice("No backupable modules are installed!");
|
||||
}
|
||||
|
||||
//Start the main table
|
||||
echo "<table cellpadding=5>";
|
||||
|
||||
//Now print the Backup Name tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("name").":";
|
||||
echo "</B></td><td>";
|
||||
echo $backup_name;
|
||||
echo "</td></tr>";
|
||||
|
||||
//Start the main tr, where all the backup progress is done
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\">";
|
||||
|
||||
//Start the main ul
|
||||
echo "<ul>";
|
||||
|
||||
//Check for temp and backup and backup_unique_code directory
|
||||
//Create them as needed
|
||||
echo "<li>Creating temporary structures";
|
||||
$status = check_and_create_backup_dir($backup_unique_code);
|
||||
//Empty dir
|
||||
if ($status) {
|
||||
$status = clear_backup_dir($backup_unique_code);
|
||||
}
|
||||
|
||||
//Delete old_entries from backup tables
|
||||
echo "<li>Deteting old data";
|
||||
$status = backup_delete_old_data();
|
||||
if (!$status) {
|
||||
error ("An error has ocurred");
|
||||
}
|
||||
|
||||
//Create the moodle.xml file
|
||||
if ($status) {
|
||||
echo "<li>Creating xml file";
|
||||
//Begin a new list to xml contents
|
||||
echo "<ul>";
|
||||
echo "<li>Writing header";
|
||||
//Obtain the xml file (create and open) and print prolog information
|
||||
$backup_file = backup_open_xml($backup_unique_code);
|
||||
echo "<li>Writing general info";
|
||||
//Prints general info about backup to file
|
||||
if ($backup_file) {
|
||||
$status = backup_general_info($backup_file,$preferences);
|
||||
}
|
||||
echo "<li>Writing course data";
|
||||
|
||||
//Start new ul (for course)
|
||||
echo "<ul>";
|
||||
|
||||
echo "<li>Course info";
|
||||
//Prints course start (tag and general info)
|
||||
if ($status) {
|
||||
$status = backup_course_start($backup_file,$preferences);
|
||||
}
|
||||
echo "<li>Sections";
|
||||
//Section info
|
||||
if ($status) {
|
||||
$status = backup_course_sections($backup_file,$preferences);
|
||||
}
|
||||
|
||||
//End course contents (close ul)
|
||||
echo "</ul>";
|
||||
|
||||
echo "<li>Writing users info";
|
||||
//User info
|
||||
if ($status) {
|
||||
$status = backup_user_info($backup_file,$preferences);
|
||||
}
|
||||
|
||||
//Print logs if selected
|
||||
if ($status) {
|
||||
if ($preferences->backup_logs) {
|
||||
echo "<li>Writing logs info";
|
||||
$status = backup_log_info($backup_file,$preferences);
|
||||
}
|
||||
}
|
||||
|
||||
//Module info, this unique function makes all the work!!
|
||||
//db export and module fileis copy
|
||||
if ($status) {
|
||||
$mods_to_backup = false;
|
||||
//Check if we have any mod to backup
|
||||
foreach ($preferences->mods as $module) {
|
||||
if ($module->backup) {
|
||||
$mods_to_backup = true;
|
||||
}
|
||||
}
|
||||
//If we have to backup some module
|
||||
if ($mods_to_backup) {
|
||||
echo "<li>Writing modules info";
|
||||
//Start modules tag
|
||||
$status = backup_modules_start ($backup_file,$preferences);
|
||||
//Open ul for module list
|
||||
echo "<ul>";
|
||||
//Iterate over modules and call backupa
|
||||
foreach ($preferences->mods as $module) {
|
||||
if ($module->backup and $status) {
|
||||
echo "<li>".$module->name;
|
||||
$status = backup_module($backup_file,$preferences,$module->name);
|
||||
}
|
||||
}
|
||||
//Close ul for module list
|
||||
echo "</ul>";
|
||||
//Close modules tag
|
||||
$status = backup_modules_end ($backup_file,$preferences);
|
||||
}
|
||||
}
|
||||
|
||||
//Prints course end
|
||||
if ($status) {
|
||||
$status = backup_course_end($backup_file,$preferences);
|
||||
}
|
||||
//Close the xml file and xml data
|
||||
if ($backup_file) {
|
||||
backup_close_xml($backup_file);
|
||||
}
|
||||
|
||||
//End xml contents (close ul)
|
||||
echo "</ul>";
|
||||
}
|
||||
|
||||
//Now, if selected, copy user files
|
||||
if ($status) {
|
||||
if ($preferences->backup_user_files) {
|
||||
echo "<li>Copying user files";
|
||||
$status = backup_copy_user_files ($preferences);
|
||||
}
|
||||
}
|
||||
|
||||
//Now, if selected, copy course files
|
||||
if ($status) {
|
||||
if ($preferences->backup_course_files) {
|
||||
echo "<li>Copying course files";
|
||||
$status = backup_copy_course_files ($preferences);
|
||||
}
|
||||
}
|
||||
|
||||
//Now, zip all the backup directory contents
|
||||
if ($status) {
|
||||
echo "<li>Zipping backup";
|
||||
$status = backup_zip ($preferences,$moodle_home);
|
||||
}
|
||||
|
||||
//Now, copy the zip file to course directory
|
||||
if ($status) {
|
||||
echo "<li>Copying zip file";
|
||||
$status = copy_zip_to_course_dir ($preferences);
|
||||
}
|
||||
|
||||
//Now, clean temporary data (db and filesystem)
|
||||
if ($status) {
|
||||
echo "<li>Cleaning up temp data";
|
||||
$status = clean_temp_data ($preferences);
|
||||
}
|
||||
|
||||
if (!$status) {
|
||||
error ("An error has ocurred");
|
||||
}
|
||||
|
||||
//Ends th main ul
|
||||
echo "</ul>";
|
||||
|
||||
//End the main tr, where all the backup is done
|
||||
echo "</td></tr>";
|
||||
|
||||
//End the main table
|
||||
echo "</table>";
|
||||
|
||||
//Print final message
|
||||
print_simple_box(get_string("backupfinished"),"CENTER");
|
||||
print_continue($moodle_home."/files/index.php?id=".$preferences->backup_course."&wdir=/".get_string("backupdir"));
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,150 @@
|
||||
<?PHP //$Id$
|
||||
//This page prints the backup form to select everything
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Checks for the required files/functions to backup every mod
|
||||
//And check if there is data about it
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$mods_home/$modname/backuplib.php";
|
||||
$modbackup = $modname."_backup_mods";
|
||||
$modcheckbackup = $modname."_check_backup_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "backup_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
//Check include user info
|
||||
$var = "backup_user_info_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
if (!isset($backup_users)) {
|
||||
$backup_users = 1;
|
||||
}
|
||||
|
||||
if (!isset($backup_logs)) {
|
||||
$backup_logs = 1;
|
||||
}
|
||||
|
||||
if (!isset($backup_user_files)) {
|
||||
$backup_user_files = 1;
|
||||
}
|
||||
|
||||
if (!isset($backup_course_files)) {
|
||||
$backup_course_files = 1;
|
||||
}
|
||||
|
||||
if ($count == 0) {
|
||||
notice("No backupable modules are installed!");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modbackup = $modname."_backup_mods";
|
||||
//If exists the lib & function
|
||||
$var = "exists_".$modname;
|
||||
if ($$var) {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
|
||||
echo "</td><td>";
|
||||
$backup_options[0] = get_string("no");
|
||||
$backup_options[1] = get_string("yes");
|
||||
$var = "backup_".$modname;
|
||||
choose_from_menu($backup_options, $var, $$var, "");
|
||||
$backup_user_options[0] = get_string("withoutuserdata");
|
||||
$backup_user_options[1] = get_string("withuserdata");
|
||||
$var = "backup_user_info_".$modname;
|
||||
choose_from_menu($backup_user_options, $var, $$var, "");
|
||||
echo "</td></tr>";
|
||||
}
|
||||
}
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
|
||||
//Now print the Users tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("users").":";
|
||||
echo "</td><td>";
|
||||
$user_options[0] = get_string("all");
|
||||
$user_options[1] = get_string("course");
|
||||
//$user_options[2] = get_string("needed");-->NOT IMPLEMENTED
|
||||
choose_from_menu($user_options, "backup_users", $backup_users, "");
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Logs tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("logs").":";
|
||||
echo "</td><td>";
|
||||
$log_options[0] = get_string("no");
|
||||
$log_options[1] = get_string("yes");
|
||||
choose_from_menu($log_options, "backup_logs", $backup_logs, "");
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the User Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string ("userfiles").":";
|
||||
echo "</td><td>";
|
||||
$user_file_options[0] = get_string("no");
|
||||
$user_file_options[1] = get_string("yes");
|
||||
choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Course Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string ("coursefiles").":";
|
||||
echo "</td><td>";
|
||||
$course_file_options[0] = get_string("no");
|
||||
$course_file_options[1] = get_string("yes");
|
||||
choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
|
||||
echo "</td></tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<BR>
|
||||
<CENTER>
|
||||
<input type="hidden" name=id value="<? p($id) ?>">
|
||||
<input type="hidden" name=launch value="check">
|
||||
<input type="submit" value="<? print_string("continue") ?>">
|
||||
<input type="submit" name=cancel value="<? print_string("cancel") ?>">
|
||||
</CENTER>
|
||||
</FORM>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?PHP //$Id$
|
||||
// This file defines the current version of the
|
||||
// backup/restore code that is being used. This can be
|
||||
// compared against the values stored in the
|
||||
// database (backup_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$backup_version = 2003052000; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
$backup_release = "0.2.1 alpha"; // User-friendly version number
|
||||
@@ -0,0 +1,883 @@
|
||||
<?PHP //$Id$
|
||||
//This file contains all the function needed in the backup utility
|
||||
//except the mod-related funtions that are into every backuplib.php inside
|
||||
//every mod directory
|
||||
|
||||
//Insert necessary category ids to backup_ids table
|
||||
function insert_category_ids ($course,$backup_unique_code) {
|
||||
global $CFG;
|
||||
$status = true;
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
|
||||
(backup_code, table_name, old_id)
|
||||
SELECT DISTINCT '$backup_unique_code','quiz_categories',t.category
|
||||
FROM {$CFG->prefix}quiz_questions t,
|
||||
{$CFG->prefix}quiz_question_grades g,
|
||||
{$CFG->prefix}quiz q
|
||||
WHERE q.course = '$course' AND
|
||||
g.quiz = q.id AND
|
||||
g.question = t.id",false);
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Delete category ids from backup_ids table
|
||||
function delete_category_ids ($backup_unique_code) {
|
||||
global $CFG;
|
||||
$status = true;
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
|
||||
WHERE backup_code = '$backup_unique_code'",false);
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Calculate the number of users to backup and put their ids in backup_ids
|
||||
//Return an array of info (name,value)
|
||||
function user_check_backup($course,$backup_unique_code,$backup_users) {
|
||||
//$backup_users=0-->all
|
||||
// 1-->course
|
||||
// 2-->needed-->NOT IMPLEMEMTED
|
||||
|
||||
global $CFG;
|
||||
global $db;
|
||||
|
||||
$count_users = 0;
|
||||
|
||||
//Select all users from user
|
||||
$users = get_records ("user");
|
||||
//Iterate over users putting their roles
|
||||
foreach ($users as $user) {
|
||||
$user->info = "";
|
||||
//Is Admin in tables (not is_admin()) !!
|
||||
if (record_exists("user_admins","userid",$user->id)) {
|
||||
$user->info .= "admin";
|
||||
$user->role_admin = true;
|
||||
}
|
||||
//Is Course Creator in tables (not is_coursecreator()) !!
|
||||
if (record_exists("user_coursecreators","userid",$user->id)) {
|
||||
$user->info .= "coursecreator";
|
||||
$user->role_coursecreator = true;
|
||||
}
|
||||
//Is Teacher in tables (not is_teacher()) !!
|
||||
if (record_exists("user_teachers","course",$course,"userid",$user->id)) {
|
||||
$user->info .= "teacher";
|
||||
$user->role_teacher = true;
|
||||
}
|
||||
//Is Student in tables (not is_student()) !!
|
||||
if (record_exists("user_students","course",$course,"userid",$user->id)) {
|
||||
$user->info .= "student";
|
||||
$user->role_student = true;
|
||||
}
|
||||
//Now create the backup_id record
|
||||
$backupids_rec->backup_code = $backup_unique_code;
|
||||
$backupids_rec->table_name = "user";
|
||||
$backupids_rec->old_id = $user->id;
|
||||
$backupids_rec->info = $user->info;
|
||||
|
||||
//Insert the record id. backup_users decide it.
|
||||
//When all users
|
||||
if ($backup_users == 0) {
|
||||
$status = insert_record("backup_ids",$backupids_rec,false);
|
||||
$count_users++;
|
||||
//When course users
|
||||
} else if ($backup_users == 1) {
|
||||
//Only if user has any role
|
||||
if ($backupids_rec->info) {
|
||||
$status = insert_record("backup_ids",$backupids_rec,false);
|
||||
$count_users++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Prepare Info
|
||||
//Gets the user data
|
||||
$info[0][0] = get_string("users");
|
||||
$info[0][1] = $count_users;
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
//Calculate the number of log entries to backup
|
||||
//Return an array of info (name,value)
|
||||
function log_check_backup($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
//Execute the insert
|
||||
$status = execute_sql($sql_insert,false);
|
||||
|
||||
//Now execute the select
|
||||
$ids = get_records_sql("SELECT DISTINCT l.id,l.course
|
||||
FROM {$CFG->prefix}log l
|
||||
WHERE l.course = '$course'");
|
||||
//Gets the user data
|
||||
$info[0][0] = get_string("logs");
|
||||
if ($ids) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
//Calculate the number of user files to backup
|
||||
//Under $CFG->dataroot/users
|
||||
//and put them (their path) in backup_ids
|
||||
//Return an array of info (name,value)
|
||||
function user_files_check_backup($course,$backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$rootdir = $CFG->dataroot."/users";
|
||||
//Check if directory exists
|
||||
if (is_dir($rootdir)) {
|
||||
$coursedirs = get_directory_list($rootdir);
|
||||
foreach ($coursedirs as $dir) {
|
||||
//Extracts user id from file path
|
||||
$tok = strtok($dir,"/");
|
||||
if ($tok) {
|
||||
$userid = $tok;
|
||||
} else {
|
||||
$tok = "";
|
||||
}
|
||||
//Insert them into backup_files
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
|
||||
(backup_code, file_type, path, old_id)
|
||||
VALUES
|
||||
('$backup_unique_code','user','$dir','$userid')",false);
|
||||
}
|
||||
}
|
||||
|
||||
//Now execute the select
|
||||
$ids = get_records_sql("SELECT DISTINCT b.path, b.old_id
|
||||
FROM {$CFG->prefix}backup_files b
|
||||
WHERE backup_code = '$backup_unique_code' AND
|
||||
file_type = 'user'");
|
||||
//Gets the user data
|
||||
$info[0][0] = get_string("files");
|
||||
if ($ids) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
//Calculate the number of course files to backup
|
||||
//under $CFG->dataroot/$course, except $CFG->moddata, and get_string("backupdir)
|
||||
//and put them (their path) in backup_ids
|
||||
//Return an array of info (name,value)
|
||||
function course_files_check_backup($course,$backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$rootdir = $CFG->dataroot."/$course";
|
||||
//Check if directory exists
|
||||
if (is_dir($rootdir)) {
|
||||
$coursedirs = get_directory_list($rootdir,$CFG->moddata);
|
||||
$backupdir = get_string("backupdir");
|
||||
foreach ($coursedirs as $dir) {
|
||||
//Check it isn't backupdir
|
||||
if (strpos($dir,$backupdir)!==0) {
|
||||
//Insert them into backup_files
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
|
||||
(backup_code, file_type, path)
|
||||
VALUES
|
||||
('$backup_unique_code','course','$dir')",false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now execute the select
|
||||
$ids = get_records_sql("SELECT DISTINCT b.path, b.old_id
|
||||
FROM {$CFG->prefix}backup_files b
|
||||
WHERE backup_code = '$backup_unique_code' AND
|
||||
file_type = 'course'");
|
||||
//Gets the user data
|
||||
$info[0][0] = get_string("files");
|
||||
if ($ids) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
//Function to check and create the needed moddata dir to
|
||||
//save all the mod backup files. We always name it moddata
|
||||
//to be able to restore it, but in restore we check for
|
||||
//$CFG->moddata !!
|
||||
function check_and_create_moddata_dir($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$backup_unique_code."/moddata",true);
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Function to check and create the "user_files" dir to
|
||||
//save all the user files we need from "users" dir
|
||||
function check_and_create_user_files_dir($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$backup_unique_code."/user_files",true);
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Function to check and create the "course_files" dir to
|
||||
//save all the course files we need from "CFG->datadir/course" dir
|
||||
function check_and_create_course_files_dir($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$backup_unique_code."/course_files",true);
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Function to create, open and write header of the xml file
|
||||
function backup_open_xml($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Open for writing
|
||||
|
||||
$file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml";
|
||||
$backup_file = fopen($file,"w");
|
||||
//Writes the header
|
||||
$status = fwrite ($backup_file,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||
if ($status) {
|
||||
$status = fwrite ($backup_file,start_tag("MOODLE_BACKUP",0,true));
|
||||
}
|
||||
if ($status) {
|
||||
return $backup_file;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Close the file
|
||||
function backup_close_xml($backup_file) {
|
||||
$status = fwrite ($backup_file,end_tag("MOODLE_BACKUP",0,true));
|
||||
return fclose($backup_file);
|
||||
}
|
||||
|
||||
//Return the xml start tag
|
||||
function start_tag($tag,$level=0,$endline=false) {
|
||||
if ($endline) {
|
||||
$endchar = "\n";
|
||||
} else {
|
||||
$endchar = "";
|
||||
}
|
||||
return str_repeat(" ",$level*2)."<".strtoupper($tag).">".$endchar;
|
||||
}
|
||||
|
||||
//Return the xml end tag
|
||||
function end_tag($tag,$level=0,$endline=true) {
|
||||
if ($endline) {
|
||||
$endchar = "\n";
|
||||
} else {
|
||||
$endchar = "";
|
||||
}
|
||||
return str_repeat(" ",$level*2)."</".strtoupper($tag).">".$endchar;
|
||||
}
|
||||
|
||||
//Return the start tag, the contents and the end tag
|
||||
function full_tag($tag,$level=0,$endline=true,$content,$to_utf=true) {
|
||||
$st = start_tag($tag,$level,$endline);
|
||||
$co="";
|
||||
if ($to_utf) {
|
||||
$co = utf8_encode(htmlspecialchars($content));
|
||||
} else {
|
||||
$co = htmlspecialchars($content);
|
||||
}
|
||||
$et = end_tag($tag,0,true);
|
||||
return $st.$co.$et;
|
||||
}
|
||||
|
||||
//Prints General info about the course
|
||||
//name, moodle_version (internal and release), backup_version, date, info in file...
|
||||
function backup_general_info ($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
fwrite ($bf,start_tag("INFO",1,true));
|
||||
|
||||
//The name of the backup
|
||||
fwrite ($bf,full_tag("NAME",2,false,$preferences->backup_name));
|
||||
//The moodle_version
|
||||
fwrite ($bf,full_tag("MOODLE_VERSION",2,false,$preferences->moodle_version));
|
||||
fwrite ($bf,full_tag("MOODLE_RELEASE",2,false,$preferences->moodle_release));
|
||||
//The backup_version
|
||||
fwrite ($bf,full_tag("BACKUP_VERSION",2,false,$preferences->backup_version));
|
||||
fwrite ($bf,full_tag("BACKUP_RELEASE",2,false,$preferences->backup_release));
|
||||
//The date
|
||||
fwrite ($bf,full_tag("DATE",2,false,$preferences->backup_unique_code));
|
||||
//Te includes tag
|
||||
fwrite ($bf,start_tag("DETAILS",2,true));
|
||||
//Now, go to mod element of preferences to print its status
|
||||
foreach ($preferences->mods as $element) {
|
||||
//Calculate info
|
||||
$included = "false";
|
||||
$userinfo = "false";
|
||||
if ($element->backup) {
|
||||
$included = "true";
|
||||
if ($element->userinfo) {
|
||||
$userinfo = "true";
|
||||
}
|
||||
}
|
||||
//Prints the mod start
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$element->name));
|
||||
fwrite ($bf,full_tag("INCLUDED",4,false,$included));
|
||||
fwrite ($bf,full_tag("USERINFO",4,false,$userinfo));
|
||||
|
||||
//Print the end
|
||||
fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
//The user in backup
|
||||
if ($preferences->backup_users == 1) {
|
||||
fwrite ($bf,full_tag("USERS",3,false,"course"));
|
||||
} else {
|
||||
fwrite ($bf,full_tag("USERS",3,false,"all"));
|
||||
}
|
||||
//The logs in backup
|
||||
if ($preferences->backup_logs == 1) {
|
||||
fwrite ($bf,full_tag("LOGS",3,false,"true"));
|
||||
} else {
|
||||
fwrite ($bf,full_tag("LOGS",3,false,"false"));
|
||||
}
|
||||
//The user files
|
||||
if ($preferences->backup_user_files == 1) {
|
||||
fwrite ($bf,full_tag("USERFILES",3,false,"true"));
|
||||
} else {
|
||||
fwrite ($bf,full_tag("USERFILES",3,false,"false"));
|
||||
}
|
||||
//The course files
|
||||
if ($preferences->backup_course_files == 1) {
|
||||
fwrite ($bf,full_tag("COURSEFILES",3,false,"true"));
|
||||
} else {
|
||||
fwrite ($bf,full_tag("COURSEFILES",3,false,"false"));
|
||||
}
|
||||
|
||||
fwrite ($bf,end_tag("DETAILS",2,true));
|
||||
|
||||
|
||||
$status = fwrite ($bf,end_tag("INFO",1,true));
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Prints course's general info (table course)
|
||||
function backup_course_start ($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Course open tag
|
||||
fwrite ($bf,start_tag("COURSE",1,true));
|
||||
//Header open tag
|
||||
fwrite ($bf,start_tag("HEADER",2,true));
|
||||
|
||||
//Get info from course
|
||||
$course=false;
|
||||
if ($courses = get_records("course","id",$preferences->backup_course)) {
|
||||
$course = $courses[$preferences->backup_course];
|
||||
}
|
||||
if ($course) {
|
||||
//Prints course info
|
||||
fwrite ($bf,full_tag("ID",3,false,$course->id));
|
||||
//Obtain the category
|
||||
$category = false;
|
||||
if ($categories = get_records("course_categories","id","$course->category")) {
|
||||
$category = $categories[$course->category];
|
||||
}
|
||||
if ($category) {
|
||||
//Prints category info
|
||||
fwrite ($bf,start_tag("CATEGORY",3,true));
|
||||
fwrite ($bf,full_tag("ID",4,false,$course->category));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$category->name));
|
||||
fwrite ($bf,end_tag("CATEGORY",3,true));
|
||||
}
|
||||
//Continues with the course
|
||||
fwrite ($bf,full_tag("PASSWORD",3,false,$course->password));
|
||||
fwrite ($bf,full_tag("FULLNAME",3,false,$course->fullname));
|
||||
fwrite ($bf,full_tag("SHORTNAME",3,false,$course->shortname));
|
||||
fwrite ($bf,full_tag("SUMMARY",3,false,$course->summary));
|
||||
fwrite ($bf,full_tag("FORMAT",3,false,$course->format));
|
||||
fwrite ($bf,full_tag("NEWSITEMS",3,false,$course->newsitems));
|
||||
fwrite ($bf,full_tag("TEACHER",3,false,$course->teacher));
|
||||
fwrite ($bf,full_tag("TEACHERS",3,false,$course->teachers));
|
||||
fwrite ($bf,full_tag("STUDENT",3,false,$course->student));
|
||||
fwrite ($bf,full_tag("STUDENTS",3,false,$course->students));
|
||||
fwrite ($bf,full_tag("GUEST",3,false,$course->guest));
|
||||
fwrite ($bf,full_tag("STARDATE",3,false,$course->stardate));
|
||||
fwrite ($bf,full_tag("NUMSECTIONS",3,false,$course->numsections));
|
||||
fwrite ($bf,full_tag("SHOWRECENT",3,false,$course->showrecent));
|
||||
fwrite ($bf,full_tag("MARKER",3,false,$course->marker));
|
||||
fwrite ($bf,full_tag("TIMECREATED",3,false,$course->timecreated));
|
||||
$status = fwrite ($bf,full_tag("TIMEMODIFIED",3,false,$course->timemodified));
|
||||
//Print header end
|
||||
fwrite ($bf,end_tag("HEADER",2,true));
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Prints course's end tag
|
||||
function backup_course_end ($bf,$preferences) {
|
||||
|
||||
//Course end tag
|
||||
$status = fwrite ($bf,end_tag("COURSE",1,true));
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
//Prints course's sections info (table course_sections)
|
||||
function backup_course_sections ($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
|
||||
//Get info from sections
|
||||
$section=false;
|
||||
if ($sections = get_records("course_sections","course",$preferences->backup_course,"section")) {
|
||||
//Section open tag
|
||||
fwrite ($bf,start_tag("SECTIONS",2,true));
|
||||
//Iterate over every section (ordered by section)
|
||||
foreach ($sections as $section) {
|
||||
//Begin Section
|
||||
fwrite ($bf,start_tag("SECTION",3,true));
|
||||
fwrite ($bf,full_tag("ID",4,false,$section->id));
|
||||
fwrite ($bf,full_tag("NUMBER",4,false,$section->section));
|
||||
fwrite ($bf,full_tag("SUMMARY",4,false,$section->summary));
|
||||
fwrite ($bf,full_tag("VISIBLE",4,false,$section->visible));
|
||||
//Now print the mods in section
|
||||
backup_course_modules ($bf,$preferences,$section);
|
||||
//End section
|
||||
fwrite ($bf,end_tag("SECTION",3,true));
|
||||
}
|
||||
//Section close tag
|
||||
$status = fwrite ($bf,end_tag("SECTIONS",2,true));
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
//Prints course's modules info (table course_modules)
|
||||
//Only for selected mods in preferences
|
||||
function backup_course_modules ($bf,$preferences,$section) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$first_record = true;
|
||||
|
||||
//Now print the mods in section
|
||||
//Extracts mod id from sequence
|
||||
$tok = strtok($section->sequence,",");
|
||||
while ($tok) {
|
||||
//Get module's type
|
||||
$moduletype = get_module_type ($preferences->backup_course,$tok);
|
||||
//Check if we've selected to backup that type
|
||||
if ($moduletype and $preferences->mods[$moduletype]->backup) {
|
||||
$selected = true;
|
||||
} else {
|
||||
$selected = false;
|
||||
}
|
||||
|
||||
if ($selected) {
|
||||
//Gets course_module data from db
|
||||
$course_module = get_records ("course_modules","id",$tok);
|
||||
//If it's the first, pring MODS tag
|
||||
if ($first_record) {
|
||||
fwrite ($bf,start_tag("MODS",4,true));
|
||||
$first_record = false;
|
||||
}
|
||||
//Print mod info from course_modules
|
||||
fwrite ($bf,start_tag("MOD",5,true));
|
||||
//Save neccesary info to backup_ids
|
||||
fwrite ($bf,full_tag("ID",6,false,$tok));
|
||||
fwrite ($bf,full_tag("TYPE",6,false,$moduletype));
|
||||
fwrite ($bf,full_tag("INSTANCE",6,false,$course_module[$tok]->instance));
|
||||
fwrite ($bf,full_tag("ADDED",6,false,$course_module[$tok]->added));
|
||||
fwrite ($bf,full_tag("DELETED",6,false,$course_module[$tok]->deleted));
|
||||
fwrite ($bf,full_tag("SCORE",6,false,$course_module[$tok]->score));
|
||||
fwrite ($bf,full_tag("VISIBLE",6,false,$course_module[$tok]->visible));
|
||||
fwrite ($bf,end_tag("MOD",5,true));
|
||||
}
|
||||
//check for next
|
||||
$tok = strtok(",");
|
||||
}
|
||||
|
||||
//Si ha habido modulos, final de MODS
|
||||
if (!$first_record) {
|
||||
$status =fwrite ($bf,end_tag("MODS",4,true));
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Print users to xml
|
||||
//Only users previously calculated in backup_ids will output
|
||||
//
|
||||
function backup_user_info ($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$users = get_records_sql("SELECT u.old_id, u.table_name,u.info
|
||||
FROM {$CFG->prefix}backup_ids u
|
||||
WHERE u.backup_code = '$preferences->backup_unique_code' AND
|
||||
u.table_name = 'user'");
|
||||
|
||||
//If we have users to backup
|
||||
if ($users) {
|
||||
//Begin Users tag
|
||||
fwrite ($bf,start_tag("USERS",2,true));
|
||||
//With every user
|
||||
foreach ($users as $user) {
|
||||
//Get user data from table
|
||||
$user_data = get_record("user","id",$user->old_id);
|
||||
//Begin User tag
|
||||
fwrite ($bf,start_tag("USER",3,true));
|
||||
//Output all user data
|
||||
fwrite ($bf,full_tag("ID",4,false,$user_data->id));
|
||||
fwrite ($bf,full_tag("CONFIRMED",4,false,$user_data->confirmed));
|
||||
fwrite ($bf,full_tag("DELETED",4,false,$user_data->deleted));
|
||||
fwrite ($bf,full_tag("USERNAME",4,false,$user_data->username));
|
||||
fwrite ($bf,full_tag("PASSWORD",4,false,$user_data->password));
|
||||
fwrite ($bf,full_tag("IDNUMBER",4,false,$user_data->idnumber));
|
||||
fwrite ($bf,full_tag("FIRSTNAME",4,false,$user_data->firstname));
|
||||
fwrite ($bf,full_tag("LASTNAME",4,false,$user_data->lastname));
|
||||
fwrite ($bf,full_tag("EMAIL",4,false,$user_data->email));
|
||||
fwrite ($bf,full_tag("ICQ",4,false,$user_data->icq));
|
||||
fwrite ($bf,full_tag("PHONE1",4,false,$user_data->phone1));
|
||||
fwrite ($bf,full_tag("PHONE2",4,false,$user_data->phone2));
|
||||
fwrite ($bf,full_tag("INSTITUTION",4,false,$user_data->institution));
|
||||
fwrite ($bf,full_tag("DEPARTMENT",4,false,$user_data->department));
|
||||
fwrite ($bf,full_tag("ADDRESS",4,false,$user_data->address));
|
||||
fwrite ($bf,full_tag("CITY",4,false,$user_data->city));
|
||||
fwrite ($bf,full_tag("COUNTRY",4,false,$user_data->country));
|
||||
fwrite ($bf,full_tag("LANG",4,false,$user_data->lang));
|
||||
fwrite ($bf,full_tag("TIMEZONE",4,false,$user_data->timezone));
|
||||
fwrite ($bf,full_tag("FIRSTACCESS",4,false,$user_data->firstaccess));
|
||||
fwrite ($bf,full_tag("LASTACCESS",4,false,$user_data->lastaccess));
|
||||
fwrite ($bf,full_tag("LASTLOGIN",4,false,$user_data->lastlogin));
|
||||
fwrite ($bf,full_tag("CURRENTLOGIN",4,false,$user_data->currentlogin));
|
||||
fwrite ($bf,full_tag("LASTIP",4,false,$user_data->lastIP));
|
||||
fwrite ($bf,full_tag("SECRET",4,false,$user_data->secret));
|
||||
fwrite ($bf,full_tag("PICTURE",4,false,$user_data->picture));
|
||||
fwrite ($bf,full_tag("URL",4,false,$user_data->url));
|
||||
fwrite ($bf,full_tag("DESCRIPTION",4,false,$user_data->description));
|
||||
fwrite ($bf,full_tag("MAILFORMAT",4,false,$user_data->mailformat));
|
||||
fwrite ($bf,full_tag("MAILDISPLAY",4,false,$user_data->maildisplay));
|
||||
fwrite ($bf,full_tag("HTMLEDITOR",4,false,$user_data->htmleditor));
|
||||
fwrite ($bf,full_tag("AUTOSUBSCRIBE",4,false,$user_data->autosubscribe));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$user_data->timemodified));
|
||||
|
||||
//Output every user role (with its associated info)
|
||||
$user->isadmin = strpos($user->info,"admin");
|
||||
$user->iscoursecreator = strpos($user->info,"coursecreator");
|
||||
$user->isteacher = strpos($user->info,"teacher");
|
||||
$user->isstudent = strpos($user->info,"student");
|
||||
if ($user->isadmin!==false or
|
||||
$user->iscoursecreator!==false or
|
||||
$user->isteacher!==false or
|
||||
$user->isstudent!==false) {
|
||||
//Begin ROLES tag
|
||||
fwrite ($bf,start_tag("ROLES",4,true));
|
||||
//PRINT ROLE INFO
|
||||
//Admins
|
||||
if ($user->isadmin!==false) {
|
||||
//Print ROLE start
|
||||
fwrite ($bf,start_tag("ROLE",5,true));
|
||||
//Print Role info
|
||||
fwrite ($bf,full_tag("TYPE",6,false,"admin"));
|
||||
//Print ROLE end
|
||||
fwrite ($bf,end_tag("ROLE",5,true));
|
||||
}
|
||||
//CourseCreator
|
||||
if ($user->iscoursecreator!==false) {
|
||||
//Print ROLE start
|
||||
fwrite ($bf,start_tag("ROLE",5,true));
|
||||
//Print Role info
|
||||
fwrite ($bf,full_tag("TYPE",6,false,"coursecreator"));
|
||||
//Print ROLE end
|
||||
fwrite ($bf,end_tag("ROLE",5,true));
|
||||
}
|
||||
//Teacher
|
||||
if ($user->isteacher!==false) {
|
||||
//Print ROLE start
|
||||
fwrite ($bf,start_tag("ROLE",5,true));
|
||||
//Print Role info
|
||||
fwrite ($bf,full_tag("TYPE",6,false,"teacher"));
|
||||
//Get specific info for teachers
|
||||
$tea = get_record("user_teachers","userid",$user->old_id,"course",$preferences->backup_course);
|
||||
fwrite ($bf,full_tag("AUTHORITY",6,false,$tea->authority));
|
||||
fwrite ($bf,full_tag("TEA_ROLE",6,false,$tea->role));
|
||||
//Print ROLE end
|
||||
fwrite ($bf,end_tag("ROLE",5,true));
|
||||
}
|
||||
//Student
|
||||
if ($user->isstudent!==false) {
|
||||
//Print ROLE start
|
||||
fwrite ($bf,start_tag("ROLE",5,true));
|
||||
//Print Role info
|
||||
fwrite ($bf,full_tag("TYPE",6,false,"student"));
|
||||
//Get specific info for students
|
||||
$stu = get_record("user_students","userid",$user->old_id,"course",$preferences->backup_course);
|
||||
fwrite ($bf,full_tag("TIMESTART",6,false,$stu->timestart));
|
||||
fwrite ($bf,full_tag("TIMEEND",6,false,$stu->timeend));
|
||||
fwrite ($bf,full_tag("TIME",6,false,$stu->time));
|
||||
//Print ROLE end
|
||||
fwrite ($bf,end_tag("ROLE",5,true));
|
||||
}
|
||||
|
||||
|
||||
//End ROLES tag
|
||||
fwrite ($bf,end_tag("ROLES",4,true));
|
||||
}
|
||||
//End User tag
|
||||
fwrite ($bf,end_tag("USER",3,true));
|
||||
}
|
||||
//End Users tag
|
||||
fwrite ($bf,end_tag("USERS",2,true));
|
||||
} else {
|
||||
//There isn't users. Impossible !!
|
||||
$status = false;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup log info (time ordered)
|
||||
function backup_log_info($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$logs = get_records ("log","course",$preferences->backup_course,"time");
|
||||
|
||||
//We have logs
|
||||
if ($logs) {
|
||||
//Pring logs header
|
||||
fwrite ($bf,start_tag("LOGS",2,true));
|
||||
//Iterate
|
||||
foreach ($logs as $log) {
|
||||
//See if it is a valid module to backup
|
||||
if ($log->module == "course" or
|
||||
$log->module == "user" or
|
||||
$preferences->mods[$log->module]->backup == 1) {
|
||||
//Begin log tag
|
||||
fwrite ($bf,start_tag("LOG",3,true));
|
||||
|
||||
//Output log tag
|
||||
fwrite ($bf,full_tag("ID",4,false,$log->id));
|
||||
fwrite ($bf,full_tag("TIME",4,false,$log->time));
|
||||
fwrite ($bf,full_tag("USERID",4,false,$log->userid));
|
||||
fwrite ($bf,full_tag("IP",4,false,$log->ip));
|
||||
fwrite ($bf,full_tag("MODULE",4,false,$log->module));
|
||||
fwrite ($bf,full_tag("ACTION",4,false,$log->action));
|
||||
fwrite ($bf,full_tag("URL",4,false,$log->url));
|
||||
fwrite ($bf,full_tag("INFO",4,false,$log->info));
|
||||
|
||||
//End log tag
|
||||
fwrite ($bf,end_tag("LOG",3,true));
|
||||
}
|
||||
}
|
||||
//End logs tag
|
||||
$status = fwrite ($bf,end_tag("LOGS",2,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Start the modules tag
|
||||
function backup_modules_start ($bf,$preferences) {
|
||||
|
||||
return fwrite ($bf,start_tag("MODULES",2,true));
|
||||
}
|
||||
|
||||
//End the modules tag
|
||||
function backup_modules_end ($bf,$preferences) {
|
||||
|
||||
return fwrite ($bf,end_tag("MODULES",2,true));
|
||||
}
|
||||
|
||||
//This function makes all the necesary calls to every mod
|
||||
//to export itself and its files !!!
|
||||
function backup_module($bf,$preferences,$module) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//First, re-check if necessary functions exists
|
||||
$modbackup = $module."_backup_mods";
|
||||
if (function_exists($modbackup)) {
|
||||
//Call the function
|
||||
$status = $modbackup($bf,$preferences);
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
//This function copies all the needed files under the "users" directory to the "user_files"
|
||||
//directory under temp/backup
|
||||
function backup_copy_user_files ($preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//First we check to "user_files" exists and create it as necessary
|
||||
//in temp/backup/$backup_code dir
|
||||
$status = check_and_create_user_files_dir($preferences->backup_unique_code);
|
||||
|
||||
//Now iterate over directories under "users" to check if that user must be
|
||||
//copied to backup
|
||||
|
||||
$rootdir = $CFG->dataroot."/users";
|
||||
//Check if directory exists
|
||||
if (is_dir($rootdir)) {
|
||||
$list = list_directories ($rootdir);
|
||||
if ($list) {
|
||||
//Iterate
|
||||
foreach ($list as $dir) {
|
||||
//Look for dir like username in backup_ids
|
||||
$data = get_record ("backup_ids","backup_code",$preferences->backup_unique_code,
|
||||
"table_name","user",
|
||||
"old_id",$dir);
|
||||
//If exists, copy it
|
||||
if ($data) {
|
||||
$status = backup_copy_file($rootdir."/".$dir,
|
||||
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/user_files/".$dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function copies all the course files under the course directory (except the moddata
|
||||
//directory to the "course_files" directory under temp/backup
|
||||
function backup_copy_course_files ($preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//First we check to "course_files" exists and create it as necessary
|
||||
//in temp/backup/$backup_code dir
|
||||
$status = check_and_create_course_files_dir($preferences->backup_unique_code);
|
||||
|
||||
//Now iterate over files and directories except $CFG->moddata and get_string("backupdir") to be
|
||||
//copied to backup
|
||||
|
||||
$rootdir = $CFG->dataroot."/".$preferences->backup_course;
|
||||
|
||||
$name_moddata = $CFG->moddata;
|
||||
$name_backupdata = get_string("backupdir");
|
||||
//Check if directory exists
|
||||
if (is_dir($rootdir)) {
|
||||
$list = list_directories_and_files ($rootdir);
|
||||
if ($list) {
|
||||
//Iterate
|
||||
foreach ($list as $dir) {
|
||||
if ($dir !== $name_moddata and $dir !== $name_backupdata) {
|
||||
$status = backup_copy_file($rootdir."/".$dir,
|
||||
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/course_files/".$dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function creates the zip file containing all the backup info
|
||||
//moodle.xml, moddata, user_files, course_files.
|
||||
//The zipped file is created in the backup directory and named with
|
||||
//the "oficial" name of the backup
|
||||
//It uses "pclzip" if available or system "zip" (unix only)
|
||||
function backup_zip ($preferences,$moodle_home) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Base dir where everything happens
|
||||
$basedir = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code;
|
||||
//Backup zip file name
|
||||
$name = $preferences->backup_name;
|
||||
//List base_dir files and directories
|
||||
$filelist = list_directories_and_files ($basedir);
|
||||
|
||||
if (empty($CFG->zip)) { // Use built-in php-based zip function
|
||||
$files = array();
|
||||
foreach ($filelist as $file) {
|
||||
//If directory, append "/"
|
||||
if (is_dir($basedir."/".$file)) {
|
||||
$file = $file."/";
|
||||
}
|
||||
//Include into array
|
||||
$files[] = $basedir."/".$file;
|
||||
}
|
||||
include_once($moodle_home."/lib/pclzip/pclzip.lib.php");
|
||||
$archive = new PclZip("$basedir/$name");
|
||||
if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,$basedir)) == 0) {
|
||||
error($archive->errorInfo(true));
|
||||
$status = false;
|
||||
}
|
||||
} else { // Use external zip program
|
||||
$files = "";
|
||||
foreach ($filelist as $file) {
|
||||
$files .= basename($file);
|
||||
$files .= " ";
|
||||
}
|
||||
$command = "cd $basedir ; $CFG->zip -r $name $files";
|
||||
$status = Exec($command);
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
//This function copies the final zip to the course dir
|
||||
function copy_zip_to_course_dir ($preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
//Backup zip file name
|
||||
$from_zip_file = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/".$preferences->backup_name;
|
||||
$to_zip_file = $CFG->dataroot."/".$preferences->backup_course."/".get_string("backupdir")."/".$preferences->backup_name;
|
||||
|
||||
//Check to directory
|
||||
$status = check_dir_exists(dirname($to_zip_file),true);
|
||||
|
||||
//Copy zip file
|
||||
if ($status) {
|
||||
$status = backup_copy_file ($from_zip_file,$to_zip_file);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?PHP //$Id$
|
||||
//
|
||||
// This file keeps track of upgrades to Moodle's
|
||||
// backup/restore utility.
|
||||
//
|
||||
// Sometimes, changes between versions involve
|
||||
// alterations to database structures and other
|
||||
// major things that may break installations.
|
||||
//
|
||||
// The upgrade function in this file will attempt
|
||||
// to perform all the necessary actions to upgrade
|
||||
// your older installtion to the current version.
|
||||
//
|
||||
// If there's something it cannot do itself, it
|
||||
// will tell you what you need to do.
|
||||
//
|
||||
// Versions are defined by backup_version.php
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function backup_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2003050300 and $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_ids` (
|
||||
`backup_code` INT(12) UNSIGNED NOT NULL,
|
||||
`table_name` VARCHAR(30) NOT NULL,
|
||||
`old_id` INT(10) UNSIGNED NOT NULL,
|
||||
`new_id` INT(10) UNSIGNED,
|
||||
PRIMARY KEY (`backup_code`, `table_name`, `old_id`)
|
||||
)
|
||||
COMMENT = 'To store and convert ids in backup/restore'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003050301 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
ADD `info` VARCHAR(30)");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003050400 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
MODIFY `info` VARCHAR(255)");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003050401 and $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_files` (
|
||||
`backup_code` INT( 10 ) UNSIGNED NOT NULL ,
|
||||
`file_type` VARCHAR( 10 ) NOT NULL ,
|
||||
`path` VARCHAR( 255 ) NOT NULL ,
|
||||
`old_id` INT( 10 ) UNSIGNED,
|
||||
`new_id` INT( 10 ) UNSIGNED,
|
||||
PRIMARY KEY ( `backup_code` , `file_type` , `path` )
|
||||
) COMMENT = 'To store and recode ids to user & course files.'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003052000 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
MODIFY `info` TEXT");
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+351
@@ -0,0 +1,351 @@
|
||||
<?PHP //$Id$
|
||||
//This file contains all the general function needed (file manipulation...)
|
||||
//not directly part of the backup/restore utility
|
||||
|
||||
//Delete old data in backup tables (if exists)
|
||||
//Two days seems to be apropiate
|
||||
function backup_delete_old_data() {
|
||||
|
||||
global $CFG;
|
||||
|
||||
//Change this if you want !!
|
||||
$days = 2;
|
||||
//End change this
|
||||
$seconds = $days * 24 * 60 * 60;
|
||||
$delete_from = time()-$seconds;
|
||||
//Now delete from tables
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
|
||||
WHERE backup_code < '$delete_from'",false);
|
||||
if ($status) {
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_files
|
||||
WHERE backup_code < '$delete_from'",false);
|
||||
}
|
||||
//Now, delete old directory (if exists)
|
||||
if ($status) {
|
||||
$status = backup_delete_old_dirs($delete_from);
|
||||
}
|
||||
return($status);
|
||||
}
|
||||
|
||||
//Function to delete dirs/files into temp/backup directory
|
||||
//older than $delete_from
|
||||
function backup_delete_old_dirs($delete_from) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
$list = get_directory_list($CFG->dataroot."/temp/backup", "", false);
|
||||
foreach ($list as $file) {
|
||||
$file_path = $CFG->dataroot."/temp/backup/".$file;
|
||||
$moddate = filemtime($file_path);
|
||||
if ($status and $moddate < $delete_from) {
|
||||
//If directory, recurse
|
||||
if (is_dir($file_path)) {
|
||||
$status = delete_dir_contents($file_path);
|
||||
//There is nothing, delete the directory itself
|
||||
if ($status) {
|
||||
$status = rmdir($file_path);
|
||||
}
|
||||
//If file
|
||||
} else {
|
||||
unlink("$file_path");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Function to check if a directory exists
|
||||
//and, optionally, create it
|
||||
function check_dir_exists($dir,$create=false) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
if(!is_dir($dir)) {
|
||||
if (!$create) {
|
||||
$status = false;
|
||||
} else {
|
||||
umask(0000);
|
||||
$status = mkdir ($dir,$CFG->directorypermissions);
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Function to check and create the needed dir to
|
||||
//save all the backup
|
||||
function check_and_create_backup_dir($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = check_dir_exists($CFG->dataroot."/temp",true);
|
||||
if ($status) {
|
||||
$status = check_dir_exists($CFG->dataroot."/temp/backup",true);
|
||||
}
|
||||
if ($status) {
|
||||
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$backup_unique_code,true);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Function to delete all the directory contents recursively
|
||||
//Copied from admin/delete.php
|
||||
function delete_dir_contents ($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
$status = true;
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != "." and $file != "..") {
|
||||
$fullfile = "$rootdir/$file";
|
||||
if (filetype($fullfile) == "dir") {
|
||||
delete_dir_contents($fullfile);
|
||||
if (!rmdir($fullfile)) {
|
||||
$status = false;
|
||||
}
|
||||
} else {
|
||||
if (!unlink("$fullfile")) {
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
//Function to clear (empty) the contents of the backup_dir
|
||||
//Copied from admin/delete.php
|
||||
function clear_backup_dir($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$rootdir = $CFG->dataroot."/temp/backup/".$backup_unique_code;
|
||||
|
||||
//Delete recursively
|
||||
$status = delete_dir_contents($rootdir);
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Returns the module type of a course_module's id in a course
|
||||
function get_module_type ($courseid,$moduleid) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$results = get_records_sql ("SELECT cm.id, m.name
|
||||
FROM {$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}modules m
|
||||
WHERE cm.course = '$courseid' AND
|
||||
cm.id = '$moduleid' AND
|
||||
m.id = cm.module");
|
||||
|
||||
if ($results) {
|
||||
$name = $results[$moduleid]->name;
|
||||
} else {
|
||||
$name = false;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
//This function return the names of all directories under a give directory
|
||||
//Not recursive
|
||||
function list_directories ($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
while ($file=readdir($dir)) {
|
||||
if ($file=="." || $file=="..") {
|
||||
continue;
|
||||
}
|
||||
if (is_dir($rootdir."/".$file)) {
|
||||
$results[$file] = $file;
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
return $results;
|
||||
}
|
||||
|
||||
//This function return the names of all directories and files under a give directory
|
||||
//Not recursive
|
||||
function list_directories_and_files ($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
while ($file=readdir($dir)) {
|
||||
if ($file=="." || $file=="..") {
|
||||
continue;
|
||||
}
|
||||
$results[$file] = $file;
|
||||
}
|
||||
closedir($dir);
|
||||
return $results;
|
||||
}
|
||||
|
||||
//This function clean data from backup tables and
|
||||
//delete all temp files used
|
||||
function clean_temp_data ($preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//true->do it, false->don't do it. To debug if necessary.
|
||||
if (true) {
|
||||
//Now delete from tables
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
|
||||
WHERE backup_code = '$preferences->backup_unique_code'",false);
|
||||
if ($status) {
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_files
|
||||
WHERE backup_code = '$preferences->backup_unique_code'",false);
|
||||
}
|
||||
//Now, delete temp directory (if exists)
|
||||
$file_path = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code;
|
||||
if (is_dir($file_path)) {
|
||||
$status = delete_dir_contents($file_path);
|
||||
//There is nothing, delete the directory itself
|
||||
if ($status) {
|
||||
$status = rmdir($file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//This functions are used to copy any file or directory ($from_file)
|
||||
//to a new file or directory ($to_file). It works recursively and
|
||||
//mantains file perms.
|
||||
//I've copied it from: http://www.php.net/manual/en/function.copy.php
|
||||
//Little modifications done
|
||||
|
||||
function backup_copy_file ($from_file,$to_file) {
|
||||
if (is_file($from_file)) {
|
||||
$perms=fileperms($from_file);
|
||||
return copy($from_file,$to_file) && chmod($to_file,$perms);
|
||||
}
|
||||
else if (is_dir($from_file)) {
|
||||
return backup_copy_dir($from_file,$to_file);
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function backup_copy_dir($from_file,$to_file) {
|
||||
if (!is_dir($to_file)) {
|
||||
mkdir($to_file);
|
||||
chmod("$to_file",0777);
|
||||
}
|
||||
$dir = opendir($from_file);
|
||||
while ($file=readdir($dir)) {
|
||||
if ($file=="." || $file=="..") {
|
||||
continue;
|
||||
}
|
||||
$status = backup_copy_file ("$from_file/$file","$to_file/$file");
|
||||
}
|
||||
closedir($dir);
|
||||
return $status;
|
||||
}
|
||||
///Ends copy file/dirs functions
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
//This function upgrades, if necesary, the backup-restore tables
|
||||
//It's called from backup.php and restore.php
|
||||
function upgrade_backup_db($updgradeto,$backup_release,$continueto) {
|
||||
|
||||
global $CFG,$db;
|
||||
|
||||
//Check backup_version
|
||||
if ($CFG->backup_version) {
|
||||
if ($updgradeto > $CFG->backup_version) { // upgrade
|
||||
$a->oldversion = $CFG->backup_version;
|
||||
$a->newversion = $updgradeto;
|
||||
$strdatabasechecking = get_string("databasechecking", "", $a);
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking);
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
if (backup_upgrade($a->oldversion)) {
|
||||
$db->debug=false;
|
||||
if (set_config("backup_version", $a->newversion)) {
|
||||
notify($strdatabasesuccess, "green");
|
||||
notify("You are running Backup/Recovery version ".$backup_release,"black");
|
||||
print_continue($continueto);
|
||||
die;
|
||||
} else {
|
||||
notify("Upgrade failed! (Could not update version in config table)");
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrade failed! See backup_version.php");
|
||||
die;
|
||||
}
|
||||
} else if ($updgradeto < $CFG->backup_version) {
|
||||
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
|
||||
}
|
||||
//Not exists. Starting installation
|
||||
} else {
|
||||
$strdatabaseupgrades = get_string("databaseupgrades");
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades);
|
||||
|
||||
if (set_config("backup_version", "2003010100")) {
|
||||
print_heading("You are currently going to install the needed structures to Backup/Recover");
|
||||
print_continue($continue_to);
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//This function is used to insert records in the backup_ids table
|
||||
function backup_putid ($backup_unique_code, $table, $old_id, $new_id, $info="") {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//First delete to avoid PK duplicates
|
||||
$status = backup_delid($backup_unique_code, $table, $old_id);
|
||||
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
|
||||
(backup_code, table_name, old_id, new_id, info)
|
||||
VALUES
|
||||
($backup_unique_code, '$table', '$old_id', '$new_id', '$info')",false);
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function is used to delete recods from the backup_ids table
|
||||
function backup_delid ($backup_unique_code, $table, $old_id) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
|
||||
WHERE backup_code = $backup_unique_code AND
|
||||
table_name = '$table' AND
|
||||
old_id = '$old_id'",false);
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function is used to get a record from the backup_ids table
|
||||
function backup_getid ($backup_unique_code, $table, $old_id) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$status = get_record ("backup_ids","backup_code",$backup_unique_code,
|
||||
"table_name",$table,
|
||||
"old_id", $old_id);
|
||||
|
||||
return $status;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,171 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//assignment mods
|
||||
|
||||
//This is the "graphical" structure of the assignment mod:
|
||||
//
|
||||
// assignment
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// assignment_submisions
|
||||
// (UL,pk->id, fk->assignment,files)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//This function executes all the backup procedure about this mod
|
||||
function assignment_backup_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over assignment table
|
||||
$assignments = get_records ("assignment","course",$preferences->backup_course,"id");
|
||||
if ($assignments) {
|
||||
foreach ($assignments as $assignment) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print assignment data
|
||||
fwrite ($bf,full_tag("ID",4,false,$assignment->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"assignment"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$assignment->name));
|
||||
fwrite ($bf,full_tag("DESCRIPTION",4,false,$assignment->description));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$assignment->format));
|
||||
fwrite ($bf,full_tag("RESUBMIT",4,false,$assignment->resubmit));
|
||||
fwrite ($bf,full_tag("TYPE",4,false,$assignment->type));
|
||||
fwrite ($bf,full_tag("MAXBYTES",4,false,$assignment->maxbytes));
|
||||
fwrite ($bf,full_tag("TIMEDUE",4,false,$assignment->timedue));
|
||||
fwrite ($bf,full_tag("GRADE",4,false,$assignment->grade));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$assignment->timemodified));
|
||||
//if we've selected to backup users info, then execute backup_assignment_submisions
|
||||
if ($preferences->mods["assignment"]->userinfo) {
|
||||
$status = backup_assignment_submissions($bf,$preferences,$assignment->id);
|
||||
}
|
||||
//End mod
|
||||
$status =fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
//if we've selected to backup users info, then backup files too
|
||||
if ($preferences->mods["assignment"]->userinfo) {
|
||||
$status = backup_assignment_files($bf,$preferences);
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup assignment_submissions contents (executed from assignment_backup_mods)
|
||||
function backup_assignment_submissions ($bf,$preferences,$assignment) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$assignment_submissions = get_records("assignment_submissions","assignment",$assignment,"id");
|
||||
//If there is submissions
|
||||
if ($assignment_submissions) {
|
||||
//Write start tag
|
||||
$status =fwrite ($bf,start_tag("SUBMISSIONS",4,true));
|
||||
//Iterate over each submission
|
||||
foreach ($assignment_submissions as $ass_sub) {
|
||||
//Start submission
|
||||
$status =fwrite ($bf,start_tag("SUBMISSION",5,true));
|
||||
//Print submission contents
|
||||
fwrite ($bf,full_tag("ID",6,false,$ass_sub->id));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$ass_sub->userid));
|
||||
fwrite ($bf,full_tag("TIMECREATED",6,false,$ass_sub->timecreated));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$ass_sub->timemodified));
|
||||
fwrite ($bf,full_tag("NUMFILES",6,false,$ass_sub->numfiles));
|
||||
fwrite ($bf,full_tag("GRADE",6,false,$ass_sub->grade));
|
||||
fwrite ($bf,full_tag("COMMENT",6,false,$ass_sub->comment));
|
||||
fwrite ($bf,full_tag("TEACHER",6,false,$ass_sub->teacher));
|
||||
fwrite ($bf,full_tag("TIMEMARKED",6,false,$ass_sub->timemarked));
|
||||
fwrite ($bf,full_tag("MAILED",6,false,$ass_sub->mailed));
|
||||
//End submission
|
||||
$status =fwrite ($bf,end_tag("SUBMISSION",5,true));
|
||||
}
|
||||
//Write end tag
|
||||
$status =fwrite ($bf,end_tag("SUBMISSIONS",4,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup assignment files because we've selected to backup user info
|
||||
//and files are user info's level
|
||||
function backup_assignment_files($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//First we check to moddata exists and create it as necessary
|
||||
//in temp/backup/$backup_code dir
|
||||
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
|
||||
//Now copy the assignment dir
|
||||
if ($status) {
|
||||
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/assignment",
|
||||
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/assignment");
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
//Return an array of info (name,value)
|
||||
function assignment_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","assignment");
|
||||
if ($ids = assignment_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
$info[1][0] = get_string("submissions","assignment");
|
||||
if ($ids = assignment_submission_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of assignments id
|
||||
function assignment_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}assignment a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of assignment_submissions id
|
||||
function assignment_submission_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.assignment
|
||||
FROM {$CFG->prefix}assignment_submissions s,
|
||||
{$CFG->prefix}assignment a
|
||||
WHERE a.course = '$course' AND
|
||||
s.assignment = a.id");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//assignment mods
|
||||
|
||||
//This is the "graphical" structure of the assignment mod:
|
||||
//
|
||||
// assignment
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// assignment_submisions
|
||||
// (UL,pk->id, fk->assignment,files)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//This function executes all the backup procedure about this mod
|
||||
function assignment_restore_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over assignment table
|
||||
$assignments = get_records ("assignment","course",$preferences->backup_course,"id");
|
||||
if ($assignments) {
|
||||
foreach ($assignments as $assignment) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print assignment data
|
||||
fwrite ($bf,full_tag("ID",4,false,$assignment->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"assignment"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$assignment->name));
|
||||
fwrite ($bf,full_tag("DESCRIPTION",4,false,$assignment->description));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$assignment->format));
|
||||
fwrite ($bf,full_tag("RESUBMIT",4,false,$assignment->resubmit));
|
||||
fwrite ($bf,full_tag("TYPE",4,false,$assignment->type));
|
||||
fwrite ($bf,full_tag("MAXBYTES",4,false,$assignment->maxbytes));
|
||||
fwrite ($bf,full_tag("TIMEDUE",4,false,$assignment->timedue));
|
||||
fwrite ($bf,full_tag("GRADE",4,false,$assignment->grade));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$assignment->timemodified));
|
||||
//if we've selected to backup users info, then execute backup_assignment_submisions
|
||||
if ($preferences->mods["assignment"]->userinfo) {
|
||||
$status = backup_assignment_submissions($bf,$preferences,$assignment->id);
|
||||
}
|
||||
//End mod
|
||||
$status =fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
//if we've selected to backup users info, then backup files too
|
||||
if ($preferences->mods["assignment"]->userinfo) {
|
||||
$status = backup_assignment_files($bf,$preferences);
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,141 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//choice mods
|
||||
|
||||
//This is the "graphical" structure of the choice mod:
|
||||
//
|
||||
// choice
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// choice_answers
|
||||
// (UL,pk->id, fk->choice)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function choice_backup_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over choice table
|
||||
$choices = get_records ("choice","course",$preferences->backup_course,"id");
|
||||
if ($choices) {
|
||||
foreach ($choices as $choice) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print choice data
|
||||
fwrite ($bf,full_tag("ID",4,false,$choice->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"choice"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$choice->name));
|
||||
fwrite ($bf,full_tag("TEXT",4,false,$choice->text));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$choice->format));
|
||||
fwrite ($bf,full_tag("ANSWER1",4,false,$choice->answer1));
|
||||
fwrite ($bf,full_tag("ANSWER2",4,false,$choice->answer2));
|
||||
fwrite ($bf,full_tag("ANSWER3",4,false,$choice->answer3));
|
||||
fwrite ($bf,full_tag("ANSWER4",4,false,$choice->answer4));
|
||||
fwrite ($bf,full_tag("ANSWER5",4,false,$choice->answer5));
|
||||
fwrite ($bf,full_tag("ANSWER6",4,false,$choice->answer6));
|
||||
fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified));
|
||||
//if we've selected to backup users info, then execute backup_choice_answers
|
||||
if ($preferences->mods["choice"]->userinfo) {
|
||||
$status = backup_choice_answers($bf,$preferences,$choice->id);
|
||||
}
|
||||
//End mod
|
||||
$status =fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup choice_answers contents (executed from choice_backup_mods)
|
||||
function backup_choice_answers ($bf,$preferences,$choice) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$choice_answers = get_records("choice_answers","choice",$choice,"id");
|
||||
//If there is submissions
|
||||
if ($choice_answers) {
|
||||
//Write start tag
|
||||
$status =fwrite ($bf,start_tag("ANSWERS",4,true));
|
||||
//Iterate over each answer
|
||||
foreach ($choice_answers as $cho_ans) {
|
||||
//Start answer
|
||||
$status =fwrite ($bf,start_tag("ANSWER",5,true));
|
||||
//Print submission contents
|
||||
fwrite ($bf,full_tag("ID",6,false,$cho_ans->id));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$cho_ans->userid));
|
||||
fwrite ($bf,full_tag("CHOICE_ANSWER",6,false,$cho_ans->answer));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$cho_ans->timemodified));
|
||||
//End answer
|
||||
$status =fwrite ($bf,end_tag("ANSWER",5,true));
|
||||
}
|
||||
//Write end tag
|
||||
$status =fwrite ($bf,end_tag("ANSWERS",4,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function choice_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","choice");
|
||||
if ($ids = choice_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
$info[1][0] = get_string("responses","choice");
|
||||
if ($ids = choice_answer_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of choices id
|
||||
function choice_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}choice a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of choice_answers id
|
||||
function choice_answer_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.choice
|
||||
FROM {$CFG->prefix}choice_answers s,
|
||||
{$CFG->prefix}choice a
|
||||
WHERE a.course = '$course' AND
|
||||
s.choice = a.id");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//choice mods
|
||||
|
||||
//This is the "graphical" structure of the choice mod:
|
||||
//
|
||||
// choice
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// choice_answers
|
||||
// (UL,pk->id, fk->choice)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function choice_restore_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over choice table
|
||||
$choices = get_records ("choice","course",$preferences->backup_course,"id");
|
||||
if ($choices) {
|
||||
foreach ($choices as $choice) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print choice data
|
||||
fwrite ($bf,full_tag("ID",4,false,$choice->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"choice"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$choice->name));
|
||||
fwrite ($bf,full_tag("TEXT",4,false,$choice->text));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$choice->format));
|
||||
fwrite ($bf,full_tag("ANSWER1",4,false,$choice->answer1));
|
||||
fwrite ($bf,full_tag("ANSWER2",4,false,$choice->answer2));
|
||||
fwrite ($bf,full_tag("ANSWER3",4,false,$choice->answer3));
|
||||
fwrite ($bf,full_tag("ANSWER4",4,false,$choice->answer4));
|
||||
fwrite ($bf,full_tag("ANSWER5",4,false,$choice->answer5));
|
||||
fwrite ($bf,full_tag("ANSWER6",4,false,$choice->answer6));
|
||||
fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified));
|
||||
//if we've selected to backup users info, then execute backup_choice_answers
|
||||
if ($preferences->mods["choice"]->userinfo) {
|
||||
$status = backup_choice_answers($bf,$preferences,$choice->id);
|
||||
}
|
||||
//End mod
|
||||
$status =fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,152 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//forum mods
|
||||
|
||||
//This is the "graphical" structure of the forum mod:
|
||||
//
|
||||
// forum
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// -----------------------------------
|
||||
// | |
|
||||
// subscriptions forum_discussions
|
||||
// (UL,pk->id, fk->forum) (UL,pk->id, fk->forum)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// forum_posts
|
||||
// (UL,pk->id,fk->discussion,nt->parent,files)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// forum_ratings
|
||||
// (UL,pk->id,fk->post)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function forum_backup_mods() {
|
||||
print "hola";
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function NO_forum_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","forum");
|
||||
if ($ids = forum_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
//Subscriptions
|
||||
$info[1][0] = get_string("subscriptions","forum");
|
||||
if ($ids = forum_subscription_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
//Discussions
|
||||
$info[2][0] = get_string("discussions","forum");
|
||||
if ($ids = forum_discussion_ids_by_course ($course)) {
|
||||
$info[2][1] = count($ids);
|
||||
} else {
|
||||
$info[2][1] = 0;
|
||||
}
|
||||
//Posts
|
||||
$info[3][0] = get_string("posts","forum");
|
||||
if ($ids = forum_post_ids_by_course ($course)) {
|
||||
$info[3][1] = count($ids);
|
||||
} else {
|
||||
$info[3][1] = 0;
|
||||
}
|
||||
//Ratings
|
||||
$info[4][0] = get_string("ratings","forum");
|
||||
if ($ids = forum_rating_ids_by_course ($course)) {
|
||||
$info[4][1] = count($ids);
|
||||
} else {
|
||||
$info[4][1] = 0;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of forums id
|
||||
function forum_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}forum a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of forum subscriptions id
|
||||
function forum_subscription_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.forum
|
||||
FROM {$CFG->prefix}forum_subscriptions s,
|
||||
{$CFG->prefix}forum a
|
||||
WHERE a.course = '$course' AND
|
||||
s.forum = a.id");
|
||||
}
|
||||
|
||||
//Returns an array of forum discussions id
|
||||
function forum_discussion_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.forum
|
||||
FROM {$CFG->prefix}forum_discussions s,
|
||||
{$CFG->prefix}forum a
|
||||
WHERE a.course = '$course' AND
|
||||
s.forum = a.id");
|
||||
}
|
||||
|
||||
//Returns an array of forum posts id
|
||||
function forum_post_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT p.id , p.discussion, s.forum
|
||||
FROM {$CFG->prefix}forum_posts p,
|
||||
{$CFG->prefix}forum_discussions s,
|
||||
{$CFG->prefix}forum a
|
||||
WHERE a.course = '$course' AND
|
||||
s.forum = a.id AND
|
||||
p.discussion = s.id");
|
||||
}
|
||||
|
||||
//Returns an array of ratings posts id
|
||||
function forum_rating_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
|
||||
FROM {$CFG->prefix}forum_ratings r,
|
||||
{$CFG->prefix}forum_posts p,
|
||||
{$CFG->prefix}forum_discussions s,
|
||||
{$CFG->prefix}forum a
|
||||
WHERE a.course = '$course' AND
|
||||
s.forum = a.id AND
|
||||
p.discussion = s.id AND
|
||||
r.post = p.id");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//journal mods
|
||||
|
||||
//This is the "graphical" structure of the journal mod:
|
||||
//
|
||||
// journal
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// journal_entries
|
||||
// (UL,pk->id, fk->journal)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function journal_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
print "hola";
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function NO_journal_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","journal");
|
||||
if ($ids = journal_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
$info[1][0] = get_string("entries","journal");
|
||||
if ($ids = journal_entry_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of journals id
|
||||
function journal_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}journal a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of journal entries id
|
||||
function journal_entry_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.journal
|
||||
FROM {$CFG->prefix}journal_entries s,
|
||||
{$CFG->prefix}journal a
|
||||
WHERE a.course = '$course' AND
|
||||
s.journal = a.id");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//pgassignment mods
|
||||
|
||||
//This is the "graphical" structure of the pgassignment mod:
|
||||
//
|
||||
// pgassignment
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// -----------------------------------
|
||||
// | |
|
||||
// pgassignment_elements pgassignment_submissions
|
||||
// (CL,pk->id, fk->pgassignment) (UL,pk->id, fk->pgassignment,files)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// pgasignments_grades
|
||||
// (UL,pk->id,fk->submission)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function NO_pgassignment_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
print "hola";
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function pgassignment_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","pgassignment");
|
||||
if ($ids = pgassignment_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
//Elements
|
||||
$info[1][0] = get_string("elements","pgassignment");
|
||||
if ($ids = pgassignment_element_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
//Submissions
|
||||
$info[2][0] = get_string("submissions","pgassignment");
|
||||
if ($ids = pgassignment_submission_ids_by_course ($course)) {
|
||||
$info[2][1] = count($ids);
|
||||
} else {
|
||||
$info[2][1] = 0;
|
||||
}
|
||||
//Grades
|
||||
$info[3][0] = get_string("grades","pgassignment");
|
||||
if ($ids = pgassignment_grade_ids_by_course ($course)) {
|
||||
$info[3][1] = count($ids);
|
||||
} else {
|
||||
$info[3][1] = 0;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of pgassignments id
|
||||
function pgassignment_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}pgassignment a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of pgassignment elements id
|
||||
function pgassignment_element_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.pgassignment
|
||||
FROM {$CFG->prefix}pgassignment_elements s,
|
||||
{$CFG->prefix}pgassignment a
|
||||
WHERE a.course = '$course' AND
|
||||
s.pgassignment = a.id");
|
||||
}
|
||||
|
||||
//Returns an array of pgassignment submissions id
|
||||
function pgassignment_submission_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.pgassignment
|
||||
FROM {$CFG->prefix}pgassignment_submissions s,
|
||||
{$CFG->prefix}pgassignment a
|
||||
WHERE a.course = '$course' AND
|
||||
s.pgassignment = a.id");
|
||||
}
|
||||
|
||||
//Returns an array of pgassignment grades id
|
||||
function pgassignment_grade_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT g.id , g.submission, s.pgassignment
|
||||
FROM {$CFG->prefix}pgassignment_grades g,
|
||||
{$CFG->prefix}pgassignment_submissions s,
|
||||
{$CFG->prefix}pgassignment a
|
||||
WHERE a.course = '$course' AND
|
||||
s.pgassignment = a.id AND
|
||||
g.submission = s.id");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,148 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//quiz mods
|
||||
|
||||
//To see, put your terminal to 132cc
|
||||
|
||||
//This is the "graphical" structure of the quiz mod:
|
||||
//
|
||||
// quiz quiz_categories
|
||||
// (CL,pk->id) (CL,pk->id)
|
||||
// | |
|
||||
// ----------------------------------------------- |
|
||||
// | | | |
|
||||
// | | | |
|
||||
// | | | |
|
||||
// quiz_attemps quiz_grades quiz_question_grades |
|
||||
// (UL,pk->id, fk->quiz) (UL,pk->id,fk->quiz) (UL,pk->id,fk->quiz) |
|
||||
// | | |
|
||||
// | | |
|
||||
// | | |
|
||||
// quiz_responses | quiz_questions
|
||||
// (UL,pk->id, fk->attempt)----------------------------------------------------(CL,pk->id,fk->category,files)
|
||||
// |
|
||||
// |
|
||||
// |
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// | | | |
|
||||
// | | | |
|
||||
// | | | | quiz_randomsamatch
|
||||
// quiz_truefalse quiz_shortanswer quiz_multichoice |---------(CL,pl->id,fk->question)
|
||||
// (CL,pl->id,fk->question) (CL,pl->id,fk->question) (CL,pl->id,fk->question) |
|
||||
// . . . |
|
||||
// . . . |
|
||||
// . . . | quiz_match
|
||||
// .................................................... |---------(CL,pl->id,fk->question)
|
||||
// . | .
|
||||
// . | .
|
||||
// . | .
|
||||
// quiz_answers | quiz_match_sub
|
||||
// (CL,pk->id,fk->question)----------------------------|---------(CL,pl->id,fk->question)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//THIS MOD BACKUP NEEDS TO USE THE mdl_backup_ids TABLE
|
||||
|
||||
function quiz_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
print "hola";
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function NO_quiz_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//Deletes data from mdl_backup_ids (categories section)
|
||||
delete_category_ids ($backup_unique_code);
|
||||
//Create date into mdl_backup_ids (categories section)
|
||||
insert_category_ids ($course,$backup_unique_code);
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","quiz");
|
||||
if ($ids = quiz_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
//Categories
|
||||
$info[1][0] = get_string("categories","quiz");
|
||||
if ($ids = quiz_category_ids_by_backup ($backup_unique_code)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
//Questions
|
||||
$info[2][0] = get_string("questions","quiz");
|
||||
if ($ids = quiz_question_ids_by_backup ($backup_unique_code)) {
|
||||
$info[2][1] = count($ids);
|
||||
} else {
|
||||
$info[2][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
//Grades
|
||||
$info[3][0] = get_string("grades","quiz");
|
||||
if ($ids = quiz_grade_ids_by_course ($course)) {
|
||||
$info[3][1] = count($ids);
|
||||
} else {
|
||||
$info[3][1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of quiz id
|
||||
function quiz_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}quiz a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of categories id
|
||||
function quiz_category_ids_by_backup ($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.old_id, a.backup_code
|
||||
FROM {$CFG->prefix}backup_ids a
|
||||
WHERE a.backup_code = '$backup_unique_code'");
|
||||
}
|
||||
|
||||
function quiz_question_ids_by_backup ($backup_unique_code) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT q.id, q.category
|
||||
FROM {$CFG->prefix}backup_ids a,
|
||||
{$CFG->prefix}quiz_questions q
|
||||
WHERE a.backup_code = '$backup_unique_code' and
|
||||
q.category = a.old_id");
|
||||
}
|
||||
|
||||
function quiz_grade_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT g.id, g.quiz
|
||||
FROM {$CFG->prefix}quiz a,
|
||||
{$CFG->prefix}quiz_grades g
|
||||
WHERE a.course = '$course' and
|
||||
g.quiz = a.id");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//resource mods
|
||||
|
||||
//This is the "graphical" structure of the resource mod:
|
||||
//
|
||||
// resource
|
||||
// (CL,pk->id,files)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//This function executes all the backup procedure about this mod
|
||||
function resource_backup_mods($bf,$preferences) {
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
////Iterate over resource table
|
||||
$resources = get_records ("resource","course",$preferences->backup_course,"id");
|
||||
if ($resources) {
|
||||
foreach ($resources as $resource) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print assignment data
|
||||
fwrite ($bf,full_tag("ID",4,false,$resource->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"resource"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$resource->name));
|
||||
fwrite ($bf,full_tag("TYPE",4,false,$resource->type));
|
||||
fwrite ($bf,full_tag("REFERENCE",4,false,$resource->reference));
|
||||
fwrite ($bf,full_tag("SUMMARY",4,false,$resource->summary));
|
||||
fwrite ($bf,full_tag("ALLTEXT",4,false,$resource->alltext));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$resource->timemodified));
|
||||
//End mod
|
||||
$status = fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function resource_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","resource");
|
||||
if ($ids = resource_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of resources id
|
||||
function resource_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}resource a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//resource mods
|
||||
|
||||
//This is the "graphical" structure of the resource mod:
|
||||
//
|
||||
// resource
|
||||
// (CL,pk->id,files)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//This function executes all the restore procedure about this mod
|
||||
function resource_restore_mods($bf,$preferences) {
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
////Iterate over resource table
|
||||
$resources = get_records ("resource","course",$preferences->backup_course,"id");
|
||||
if ($resources) {
|
||||
foreach ($resources as $resource) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print assignment data
|
||||
fwrite ($bf,full_tag("ID",4,false,$resource->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"resource"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$resource->name));
|
||||
fwrite ($bf,full_tag("TYPE",4,false,$resource->type));
|
||||
fwrite ($bf,full_tag("REFERENCE",4,false,$resource->reference));
|
||||
fwrite ($bf,full_tag("SUMMARY",4,false,$resource->summary));
|
||||
fwrite ($bf,full_tag("ALLTEXT",4,false,$resource->alltext));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$resource->timemodified));
|
||||
//End mod
|
||||
$status = fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,174 @@
|
||||
<?PHP //$Id$
|
||||
//This php script contains all the stuff to backup/restore
|
||||
//survey mods
|
||||
|
||||
//This is the "graphical" structure of the survey mod:
|
||||
// --------------------
|
||||
// survey | survey_questions |
|
||||
// (CL,pk->id) |(CL,pk->id,?????) |
|
||||
// | --------------------
|
||||
// |
|
||||
// -----------------------------------
|
||||
// | |
|
||||
// survey_analysis survey_answers
|
||||
// (UL,pk->id, fk->survey) (UL,pk->id, fk->survey)
|
||||
//
|
||||
// Meaning: pk->primary key field of the table
|
||||
// fk->foreign key to link with parent
|
||||
// nt->nested field (recursive data)
|
||||
// CL->course level info
|
||||
// UL->user level info
|
||||
// files->table may have files)
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function survey_backup_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over survey table
|
||||
$surveys = get_records ("survey","course",$preferences->backup_course,"id");
|
||||
if ($surveys) {
|
||||
foreach ($surveys as $survey) {
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
//Print choice data
|
||||
fwrite ($bf,full_tag("ID",4,false,$survey->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"survey"));
|
||||
fwrite ($bf,full_tag("TEMPLATE",4,false,$survey->template));
|
||||
fwrite ($bf,full_tag("DAYS",4,false,$survey->days));
|
||||
fwrite ($bf,full_tag("TIMECREATED",4,false,$survey->timecreated));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$survey->timemodified));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$survey->name));
|
||||
fwrite ($bf,full_tag("INTRO",4,false,$survey->intro));
|
||||
fwrite ($bf,full_tag("QUESTIONS",4,false,$survey->questions));
|
||||
|
||||
//if we've selected to backup users info, then execute backup_survey_answers and
|
||||
//backup_survey_analysis
|
||||
if ($preferences->mods["survey"]->userinfo) {
|
||||
$status = backup_survey_answers($bf,$preferences,$survey->id);
|
||||
$status = backup_survey_analysis($bf,$preferences,$survey->id);
|
||||
}
|
||||
//End mod
|
||||
$status =fwrite ($bf,end_tag("MOD",3,true));
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup survey_answers contents (executed from survey_backup_mods)
|
||||
function backup_survey_answers ($bf,$preferences,$survey) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$survey_answers = get_records("survey_answers","survey",$survey,"id");
|
||||
//If there is answers
|
||||
if ($survey_answers) {
|
||||
//Write start tag
|
||||
$status =fwrite ($bf,start_tag("ANSWERS",4,true));
|
||||
//Iterate over each answer
|
||||
foreach ($survey_answers as $sur_ans) {
|
||||
//Start answer
|
||||
$status =fwrite ($bf,start_tag("ANSWER",5,true));
|
||||
//Print survey_answers contents
|
||||
fwrite ($bf,full_tag("ID",6,false,$sur_ans->id));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$sur_ans->userid));
|
||||
fwrite ($bf,full_tag("QUESTION",6,false,$sur_ans->question));
|
||||
fwrite ($bf,full_tag("TIME",6,false,$sur_ans->time));
|
||||
fwrite ($bf,full_tag("ANSWER1",6,false,$sur_ans->answer1));
|
||||
fwrite ($bf,full_tag("ANSWER2",6,false,$sur_ans->answer2));
|
||||
//End answer
|
||||
$status =fwrite ($bf,end_tag("ANSWER",5,true));
|
||||
}
|
||||
//Write end tag
|
||||
$status =fwrite ($bf,end_tag("ANSWERS",4,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup survey_analysis contents (executed from survey_backup_mods)
|
||||
function backup_survey_analysis ($bf,$preferences,$survey) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$survey_analysis = get_records("survey_analysis","survey",$survey,"id");
|
||||
//If there is analysis
|
||||
if ($survey_analysis) {
|
||||
//Write start tag
|
||||
$status =fwrite ($bf,start_tag("ANALYSIS",4,true));
|
||||
//Iterate over each analysis
|
||||
foreach ($survey_analysis as $sur_ana) {
|
||||
//Start answer
|
||||
$status =fwrite ($bf,start_tag("ANALYS",5,true));
|
||||
//Print survey_analysis contents
|
||||
fwrite ($bf,full_tag("ID",6,false,$sur_ana->id));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$sur_ana->userid));
|
||||
fwrite ($bf,full_tag("NOTES",6,false,$sur_ana->notes));
|
||||
//End answer
|
||||
$status =fwrite ($bf,end_tag("ANALYS",5,true));
|
||||
}
|
||||
//Write end tag
|
||||
$status =fwrite ($bf,end_tag("ANALYSIS",4,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function survey_check_backup_mods($course,$user_data=false,$backup_unique_code) {
|
||||
//First the course data
|
||||
$info[0][0] = get_string("modulenameplural","survey");
|
||||
if ($ids = survey_ids ($course)) {
|
||||
$info[0][1] = count($ids);
|
||||
} else {
|
||||
$info[0][1] = 0;
|
||||
}
|
||||
|
||||
//Now, if requested, the user_data
|
||||
if ($user_data) {
|
||||
//Subscriptions
|
||||
$info[1][0] = get_string("answers","survey");
|
||||
if ($ids = survey_answer_ids_by_course ($course)) {
|
||||
$info[1][1] = count($ids);
|
||||
} else {
|
||||
$info[1][1] = 0;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
|
||||
|
||||
//Returns an array of surveys id
|
||||
function survey_ids ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}survey a
|
||||
WHERE a.course = '$course'");
|
||||
}
|
||||
|
||||
//Returns an array of survey answer id
|
||||
function survey_answer_ids_by_course ($course) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.survey
|
||||
FROM {$CFG->prefix}survey_answers s,
|
||||
{$CFG->prefix}forum a
|
||||
WHERE a.course = '$course' AND
|
||||
s.survey = a.id");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?PHP //$Id$
|
||||
//This script is used to configure and execute the restore proccess.
|
||||
|
||||
//Define some globals for all the script
|
||||
|
||||
//MUST CHANGE WITH FINAL BACKUP LOCATION !! WITHOUT TRAILING SLASH !!
|
||||
//ALL RELATIVE FROM THE LOCATION OF THE restore.php SCRIPT !!!
|
||||
|
||||
$moodle_home = "../../..";
|
||||
$mods_home = "mod";
|
||||
|
||||
//END MUST CHANGE
|
||||
|
||||
//Units used
|
||||
require_once ("$moodle_home/config.php");
|
||||
require_once ("$moodle_home/version.php");
|
||||
require_once ("backup_version.php");
|
||||
require_once ("db/backup_$CFG->dbtype.php");
|
||||
require_once ("lib.php");
|
||||
require_once ("restorelib.php");
|
||||
|
||||
//Optional
|
||||
optional_variable($file);
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Check backup_version
|
||||
upgrade_backup_db($backup_version,$backup_release,"restore.php");
|
||||
|
||||
//Get strings
|
||||
$strcourserestore = get_string("courserestore");
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
//If no file has been selected from the FileManager, inform and end
|
||||
if (!$file) {
|
||||
print_header("$site->shortname: $strcourserestore", $site->fullname,
|
||||
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcourserestore");
|
||||
print_heading(get_string("nofilesselected"));
|
||||
print_continue("$moodle_home/$CFG->admin/index.php");
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
//If cancel has been selected, inform and end
|
||||
if ($cancel) {
|
||||
print_header("$site->shortname: $strcourserestore", $site->fullname,
|
||||
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcourserestore");
|
||||
print_heading(get_string("restorecancelled"));
|
||||
print_continue("$moodle_home/$CFG->admin/index.php");
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
//We are here, so me have a file.
|
||||
//Print header
|
||||
print_header("$site->shortname: $strcourserestore", $site->fullname,
|
||||
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> ->
|
||||
$strcourserestore -> ".basename($file));
|
||||
//Print form
|
||||
print_heading("$strcourserestore: ".basename($file));
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
include_once("restore_precheck.html");
|
||||
} else if ($launch == "form") {
|
||||
include_once("restore_form.html");
|
||||
} else if ($launch == "check") {
|
||||
include_once("restore_check.html");
|
||||
} else if ($launch == "execute") {
|
||||
include_once("restore_execute.html");
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
//Print footer
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
<?PHP //$Id$
|
||||
//This page receive all the restore_form data. Then, if existing course
|
||||
//has been selected, shows a list of courses to select one.
|
||||
//It cheks that the parammeter from restore_form are coherent.
|
||||
//It puts all the restore info in the session.
|
||||
//Finally, it calls restore_execute to do the hard work
|
||||
|
||||
//Get objects from session
|
||||
if ($SESSION) {
|
||||
$info = $SESSION->info;
|
||||
$course_header = $SESSION->course_header;
|
||||
$restore = $SESSION->restore;
|
||||
}
|
||||
|
||||
//If restore session info exists, but we are posting parameters
|
||||
//manually, this has prioriry
|
||||
if ($restore and isset($restore_restoreto)) {
|
||||
unset($restore);
|
||||
}
|
||||
|
||||
//Check required objects from session
|
||||
|
||||
//info
|
||||
require_variable($info);
|
||||
|
||||
//course_header
|
||||
require_variable($course_header);
|
||||
|
||||
//If the restore object doesn't exist, we are going
|
||||
//to check every variable individually and create it
|
||||
|
||||
if (!$restore) {
|
||||
//Check that we have all we need
|
||||
//backup_unique_code
|
||||
require_variable($backup_unique_code);
|
||||
//file
|
||||
require_variable($file);
|
||||
//Checks for the required restoremod parameters
|
||||
if ($allmods = get_records("modules")) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$var = "restore_".$modname;
|
||||
require_variable($$var);
|
||||
$var = "restore_user_info_".$modname;
|
||||
require_variable($$var);
|
||||
}
|
||||
}
|
||||
//restoreto
|
||||
require_variable($restore_restoreto);
|
||||
//restore_users
|
||||
require_variable($restore_users);
|
||||
//restore_logs
|
||||
require_variable($restore_logs);
|
||||
//restore_user_files
|
||||
require_variable($restore_user_files);
|
||||
//restore_course_files
|
||||
require_variable($restore_course_files);
|
||||
//restore_course_files
|
||||
require_variable($restore_course_files);
|
||||
|
||||
//Check we've selected a course
|
||||
if (!isset($course_id)) {
|
||||
$course_id = 0;
|
||||
}
|
||||
|
||||
//We are here, having all we need !!
|
||||
//Create the restore object and put it in the session
|
||||
$restore->backup_unique_code = $backup_unique_code;
|
||||
$restore->file = $file;
|
||||
if ($allmods = get_records("modules")) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$var = "restore_".$modname;
|
||||
$restore->mods[$modname]->restore=$$var;
|
||||
$var = "restore_user_info_".$modname;
|
||||
$restore->mods[$modname]->userinfo=$$var;
|
||||
}
|
||||
}
|
||||
$restore->restoreto=$restore_restoreto;
|
||||
$restore->users=$restore_users;
|
||||
$restore->logs=$restore_logs;
|
||||
$restore->user_files=$restore_user_files;
|
||||
$restore->course_files=$restore_course_files;
|
||||
$restore->course_id=$course_id;
|
||||
} else {
|
||||
//We have the object, so check if we have a new course_id
|
||||
//passed as parammeter
|
||||
if ($course_id) {
|
||||
$restore->course_id=$course_id;
|
||||
}
|
||||
}
|
||||
//We have the object with data, put it in the session
|
||||
$SESSION->restore = $restore;
|
||||
|
||||
//From here to the wnd of the script, only use the $restore object
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Depending the selected restoreto:
|
||||
// 0-Existing course: Select the destination course and launch the check again.
|
||||
// 1-New course: Create the restore object (checking everything) and launch the execute.
|
||||
|
||||
//Select course
|
||||
if (($restore->restoreto == 0) and ($restore->course_id == 0)) {
|
||||
if ($courses = get_courses()) {
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
foreach ($courses as $course) {
|
||||
echo "<A HREF=\"restore.php?course_id=$course->id&launch=check&file=$file\">$course->fullname ($course->shortname)</A><BR>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
print_heading(get_string("nocoursesyet"));
|
||||
print_continue("$moodle_home/$CFG->admin/index.php");
|
||||
}
|
||||
//Checks everything and execute restore
|
||||
} else if ((($restore->restoreto == 0) and ($restore->course_id != 0)) or ($restore->restoreto == 1)) {
|
||||
$show_continue_button = true;
|
||||
//Check if we've selected any mod's user info and restore->users
|
||||
//is set to none. Change it to course and inform.
|
||||
if ($restore->users == 2) {
|
||||
$changed = false;
|
||||
$mods = $restore->mods;
|
||||
foreach ($mods as $mod) {
|
||||
if ($mod->userinfo) {
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
if ($changed) {
|
||||
echo get_string ("noteuserschangednonetocourse");
|
||||
echo "<hr noshade size=\"1\">";
|
||||
$restore->users = 1;
|
||||
}
|
||||
}
|
||||
//Save the restore session object
|
||||
$SESSION->restore = $restore;
|
||||
if ($show_continue_button) {
|
||||
//Print the continue button to execute the restore NOW !!!!
|
||||
//All is prepared !!!
|
||||
echo "<CENTER>";
|
||||
echo get_string("presscontinuetolaunchrestore");
|
||||
echo "<br>";
|
||||
$hidden["launch"] = "execute";
|
||||
$hidden["file"] = $file;
|
||||
print_single_button("restore.php", $hidden, get_string("continue"),"post");
|
||||
echo "</CENTER>";
|
||||
} else {
|
||||
//Show error
|
||||
error ("Something was wrong checking restore preferences");
|
||||
}
|
||||
|
||||
//If we are here. Something must be wrong. Debug !!!
|
||||
} else {
|
||||
print_object($restore);
|
||||
print_object($info);
|
||||
print_object($course_header);
|
||||
error ("Something must be wrong");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,195 @@
|
||||
<?PHP //$Id$
|
||||
//This page receives the required info and executes the restore
|
||||
//with the parameters suplied. Whe finished, delete temporary
|
||||
//data from backup_tables and temp directory
|
||||
|
||||
//Get objects from session
|
||||
if ($SESSION) {
|
||||
$info = $SESSION->info;
|
||||
$course_header = $SESSION->course_header;
|
||||
$restore = $SESSION->restore;
|
||||
}
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Start the main table
|
||||
echo "<table cellpadding=5>";
|
||||
echo "<tr><td>";
|
||||
|
||||
//Start the main ul
|
||||
echo "<ul>";
|
||||
|
||||
//Init status
|
||||
$status = true;
|
||||
|
||||
//Localtion of the xml file
|
||||
$xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code."/moodle.xml";
|
||||
|
||||
//If we've selected to restore into new course
|
||||
//create it (course)
|
||||
//Saving conversion id variables into backup_tables
|
||||
if ($restore->restoreto ==1) {
|
||||
echo "<li>Creating new course";
|
||||
$status = restore_create_new_course($restore,&$course_header);
|
||||
//Print course fullname and shortname and category
|
||||
if ($status) {
|
||||
echo "<ul>";
|
||||
echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")";
|
||||
echo "<li>".get_string("category").": ".$course_header->category->name;
|
||||
echo "</ul>";
|
||||
//Put the destination course_id
|
||||
$restore->course_id = $course_header->course_id;
|
||||
}
|
||||
} else {
|
||||
$course = get_record("course","id",$restore->course_id);
|
||||
if ($course) {
|
||||
echo "<li>Using existing course";
|
||||
echo "<ul>";
|
||||
echo "<li>From: ".$course_header->course_fullname." (".$course_header->course_shortname.")";
|
||||
echo "<li>To: ".$course->fullname." (".$course->shortname.")";
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
|
||||
//Now create the course_sections and their associated course_modules
|
||||
if ($status) {
|
||||
if ($restore->restoreto == 1) {
|
||||
echo "<li>Creating sections";
|
||||
$status = restore_create_sections($restore,$xml_file);
|
||||
} else if ($restore->restoreto == 0) {
|
||||
echo "<li>Checking sections";
|
||||
$status = restore_create_sections($restore,$xml_file);
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Now create users as needed
|
||||
if ($status and ($restore->users == 0 or $restore->users == 1)) {
|
||||
echo "<li>Creating users";
|
||||
$status = restore_create_users($restore,$xml_file);
|
||||
//Now print info about the work done
|
||||
if ($status) {
|
||||
$recs = get_records_sql("select old_id, info from {$CFG->prefix}backup_ids
|
||||
where backup_code = '$restore->backup_unique_code' and
|
||||
table_name = 'user'");
|
||||
//We've records
|
||||
if ($recs) {
|
||||
$new_count = 0;
|
||||
$exists_count = 0;
|
||||
$student_count = 0;
|
||||
$teacher_count = 0;
|
||||
$coursecreator_count = 0;
|
||||
$admin_count = 0;
|
||||
$other_count = 0;
|
||||
//Iterate, filling counters
|
||||
foreach ($recs as $rec) {
|
||||
if (strpos($rec->info,"new") !== false) {
|
||||
$new_count++;
|
||||
}
|
||||
if (strpos($rec->info,"exists") !== false) {
|
||||
$exists_count++;
|
||||
}
|
||||
if (strpos($rec->info,"admin")) {
|
||||
$admin_count++;
|
||||
} else if (strpos($rec->info,"coursecreator")) {
|
||||
$coursecreator_count++;
|
||||
} else if (strpos($rec->info,"teacher")) {
|
||||
$teacher_count++;
|
||||
} else if (strpos($rec->info,"student")) {
|
||||
$student_count++;
|
||||
} else if ($rec->info == "new" or $rec->info == "exists") {
|
||||
$other_count++;
|
||||
}
|
||||
}
|
||||
//Now print information gathered
|
||||
echo " (new: ".$new_count.", existing: ".$exists_count.")";
|
||||
echo "<ul>";
|
||||
echo "<li>Students: ".$student_count;
|
||||
echo "<li>Teachers: ".$teacher_count;
|
||||
echo "<li>Course Creators: ".$coursecreator_count;
|
||||
echo "<li>Admins: ".$admin_count;
|
||||
echo "<li>Other: ".$other_count;
|
||||
echo "</ul>";
|
||||
} else {
|
||||
//Something is wrong. There is no users !!
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now create user_files as needed
|
||||
if ($status and ($restore->user_files)) {
|
||||
echo "<li>Copying User Files";
|
||||
$status = restore_user_files($restore);
|
||||
//If all is ok (and we have a counter)
|
||||
if ($status and ($status !== true)) {
|
||||
//Inform about user dirs created from backup
|
||||
echo "<ul>";
|
||||
echo "<li>User Zones: ".$status;
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
|
||||
//Now create course files as needed
|
||||
if ($status and ($restore->course_files)) {
|
||||
echo "<li>Copying Course Files";
|
||||
$status = restore_course_files($restore);
|
||||
//If all is ok (and we have a counter)
|
||||
if ($status and ($status !== true)) {
|
||||
//Inform about user dirs created from backup
|
||||
echo "<ul>";
|
||||
echo "<li>Main Files/Folders: ".$status;
|
||||
echo "</ul>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Now create log entries as needed
|
||||
if ($status and ($restore->logs)) {
|
||||
echo "<li>Creating Log Entries <b>(not implemented)</b>. Execute after everything...";
|
||||
}
|
||||
|
||||
//Now, if all is OK, adjust the instance field in course_modules !!
|
||||
|
||||
//Now if all is OK, update course modinfo field !!
|
||||
|
||||
//End the main ul
|
||||
echo "</ul>";
|
||||
|
||||
|
||||
//End the main table
|
||||
echo "</tr></td>";
|
||||
echo "</table>";
|
||||
|
||||
if (!$status) {
|
||||
error ("An error has ocurred");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,226 @@
|
||||
<?PHP //$Id$
|
||||
//This page prints the restore form to select everything yo want
|
||||
//to restore. Form is dinamically buid, depending of "info" object
|
||||
//that contains the backup contents and depending of every mod
|
||||
//capabilities.
|
||||
|
||||
//Get objects from session
|
||||
$info = $SESSION->info;
|
||||
$course_header = $SESSION->course_header;
|
||||
|
||||
//Check that we have all we need
|
||||
//backup_unique_code
|
||||
require_variable($backup_unique_code);
|
||||
//file
|
||||
require_variable($file);
|
||||
//info
|
||||
require_variable($info);
|
||||
//course_header
|
||||
require_variable($course_header);
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Checks for the required files/functions to restore every mod
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "$mods_home/$modname/restorelib.php";
|
||||
$modrestore = $modname."_restore_mods";
|
||||
if (file_exists($modfile)) {
|
||||
include_once($modfile);
|
||||
if (function_exists($modrestore)) {
|
||||
$var = "exists_".$modname;
|
||||
$$var = true;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
//Check data
|
||||
//Check module info
|
||||
$var = "restore_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
//Check include user info
|
||||
$var = "restore_user_info_".$modname;
|
||||
if (!isset($$var)) {
|
||||
$$var = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
if (!isset($restore_users)) {
|
||||
$restore_users = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_logs)) {
|
||||
$restore_logs = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_user_files)) {
|
||||
$restore_user_files = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_course_files)) {
|
||||
$restore_course_files = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_restoreto)) {
|
||||
$restore_restoreto = 1;
|
||||
}
|
||||
|
||||
if ($count == 0) {
|
||||
notice("No restorable modules are installed!");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?
|
||||
|
||||
//First, course destination
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><b>";
|
||||
echo get_string("restoreto").":</b>";
|
||||
echo "</td><td>";
|
||||
$restore_restoreto_options[0] = get_string("existingcourse");
|
||||
$restore_restoreto_options[1] = get_string("newcourse");
|
||||
choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
|
||||
echo "</td></tr>";
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
//Now, check modules and info and show posibilities
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modrestore = $modname."_restore_mods";
|
||||
//If exists the lib & function
|
||||
$exist = "exists_".$modname;
|
||||
$restore_var = "restore_".$modname;
|
||||
$user_info_var = "restore_user_info_".$modname;
|
||||
if ($$exist) {
|
||||
//Now check that we have that module info in the backup file
|
||||
if ($info->mods[$modname]->backup == "true") {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
|
||||
echo "</td><td>";
|
||||
$restore_options[0] = get_string("no");
|
||||
$restore_options[1] = get_string("yes");
|
||||
choose_from_menu($restore_options, $restore_var, $$restore_var, "");
|
||||
//If backup contains user data, then show menu, else fix it to
|
||||
//without user data
|
||||
if ($info->mods[$modname]->userinfo == "true") {
|
||||
$restore_user_options[0] = get_string("withoutuserdata");
|
||||
$restore_user_options[1] = get_string("withuserdata");
|
||||
choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
|
||||
} else {
|
||||
//Module haven't userdata
|
||||
echo get_string("withoutuserdata");
|
||||
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
|
||||
echo "<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\">";
|
||||
}
|
||||
}
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
|
||||
//Now print the Users tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("users").":";
|
||||
echo "</td><td>";
|
||||
//If all users are in the backup file
|
||||
if ($info->backup_users == "all") {
|
||||
$user_options[0] = get_string("all");
|
||||
}
|
||||
$user_options[1] = get_string("course");
|
||||
$user_options[2] = get_string("none");
|
||||
//$user_options[2] = get_string("needed");-->NOT IMPLEMENTED
|
||||
choose_from_menu($user_options, "restore_users", $restore_users, "");
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Logs tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("logs").":";
|
||||
echo "</td><td>";
|
||||
//If logs are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_logs == "true") {
|
||||
$log_options[0] = get_string("no");
|
||||
$log_options[1] = get_string("yes");
|
||||
choose_from_menu($log_options, "restore_logs", $restore_logs, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the User Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string ("userfiles").":";
|
||||
echo "</td><td>";
|
||||
//If user files are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_user_files == "true") {
|
||||
$user_file_options[0] = get_string("no");
|
||||
$user_file_options[1] = get_string("yes");
|
||||
choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Course Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string ("coursefiles").":";
|
||||
echo "</td><td>";
|
||||
//If course files are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_course_files == "true") {
|
||||
$course_file_options[0] = get_string("no");
|
||||
$course_file_options[1] = get_string("yes");
|
||||
choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\">";
|
||||
echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<BR>
|
||||
<CENTER>
|
||||
<input type="hidden" name=id value="<? p($id) ?>">
|
||||
<input type="hidden" name=launch value="check">
|
||||
<input type="submit" value="<? print_string("continue") ?>">
|
||||
<input type="submit" name=cancel value="<? print_string("cancel") ?>">
|
||||
</CENTER>
|
||||
</FORM>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?PHP // $Id$
|
||||
//This page copies th zip to the temp directory,
|
||||
//unzip it, check that it is a valid backup file
|
||||
//inform about its contents and fill all the necesary
|
||||
//variables to continue with the restore.
|
||||
|
||||
//Checks we have the file variable
|
||||
if (!isset($file)) {
|
||||
error ("File not specified");
|
||||
}
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Prepend dataroot to variable to have the absolute path
|
||||
$file = $CFG->dataroot."/".$file;
|
||||
|
||||
//Start the main table
|
||||
echo "<table cellpadding=5>";
|
||||
echo "<tr><td>";
|
||||
|
||||
//Start the mail ul
|
||||
echo "<ul>";
|
||||
|
||||
//Check the file exists
|
||||
if (!is_file($file)) {
|
||||
error ("File not exists ($file)");
|
||||
}
|
||||
|
||||
//Check the file name ends with .zip
|
||||
if (!substr($file,-4) == ".zip") {
|
||||
error ("File has an incorrect extension");
|
||||
}
|
||||
|
||||
//Now calculate the unique_code for this restore
|
||||
$backup_unique_code = time();
|
||||
|
||||
//Now check and create the backup dir (if it doesn't exist)
|
||||
$status = check_and_create_backup_dir($backup_unique_code);
|
||||
//Empty dir
|
||||
if ($status) {
|
||||
echo "<li>Creating temp dir";
|
||||
$status = clear_backup_dir($backup_unique_code);
|
||||
}
|
||||
|
||||
//Now delete old data and directories under dataroot/temp/backup
|
||||
if ($status) {
|
||||
echo "<li>Cleaning old data";
|
||||
$status = backup_delete_old_data();
|
||||
}
|
||||
|
||||
//Now copy he zip file to dataroot/temp/backup/backup_unique_code
|
||||
if ($status) {
|
||||
$status = backup_copy_file($file,$CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file));
|
||||
}
|
||||
|
||||
//Now unzip the file
|
||||
if ($status) {
|
||||
echo "<li>Retrieving backup file";
|
||||
$status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file),$moodle_home);
|
||||
}
|
||||
|
||||
//Now check for the moodle.xml file
|
||||
if ($status) {
|
||||
$xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml";
|
||||
echo "<li>Checking backup file";
|
||||
$status = restore_check_moodle_file ($xml_file);
|
||||
}
|
||||
|
||||
$info = "";
|
||||
$course_header = "";
|
||||
|
||||
//Now read the info tag (all)
|
||||
if ($status) {
|
||||
echo "<li>Reading info from file";
|
||||
//Reading info from file
|
||||
$info = restore_read_xml_info ($xml_file);
|
||||
//Reading course_header from file
|
||||
$course_header = restore_read_xml_course_header ($xml_file);
|
||||
}
|
||||
|
||||
//End the main ul
|
||||
echo "</ul>";
|
||||
|
||||
//End the main table
|
||||
echo "</tr></td>";
|
||||
echo "</table>";
|
||||
|
||||
//Now we print in other table, the backup and the course it contains info
|
||||
if ($info and $course_header and $status) {
|
||||
//First, the course info
|
||||
$status = restore_print_course_header($course_header);
|
||||
//Now, the backup info
|
||||
if ($status) {
|
||||
$status = restore_print_info($info);
|
||||
}
|
||||
}
|
||||
|
||||
//Save course header and info into php session
|
||||
if ($status) {
|
||||
$SESSION->info = $info;
|
||||
$SESSION->course_header = $course_header;
|
||||
}
|
||||
|
||||
//Finally, a little form to continue
|
||||
//with some hidden fields
|
||||
if ($status) {
|
||||
echo "<br><CENTER>";
|
||||
$hidden["backup_unique_code"] = $backup_unique_code;
|
||||
$hidden["launch"] = "form";
|
||||
$hidden["file"] = $file;
|
||||
print_single_button("restore.php", $hidden, get_string("continue"),"post");
|
||||
echo "</CENTER>";
|
||||
}
|
||||
|
||||
if (!$status) {
|
||||
error ("An error has ocurred");
|
||||
}
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
+88
-33
@@ -12,7 +12,7 @@
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 2001-2002 Martin Dougiamas http://dougiamas.com //
|
||||
// Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
@@ -28,59 +28,114 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
unset($CFG); // Ignore this line
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//=========================================================================
|
||||
// 1. DATABASE SETUP
|
||||
//=========================================================================
|
||||
// First, you need to configure the database where all Moodle data //
|
||||
// will be stored. This database must already have been created //
|
||||
// and a username/password created to access it. If you specify mysql //
|
||||
// then Moodle can set up all your tables for you. If you try to use //
|
||||
// a different database you will need to set up all your tables by hand //
|
||||
// which could be a big job. See doc/install.html //
|
||||
// and a username/password created to access it. //
|
||||
// //
|
||||
// mysql - the prefix is optional, but useful when installing //
|
||||
// into databases that already contain tables. //
|
||||
//
|
||||
// postgres7 - the prefix is REQUIRED, regardless of whether the //
|
||||
// database already contains tables. //
|
||||
|
||||
$CFG->dbtype = "mysql"; // eg mysql (postgres7, oracle, access etc)
|
||||
$CFG->dbhost = "localhost"; // eg localhost
|
||||
$CFG->dbname = "moodle"; // eg moodle
|
||||
$CFG->dbuser = "username";
|
||||
$CFG->dbpass = "password";
|
||||
$CFG->dbtype = 'mysql'; // mysql or postgres7 (for now)
|
||||
$CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
|
||||
$CFG->dbname = 'moodle'; // database name, eg moodle
|
||||
$CFG->dbuser = 'username'; // your database username
|
||||
$CFG->dbpass = 'password'; // your database password
|
||||
|
||||
$CFG->dbpersist = true; // Use persistent database connection?
|
||||
// (should be 'true' for 99% of sites)
|
||||
|
||||
$CFG->prefix = 'mdl_'; // Prefix to use for all table names
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//=========================================================================
|
||||
// 2. WEB SITE LOCATION
|
||||
//=========================================================================
|
||||
// Now you need to tell Moodle where it is located. Specify the full
|
||||
// web address where moodle has been installed (without trailing slash)
|
||||
// web address to where moodle has been installed. If your web site
|
||||
// is accessible via multiple URLs then choose the most natural one
|
||||
// that your students would use. Do not include a trailing slash.
|
||||
|
||||
$CFG->wwwroot = "http://example.com/moodle";
|
||||
$CFG->wwwroot = 'http://example.com/moodle';
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//=========================================================================
|
||||
// 3. SERVER FILES LOCATION
|
||||
//=========================================================================
|
||||
// Next, specify the full OS directory path to this same location
|
||||
// For Windows this might be something like "C:\apache\htdocs\moodle"
|
||||
// Make sure the upper/lower case is correct. Some examples:
|
||||
//
|
||||
// $CFG->dirroot = 'C:\FoxServ\www\moodle'; // Windows
|
||||
// $CFG->dirroot = '/var/www/html/moodle'; // Redhat Linux
|
||||
|
||||
$CFG->dirroot = "/web/moodle";
|
||||
$CFG->dirroot = '/var/www/html/moodle';
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//=========================================================================
|
||||
// 4. DATA FILES LOCATION
|
||||
//=========================================================================
|
||||
// Now you need a place where Moodle can save uploaded files. This
|
||||
// directory should be writeable by the web server user (usually 'nobody'
|
||||
// or 'apache'), but it should not be accessible directly via the web.
|
||||
// directory should be readable AND WRITEABLE by the web server user
|
||||
// (usually 'nobody' or 'apache'), but it should not be accessible
|
||||
// directly via the web.
|
||||
//
|
||||
// - On hosting systems you might need to make sure that your "group" has
|
||||
// no permissions at all, but that "others" have full permissions.
|
||||
//
|
||||
// - On Windows systems you might specify something like 'C:\moodledata'
|
||||
|
||||
$CFG->dataroot = "/home/moodledata";
|
||||
$CFG->dataroot = '/home/moodledata';
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// A very small percentage of servers have a bug which causes HTTP_REFERER
|
||||
// not to work. The symptoms of this are that you fill out the configure
|
||||
// form during Moodle setup but when hit save you find yourself on the
|
||||
// same form, unable to progress. If this happens to you, come back here
|
||||
// and set the following to true. Otherwise this should always be false.
|
||||
//=========================================================================
|
||||
// 5. DATA FILES PERMISSIONS
|
||||
//=========================================================================
|
||||
// The following parameter sets the permissions of new directories
|
||||
// created by Moodle within the data directory. The format is in
|
||||
// octal format (as used by the Unix utility chmod, for example).
|
||||
// The default is usually OK, but you may want to change it to 0750
|
||||
// if you are concerned about world-access to the files (you will need
|
||||
// to make sure the web server process (eg Apache) can access the files.
|
||||
// NOTE: the prefixed 0 is important, and don't use quotes.
|
||||
|
||||
$CFG->buggy_referer = false;
|
||||
$CFG->directorypermissions = 0777;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// To continue the setup, use your web browser to go to your Moodle page //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//=========================================================================
|
||||
// 6. DIRECTORY LOCATION (most people can just ignore this setting)
|
||||
//=========================================================================
|
||||
// A very few webhosts use /admin as a special URL for you to access a
|
||||
// control panel or something. Unfortunately this conflicts with the
|
||||
// standard location for the Moodle admin pages. You can fix this by
|
||||
// renaming the admin directory in your installation, and putting that
|
||||
// new name here. eg "moodleadmin". This will fix admin links in Moodle.
|
||||
|
||||
$CFG->libdir = "$CFG->dirroot/lib"; // Do not change this
|
||||
require("$CFG->libdir/setup.php"); // Do not change this
|
||||
$CFG->admin = 'admin';
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// ALL DONE! To continue installation, visit your main page with a browser
|
||||
//=========================================================================
|
||||
|
||||
if (! @include_once("$CFG->dirroot/lib/setup.php")) { // Do not edit
|
||||
if ($CFG->dirroot == dirname(__FILE__)) {
|
||||
echo "<p>Could not find this file: $CFG->dirroot/lib/setup.php</p>";
|
||||
echo "<p>Are you sure all your files have been uploaded?</p>";
|
||||
} else {
|
||||
echo "<p>Error detected in config.php</p>";
|
||||
echo "<p>Error in: \$CFG->dirroot = '$CFG->dirroot';</p>";
|
||||
echo "<p>Try this: \$CFG->dirroot = '".dirname(__FILE__)."';</p>";
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
|
||||
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
|
||||
?>
|
||||
|
||||
+32
-14
@@ -1,8 +1,10 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this course!");
|
||||
@@ -25,29 +27,45 @@
|
||||
$stradd = get_string("add");
|
||||
|
||||
print_header("$site->shortname: $strcategories", "$site->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strcategories");
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strcategories");
|
||||
|
||||
print_heading($strcategories);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
$categories = array();
|
||||
|
||||
// Peel out all the data from variable names.
|
||||
foreach ($HTTP_POST_VARS as $key => $val) {
|
||||
if ($key == "new" and $val != "") {
|
||||
$cat->name = $val;
|
||||
if (!insert_record("course_categories", $cat)) {
|
||||
error("Could not insert the new category '$val'");
|
||||
} else {
|
||||
notify(get_string("categoryadded", "", $val));
|
||||
foreach ($form as $key => $val) {
|
||||
if ($key == "new") {
|
||||
if (!empty($val)) {
|
||||
if (get_records("course_categories", "name", $val)) {
|
||||
notify(get_string("categoryduplicate", "", $val));
|
||||
} else {
|
||||
$cat->name = $val;
|
||||
if (!insert_record("course_categories", $cat)) {
|
||||
error("Could not insert the new category '$val'");
|
||||
} else {
|
||||
notify(get_string("categoryadded", "", $val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$cat->id = substr($key,1);
|
||||
$cat->id = substr($key,1);
|
||||
$cat->name = $val;
|
||||
|
||||
if ($existingcats = get_records("course_categories", "name", $val)) {
|
||||
foreach($existingcats as $existingcat) {
|
||||
if ($existingcat->id != $cat->id) {
|
||||
notify(get_string("categoryduplicate", "", $val));
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!update_record("course_categories", $cat)) {
|
||||
error("Could not update the category '$val'");
|
||||
}
|
||||
@@ -57,7 +75,7 @@
|
||||
|
||||
|
||||
/// Get the existing categories
|
||||
if (!$categories = get_all_categories()) {
|
||||
if (!$categories = get_categories()) {
|
||||
// Try and make one
|
||||
$cat->name = get_string("miscellaneous");
|
||||
if ($cat->id = insert_record("course_categories", $cat)) {
|
||||
@@ -86,7 +104,7 @@
|
||||
}
|
||||
|
||||
/// Find any orphan courses that don't yet have a valid category and set to default
|
||||
if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0")) {
|
||||
if ($courses = get_courses()) {
|
||||
foreach ($courses as $course) {
|
||||
if (!isset( $categories[$course->category] )) {
|
||||
set_field("course", "category", $default, "id", $course->id);
|
||||
|
||||
+9
-9
@@ -1,7 +1,7 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only code to delete a course utterly
|
||||
|
||||
require("../config.php");
|
||||
require_once("../config.php");
|
||||
|
||||
optional_variable($id); // course id
|
||||
optional_variable($delete); // delete confirmation
|
||||
@@ -21,18 +21,18 @@
|
||||
|
||||
if (!$id) {
|
||||
print_header("$site->shortname: $strdeletecourse", $site->fullname,
|
||||
"<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strdeletecourse");
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strdeletecourse");
|
||||
|
||||
if ($courses = get_records_sql("SELECT * from course WHERE category > 0 ORDER BY fullname")) {
|
||||
if ($courses = get_courses()) {
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
foreach ($courses as $course) {
|
||||
echo "<A HREF=\"delete.php?id=$course->id\">$course->fullname</A><BR>";
|
||||
echo "<A HREF=\"delete.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
print_heading(get_string("nocoursesyet"));
|
||||
print_continue("$CFG->wwwroot/admin/");
|
||||
print_continue("../$CFG->admin/index.php");
|
||||
}
|
||||
print_footer();
|
||||
exit;
|
||||
@@ -46,10 +46,10 @@
|
||||
$strdeletecheck = get_string("deletecheck", "", $course->shortname);
|
||||
$strdeletecoursecheck = get_string("deletecoursecheck");
|
||||
print_header("$site->shortname: $strdeletecheck", $site->fullname,
|
||||
"<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> ->
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> ->
|
||||
<A HREF=\"delete.php\">$strdeletecourse</A> -> $strdeletecheck");
|
||||
|
||||
notice_yesno("$strdeletecoursecheck<BR><BR>$course->fullname",
|
||||
notice_yesno("$strdeletecoursecheck<BR><BR>$course->fullname ($course->shortname)",
|
||||
"delete.php?id=$course->id&delete=".md5($course->timemodified),
|
||||
"delete.php");
|
||||
exit;
|
||||
@@ -63,7 +63,7 @@
|
||||
$strdeletingcourse = get_string("deletingcourse", "", $course->shortname);
|
||||
|
||||
print_header("$site->shortname: $strdeletingcourse", $site->fullname,
|
||||
"<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> ->
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> ->
|
||||
<A HREF=\"delete.php\">$strdeletecourse</A> -> $strdeletingcourse");
|
||||
|
||||
print_heading($strdeletingcourse);
|
||||
@@ -71,7 +71,7 @@
|
||||
$strdeleted = get_string("deleted");
|
||||
// First delete every instance of every module
|
||||
|
||||
if ($allmods = get_records_sql("SELECT * FROM modules") ) {
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = "../mod/$modname/lib.php";
|
||||
|
||||
+20
-21
@@ -2,30 +2,30 @@
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("fullname") ?>:</td>
|
||||
<td><input type="text" name="fullname" size=50 value="<? p($form->fullname) ?>">
|
||||
<td><input type="text" name="fullname" maxlength="254" size=50 value="<? p($form->fullname) ?>">
|
||||
<? helpbutton("coursefullname", get_string("fullname")) ?>
|
||||
<? formerr($err["fullname"]) ?>
|
||||
<? if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("shortname") ?>:</td>
|
||||
<td><input type="text" name="shortname" size=10 value="<? p($form->shortname) ?>">
|
||||
<td><input type="text" name="shortname" maxlength="15" size="10" value="<? p($form->shortname) ?>">
|
||||
<? helpbutton("courseshortname", get_string("shortname")) ?>
|
||||
<? formerr($err["shortname"]) ?>
|
||||
<? if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("summary") ?>:</td>
|
||||
<td><TEXTAREA NAME=summary COLS=50 ROWS=10 WRAP=virtual><? p($form->summary) ?></TEXTAREA>
|
||||
<? helpbutton("text", get_string("helptext")) ?>
|
||||
<? formerr($err["summary"]) ?>
|
||||
<? if (isset($err["summary"])) formerr($err["summary"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("enrolmentkey") ?>:</td>
|
||||
<td><input type="text" name="password" size=25 value="<? p($form->password) ?>">
|
||||
<? helpbutton("enrolmentkey", get_string("enrolmentkey")) ?>
|
||||
<? formerr($err["password"]) ?>
|
||||
<? if (isset($err["password"])) formerr($err["password"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
@@ -43,7 +43,6 @@
|
||||
<td><?
|
||||
choose_from_menu ($form->categories, "category", "$form->category", "");
|
||||
helpbutton("coursecategory", get_string("category"));
|
||||
formerr($err["category"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -52,7 +51,6 @@
|
||||
<td><?
|
||||
choose_from_menu ($form->courseformats, "format", "$form->format", "");
|
||||
helpbutton("courseformats", get_string("courseformats"));
|
||||
formerr($err["format"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -75,7 +73,6 @@
|
||||
"10" => "10 $newsitems");
|
||||
choose_from_menu ($options, "newsitems", "$form->newsitems", "");
|
||||
helpbutton("coursenewsitems", get_string("newsitemsnumber"));
|
||||
formerr($err["newsitems"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -84,7 +81,6 @@
|
||||
<td><?
|
||||
print_date_selector("startday", "startmonth", "startyear", $form->startdate);
|
||||
helpbutton("coursestartdate", get_string("startdate"));
|
||||
formerr($err["startdate"]);
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
@@ -93,9 +89,8 @@
|
||||
for ($i=1; $i<=52; $i++) {
|
||||
$sectionmenu[$i] = "$i";
|
||||
}
|
||||
choose_from_menu ($sectionmenu, "numsections", "$form->numsections");
|
||||
choose_from_menu ($sectionmenu, "numsections", "$form->numsections", "");
|
||||
helpbutton("coursenumsections", get_string("numberweeks"));
|
||||
formerr($err["numsections"]);
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
@@ -110,31 +105,35 @@
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" size=25 value="<? p($form->teacher) ?>">
|
||||
(<? print_string("wordforteachereg") ?>) <? formerr($err["teacher"]) ?>
|
||||
<td><input type="text" name="teacher" maxlength="100" size=25 value="<? p($form->teacher) ?>">
|
||||
(<? print_string("wordforteachereg") ?>)
|
||||
<? if (isset($err["teacher"])) formerr($err["teacher"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" size=25 value="<? p($form->teachers) ?>">
|
||||
(<? print_string("wordforteacherseg") ?>) <? formerr($err["teachers"]) ?>
|
||||
<td><input type="text" name="teachers" maxlength="100" size=25 value="<? p($form->teachers) ?>">
|
||||
(<? print_string("wordforteacherseg") ?>)
|
||||
<? if (isset($err["teachers"])) formerr($err["teachers"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" size=25 value="<? p($form->student) ?>">
|
||||
(<? print_string("wordforstudenteg") ?>) <? formerr($err["student"]) ?>
|
||||
<td><input type="text" name="student" maxlength="100" size=25 value="<? p($form->student) ?>">
|
||||
(<? print_string("wordforstudenteg") ?>)
|
||||
<? if (isset($err["student"])) formerr($err["student"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><? print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" size=25 value="<? p($form->students) ?>">
|
||||
(<? print_string("wordforstudentseg") ?>) <? formerr($err["students"]) ?>
|
||||
<td><input type="text" name="students" maxlength="100" size=25 value="<? p($form->students) ?>">
|
||||
(<? print_string("wordforstudentseg") ?>)
|
||||
<? if (isset($err["students"])) formerr($err["students"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<? print_string("savechanges") ?>"></td>
|
||||
</TABLE>
|
||||
<INPUT type="hidden" name="id" value="<?=$course->id ?>">
|
||||
<INPUT type="hidden" name="id" value="<?=$form->id ?>">
|
||||
</FORM>
|
||||
|
||||
+63
-22
@@ -1,39 +1,40 @@
|
||||
<?PHP // $Id$
|
||||
// Edit course settings
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
optional_variable($id, 0); // course id
|
||||
|
||||
require_login();
|
||||
|
||||
if ($id) {
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can edit the course!");
|
||||
}
|
||||
} else { // Admin is creating a new course
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page");
|
||||
if (!iscreator()) {
|
||||
error("Only administrators and teachers can use this page");
|
||||
}
|
||||
|
||||
$course = NULL;
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/admin/");
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
|
||||
$form = (object)$HTTP_POST_VARS;
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
$form->startdate = make_timestamp($form->startyear, $form->startmonth, $form->startday);
|
||||
|
||||
@@ -43,7 +44,7 @@
|
||||
|
||||
$form->timemodified = time();
|
||||
|
||||
if ($course) {
|
||||
if (!empty($course)) {
|
||||
if (update_record("course", $form)) {
|
||||
add_to_log($course->id, "course", "update", "edit.php?id=$id", "");
|
||||
redirect("view.php?id=$course->id", get_string("changessaved"));
|
||||
@@ -53,14 +54,33 @@
|
||||
} else {
|
||||
$form->timecreated = time();
|
||||
|
||||
if ($newid = insert_record("course", $form)) { // Set up new course
|
||||
$section->course = $newid; // Create a default section.
|
||||
if ($newcourseid = insert_record("course", $form)) { // Set up new course
|
||||
$section = NULL;
|
||||
$section->course = $newcourseid; // Create a default section.
|
||||
$section->section = 0;
|
||||
$section->timemodified = time();
|
||||
$section->id = insert_record("course_sections", $section);
|
||||
|
||||
add_to_log($newid, "course", "new", "view.php?id=$newid", "");
|
||||
redirect("teacher.php?id=$newid", get_string("changessaved"));
|
||||
add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", "");
|
||||
|
||||
if (isadmin()) { // Redirect admin to add teachers
|
||||
redirect("../$CFG->admin/teacher.php?id=$newcourseid", get_string("changessaved"));
|
||||
|
||||
} else { // Add current teacher and send to course
|
||||
|
||||
$newteacher = NULL;
|
||||
$newteacher->userid = $USER->id;
|
||||
$newteacher->course = $newcourseid;
|
||||
$newteacher->authority = 1; // First teacher is the main teacher
|
||||
|
||||
if (!$newteacher->id = insert_record("user_teachers", $newteacher)) {
|
||||
error("Could not add you to this new course!");
|
||||
}
|
||||
|
||||
$USER->teacher[$newcourseid] = true;
|
||||
|
||||
redirect("view.php?id=$newcourseid", get_string("changessaved"));
|
||||
}
|
||||
|
||||
} else {
|
||||
error("Serious Error! Could not create the new course!");
|
||||
}
|
||||
@@ -76,8 +96,8 @@
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (!$form) {
|
||||
if ($course) {
|
||||
if (empty($form)) {
|
||||
if (!empty($course)) {
|
||||
$form = $course;
|
||||
} else {
|
||||
$form->startdate = time() + 3600 * 24;
|
||||
@@ -89,14 +109,21 @@
|
||||
$form->students = get_string("defaultcoursestudents");
|
||||
$form->summary = get_string("defaultcoursesummary");
|
||||
$form->format = "weeks";
|
||||
$form->password = "";
|
||||
$form->guest = 0;
|
||||
$form->numsections = 10;
|
||||
$form->newsitems = 5;
|
||||
$form->showrecent = 1;
|
||||
$form->category = 1;
|
||||
$form->id = "";
|
||||
}
|
||||
}
|
||||
|
||||
$form->categories = get_records_sql_menu("SELECT id,name FROM course_categories");
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$form->categories = get_records_select_menu("course_categories", "", "name", "id,name");
|
||||
|
||||
$form->courseformats = array (
|
||||
"weeks" => get_string("formatweeks"),
|
||||
@@ -108,13 +135,13 @@
|
||||
$straddnewcourse = get_string("addnewcourse");
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
if (isset($course)) {
|
||||
if (!empty($course)) {
|
||||
print_header($streditcoursesettings, "$course->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
|
||||
-> $streditcoursesettings", $focus);
|
||||
} else {
|
||||
print_header("$site->shortname: $straddnewcourse", "$site->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/admin/\">$stradministration</A>
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A>
|
||||
-> $straddnewcourse", $focus);
|
||||
}
|
||||
|
||||
@@ -137,6 +164,20 @@ function validate_form($course, &$form, &$err) {
|
||||
if (empty($form->shortname))
|
||||
$err["shortname"] = get_string("missingshortname");
|
||||
|
||||
if ($foundcourses = get_records("course", "shortname", $form->shortname)) {
|
||||
if (!empty($course->id)) {
|
||||
unset($foundcourses[$course->id]);
|
||||
}
|
||||
if (!empty($foundcourses)) {
|
||||
foreach ($foundcourses as $foundcourse) {
|
||||
$foundcoursenames[] = $foundcourse->fullname;
|
||||
}
|
||||
$foundcoursenamestring = addslashes(implode(',', $foundcoursenames));
|
||||
|
||||
$err["shortname"] = get_string("shortnametaken", "", $foundcoursenamestring);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($form->summary))
|
||||
$err["summary"] = get_string("missingsummary");
|
||||
|
||||
|
||||
+26
-2
@@ -1,7 +1,26 @@
|
||||
<BLOCKQUOTE>
|
||||
<FORM name="form" method="post" action="editsection.php">
|
||||
<FORM name="theform" method="post" <?=$onsubmit ?> action="editsection.php">
|
||||
<TABLE BORDER=0 cellpadding=0 cellspacing=0>
|
||||
<TR>
|
||||
<TD align=top>
|
||||
<P><B><? print_string("summaryof", "", "$sectionname $form->section") ?></B></P>
|
||||
<TEXTAREA NAME=summary COLS=60 ROWS=4 WRAP=virtual><?=$form->summary ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD align=top width=100>
|
||||
|
||||
</TD>
|
||||
<TD align=top>
|
||||
<FONT SIZE=-1>
|
||||
<? helpbutton("summaries", get_string("helpsummaries"), "moodle", true, true);
|
||||
if ($usehtmleditor) {
|
||||
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
|
||||
} else {
|
||||
helpbutton("text", get_string("helptext"), "moodle", true, true);
|
||||
}
|
||||
?>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR></TABLE>
|
||||
<? print_textarea($usehtmleditor, 4, 60, 595, 200, "summary", $form->summary); ?>
|
||||
<P>
|
||||
<INPUT type="hidden" name=id value="<?=$form->id ?>">
|
||||
<INPUT type="submit" value="<? print_string("savechanges") ?>">
|
||||
@@ -9,3 +28,8 @@
|
||||
</P>
|
||||
</FORM>
|
||||
</BLOCKQUOTE>
|
||||
<?
|
||||
if ($usehtmleditor) {
|
||||
print_richedit_javascript("theform", "summary", "no");
|
||||
}
|
||||
?>
|
||||
|
||||
+16
-8
@@ -1,11 +1,13 @@
|
||||
<?PHP // $Id$
|
||||
// Edit the introduction of a section
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); // Week ID
|
||||
|
||||
require_login();
|
||||
|
||||
if (! $section = get_record("course_sections", "id", $id)) {
|
||||
error("Course section is incorrect");
|
||||
}
|
||||
@@ -14,8 +16,6 @@
|
||||
error("Could not find the course!");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can edit this!");
|
||||
}
|
||||
@@ -23,11 +23,11 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
$timenow = time();
|
||||
|
||||
if (! set_field("course_sections", "summary", $summary, "id", $section->id)) {
|
||||
if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
|
||||
error("Could not update the summary!");
|
||||
}
|
||||
|
||||
@@ -39,14 +39,22 @@
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (! $form ) {
|
||||
if (empty($form)) {
|
||||
$form = $section;
|
||||
}
|
||||
|
||||
if ($usehtmleditor = can_use_richtext_editor()) {
|
||||
$onsubmit = "onsubmit=\"copyrichtext(theform.summary);\"";
|
||||
} else {
|
||||
$onsubmit = "";
|
||||
}
|
||||
|
||||
$sectionname = get_string("name$course->format");
|
||||
$stredit = get_string("edit", "", " $sectionname $section->section");
|
||||
|
||||
print_header($stredit, $stredit, "", "form.summary");
|
||||
print_header("$course->shortname: $stredit", "$course->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
|
||||
-> $stredit", "form.summary");
|
||||
|
||||
include("editsection.html");
|
||||
|
||||
|
||||
+8
-10
@@ -1,24 +1,26 @@
|
||||
<?PHP // $Id$
|
||||
// Asks for a course pass key, once only, and enrols that user
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id);
|
||||
|
||||
require_login();
|
||||
require_variable($id);
|
||||
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) { // form submitted
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if ($password == $course->password) {
|
||||
if ($form->password == $course->password) {
|
||||
|
||||
if (isguest()) {
|
||||
add_to_log($course->id, "course", "guest", "view.php?id=$course->id", "$REMOTE_ADDR, $REMOTE_HOST");
|
||||
|
||||
} else {
|
||||
} else if (!record_exists("user_students", "userid", $USER->id, "course", $course->id)) {
|
||||
|
||||
if (! enrol_student($USER->id, $course->id)) {
|
||||
error("An error occurred while trying to enrol you.");
|
||||
}
|
||||
@@ -38,12 +40,10 @@
|
||||
}
|
||||
|
||||
$USER->student["$id"] = true;
|
||||
save_session("USER");
|
||||
|
||||
if ($SESSION->wantsurl) {
|
||||
$destination = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
save_session("SESSION");
|
||||
} else {
|
||||
$destination = "$CFG->wwwroot/course/view.php?id=$id";
|
||||
}
|
||||
@@ -72,12 +72,10 @@
|
||||
}
|
||||
|
||||
$USER->student["$id"] = true;
|
||||
save_session("USER");
|
||||
|
||||
if ($SESSION->wantsurl) {
|
||||
$destination = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
save_session("SESSION");
|
||||
} else {
|
||||
$destination = "$CFG->wwwroot/course/view.php?id=$id";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?PHP // $Id$
|
||||
// Displays all grades for a student in a course
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); // course id
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
$strgrades = get_string("grades");
|
||||
$strgrade = get_string("grade");
|
||||
$strmax = get_string("maximumshort");
|
||||
$stractivityreport = get_string("activityreport");
|
||||
|
||||
|
||||
/// Get a list of all students
|
||||
|
||||
$columnhtml = array(); // Accumulate column html in this array.
|
||||
$grades = array(); // Collect all grades in this array
|
||||
$maxgrades = array(); // Collect all max grades in this array
|
||||
$totalgrade = 0;
|
||||
$totalmaxgrade = 0;
|
||||
|
||||
|
||||
/// Collect modules data
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
|
||||
|
||||
/// Search through all the modules, pulling out grade data
|
||||
$sections = get_all_sections($course->id); // Sort everything the same as the course
|
||||
for ($i=0; $i<=$course->numsections; $i++) {
|
||||
if (isset($sections[$i])) { // should always be true
|
||||
$section = $sections[$i];
|
||||
if (!empty($section->sequence)) {
|
||||
$sectionmods = explode(",", $section->sequence);
|
||||
foreach ($sectionmods as $sectionmod) {
|
||||
$mod = $mods[$sectionmod];
|
||||
if ($mod->visible) {
|
||||
$instance = get_record("$mod->modname", "id", "$mod->instance");
|
||||
$libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
|
||||
if (file_exists($libfile)) {
|
||||
require_once($libfile);
|
||||
$gradefunction = $mod->modname."_grades";
|
||||
if (function_exists($gradefunction)) { // Skip modules without grade function
|
||||
if ($modgrades = $gradefunction($mod->instance)) {
|
||||
|
||||
$image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
|
||||
" TITLE=\"$mod->modfullname\">".
|
||||
"<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
|
||||
"HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
|
||||
$columnhtml[] = "$image ".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
||||
"$instance->name".
|
||||
"</A>";
|
||||
|
||||
if (empty($modgrades->grades[$USER->id])) {
|
||||
$grades[] = "";
|
||||
} else {
|
||||
$grades[] = $modgrades->grades[$USER->id];
|
||||
$totalgrade += (float)$modgrades->grades[$USER->id];
|
||||
}
|
||||
|
||||
if (empty($modgrades->maxgrade)) {
|
||||
$maxgrades[] = "";
|
||||
} else {
|
||||
$maxgrades[] = $modgrades->maxgrade;
|
||||
$totalmaxgrade += $modgrades->maxgrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// OK, we have all the data, now present it to the user
|
||||
|
||||
print_header("$course->shortname: $strgrades", "$course->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
|
||||
-> $strgrades");
|
||||
|
||||
print_heading($strgrades);
|
||||
|
||||
$table->head = array( get_string("activity"), get_string("maximumgrade"), get_string("grade"));
|
||||
$table->align = array("LEFT", "RIGHT", "RIGHT");
|
||||
|
||||
foreach ($grades as $key => $grade) {
|
||||
$table->data[] = array($columnhtml[$key], $maxgrades[$key], $grade);
|
||||
}
|
||||
|
||||
$table->data[] = array(get_string("total"), $totalmaxgrade, $totalgrade);
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_continue("view.php?id=$course->id");
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
+53
-25
@@ -1,21 +1,19 @@
|
||||
<?PHP // $Id$
|
||||
// Displays all grades for a course
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require("$CFG->libdir/psxlsgen.php");
|
||||
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
require_once("../lib/psxlsgen.php");
|
||||
|
||||
require_variable($id); // course id
|
||||
optional_variable($download, ""); // to download data
|
||||
|
||||
require_login();
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can use this page!");
|
||||
}
|
||||
@@ -28,7 +26,10 @@
|
||||
|
||||
/// Get a list of all students
|
||||
|
||||
if (!$students = get_course_students($course->id)) {
|
||||
if (!$students = get_course_students($course->id, "u.lastname ASC")) {
|
||||
print_header("$course->shortname: $strgrades", "$course->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
|
||||
-> $strgrades");
|
||||
print_heading(get_string("nostudentsyet"));
|
||||
print_footer($course);
|
||||
exit;
|
||||
@@ -36,6 +37,7 @@
|
||||
|
||||
foreach ($students as $student) {
|
||||
$grades[$student->id] = array(); // Collect all grades in this array
|
||||
$gradeshtml[$student->id] = array(); // Collect all grades html formatted in this array
|
||||
$totals[$student->id] = array(); // Collect all totals in this array
|
||||
}
|
||||
$columns = array(); // Accumulate column names in this array.
|
||||
@@ -43,7 +45,7 @@
|
||||
|
||||
|
||||
/// Collect modules data
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
|
||||
|
||||
/// Search through all the modules, pulling out grade data
|
||||
@@ -63,26 +65,52 @@
|
||||
if (function_exists($gradefunction)) { // Skip modules without grade function
|
||||
if ($modgrades = $gradefunction($mod->instance)) {
|
||||
|
||||
if ($modgrades->maxgrade) {
|
||||
$maxgrade = "<BR>$strmax: $modgrades->maxgrade";
|
||||
if (!empty($modgrades->maxgrade)) {
|
||||
if ($mod->visible) {
|
||||
$maxgrade = "$strmax: $modgrades->maxgrade";
|
||||
$maxgradehtml = "<BR>$strmax: $modgrades->maxgrade";
|
||||
} else {
|
||||
$maxgrade = "$strmax: $modgrades->maxgrade";
|
||||
$maxgradehtml = "<BR><FONT class=\"dimmed_text\">$strmax: $modgrades->maxgrade</FONT>";
|
||||
}
|
||||
} else {
|
||||
$maxgrade = "";
|
||||
$maxgradehtml = "";
|
||||
}
|
||||
|
||||
$image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
|
||||
" TITLE=\"$mod->modfullname\">".
|
||||
"<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
|
||||
"HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
|
||||
$columnhtml[] = "$image ".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
||||
"$instance->name".
|
||||
"</A>$maxgrade";
|
||||
$columns[] = "$mod->modfullname: $instance->name - $modgrades->maxgrade";
|
||||
if ($mod->visible) {
|
||||
$columnhtml[] = "$image ".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
||||
"$instance->name".
|
||||
"</A>$maxgradehtml";
|
||||
} else {
|
||||
$columnhtml[] = "$image ".
|
||||
"<A CLASS=\"dimmed\" HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
||||
"$instance->name".
|
||||
"</A>$maxgradehtml";
|
||||
}
|
||||
$columns[] = "$mod->modfullname: $instance->name - $maxgrade";
|
||||
|
||||
foreach ($students as $student) {
|
||||
$grades[$student->id][] = $modgrades->grades[$student->id]; // may be empty, that's ok
|
||||
if ($modgrades->maxgrade) {
|
||||
$totals[$student->id] = (float)($totals[$student->id]) + (float)($modgrades->grades[$student->id]);
|
||||
if (!empty($modgrades->grades[$student->id])) {
|
||||
$grades[$student->id][] = $currentstudentgrade = $modgrades->grades[$student->id];
|
||||
if ($mod->visible) {
|
||||
$gradeshtml[$student->id][] = $modgrades->grades[$student->id];
|
||||
} else {
|
||||
$gradeshtml[$student->id][] = "<FONT class=\"dimmed_text\">".
|
||||
$modgrades->grades[$student->id].
|
||||
"</FONT>";
|
||||
}
|
||||
} else {
|
||||
$grades[$student->id][] = $currentstudentgrade = "";
|
||||
$gradeshtml[$student->id][] = "";
|
||||
}
|
||||
if (!empty($modgrades->maxgrade)) {
|
||||
$totals[$student->id] = (float)($totals[$student->id]) + (float)($currentstudentgrade);
|
||||
} else {
|
||||
$totals[$student->id] = (float)($totals[$student->id]) + 0;
|
||||
}
|
||||
@@ -131,7 +159,7 @@
|
||||
$myxls->InsertNumber($totals[$student->id]);
|
||||
}
|
||||
|
||||
$myxls->SendFile("$course->shortname $strgrades");
|
||||
$myxls->SendFileName("$course->shortname $strgrades");
|
||||
|
||||
exit;
|
||||
|
||||
@@ -174,9 +202,9 @@
|
||||
|
||||
print_heading($strgrades);
|
||||
|
||||
$table->head = array_merge(array ("", get_string("name")), $columnhtml, get_string("total"));
|
||||
$table->head = array_merge(array ("", get_string("firstname"), get_string("lastname")), $columnhtml, get_string("total"));
|
||||
$table->width = array(35, "");
|
||||
$table->align = array("LEFT", "LEFT");
|
||||
$table->align = array("LEFT", "RIGHT", "LEFT");
|
||||
foreach ($columns as $column) {
|
||||
$table->width[] = "";
|
||||
$table->align[] = "CENTER";
|
||||
@@ -184,10 +212,10 @@
|
||||
$table->width[] = "";
|
||||
$table->align[] = "CENTER";
|
||||
|
||||
foreach ($grades as $studentid => $studentgrades) {
|
||||
$student = $students[$studentid];
|
||||
foreach ($students as $key => $student) {
|
||||
$studentgrades = $gradeshtml[$student->id];
|
||||
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
||||
$name = array ("$picture", "<A TITLE=\"$stractivityreport\" HREF=\"user.php?id=$course->id&user=$student->id\">$student->firstname $student->lastname</A>");
|
||||
$name = array ("$picture", "$student->firstname", "$student->lastname");
|
||||
$total = array ($totals[$student->id]);
|
||||
|
||||
$table->data[] = array_merge($name, $studentgrades, $total);
|
||||
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
<?PHP // $Id$
|
||||
// Display list of all courses
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
optional_variable($category, "");
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
$strmycourses = get_string("mycourses");
|
||||
$strfulllistofcourses = get_string("fulllistofcourses");
|
||||
|
||||
if (!$categories = get_all_categories()) {
|
||||
if (!$categories = get_categories()) {
|
||||
error("Could not find any course categories!");
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
$showcategories = (count($categories) > 1);
|
||||
if ($showcategories) {
|
||||
echo "<TABLE WIDTH=\"100%\" CELLPADDING=10 BORDER=0>";
|
||||
echo "<TR><TD WIDTH=180 VALIGN=TOP>";
|
||||
print_course_categories($categories, $category, 180);
|
||||
echo "</TD><TD WIDTH=\"100%\" VALIGN=TOP>";
|
||||
echo "<TABLE WIDTH=\"100%\" CELLPADDING=\"8\" BORDER=\"0\">";
|
||||
echo "<TR><TD WIDTH=\"200\" VALIGN=\"TOP\">";
|
||||
print_course_categories($categories, $category, 200);
|
||||
echo "</TD><TD WIDTH=\"*\" VALIGN=\"TOP\">";
|
||||
} else {
|
||||
echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD VALIGN=top>";
|
||||
$category="all";
|
||||
|
||||
+438
-242
File diff suppressed because it is too large
Load Diff
+23
-11
@@ -1,14 +1,14 @@
|
||||
<?PHP // $Id$
|
||||
// Displays different views of the logs.
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); // Course ID
|
||||
optional_variable($user); // User to display
|
||||
optional_variable($date); // Date to display
|
||||
optional_variable($user, 0); // User to display
|
||||
optional_variable($date, 0); // Date to display
|
||||
|
||||
require_login($id);
|
||||
require_login();
|
||||
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
@@ -26,6 +26,7 @@
|
||||
}
|
||||
|
||||
$strlogs = get_string("logs");
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
|
||||
if ($user || $date) {
|
||||
@@ -39,12 +40,18 @@
|
||||
$userinfo = "$u->firstname $u->lastname";
|
||||
}
|
||||
if ($date) {
|
||||
$dateinfo = userdate($date, "%A, %d %B %Y");
|
||||
$dateinfo = userdate($date, get_string("strftimedaydate"));
|
||||
}
|
||||
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"view.php?id=$course->id\">$course->shortname</A> ->
|
||||
<A HREF=\"log.php?id=$course->id\">$strlogs</A> -> $userinfo, $dateinfo", "");
|
||||
if ($course->category) {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"view.php?id=$course->id\">$course->shortname</A> ->
|
||||
<A HREF=\"log.php?id=$course->id\">$strlogs</A> -> $userinfo, $dateinfo", "");
|
||||
} else {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> ->
|
||||
<A HREF=\"log.php?id=$course->id\">$strlogs</A> -> $userinfo, $dateinfo", "");
|
||||
}
|
||||
|
||||
print_heading("$course->fullname: $userinfo, $dateinfo (".usertimezone().")");
|
||||
|
||||
@@ -53,8 +60,13 @@
|
||||
print_log($course, $user, $date, "ORDER BY l.time DESC");
|
||||
|
||||
} else {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"view.php?id=$course->id\">$course->shortname</A> -> $strlogs", "");
|
||||
if ($course->category) {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"view.php?id=$course->id\">$course->shortname</A> -> $strlogs", "");
|
||||
} else {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strlogs", "");
|
||||
}
|
||||
|
||||
print_heading(get_string("chooselogs").":");
|
||||
|
||||
|
||||
+8
-18
@@ -1,9 +1,9 @@
|
||||
<?PHP // $Id$
|
||||
// Produces a graph of log accesses
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require("$CFG->libdir/graphlib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->libdir/graphlib.php");
|
||||
|
||||
require_variable($id); // Course ID
|
||||
require_variable($type); // Graph Type
|
||||
@@ -34,9 +34,9 @@
|
||||
switch ($type) {
|
||||
case "usercourse.png":
|
||||
|
||||
$COURSE_MAX_LOG_DISPLAY = $COURSE_MAX_LOG_DISPLAY * 3600 * 24; // seconds
|
||||
if ($timenow - $course->startdate > $COURSE_MAX_LOG_DISPLAY) {
|
||||
$course->startdate = $timenow - $COURSE_MAX_LOG_DISPLAY;
|
||||
$maxseconds = COURSE_MAX_LOG_DISPLAY * 3600 * 24; // seconds
|
||||
if ($timenow - $course->startdate > $maxseconds) {
|
||||
$course->startdate = $timenow - $maxseconds;
|
||||
}
|
||||
$timestart = $coursestart = usergetmidnight($course->startdate);
|
||||
|
||||
@@ -63,12 +63,7 @@
|
||||
$timestart = $timefinish;
|
||||
}
|
||||
|
||||
if ($rawlogs = get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day,
|
||||
count(*) as num FROM log
|
||||
WHERE user = '$user->id'
|
||||
AND course = '$course->id'
|
||||
AND `time` > '$coursestart'
|
||||
GROUP BY day ")) {
|
||||
if ($rawlogs = get_logs_usercourse($user->id, $course->id, $coursestart)) {
|
||||
foreach ($rawlogs as $rawlog) {
|
||||
$logs[$rawlog->day] = $rawlog->num;
|
||||
}
|
||||
@@ -116,12 +111,7 @@
|
||||
$hours[$i] = userdate($hour, "$hh %p");
|
||||
}
|
||||
|
||||
if ($rawlogs = get_records_sql("SELECT floor((`time` - $daystart)/3600) as hour,
|
||||
count(*) as num FROM log
|
||||
WHERE user = '$user->id'
|
||||
AND course = '$course->id'
|
||||
AND `time` > '$daystart'
|
||||
GROUP BY hour ")) {
|
||||
if ($rawlogs = get_logs_userday($user->id, $course->id, $daystart)) {
|
||||
foreach ($rawlogs as $rawlog) {
|
||||
$logs[$rawlog->hour] = $rawlog->num;
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,8 +1,8 @@
|
||||
<?PHP // $Id$
|
||||
// Allows a teacher/admin to login as another user (in stealth mode)
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); // course id
|
||||
optional_variable($user); // login as this user
|
||||
@@ -18,8 +18,7 @@
|
||||
$USER = get_user_info_from_db("id", $USER->realuser);
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot;
|
||||
save_session("USER");
|
||||
redirect($HTTP_REFERER);
|
||||
redirect($_SERVER["HTTP_REFERER"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -42,7 +41,6 @@
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot;
|
||||
$USER->realuser = $teacher_id;
|
||||
save_session("USER");
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
$student_name = "$USER->firstname $USER->lastname";
|
||||
|
||||
+7
-5
@@ -1,10 +1,12 @@
|
||||
<?PHP // $Id$
|
||||
// Displays live view of recent logs
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_login($id);
|
||||
require_variable($id);
|
||||
|
||||
require_login();
|
||||
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
@@ -15,10 +17,10 @@
|
||||
}
|
||||
|
||||
$strlivelogs = get_string("livelogs");
|
||||
$strupdatesevery = get_string("updatesevery", "moodle", $COURSE_LIVELOG_REFRESH);
|
||||
$strupdatesevery = get_string("updatesevery", "moodle", COURSE_LIVELOG_REFRESH);
|
||||
|
||||
print_header("$strlivelogs ($strupdatesevery)", "$strlivelogs", "", "",
|
||||
"<META HTTP-EQUIV='Refresh' CONTENT='$COURSE_LIVELOG_REFRESH; URL=loglive.php?id=$id'>");
|
||||
"<META HTTP-EQUIV='Refresh' CONTENT='".COURSE_LIVELOG_REFRESH."; URL=loglive.php?id=$id'>");
|
||||
|
||||
$user=0;
|
||||
$date=time() - 3600;
|
||||
|
||||
+90
-31
@@ -5,11 +5,12 @@
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (isset($cancel)) {
|
||||
if ($SESSION->returnpage) {
|
||||
if (!empty($SESSION->returnpage)) {
|
||||
$return = $SESSION->returnpage;
|
||||
unset($SESSION->returnpage);
|
||||
save_session("SESSION");
|
||||
redirect($return);
|
||||
} else {
|
||||
redirect("view.php?id=$mod->course");
|
||||
@@ -17,25 +18,22 @@
|
||||
}
|
||||
|
||||
|
||||
if (isset($course) && isset($HTTP_POST_VARS)) { // add or update form submitted
|
||||
if (isset($_POST["course"])) { // add or update form submitted
|
||||
|
||||
if (isset($SESSION->modform)) { // Variables are stored in the session
|
||||
$mod = $SESSION->modform;
|
||||
unset($SESSION->modform);
|
||||
save_session("SESSION");
|
||||
} else {
|
||||
$mod = (object)$HTTP_POST_VARS;
|
||||
$mod = (object)$_POST;
|
||||
}
|
||||
|
||||
require_login($mod->course);
|
||||
|
||||
if (!isteacher($mod->course)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
|
||||
$modlib = "../mod/$mod->modulename/lib.php";
|
||||
if (file_exists($modlib)) {
|
||||
include($modlib);
|
||||
include_once($modlib);
|
||||
} else {
|
||||
error("This module is missing important code! ($modlib)");
|
||||
}
|
||||
@@ -48,7 +46,9 @@
|
||||
if (! $updateinstancefunction($mod)) {
|
||||
error("Could not update the $mod->modulename");
|
||||
}
|
||||
add_to_log($mod->course, "course", "update mod", "../mod/$mod->modulename/view.php?id=$mod->coursemodule", "$mod->modulename $mod->instance");
|
||||
add_to_log($mod->course, "course", "update mod",
|
||||
"../mod/$mod->modulename/view.php?id=$mod->coursemodule",
|
||||
"$mod->modulename $mod->instance");
|
||||
break;
|
||||
|
||||
case "add":
|
||||
@@ -67,7 +67,9 @@
|
||||
if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
|
||||
error("Could not update the course module with the correct section");
|
||||
}
|
||||
add_to_log($mod->course, "course", "add mod", "../mod/$mod->modulename/view.php?id=$mod->coursemodule", "$mod->modulename $mod->instance");
|
||||
add_to_log($mod->course, "course", "add mod",
|
||||
"../mod/$mod->modulename/view.php?id=$mod->coursemodule",
|
||||
"$mod->modulename $mod->instance");
|
||||
break;
|
||||
case "delete":
|
||||
if (! $deleteinstancefunction($mod->instance)) {
|
||||
@@ -79,22 +81,20 @@
|
||||
if (! delete_mod_from_section($mod->coursemodule, "$mod->section")) {
|
||||
notify("Could not delete the $mod->modulename from that section");
|
||||
}
|
||||
add_to_log($mod->course, "course", "delete mod", "view.php?id=$mod->course", "$mod->modulename $mod->instance");
|
||||
add_to_log($mod->course, "course", "delete mod",
|
||||
"view.php?id=$mod->course",
|
||||
"$mod->modulename $mod->instance");
|
||||
break;
|
||||
default:
|
||||
error("No mode defined");
|
||||
|
||||
}
|
||||
|
||||
$modinfo = serialize(get_array_of_activities($mod->course));
|
||||
if (!set_field("course", "modinfo", $modinfo, "id", $mod->course)) {
|
||||
error("Could not cache module information!");
|
||||
}
|
||||
rebuild_course_cache($mod->course);
|
||||
|
||||
if ($SESSION->returnpage) {
|
||||
if (!empty($SESSION->returnpage)) {
|
||||
$return = $SESSION->returnpage;
|
||||
unset($SESSION->returnpage);
|
||||
save_session("SESSION");
|
||||
redirect($return);
|
||||
} else {
|
||||
redirect("view.php?id=$mod->course");
|
||||
@@ -110,15 +110,75 @@
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("This course module doesn't exist");
|
||||
}
|
||||
|
||||
if (!isteacher($cm->course)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
|
||||
move_module($cm, $move);
|
||||
|
||||
$modinfo = serialize(get_array_of_activities($cm->course));
|
||||
if (!set_field("course", "modinfo", $modinfo, "id", $cm->course)) {
|
||||
error("Could not cache module information!");
|
||||
rebuild_course_cache($cm->course);
|
||||
|
||||
$site = get_site();
|
||||
if ($site->id == $cm->course) {
|
||||
redirect($CFG->wwwroot);
|
||||
} else {
|
||||
redirect("view.php?id=$cm->course");
|
||||
}
|
||||
exit;
|
||||
|
||||
} else if (isset($hide)) {
|
||||
|
||||
if (! $cm = get_record("course_modules", "id", $hide)) {
|
||||
error("This course module doesn't exist");
|
||||
}
|
||||
|
||||
redirect($HTTP_REFERER);
|
||||
if (!isteacher($cm->course)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
|
||||
hide_course_module($cm->id);
|
||||
|
||||
rebuild_course_cache($cm->course);
|
||||
|
||||
$site = get_site();
|
||||
if ($site->id == $cm->course) {
|
||||
redirect($CFG->wwwroot);
|
||||
} else {
|
||||
redirect("view.php?id=$cm->course");
|
||||
}
|
||||
exit;
|
||||
|
||||
} else if (isset($show)) {
|
||||
|
||||
if (! $cm = get_record("course_modules", "id", $show)) {
|
||||
error("This course module doesn't exist");
|
||||
}
|
||||
|
||||
if (!isteacher($cm->course)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
|
||||
if (! $section = get_record("course_sections", "id", $cm->section)) {
|
||||
error("This module doesn't exist");
|
||||
}
|
||||
|
||||
if (! $module = get_record("modules", "id", $cm->module)) {
|
||||
error("This module doesn't exist");
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
|
||||
if ($module->visible and ($section->visible or ($site->id == $cm->course))) {
|
||||
show_course_module($cm->id);
|
||||
rebuild_course_cache($cm->course);
|
||||
}
|
||||
|
||||
if ($site->id == $cm->course) {
|
||||
redirect($CFG->wwwroot);
|
||||
} else {
|
||||
redirect("view.php?id=$cm->course");
|
||||
}
|
||||
exit;
|
||||
|
||||
} else if (isset($delete)) { // value = course module
|
||||
@@ -131,8 +191,6 @@
|
||||
error("This course doesn't exist");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
@@ -163,7 +221,7 @@
|
||||
$form->fullmodulename = $fullmodulename;
|
||||
$form->instancename = $instance->name;
|
||||
|
||||
include("mod_delete.html");
|
||||
include_once("mod_delete.html");
|
||||
|
||||
exit;
|
||||
|
||||
@@ -178,6 +236,10 @@
|
||||
error("This course doesn't exist");
|
||||
}
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
|
||||
if (! $module = get_record("modules", "id", $cm->module)) {
|
||||
error("This module doesn't exist");
|
||||
}
|
||||
@@ -192,7 +254,6 @@
|
||||
|
||||
if (isset($return)) {
|
||||
$SESSION->returnpage = "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id";
|
||||
save_session("SESSION");
|
||||
}
|
||||
|
||||
$form->coursemodule = $cm->id;
|
||||
@@ -218,7 +279,7 @@
|
||||
} else if (isset($add)) {
|
||||
|
||||
if (!$add) {
|
||||
redirect($HTTP_REFERER);
|
||||
redirect($_SERVER["HTTP_REFERER"]);
|
||||
die;
|
||||
}
|
||||
|
||||
@@ -237,7 +298,8 @@
|
||||
$form->course = $course->id;
|
||||
$form->module = $module->id;
|
||||
$form->modulename = $module->name;
|
||||
$form->instance = $cm->instance;
|
||||
$form->instance = "";
|
||||
$form->coursemodule = "";
|
||||
$form->mode = "add";
|
||||
|
||||
$sectionname = get_string("name$course->format");
|
||||
@@ -255,8 +317,6 @@
|
||||
error("No action was specfied");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("You can't modify this course!");
|
||||
}
|
||||
@@ -275,7 +335,6 @@
|
||||
}
|
||||
|
||||
unset($SESSION->modform); // Clear any old ones that may be hanging around.
|
||||
save_session("SESSION");
|
||||
|
||||
$modform = "../mod/$module->name/mod.html";
|
||||
|
||||
@@ -283,7 +342,7 @@
|
||||
|
||||
print_heading($pageheading);
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include($modform);
|
||||
include_once($modform);
|
||||
print_simple_box_end();
|
||||
|
||||
} else {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<input type="hidden" name=coursemodule value="<? p($form->coursemodule) ?>">
|
||||
<input type="hidden" name=modulename value="<? p($form->modulename) ?>">
|
||||
<input type="hidden" name=instance value="<? p($form->instance) ?>">
|
||||
<input type="submit" value=" Yes "> <input type=button value=" No " onclick="javascript:history.go(-1);">
|
||||
<input type="submit" value=" <? print_string("yes")?> ">
|
||||
<input type=button value=" <? print_string("no")?> " onclick="javascript:history.go(-1);">
|
||||
</FORM>
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
+26
-24
@@ -1,27 +1,27 @@
|
||||
<? // $Id$
|
||||
<?php // $Id$
|
||||
// social.php - course format featuring social forum
|
||||
// included from view.php
|
||||
|
||||
include_once("$CFG->dirroot/mod/forum/lib.php");
|
||||
include_once("$CFG->dirroot/mod/resource/lib.php");
|
||||
require_once("$CFG->dirroot/mod/forum/lib.php");
|
||||
require_once("$CFG->dirroot/mod/resource/lib.php");
|
||||
|
||||
$leftwidth = 210;
|
||||
?>
|
||||
|
||||
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
|
||||
<TR>
|
||||
<TD WIDTH="<?=$leftwidth?>" VALIGN="TOP">
|
||||
<?
|
||||
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
|
||||
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".
|
||||
<table width="100%" border="0" cellspacing="5" cellpadding="5">
|
||||
<tr>
|
||||
<td width="<?php echo $leftwidth?>" valign="top">
|
||||
<?php
|
||||
$moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
$modicon[]="<img src=\"$pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
|
||||
$editmyprofile = "<a title=\"$USER->firstname $USER->lastname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".
|
||||
get_string("editmyprofile")."</A>";
|
||||
if ($USER->description) {
|
||||
$moddata[]= $editmyprofile;
|
||||
} else {
|
||||
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
|
||||
$moddata[]= $editmyprofile." <blink>*</blink>";
|
||||
}
|
||||
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$modicon[]="<img src=\"$pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
|
||||
print_side_block(get_string("people"), "", $moddata, $modicon, "", $leftwidth);
|
||||
|
||||
|
||||
@@ -42,34 +42,36 @@
|
||||
|
||||
/// Print a form to search forums
|
||||
$searchform = forum_print_search_form($course, "", true);
|
||||
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
|
||||
$searchform = "<div align=\"center\">$searchform</div>";
|
||||
print_side_block(get_string("search","forum"), $searchform, "", "", "", $leftwidth);
|
||||
|
||||
/// Admin links and controls
|
||||
if (isteacher($course->id)) {
|
||||
print_course_admin_links($course, "100%", $leftwidth);
|
||||
}
|
||||
print_course_admin_links($course);
|
||||
|
||||
echo "</TD>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<TD WIDTH=\"*\" VALIGN=\"TOP\">";
|
||||
echo "<td width=\"*\" valign=\"top\">";
|
||||
if ($social = forum_get_course_forum($course->id, "social")) {
|
||||
if (forum_is_subscribed($USER->id, $social->id)) {
|
||||
$subtext = get_string("unsubscribe", "forum");
|
||||
} else {
|
||||
$subtext = get_string("subscribe", "forum");
|
||||
}
|
||||
$headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR><TD>".get_string("socialheadline")."</TD><TD ALIGN=RIGHT><FONT SIZE=1><A HREF=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</A></TD></TR></TABLE>";
|
||||
$headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr><td>".
|
||||
get_string("socialheadline").
|
||||
"</td><td align=right><font size=1>".
|
||||
"<a href=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</a></td>".
|
||||
"</tr></table>";
|
||||
print_heading_block($headertext);
|
||||
echo "<IMG ALT=\"\" HEIGHT=7 SRC=\"../pix/spacer.gif\"><BR>";
|
||||
echo "<img alt=\"\" height=7 src=\"../pix/spacer.gif\"><br>";
|
||||
|
||||
forum_print_latest_discussions($social->id, 10, "plain", "DESC", false);
|
||||
forum_print_latest_discussions($social->id, 10, "plain", "", false);
|
||||
|
||||
} else {
|
||||
notify("Could not find or create a social forum here");
|
||||
}
|
||||
?>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign teachers to courses
|
||||
|
||||
require("../config.php");
|
||||
require("../user/lib.php");
|
||||
|
||||
optional_variable($id); // course id
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/admin/");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
$strassignteachers = get_string("assignteachers");
|
||||
$stradministration = get_string("administration");
|
||||
$strexistingteachers = get_string("existingteachers");
|
||||
$strnoexistingteachers = get_string("noexistingteachers");
|
||||
$strpotentialteachers = get_string("potentialteachers");
|
||||
$strnopotentialteachers = get_string("nopotentialteachers");
|
||||
$straddteacher = get_string("addteacher");
|
||||
$strremoveteacher = get_string("removeteacher");
|
||||
$strsearch = get_string("search");
|
||||
$strsearchagain = get_string("searchagain");
|
||||
$strtoomanytoshow = get_string("toomanytoshow");
|
||||
|
||||
if (!$id) {
|
||||
print_header("$site->shortname: $strassignteachers", "$site->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strassignteachers");
|
||||
|
||||
if ($courses = get_records_sql("SELECT * from course WHERE category > 0 ORDER BY fullname")) {
|
||||
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
foreach ($courses as $course) {
|
||||
echo "<A HREF=\"teacher.php?id=$course->id\">$course->fullname</A><BR>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
print_heading(get_string("nocoursesyet"));
|
||||
print_continue("$CFG->wwwroot/admin/");
|
||||
}
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect (can't find it)");
|
||||
}
|
||||
|
||||
|
||||
print_header("$site->shortname: $course->shortname: $strassignteachers",
|
||||
"$site->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> ->
|
||||
<A HREF=\"teacher.php\">$strassignteachers</A> ->
|
||||
$course->shortname", "");
|
||||
print_heading("<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A>");
|
||||
|
||||
|
||||
/// Get all existing teachers for this course.
|
||||
$teachers = get_course_teachers($course->id);
|
||||
|
||||
/// Add a teacher if one is specified
|
||||
|
||||
if ($add) {
|
||||
if (! $user = get_record("user", "id", $add)) {
|
||||
error("That teacher (id = $add) doesn't exist", "teacher.php?id=$course->id");
|
||||
}
|
||||
|
||||
if ($teachers) {
|
||||
foreach ($teachers as $tt) {
|
||||
if ($tt->id == $user->id) {
|
||||
error("That user is already a teacher for this course.", "teacher.php?id=$course->id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$teacher->user = $user->id;
|
||||
$teacher->course = $course->id;
|
||||
if ($teachers) {
|
||||
$teacher->authority = 2;
|
||||
} else {
|
||||
$teacher->authority = 1; // First teacher is the main teacher
|
||||
}
|
||||
$teacher->id = insert_record("user_teachers", $teacher);
|
||||
if (! $teacher->id) {
|
||||
error("Could not add that teacher to this course!");
|
||||
}
|
||||
$teachers[] = $user;
|
||||
}
|
||||
|
||||
/// Remove a teacher if one is specified.
|
||||
|
||||
if ($remove) {
|
||||
if (! $user = get_record("user", "id", $remove)) {
|
||||
error("That teacher (id = $remove) doesn't exist", "teacher.php?id=$course->id");
|
||||
}
|
||||
if ($teachers) {
|
||||
foreach ($teachers as $key => $tt) {
|
||||
if ($tt->id == $user->id) {
|
||||
remove_teacher($user->id, $course->id);
|
||||
unset($teachers[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print the lists of existing and potential teachers
|
||||
|
||||
echo "<TABLE CELLPADDING=2 CELLSPACING=10 ALIGN=CENTER>";
|
||||
echo "<TR><TH WIDTH=50%>$strexistingteachers</TH><TH WIDTH=50%>$strpotentialteachers</TH></TR>";
|
||||
echo "<TR><TD WIDTH=50% NOWRAP VALIGN=TOP>";
|
||||
|
||||
/// First, show existing teachers for this course
|
||||
|
||||
if (! $teachers) {
|
||||
echo "<P ALIGN=CENTER>$strnoexistingteachers</A>";
|
||||
|
||||
} else {
|
||||
foreach ($teachers as $teacher) {
|
||||
echo "<P ALIGN=right>$teacher->firstname $teacher->lastname, $teacher->email <A HREF=\"teacher.php?id=$course->id&remove=$teacher->id\" TITLE=\"$strremoveteacher\"><IMG SRC=\"../pix/t/right.gif\" BORDER=0></A></P>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<TD WIDTH=50% NOWRAP VALIGN=TOP>";
|
||||
|
||||
/// Print list of potential teachers
|
||||
|
||||
if ($search) {
|
||||
$users = get_records_sql("SELECT * from user WHERE confirmed = 1 AND deleted = 0
|
||||
AND (firstname LIKE '%$search%' OR
|
||||
lastname LIKE '%$search%' OR
|
||||
email LIKE '%$search%')
|
||||
AND username <> 'guest' AND username <> 'changeme'");
|
||||
} else {
|
||||
$users = get_records_sql("SELECT * from user WHERE confirmed = 1 AND deleted = 0
|
||||
AND username <> 'guest' AND username <> 'changeme'");
|
||||
}
|
||||
|
||||
|
||||
if ($users) {
|
||||
foreach ($users as $user) { // Remove users who are already teachers
|
||||
if ($teachers) {
|
||||
foreach ($teachers as $teacher) {
|
||||
if ($teacher->id == $user->id) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
$potential[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $potential) {
|
||||
echo "<P ALIGN=CENTER>$strnopotentialteachers</A>";
|
||||
if ($search) {
|
||||
echo "<FORM ACTION=teacher.php METHOD=GET>";
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
|
||||
echo "<INPUT TYPE=text NAME=search SIZE=20>";
|
||||
echo "<INPUT TYPE=submit VALUE=\"$strsearchagain\">";
|
||||
echo "</FORM>";
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($search) {
|
||||
echo "<P ALIGN=CENTER>($strsearchresults)</P>";
|
||||
}
|
||||
if (count($potential) <= 20) {
|
||||
foreach ($potential as $user) {
|
||||
echo "<P ALIGN=LEFT><A HREF=\"teacher.php?id=$course->id&add=$user->id\" TITLE=\"$straddteacher\"><IMG SRC=\"../pix/t/left.gif\" BORDER=0></A> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
} else {
|
||||
echo "<P ALIGN=CENTER>There are too many users to show.<BR>";
|
||||
echo "Enter a search word here.";
|
||||
echo "<FORM ACTION=teacher.php METHOD=GET>";
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
|
||||
echo "<INPUT TYPE=text NAME=search SIZE=20>";
|
||||
echo "<INPUT TYPE=submit VALUE=\"$strsearch\">";
|
||||
echo "</FORM>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</TR></TABLE>";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+9
-9
@@ -1,17 +1,17 @@
|
||||
<?PHP // $Id$
|
||||
// Allows a teacher to edit teacher order and roles for a course
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); // course id
|
||||
|
||||
require_login();
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can edit the course!");
|
||||
}
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
$rank = array();
|
||||
|
||||
// Peel out all the data from variable names.
|
||||
foreach ($HTTP_POST_VARS as $key => $val) {
|
||||
foreach ($form as $key => $val) {
|
||||
if ($key <> "id") {
|
||||
$type = substr($key,0,1);
|
||||
$num = substr($key,1);
|
||||
@@ -33,11 +33,11 @@
|
||||
}
|
||||
|
||||
foreach ($rank as $num => $vals) {
|
||||
if (! $teacher = get_record_sql("SELECT * FROM user_teachers WHERE course='$course->id' and user='$num'")) {
|
||||
if (! $teacher = get_record("user_teachers", "course", "$course->id", "userid", "$num")) {
|
||||
error("No such teacher in course $course->shortname with user id $num");
|
||||
}
|
||||
$teacher->role = $vals[r];
|
||||
$teacher->authority = $vals[a];
|
||||
$teacher->role = $vals['r'];
|
||||
$teacher->authority = $vals['a'];
|
||||
if (!update_record("user_teachers", $teacher)) {
|
||||
error("Could not update teacher entry id = $teacher->id");
|
||||
}
|
||||
|
||||
+126
-95
@@ -6,24 +6,16 @@
|
||||
// courses that aren't so rigidly defined by time.
|
||||
// Included from "view.php"
|
||||
|
||||
include_once("$CFG->dirroot/mod/forum/lib.php");
|
||||
require_once("$CFG->dirroot/mod/forum/lib.php");
|
||||
|
||||
if (! $sections = get_all_sections($course->id) ) {
|
||||
$section->course = $course->id; // Create a default section.
|
||||
$section->section = 0;
|
||||
$section->id = insert_record("course_sections", $section);
|
||||
if (! $sections = get_all_sections($course->id) ) {
|
||||
error("Error finding or creating section structures for this course");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($topic)) {
|
||||
if ($topic == "all") {
|
||||
unset($USER->topic);
|
||||
$displaysection = course_set_display($course->id, $topic);
|
||||
} else {
|
||||
if (isset($USER->display[$course->id])) { // for admins, mostly
|
||||
$displaysection = $USER->display[$course->id];
|
||||
} else {
|
||||
$USER->topic = $topic;
|
||||
$displaysection = course_set_display($course->id, 0);
|
||||
}
|
||||
save_session("USER");
|
||||
}
|
||||
|
||||
if (isteacher($course->id) and isset($marker)) {
|
||||
@@ -40,25 +32,33 @@
|
||||
$streditsummary = get_string("editsummary");
|
||||
$stradd = get_string("add");
|
||||
$stractivities = get_string("activities");
|
||||
$strshowalltopics = get_string("showalltopics");
|
||||
if (isediting($course->id)) {
|
||||
$strstudents = moodle_strtolower($course->students);
|
||||
$strtopichide = get_string("topichide", "", $strstudents);
|
||||
$strtopicshow = get_string("topicshow", "", $strstudents);
|
||||
$strmarkthistopic = get_string("markthistopic");
|
||||
$strmarkedthistopic = get_string("markedthistopic");
|
||||
}
|
||||
|
||||
|
||||
/// Layout the whole page as three big columns.
|
||||
echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
|
||||
echo "<table border=0 cellpadding=3 cellspacing=0 width=100%>";
|
||||
|
||||
/// The left column ...
|
||||
|
||||
echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
|
||||
echo "<tr valign=top><td valign=top width=180>";
|
||||
|
||||
/// Links to people
|
||||
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
|
||||
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
|
||||
$moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
$modicon[]="<img src=\"$pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
|
||||
$editmyprofile = "<a title=\"$USER->firstname $USER->lastname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</a>";
|
||||
if ($USER->description) {
|
||||
$moddata[]= $editmyprofile;
|
||||
} else {
|
||||
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
|
||||
$moddata[]= $editmyprofile." <blink>*</blink>";
|
||||
}
|
||||
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$modicon[]="<img src=\"$pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
|
||||
print_side_block(get_string("people"), "", $moddata, $modicon);
|
||||
|
||||
|
||||
@@ -67,24 +67,22 @@
|
||||
$modicon = array();
|
||||
if ($modnamesused) {
|
||||
foreach ($modnamesused as $modname => $modfullname) {
|
||||
$moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
|
||||
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$moddata[] = "<a href=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</a>";
|
||||
$modicon[] = "<img src=\"$modpixpath/$modname/icon.gif\" height=16 width=16 alt=\"\">";
|
||||
}
|
||||
}
|
||||
print_side_block($stractivities, "", $moddata, $modicon);
|
||||
|
||||
/// Print a form to search forums
|
||||
$searchform = forum_print_search_form($course, "", true);
|
||||
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
|
||||
$searchform = "<div align=\"center\">$searchform</div>";
|
||||
print_side_block(get_string("search","forum"), $searchform);
|
||||
|
||||
/// Admin links and controls
|
||||
if (isteacher($course->id)) {
|
||||
print_course_admin_links($course);
|
||||
}
|
||||
print_course_admin_links($course);
|
||||
|
||||
/// Start main column
|
||||
echo "</TD><TD WIDTH=\"*\">";
|
||||
echo "</td><td width=\"*\">";
|
||||
|
||||
print_heading_block(get_string("topicoutline"), "100%", "outlineheadingblock");
|
||||
print_spacer(8, 1, true);
|
||||
@@ -93,36 +91,35 @@
|
||||
|
||||
/// Print Section 0
|
||||
|
||||
$topic = 0;
|
||||
$thistopic = $sections[$topic];
|
||||
$section = 0;
|
||||
$thissection = $sections[$section];
|
||||
|
||||
if ($thistopic->summary or $thistopic->sequence or isediting($course->id)) {
|
||||
echo "<TR>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" VALIGN=top WIDTH=20> </TD>";
|
||||
echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
|
||||
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\" valign=top width=20> </td>";
|
||||
echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontent\" width=\"100%\">";
|
||||
|
||||
if (isediting($course->id)) {
|
||||
$thistopic->summary .= " <A TITLE=\"$streditsummary\" ".
|
||||
"HREF=\"editsection.php?id=$thistopic->id\"><IMG SRC=\"../pix/t/edit.gif\" ".
|
||||
"BORDER=0 ALT=\"$streditsummary\"></A></P>";
|
||||
$thissection->summary .= " <a title=\"$streditsummary\" ".
|
||||
"href=\"editsection.php?id=$thissection->id\"><img src=\"$pixpath/t/edit.gif\" ".
|
||||
"height=11 width=11 border=0 alt=\"$streditsummary\"></a></p>";
|
||||
}
|
||||
|
||||
echo text_to_html($thistopic->summary);
|
||||
echo text_to_html($thissection->summary);
|
||||
|
||||
print_section($course, $thistopic, $mods, $modnamesused);
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<DIV ALIGN=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$topic&add=",
|
||||
$modnames, "section$topic", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</DIV>";
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</TD>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" VALIGN=top ALIGN=CENTER WIDTH=10> ";
|
||||
echo "</TD>";
|
||||
echo "</TR>";
|
||||
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
|
||||
echo "</td>";
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\" valign=top align=center width=10>";
|
||||
echo " </td></tr>";
|
||||
echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
|
||||
}
|
||||
|
||||
|
||||
@@ -134,85 +131,119 @@
|
||||
|
||||
while ($section <= $course->numsections) {
|
||||
|
||||
if (isset($USER->topic)) { // Just display a single topic
|
||||
if ($USER->topic != $section) {
|
||||
$section++;
|
||||
continue;
|
||||
}
|
||||
if (!empty($displaysection) and $displaysection != $section) {
|
||||
$section++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$currenttopic = ($course->marker == $section);
|
||||
if (!empty($sections[$section])) {
|
||||
$thissection = $sections[$section];
|
||||
|
||||
if ($currenttopic) {
|
||||
$highlightcolor = $THEME->cellheading2;
|
||||
} else {
|
||||
$highlightcolor = $THEME->cellheading;
|
||||
}
|
||||
|
||||
echo "<TR>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top WIDTH=20>";
|
||||
echo "<P ALIGN=CENTER><FONT SIZE=3><B>$section</B></FONT></P>";
|
||||
echo "</TD>";
|
||||
|
||||
echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
|
||||
|
||||
if (! $thissection = $sections[$section]) {
|
||||
unset($thissection);
|
||||
$thissection->course = $course->id; // Create a new section structure
|
||||
$thissection->section = $section;
|
||||
$thissection->summary = "";
|
||||
$thissection->visible = 1;
|
||||
if (!$thissection->id = insert_record("course_sections", $thissection)) {
|
||||
notify("Error inserting new topic!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
$thissection->summary .= " <A HREF=editsection.php?id=$thissection->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>";
|
||||
$currenttopic = ($course->marker == $section);
|
||||
|
||||
if (!$thissection->visible) {
|
||||
$colorsides = "bgcolor=\"$THEME->hidden\" class=\"topicsoutlinesidehidden\"";
|
||||
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontenthidden\"";
|
||||
} else if ($currenttopic) {
|
||||
$colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"topicsoutlinesidehighlight\"";
|
||||
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontenthighlight\"";
|
||||
} else {
|
||||
$colorsides = "bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\"";
|
||||
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontent\"";
|
||||
}
|
||||
|
||||
echo text_to_html($thissection->summary);
|
||||
echo "<tr>";
|
||||
echo "<td nowrap $colorsides valign=top width=20>";
|
||||
echo "<p align=center><font size=3><b>$section</b></font></p>";
|
||||
echo "</td>";
|
||||
|
||||
if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students
|
||||
echo "<td valign=top align=center $colormain width=\"100%\">";
|
||||
echo get_string("notavailable");
|
||||
echo "</td>";
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
} else {
|
||||
echo "<td valign=top $colormain width=\"100%\">";
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<DIV ALIGN=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</DIV>";
|
||||
if (isediting($course->id)) {
|
||||
$thissection->summary .= " <a title=\"$streditsummary\" href=editsection.php?id=$thissection->id>".
|
||||
"<img src=\"$pixpath/t/edit.gif\" border=0 height=11 width=11></a>";
|
||||
}
|
||||
|
||||
echo text_to_html($thissection->summary);
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...");
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
}
|
||||
echo "<td nowrap $colorsides valign=top align=center width=10>";
|
||||
echo "<font size=1>";
|
||||
|
||||
echo "</TD>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>";
|
||||
echo "<FONT SIZE=1>";
|
||||
if (isset($USER->topic)) {
|
||||
$strshowalltopics = get_string("showalltopics");
|
||||
echo "<A HREF=\"view.php?id=$course->id&topic=all\" TITLE=\"$strshowalltopics\"><IMG SRC=../pix/i/all.gif BORDER=0></A><BR><BR>";
|
||||
if ($displaysection == $section) { // Show the zoom boxes
|
||||
echo "<a href=\"view.php?id=$course->id&topic=all\" title=\"$strshowalltopics\">".
|
||||
"<img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a><br />";
|
||||
} else {
|
||||
$strshowonlytopic = get_string("showonlytopic", "", $section);
|
||||
echo "<A HREF=\"view.php?id=$course->id&topic=$section\" TITLE=\"$strshowonlytopic\"><IMG SRC=../pix/i/one.gif BORDER=0></A><BR><BR>";
|
||||
echo "<a href=\"view.php?id=$course->id&topic=$section\" title=\"$strshowonlytopic\">".
|
||||
"<img src=\"$pixpath/i/one.gif\" height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
if (isediting($course->id) and $course->marker != $section) {
|
||||
$strmarkthistopic = get_string("markthistopic");
|
||||
echo "<A HREF=\"view.php?id=$course->id&marker=$section\" TITLE=\"$strmarkthistopic\"><IMG SRC=../pix/i/marker.gif BORDER=0></A><BR><BR>";
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if ($course->marker == $section) { // Show the "light globe" on/off
|
||||
echo "<a href=\"view.php?id=$course->id&marker=0\" title=\"$strmarkedthistopic\">".
|
||||
"<img src=\"$pixpath/i/marked.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
} else {
|
||||
echo "<a href=\"view.php?id=$course->id&marker=$section\" title=\"$strmarkthistopic\">".
|
||||
"<img src=\"$pixpath/i/marker.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo "<a href=\"view.php?id=$course->id&hide=$section\" title=\"$strtopichide\">".
|
||||
"<img src=\"$pixpath/i/hide.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
} else {
|
||||
echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strtopicshow\">".
|
||||
"<img src=\"$pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
|
||||
}
|
||||
echo "</TD>";
|
||||
echo "</TR>";
|
||||
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
|
||||
|
||||
$section++;
|
||||
}
|
||||
echo "</TABLE>";
|
||||
echo "</table>";
|
||||
|
||||
|
||||
if ($news or $course->showrecent) {
|
||||
echo "</TD><TD WIDTH=210>";
|
||||
echo "</td><td width=210>";
|
||||
|
||||
/// Print all the news items.
|
||||
|
||||
if ($news) {
|
||||
print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews");
|
||||
echo "<FONT SIZE=\"-2\">";
|
||||
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
|
||||
echo "</FONT>";
|
||||
echo "<font size=\"-2\">";
|
||||
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", false);
|
||||
echo "</font>";
|
||||
print_side_block_end();
|
||||
}
|
||||
|
||||
@@ -226,6 +257,6 @@
|
||||
print_spacer(1, 120, true);
|
||||
}
|
||||
|
||||
echo "</TD></TR></TABLE>\n";
|
||||
echo "</td></tr></table>\n";
|
||||
|
||||
?>
|
||||
|
||||
+2
-3
@@ -5,8 +5,8 @@
|
||||
// but will remove them from the student list and prevent
|
||||
// any course email being sent to them.
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($id); //course
|
||||
optional_variable($user, $USER->id); //user
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
if ($user->id == $USER->id) {
|
||||
unset($USER->student["$id"]);
|
||||
save_session("USER");
|
||||
redirect("$CFG->wwwroot");
|
||||
}
|
||||
|
||||
|
||||
+19
-16
@@ -2,30 +2,29 @@
|
||||
|
||||
// Display user activity reports for a course
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
$modes = array("outline", "complete", "todaylogs", "alllogs");
|
||||
|
||||
require_variable($id); // course id
|
||||
require_variable($user); // user id
|
||||
optional_variable($mode, "outline");
|
||||
|
||||
$modes = array("outline", "complete", "todaylogs", "alllogs");
|
||||
require_login();
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course id is incorrect.");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
if (!isteacher($course->id)) {
|
||||
error("You are not allowed to look at this page");
|
||||
}
|
||||
|
||||
if (! $user = get_record("user", "id", $user)) {
|
||||
error("User ID is incorrect");
|
||||
}
|
||||
|
||||
if (!isteacher($course->id) and $user->id != $USER->id ) {
|
||||
error("You are not allowed to look at this page");
|
||||
}
|
||||
|
||||
|
||||
add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
|
||||
|
||||
$stractivityreport = get_string("activityreport");
|
||||
@@ -49,19 +48,20 @@
|
||||
}
|
||||
print_heading("$user->firstname $user->lastname");
|
||||
|
||||
echo "<TABLE CELLPADDING=10 ALIGN=CENTER><TR>";
|
||||
echo "<TD>Reports: </TD>";
|
||||
echo "<table cellpadding=10 align=center><tr>";
|
||||
echo "<td>reports: </td>";
|
||||
|
||||
foreach ($modes as $listmode) {
|
||||
$strmode = get_string($listmode);
|
||||
if ($mode == $listmode) {
|
||||
echo "<TD><U>$strmode</U></TD>";
|
||||
echo "<td><u>$strmode</u></td>";
|
||||
} else {
|
||||
echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=$listmode>$strmode</A></TD>";
|
||||
echo "<td><a href=user.php?id=$course->id&user=$user->id&mode=$listmode>$strmode</a></td>";
|
||||
}
|
||||
}
|
||||
echo "</TR></TABLE>";
|
||||
echo "</tr></table>";
|
||||
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
|
||||
switch ($mode) {
|
||||
case "todaylogs" :
|
||||
@@ -107,6 +107,9 @@
|
||||
|
||||
$sectionmods = explode(",", $section->sequence);
|
||||
foreach ($sectionmods as $sectionmod) {
|
||||
if (empty($mods[$sectionmod])) {
|
||||
continue;
|
||||
}
|
||||
$mod = $mods[$sectionmod];
|
||||
$instance = get_record("$mod->modname", "id", "$mod->instance");
|
||||
$libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
|
||||
@@ -175,7 +178,7 @@ function print_outline_row($mod, $instance, $result) {
|
||||
echo "<TD> </TD>";
|
||||
if (isset($result->time)) {
|
||||
$timeago = format_time(time() - $result->time);
|
||||
echo "<TD VALIGN=top NOWRAP>".userdate($result->time)." ($timeago ago)</TD>";
|
||||
echo "<TD VALIGN=top NOWRAP>".userdate($result->time)." ($timeago)</TD>";
|
||||
}
|
||||
echo "</TR>";
|
||||
}
|
||||
|
||||
+44
-19
@@ -2,8 +2,8 @@
|
||||
|
||||
// Display the course home page.
|
||||
|
||||
require("../config.php");
|
||||
require("lib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
optional_variable($id);
|
||||
optional_variable($name);
|
||||
@@ -22,39 +22,64 @@
|
||||
}
|
||||
}
|
||||
|
||||
require_login($id);
|
||||
require_login($course->id);
|
||||
|
||||
add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
|
||||
|
||||
if ( isteacher($course->id) ) {
|
||||
if ($edit == "on") {
|
||||
$USER->editing = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->editing = false;
|
||||
if (isteacher($course->id)) {
|
||||
if (isset($edit)) {
|
||||
if ($edit == "on") {
|
||||
$USER->editing = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->editing = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($hide)) {
|
||||
set_section_visible($course->id, $hide, "0");
|
||||
}
|
||||
|
||||
if (isset($show)) {
|
||||
set_section_visible($course->id, $show, "1");
|
||||
}
|
||||
}
|
||||
if ($help == "on") {
|
||||
$USER->help = true;
|
||||
} else if ($help == "off") {
|
||||
$USER->help = false;
|
||||
}
|
||||
save_session("USER");
|
||||
|
||||
$SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
save_session("SESSION");
|
||||
|
||||
if (! $course->category) { // This course is not a real course.
|
||||
redirect("$CFG->wwwroot/");
|
||||
}
|
||||
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = "../pix";
|
||||
$modpixpath = "../mod";
|
||||
} else {
|
||||
$pixpath = "../theme/$CFG->theme/pix";
|
||||
$modpixpath = "../theme/$CFG->theme/pix/mod";
|
||||
}
|
||||
|
||||
$courseword = get_string("course");
|
||||
|
||||
print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
|
||||
update_course_icon($course->id));
|
||||
$loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
|
||||
|
||||
print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
|
||||
update_course_icon($course->id), $loggedinas);
|
||||
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
|
||||
if (! $sections = get_all_sections($course->id)) { // No sections found
|
||||
// Double-check to be extra sure
|
||||
if (! $section = get_record("course_sections", "course", $course->id, "section", 0)) {
|
||||
$section->course = $course->id; // Create a default section.
|
||||
$section->section = 0;
|
||||
$section->visible = 1;
|
||||
$section->id = insert_record("course_sections", $section);
|
||||
}
|
||||
if (! $sections = get_all_sections($course->id) ) { // Try again
|
||||
error("Error finding or creating section structures for this course");
|
||||
}
|
||||
}
|
||||
|
||||
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
|
||||
$sections = get_all_sections($course->id);
|
||||
|
||||
switch ($course->format) {
|
||||
case "weeks":
|
||||
|
||||
+144
-115
@@ -2,52 +2,51 @@
|
||||
// Display the whole course as "weeks" made of of modules
|
||||
// Included from "view.php"
|
||||
|
||||
include_once("$CFG->dirroot/mod/forum/lib.php");
|
||||
require_once("$CFG->dirroot/mod/forum/lib.php");
|
||||
|
||||
if (! $sections = get_all_sections($course->id)) {
|
||||
$section->course = $course->id; // Create a default section.
|
||||
$section->section = 0;
|
||||
$section->id = insert_record("course_sections", $section);
|
||||
if (! $sections = get_all_sections($course->id) ) {
|
||||
error("Error finding or creating section structures for this course");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($week)) {
|
||||
if ($week == "all") {
|
||||
unset($USER->section);
|
||||
$displaysection = course_set_display($course->id, $week);
|
||||
} else {
|
||||
if (isset($USER->display[$course->id])) {
|
||||
$displaysection = $USER->display[$course->id];
|
||||
} else {
|
||||
$USER->section = $week;
|
||||
$displaysection = course_set_display($course->id, 0);
|
||||
}
|
||||
save_session("USER");
|
||||
}
|
||||
|
||||
if ($course->newsitems) {
|
||||
$news = forum_get_course_forum($course->id, "news");
|
||||
}
|
||||
|
||||
$streditsummary = get_string("editsummary");
|
||||
$stradd = get_string("add");
|
||||
$stractivities = get_string("activities");
|
||||
$streditsummary = get_string("editsummary");
|
||||
$stradd = get_string("add");
|
||||
$stractivities = get_string("activities");
|
||||
$strshowallweeks = get_string("showallweeks");
|
||||
if (isediting($course->id)) {
|
||||
$strstudents = moodle_strtolower($course->students);
|
||||
$strweekhide = get_string("weekhide", "", $strstudents);
|
||||
$strweekshow = get_string("weekshow", "", $strstudents);
|
||||
}
|
||||
|
||||
|
||||
/// Layout the whole page as three big columns.
|
||||
echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
|
||||
echo "<table border=0 cellpadding=3 cellspacing=0 width=100%>";
|
||||
|
||||
/// The left column ...
|
||||
|
||||
echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
|
||||
echo "<tr valign=top><td valign=top width=180>";
|
||||
|
||||
/// Links to people
|
||||
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
|
||||
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
|
||||
$moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
$modicon[]="<img src=\"$pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
|
||||
$editmyprofile = "<a title=\"$USER->firstname $USER->lastname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</a>";
|
||||
if ($USER->description) {
|
||||
$moddata[]= $editmyprofile;
|
||||
} else {
|
||||
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
|
||||
$moddata[]= $editmyprofile." <blink>*</blink>";
|
||||
}
|
||||
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$modicon[]="<img src=\"$pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
|
||||
print_side_block(get_string("people"), "", $moddata, $modicon);
|
||||
|
||||
|
||||
@@ -56,162 +55,192 @@
|
||||
$modicon = array();
|
||||
if ($modnamesused) {
|
||||
foreach ($modnamesused as $modname => $modfullname) {
|
||||
$moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
|
||||
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
|
||||
$moddata[] = "<a href=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</a>";
|
||||
$modicon[] = "<img src=\"$modpixpath/$modname/icon.gif\" height=16 width=16 alt=\"\">";
|
||||
}
|
||||
}
|
||||
print_side_block($stractivities, "", $moddata, $modicon);
|
||||
|
||||
/// Print a form to search forums
|
||||
$searchform = forum_print_search_form($course, "", true);
|
||||
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
|
||||
$searchform = "<div align=\"center\">$searchform</div>";
|
||||
print_side_block(get_string("search","forum"), $searchform);
|
||||
|
||||
|
||||
/// Admin links and controls
|
||||
if (isteacher($course->id)) {
|
||||
print_course_admin_links($course);
|
||||
}
|
||||
print_course_admin_links($course);
|
||||
|
||||
|
||||
/// Start main column
|
||||
echo "</TD><TD WIDTH=\"*\">";
|
||||
echo "</td><td width=\"*\">";
|
||||
print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
|
||||
print_spacer(8, 1, true);
|
||||
|
||||
echo "<table class=\"weeklyoutline\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" width=\"100%\">";
|
||||
|
||||
/// Print Week 0 with general activities
|
||||
/// Print Section 0 with general activities
|
||||
|
||||
$week = 0;
|
||||
$thisweek = $sections[$week];
|
||||
$section = 0;
|
||||
$thissection = $sections[$section];
|
||||
|
||||
if ($thisweek->summary or $thisweek->sequence or isediting($course->id)) {
|
||||
echo "<TR>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" VALIGN=top WIDTH=20> </TD>";
|
||||
echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
|
||||
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top width=20> </td>";
|
||||
echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" width=\"100%\">";
|
||||
|
||||
if (isediting($course->id)) {
|
||||
$thisweek->summary .= " <A TITLE=\"$streditsummary\" ".
|
||||
"HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" ".
|
||||
"BORDER=0 ALT=\"$streditsummary\"></A></P>";
|
||||
$thissection->summary .= " <a title=\"$streditsummary\" ".
|
||||
"href=\"editsection.php?id=$thissection->id\"><img height=11 width=11 src=\"$pixpath/t/edit.gif\" ".
|
||||
"border=0 alt=\"$streditsummary\"></a></p>";
|
||||
}
|
||||
|
||||
echo text_to_html($thisweek->summary);
|
||||
echo text_to_html($thissection->summary);
|
||||
|
||||
print_section($course, $thisweek, $mods, $modnamesused);
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<DIV ALIGN=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
|
||||
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</DIV>";
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</TD>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" VALIGN=top ALIGN=CENTER WIDTH=10>";
|
||||
echo "</TD>";
|
||||
echo "</TR>";
|
||||
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
|
||||
echo "</td>";
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top align=center width=10>";
|
||||
echo " </td></tr>";
|
||||
echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
|
||||
}
|
||||
|
||||
|
||||
/// Now all the weekly sections
|
||||
$timenow = time();
|
||||
$weekdate = $course->startdate; // this should be 0:00 Monday of that week
|
||||
$week = 1;
|
||||
$section = 1;
|
||||
$weekofseconds = 604800;
|
||||
$course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
|
||||
|
||||
$strftimedateshort = " ".get_string("strftimedateshort");
|
||||
|
||||
while ($weekdate < $course->enddate) {
|
||||
|
||||
$nextweekdate = $weekdate + ($weekofseconds);
|
||||
$weekday = userdate($weekdate, $strftimedateshort);
|
||||
$endweekday = userdate($weekdate+518400, $strftimedateshort);
|
||||
|
||||
if (isset($USER->section)) { // Just display a single week
|
||||
if ($USER->section != $week) {
|
||||
$week++;
|
||||
$weekdate = $nextweekdate;
|
||||
continue;
|
||||
}
|
||||
if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
|
||||
$section++;
|
||||
$weekdate = $nextweekdate;
|
||||
continue;
|
||||
}
|
||||
|
||||
$thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
|
||||
if (!empty($sections[$section])) {
|
||||
$thissection = $sections[$section];
|
||||
|
||||
$weekday = userdate($weekdate, " %d %B");
|
||||
$endweekday = userdate($weekdate+518400, " %d %B");
|
||||
|
||||
if ($thisweek) {
|
||||
$highlightcolor = $THEME->cellheading2;
|
||||
} else {
|
||||
$highlightcolor = $THEME->cellheading;
|
||||
}
|
||||
|
||||
echo "<TR>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top WIDTH=20>";
|
||||
echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
|
||||
echo "</TD>";
|
||||
|
||||
echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
|
||||
echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
|
||||
|
||||
if (! $thisweek = $sections[$week]) {
|
||||
$thisweek->course = $course->id; // Create a new week structure
|
||||
$thisweek->section = $week;
|
||||
$thisweek->summary = "";
|
||||
if (!$thisweek->id = insert_record("course_sections", $thisweek)) {
|
||||
unset($thissection);
|
||||
$thissection->course = $course->id; // Create a new week structure
|
||||
$thissection->section = $section;
|
||||
$thissection->summary = "";
|
||||
$thissection->visible = 1;
|
||||
if (!$thissection->id = insert_record("course_sections", $thissection)) {
|
||||
notify("Error inserting new week!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
$thisweek->summary .= " <A TITLE=\"$streditsummary\" HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>";
|
||||
}
|
||||
$currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
|
||||
|
||||
echo text_to_html($thisweek->summary);
|
||||
|
||||
print_section($course, $thisweek, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<DIV ALIGN=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
|
||||
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</DIV>";
|
||||
}
|
||||
|
||||
echo "</TD>";
|
||||
echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>";
|
||||
echo "<FONT SIZE=1>";
|
||||
if (isset($USER->section)) {
|
||||
$strshowallweeks = get_string("showallweeks");
|
||||
echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"$strshowallweeks\"><IMG SRC=../pix/i/all.gif BORDER=0></A></FONT>";
|
||||
if (!$thissection->visible) {
|
||||
$colorsides = "bgcolor=\"$THEME->hidden\" class=\"weeklyoutlinesidehidden\"";
|
||||
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthidden\"";
|
||||
} else if ($currentweek) {
|
||||
$colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"weeklyoutlinesidehighlight\"";
|
||||
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthighlight\"";
|
||||
} else {
|
||||
$strshowonlyweek = get_string("showonlyweek", "", $week);
|
||||
echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"$strshowonlyweek\"><IMG SRC=../pix/i/one.gif BORDER=0></A></FONT>";
|
||||
$colorsides = "bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\"";
|
||||
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\"";
|
||||
}
|
||||
echo "</TD>";
|
||||
echo "</TR>";
|
||||
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
|
||||
|
||||
$week++;
|
||||
echo "<tr>";
|
||||
echo "<td nowrap $colorsides valign=top width=20>";
|
||||
echo "<p align=center><font size=3><b>$section</b></font></p>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td valign=top $colormain width=\"100%\">";
|
||||
|
||||
if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students
|
||||
echo "<p class=\"weeklydatetext\">$weekday - $endweekday ";
|
||||
echo "(".get_string("notavailable").")";
|
||||
echo "</p>";
|
||||
echo "</td>";
|
||||
|
||||
} else {
|
||||
|
||||
echo "<p class=\"weeklydatetext\">$weekday - $endweekday</p>";
|
||||
|
||||
if (isediting($course->id)) {
|
||||
$thissection->summary .= " <a title=\"$streditsummary\" href=\"editsection.php?id=$thissection->id\">".
|
||||
"<img src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a></p>";
|
||||
}
|
||||
|
||||
echo text_to_html($thissection->summary);
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...");
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
}
|
||||
echo "<td nowrap $colorsides valign=top align=center width=10>";
|
||||
echo "<font size=1>";
|
||||
|
||||
if ($displaysection == $section) {
|
||||
echo "<a href=\"view.php?id=$course->id&week=all\" title=\"$strshowallweeks\">".
|
||||
"<img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a><br />";
|
||||
} else {
|
||||
$strshowonlyweek = get_string("showonlyweek", "", $section);
|
||||
echo "<a href=\"view.php?id=$course->id&week=$section\" title=\"$strshowonlyweek\">".
|
||||
"<img src=\"$pixpath/i/one.gif\" height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo "<a href=\"view.php?id=$course->id&hide=$section\" title=\"$strweekhide\">".
|
||||
"<img src=\"$pixpath/i/hide.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
} else {
|
||||
echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strweekshow\">".
|
||||
"<img src=\"$pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
|
||||
|
||||
$section++;
|
||||
$weekdate = $nextweekdate;
|
||||
}
|
||||
echo "</TABLE>";
|
||||
echo "</table>";
|
||||
|
||||
if ($news or $course->showrecent) {
|
||||
echo "</TD><TD WIDTH=210>";
|
||||
if (!empty($news) or !empty($course->showrecent)) {
|
||||
echo "</td><td width=210>";
|
||||
|
||||
// Print all the news items.
|
||||
|
||||
if ($news) {
|
||||
if (!empty($news)) {
|
||||
print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews");
|
||||
echo "<FONT SIZE=\"-2\">";
|
||||
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
|
||||
echo "</FONT>";
|
||||
echo "<font size=\"-2\">";
|
||||
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", false);
|
||||
echo "</font>";
|
||||
print_side_block_end();
|
||||
}
|
||||
|
||||
// Print all the recent activity
|
||||
if ($course->showrecent) {
|
||||
if (!empty($course->showrecent)) {
|
||||
print_side_block_start(get_string("recentactivity"), 210, "sideblockrecentactivity");
|
||||
print_recent_activity($course);
|
||||
print_side_block_end();
|
||||
@@ -220,6 +249,6 @@
|
||||
print_spacer(1, 120, true);
|
||||
}
|
||||
|
||||
echo "</TD></TR></TABLE>\n";
|
||||
echo "</td></tr></table>\n";
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Moodle Docs: Background</TITLE>
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.css" TYPE="TEXT/CSS">
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#ffffff">
|
||||
|
||||
<H2>Background</H2>
|
||||
|
||||
<P>Moodle is an active and evolving work in progress.</P>
|
||||
<P>I've been working on it, in some way or other, for several years. It started
|
||||
in the 90's when I was webmaster at <a target=_top href="http://www.curtin.edu.au/">Curtin University
|
||||
of Technology</a> and a system administrator of their WebCT installation. I
|
||||
encountered many frustrations with the WebCT beast and developed an itch that
|
||||
needed scratching - there had to be a better way (no, not Blackboard :-)</P>
|
||||
<P>I also know a lot of people in schools and smaller institutions (and some big
|
||||
ones!) who want to make better use of the Internet but don't know where to start
|
||||
in the maze of technologies and pedagogies that are out there. I've always hoped
|
||||
there would be a Free alternative that such people could use to help them move
|
||||
their teaching skills into the online environment.</P>
|
||||
<P>My strong beliefs in the unrealised possibilities of Internet-based education
|
||||
led me to complete a Masters and then a PhD in Education, combining my former
|
||||
career in Computer Science with newly constructed knowledge about the nature
|
||||
of learning and collaboration.</P>
|
||||
<P>Since then Moodle has progressed through several very different prototypes
|
||||
until the release of version 1.0 upon a largely unsuspecting world on
|
||||
August 20, 2002 and a steady series of improved releases since then.
|
||||
<P>I've been using it in several courses and find it an
|
||||
extremely usable and reliable tool for building high-quality online courses
|
||||
- others are reporting the same. Given the context in which it's been designed,
|
||||
it works particularly well for smaller institutions, or for smaller, more intimate
|
||||
classes.</P>
|
||||
<P>When compared to the big commercial tools such as WebCT or Blackboard I think
|
||||
it still falls short in some areas (such as scalability and standards support),
|
||||
but it comes out ahead in many others (see <a href="features.html">Features</a>).
|
||||
</P>
|
||||
<P> </P>
|
||||
|
||||
<P ALIGN="CENTER"><FONT SIZE="1"><A HREF="." TARGET="_top">Moodle Documentation</A></FONT></P>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1">Version: $Id$</FONT></P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,24 +0,0 @@
|
||||
<HEAD>
|
||||
<!-- $Id$ -->
|
||||
<TITLE>Moodle Docs: Table of Contents</TITLE>
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.css" TYPE="TEXT/CSS">
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
<FONT SIZE=2 FACE="san-serif">
|
||||
<P><B>Moodle Documentation</B></P>
|
||||
<LI><A TARGET="main" HREF="intro.html">Introduction</A>
|
||||
|
||||
<LI><A TARGET="main" HREF="background.html">Background</A>
|
||||
<LI><A TARGET="main" HREF="features.html">Features</A>
|
||||
<LI><A TARGET="main" HREF="release.html">Release Notes</A>
|
||||
<LI><A TARGET="main" HREF="install.html">Installation</A>
|
||||
<LI><A TARGET="main" HREF="upgrade.html">Upgrading</A>
|
||||
<LI><A TARGET="main" HREF="teacher.html">Teacher Manual</A>
|
||||
<LI><A TARGET="main" HREF="developer.html">Developer Manual</A>
|
||||
<LI><A TARGET="main" HREF="future.html">Future</A>
|
||||
<LI><A TARGET="main" HREF="credits.html">Credits</A>
|
||||
<LI><A TARGET="main" HREF="licence.html">License</A>
|
||||
</FONT>
|
||||
</BODY>
|
||||
|
||||
+10
-14
@@ -2,20 +2,16 @@
|
||||
|
||||
require("../config.php");
|
||||
|
||||
$info = document_file("files.php", false);
|
||||
|
||||
include($info->filepath);
|
||||
|
||||
print_header();
|
||||
|
||||
echo "<FONT SIZE=2 FACE=\"san-serif\">";
|
||||
foreach ($string as $file => $filename) {
|
||||
echo "<LI><A TARGET=\"main\" HREF=\"$CFG->wwwroot/doc/?file=$file\">$filename</A></LI>";
|
||||
}
|
||||
echo "</FONT>";
|
||||
|
||||
?>
|
||||
|
||||
<FONT SIZE=2 FACE="san-serif">
|
||||
<LI><A TARGET="main" HREF="intro.html">Introduction</A>
|
||||
<LI><A TARGET="main" HREF="background.html">Background</A>
|
||||
<LI><A TARGET="main" HREF="features.html">Features</A>
|
||||
<LI><A TARGET="main" HREF="release.html">Release Notes</A>
|
||||
<LI><A TARGET="main" HREF="install.html">Installation</A>
|
||||
<LI><A TARGET="main" HREF="upgrade.html">Upgrading</A>
|
||||
<LI><A TARGET="main" HREF="teacher.html">Teacher Manual</A>
|
||||
<LI><A TARGET="main" HREF="developer.html">Developer Manual</A>
|
||||
<LI><A TARGET="main" HREF="future.html">Future</A>
|
||||
<LI><A TARGET="main" HREF="credits.html">Credits</A>
|
||||
<LI><A TARGET="main" HREF="licence.html">License</A>
|
||||
</FONT>
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Moodle Docs: How to use CVS</TITLE>
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.css" TYPE="TEXT/CSS">
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#ffffff">
|
||||
|
||||
<H2>How to use CVS</H2>
|
||||
<BLOCKQUOTE>
|
||||
<P>CVS is the Concurrent Versioning System. It's a commonly used way
|
||||
of storing source code because it keeps versions of all files so
|
||||
that nothing is ever lost, and usage by different people is tracked.</P>
|
||||
|
||||
<P>To use Moodle's CVS archive (as a developer) from a Unix machine, you first
|
||||
need to have an account on <a href="http://www.sf.net/">Sourceforge</a>. For
|
||||
the example, let's assume your username is <strong>myusername</strong> and your
|
||||
password is <strong>mypassword</strong>. Secondly, you need to contact me (<A
|
||||
HREF="http://dougiamas.com/">Martin Dougiamas</A>) to get write access
|
||||
to particular directories.</P>
|
||||
<P>With that done, you should have all the permissions you need, so you just need
|
||||
to set up your machine and download the current sources so you can start working
|
||||
on them.</P>
|
||||
<P>Sourceforge CVS uses ssh as a transport layer for security, so you will have
|
||||
to set this CVS_RSH environment variable in your Unix shell:</P>
|
||||
<blockquote>
|
||||
<pre><strong>setenv CVS_RSH ssh</strong> (for csh, tcsh etc)</pre>
|
||||
|
||||
<pre><strong>export CVS_RSH=ssh</strong> (for sh, bash etc)</pre>
|
||||
|
||||
</blockquote>
|
||||
<p>It's best to put this in your .bashrc or .cshrc so you don't have to type it
|
||||
all the time. Then, check out Moodle using this (all one line): </p>
|
||||
<blockquote>
|
||||
<pre><strong>cvs -z3 -d:ext:myusername@cvs.moodle.sourceforge.net:/cvsroot/moodle co moodle</strong></pre>
|
||||
|
||||
</blockquote>
|
||||
<p>Don't try to do run this first CVS command into an existing moodle directory
|
||||
- start fresh with a new directory.</p>
|
||||
<p>Note that you will be prompted for <strong>mypassword</strong> with each CVS
|
||||
command. To avoid this, follow the <a href="http://sourceforge.net/account/editsshkeys.php">Sourceforge
|
||||
directions about using authorized keys</a>.</p>
|
||||
<p>Now, you should have a new 'moodle' directory. You can rename it and move it
|
||||
around if you like. Go into it: </p>
|
||||
<blockquote>
|
||||
<pre><strong>cd moodle </strong></pre>
|
||||
|
||||
</blockquote>
|
||||
<p>All the latest Moodle files should be in there. You can now change files in
|
||||
your copy. To compare your files against the main CVS copy on the server use
|
||||
cvs diff, eg: </p>
|
||||
<blockquote>
|
||||
<pre><strong>cvs diff -c config-dist.php
|
||||
cvs diff -c lang</strong></pre>
|
||||
|
||||
</blockquote>
|
||||
<p>To fetch the latest updates from the server use: </p>
|
||||
<blockquote>
|
||||
<pre><strong>cvs update -dP</strong> </pre>
|
||||
|
||||
</blockquote>
|
||||
<p>To copy your new files back to the server you would do: </p>
|
||||
<blockquote>
|
||||
<pre><strong>cd lang/ca
|
||||
cvs commit</strong> </pre>
|
||||
|
||||
</blockquote>
|
||||
<p>You will be prompted to add some comments (depends on your default text editor)
|
||||
... add a comment and close the editor ... the files will be sent to Sourceforge
|
||||
and stored. Done! </p>
|
||||
<p>To save more time you can put default arguments into a file called .cvsrc in
|
||||
your home directory. For example, mine contains: </p>
|
||||
<blockquote>
|
||||
<pre><strong>diff -c
|
||||
update -dP</strong> </pre>
|
||||
|
||||
</blockquote>
|
||||
<p>Try 'cvs help' for more details ... </p>
|
||||
<P> </P>
|
||||
|
||||
</BLOCKQUOTE>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1"><A HREF="." TARGET="_top">Moodle Documentation</A></FONT></P>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1">Version: $Id: features.html,v 1.2 2001/12/09
|
||||
10:34:19 martin Exp $</FONT></P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,45 +0,0 @@
|
||||
<HEAD>
|
||||
<TITLE>Moodle Docs: Future</TITLE>
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.css" TYPE="TEXT/CSS">
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
|
||||
<H2>Future</H2>
|
||||
<P>I'm committed to continuing my work on Moodle and on keeping it Open and Free.
|
||||
I have a deeply-held belief in the importance of unrestricted education and
|
||||
empowered teaching, and Moodle is the main way I can contribute to the realisation
|
||||
of these ideals.
|
||||
|
||||
<P>As Moodle gains in maturity, I hope its directions are influenced by the community
|
||||
of developers and users. A dynamic database of proposed features and their status
|
||||
can be found at <A TARGET=_top HREF="http://bugs.moodle.org/">bugs.moodle.org</A>.
|
||||
Your <A href="developer.html">contributions</a> in the form of ideas, code,
|
||||
feedback and promotion are all very welcome.
|
||||
|
||||
<P>Until about April 2003, my own involvement will slow down while I finish my PhD thesis.
|
||||
During this time there will still be releases, but they will only contain minor
|
||||
new features and bug fixes. I will also be including modules and other code contributed
|
||||
by others.
|
||||
|
||||
<P>After this time, by around June/July 2003, I am expecting a major release called Moodle 2.0
|
||||
that will include major new features such as:
|
||||
<UL>
|
||||
<LI>Stronger pedagogical support for both teachers and students
|
||||
<LI>Support for groups and group work
|
||||
<LI>Rewritten display incorporating XML, XSL and CSS for full flexibility
|
||||
and compatibility with all modern web standards.
|
||||
<LI>Basic support for IMS and SCORM
|
||||
<LI>A variety of new modules (chat, tracker etc)
|
||||
<LI>Whatever else seems most important at the time :-)
|
||||
</UL>
|
||||
|
||||
<P>About this time I will also be experimenting with ways of making
|
||||
Moodle development more sustainable for the long term. This may
|
||||
include offering services for payment - although the software itself
|
||||
will always remain Free.
|
||||
|
||||
<P ALIGN="CENTER"> </P>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1"><A HREF="." TARGET="_top">Moodle Documentation</A></FONT></P>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1">Version: $Id$</FONT></P>
|
||||
</BODY>
|
||||
@@ -1,8 +0,0 @@
|
||||
<HEAD>
|
||||
<TITLE>Moodle Documentation</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<FRAMESET COLS="200,*">
|
||||
<FRAME NAME="contents" SRC="contents.html">
|
||||
<FRAME NAME="main" SRC="intro.html">
|
||||
</FRAMESET>
|
||||
+29
-5
@@ -2,12 +2,36 @@
|
||||
|
||||
require("../config.php");
|
||||
|
||||
optional_variable($file, "intro.html"); // file in this directory to view
|
||||
optional_variable($file, ""); // docs file to view
|
||||
optional_variable($frame, ""); // docs file to view
|
||||
optional_variable($sub, ""); // sub-section (named anchor)
|
||||
optional_variable($lang, ""); // override current language
|
||||
|
||||
$file = clean_filename($file);
|
||||
if (!empty($lang)) {
|
||||
$SESSION->lang = $lang;
|
||||
}
|
||||
|
||||
if (!file_exists($file)) {
|
||||
error("404 - File not found");
|
||||
if (!empty($sub)) {
|
||||
$sub = "#$sub";
|
||||
} else {
|
||||
$sub = "";
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
$include = false;
|
||||
if (empty($frame)) {
|
||||
$file = "intro.html";
|
||||
} else {
|
||||
$file = $frame;
|
||||
}
|
||||
} else {
|
||||
$include = true;
|
||||
}
|
||||
|
||||
document_file($file, $include);
|
||||
|
||||
if ($include) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -20,6 +44,6 @@
|
||||
<FRAME NAME="top" SRC="top.php">
|
||||
<FRAMESET COLS="200,*">
|
||||
<FRAME NAME="contents" SRC="contents.php">
|
||||
<FRAME NAME="main" SRC="<?PHP echo "$file"; ?>">
|
||||
<FRAME NAME="main" SRC="index.php?file=<?PHP echo "$file$sub"; ?>">
|
||||
</FRAMESET>
|
||||
</FRAMESET>
|
||||
|
||||
+40
-19
@@ -1,6 +1,6 @@
|
||||
<HEAD>
|
||||
<TITLE>Moodle Docs: Installation</TITLE>
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.css" TYPE="TEXT/CSS">
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.php" TYPE="TEXT/CSS">
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
@@ -26,29 +26,32 @@
|
||||
<H3><A NAME="requirements"></A>1. Requirements</H3>
|
||||
<blockquote>
|
||||
<p>Moodle is primarily developed in Linux using PHP, Apache and MySQL, and regularly
|
||||
tested under Windows XP and Mac OS X environments.</p>
|
||||
tested with PostgreSQL and in Windows XP and Mac OS X environments.</p>
|
||||
<p>All you should need are:</p>
|
||||
<ul>
|
||||
<ol>
|
||||
<li>a working installation of <A HREF="http://www.php.net/">PHP</A> (version
|
||||
4.1.0 or later), with the following features enabled (most PHP installations
|
||||
these days will have all of these):
|
||||
<ul>
|
||||
<LI>JPEG and/or PNG image editing support via the <A HREF="http://www.boutell.com/gd/">GD library</A></li>
|
||||
<LI>Sessions support
|
||||
<LI>File uploading
|
||||
<LI>Sessions support</LI>
|
||||
<LI>File uploading allowed</LI>
|
||||
</UL>
|
||||
<li>a working database server (<A HREF="http://www.mysql.com/">MySQL</A> for
|
||||
now, but soon it will support PostgreSQL, MSSQL, Oracle, Interbase, Foxpro,
|
||||
Access, ADO, Sybase, DB2 or ODBC).</li>
|
||||
</ul>
|
||||
</LI>
|
||||
<li>a working database server: <A HREF="http://www.mysql.com/">MySQL</A> or <A HREF="http://www.postgresql.org/">PostgreSQL</A> are recommended. (MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 or ODBC are also theoretically supported but will require you to manually set up the database tables).</li>
|
||||
</ol>
|
||||
<p>On a Windows platform, the quickest way to satisfy these requirements is
|
||||
to download <A HREF="http://www.foxserv.net/">FoxServ</A>,
|
||||
or <A HREF="http://www.easyphp.org/">EasyPHP</A> which will install Apache,
|
||||
PHP, and MySQL for you. Make sure you enable the GD module so Moodle can process
|
||||
images - you may have to edit php.ini and remove the comment (;) from this
|
||||
line: 'extension=php_gd.dll'.</p>
|
||||
|
||||
<p>On Mac OS X I highly recommend the <a href="http://fink.sourceforge.net/">fink</a>
|
||||
project.</p>
|
||||
project as a way to download easily-maintainable packages for all of this.</p>
|
||||
|
||||
<p>If you're on Linux or another Unix then I'll assume you can figure all this out for yourself! ;-) </p>
|
||||
|
||||
</blockquote>
|
||||
<P> </P>
|
||||
<H3><A NAME="downloading"></A>2. Download</H3>
|
||||
@@ -95,7 +98,7 @@
|
||||
such as course documents and user pictures.</p>
|
||||
|
||||
<p>Create a directory for this purpose somewhere. For security, it's best that
|
||||
this directory is NOT accessible via the web. The easiest way to do this
|
||||
this directory is NOT accessible directly via the web. The easiest way to do this
|
||||
is to simply locate it OUTSIDE the web directory, otherwise protect it
|
||||
by creating a file in the data directory called .htaccess, containing this line:
|
||||
<blockquote>
|
||||
@@ -106,6 +109,13 @@
|
||||
the web server software (eg Apache) has permission to write
|
||||
to this directory. On Unix machines, this means setting the owner of the directory
|
||||
to be something like "nobody" or "apache".</p>
|
||||
|
||||
<p>On many shared hosting servers, you will probably need to restrict all file access
|
||||
to your "group" (to prevent other webhost customers from looking at or changing your files),
|
||||
but provide full read/write access to everyone else (which will allow the web server
|
||||
to access your files). Speak to your server administrator if you are having
|
||||
trouble setting this up securely.</p>
|
||||
|
||||
</blockquote>
|
||||
<P> </P>
|
||||
<H3><A NAME="database"></A>5. Create a database</H3>
|
||||
@@ -117,7 +127,7 @@
|
||||
the password then your whole database system would be at risk, rather than
|
||||
just one database.
|
||||
</p>
|
||||
<p>eg for MySQL: </p>
|
||||
<p>Example command lines for MySQL: </p>
|
||||
<PRE>
|
||||
# mysql -u root -p
|
||||
> CREATE DATABASE moodle;
|
||||
@@ -125,14 +135,18 @@
|
||||
TO moodleuser@localhost IDENTIFIED BY 'yourpassword';
|
||||
> quit
|
||||
# mysqladmin -p reload
|
||||
</PRE>
|
||||
<p>Example command lines for PostgreSQL: </p>
|
||||
<PRE>
|
||||
# su - postgres
|
||||
> psql -c "create user moodleuser createdb;" template1
|
||||
> psql -c "create database moodle;" -U moodleuser template1
|
||||
> psql -c "alter user moodleuser nocreatedb;" template1
|
||||
</PRE>
|
||||
<p>(For MySQL I highly recommend the use of <a href="http://phpmyadmin.sourceforge.net/">phpMyAdmin</a>
|
||||
to manage your databases).</p>
|
||||
<p>Note that Moodle currently does not yet support table name prefixes, and works best with a whole
|
||||
database to itself. If you do want to install Moodle in a database that already contains
|
||||
tables, and are SURE that Moodle tables will not conflict with any tables
|
||||
that you already have installed, then you can call this script in your moodle
|
||||
installation: admin/forcetables.php</p>
|
||||
<p>As of version 1.0.8, Moodle now supports table prefixes, and so can safely share
|
||||
a database with tables from other applications.</p>
|
||||
</blockquote>
|
||||
<P> </P>
|
||||
<H3><A NAME="webserver" id="webserver"></A>6. Check your web server settings</H3>
|
||||
@@ -193,7 +207,8 @@ php_value post_max_size 2M
|
||||
<p>To start with, make a copy of config-dist.php and call it config.php. We
|
||||
do this so that your config.php won't be overwritten in case you upgrade Moodle
|
||||
later on. </p>
|
||||
<p>Edit config.php to specify the database details that you just defined, as
|
||||
<p>Edit config.php to specify the database details that you just defined (including
|
||||
a table prefix - notice this is REQUIRED for PostgreSQL), as
|
||||
well as the site address, file system directory and data directory.
|
||||
The config file has detailed directions.</p>
|
||||
<p>For the rest of this installation document we will assume your site is at:
|
||||
@@ -245,7 +260,13 @@ php_value post_max_size 2M
|
||||
come back and edit these later on using the admin interface. Scroll down
|
||||
to the bottom and click "Save changes".</p>
|
||||
|
||||
<p>Next is a form where you can define parameters for your Moodle site and the
|
||||
<p>If (and only if) you find yourself getting stuck on this page or the next
|
||||
page, unable to continue, then your server probably has what I call the
|
||||
"buggy referrer" problem. This is easy to fix: just edit
|
||||
your config.php and set the variable buggy_referrer to <i>true</i>, then
|
||||
try the page again.</p>
|
||||
|
||||
<p>The next page is a form where you can define parameters for your Moodle site and the
|
||||
front page, such as the name, format, description and so on.
|
||||
|
||||
Fill this out (you can always go back and change these later) and then press
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Moodle Docs: Introduction</TITLE>
|
||||
<LINK REL="stylesheet" HREF="../theme/standard/styles.css" TYPE="TEXT/CSS">
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#ffffff">
|
||||
|
||||
<H2>Introduction</H2>
|
||||
|
||||
<P>Moodle is a software package for producing internet-based courses and web sites.
|
||||
It's an ongoing development project designed to support a <A HREF="http://dougiamas.com/writing/herdsa2002/">social constructionist</A> framework of education. </P>
|
||||
|
||||
<P>Moodle is provided freely as <A HREF="http://www.opensource.org/docs/definition_plain.html">
|
||||
Open Source</A> software (under the <A HREF="http://www.gnu.org/copyleft/gpl.html">
|
||||
GNU Public License</A>). Basically this means Moodle is copyrighted, but that you have additional
|
||||
freedoms. You are allowed to copy, use and modify Moodle <B>provided</B> that you agree: to provide
|
||||
the source to others; to not modify or remove the original license, and apply this same
|
||||
license to any derivative work.
|
||||
|
||||
<P>Moodle will run on any computer that can run <A HREF="http://www.php.net/">
|
||||
PHP</A>, and can support many types of database (particularly <a href="http://www.mysql.com/">MySQL</a>).</P>
|
||||
|
||||
<P>The word Moodle is an acronym for Modular Object-Oriented Dynamic Learning
|
||||
Environment, which is mostly useful to programmers and education theorists.
|
||||
It's also a verb that describes the process of lazily meandering through
|
||||
something, doing things as it occurs to you to do them, an enjoyable tinkering
|
||||
that often leads to insight and creativity. As such it applies both to the way
|
||||
Moodle was developed, and to the way a student or teacher might approach studying
|
||||
or teaching an online course.</P>
|
||||
<P><BR>
|
||||
</P>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1"><A HREF="." TARGET="_top">Moodle Documentation</A></FONT></P>
|
||||
<P ALIGN="CENTER"><FONT SIZE="1">Version: $Id$</FONT></P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
+9
-1
@@ -2,11 +2,19 @@
|
||||
|
||||
require("../config.php");
|
||||
|
||||
if (empty($CFG->langmenu)) {
|
||||
$langmenu = "";
|
||||
} else {
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
$langmenu = popup_form ("$CFG->wwwroot/doc/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Site is misconfigured");
|
||||
}
|
||||
$strdocumentation = get_string("documentation");
|
||||
print_header("$site->shortname: $strdocumentation", "$site->fullname", "$strdocumentation", "", "", true, "", navmenu($site));
|
||||
print_header("$site->shortname: $strdocumentation", "$site->fullname", "$strdocumentation", "", "", true, $langmenu, navmenu($site));
|
||||
|
||||
?>
|
||||
|
||||
|
||||
+4
-7
@@ -7,11 +7,6 @@
|
||||
|
||||
$file = clean_filename($file);
|
||||
|
||||
if (!file_exists($file)) {
|
||||
error("404 - File not found");
|
||||
}
|
||||
|
||||
|
||||
if ($id) {
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course is misconfigured");
|
||||
@@ -28,9 +23,11 @@
|
||||
"<A HREF=\"view.php?file=contents.html\">$strdocumentation</A>");
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo "<BLOCKQUOTE>";
|
||||
include($file);
|
||||
|
||||
document_file($file, true);
|
||||
|
||||
echo "</BLOCKQUOTE>";
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
// This function fetches files from the data directory
|
||||
// Syntax: file.php/courseid/dir/.../dir/filename.ext
|
||||
|
||||
require("config.php");
|
||||
require("files/mimetypes.php");
|
||||
require_once("config.php");
|
||||
require_once("files/mimetypes.php");
|
||||
|
||||
$lifetime = 86400;
|
||||
|
||||
if (isset($file)) { // workaround for situations where / syntax doesn't work
|
||||
$PATH_INFO = $file;
|
||||
$pathinfo = $file;
|
||||
} else {
|
||||
$pathinfo = get_slash_arguments("file.php");
|
||||
}
|
||||
|
||||
if (!$PATH_INFO) {
|
||||
error("This script DEPENDS on PATH_INFO being available. Read the README.");
|
||||
if (!$pathinfo) {
|
||||
error("No file parameters!");
|
||||
}
|
||||
|
||||
if (! $args = get_slash_arguments()) {
|
||||
if (! $args = parse_slash_arguments($pathinfo)) {
|
||||
error("No valid arguments supplied");
|
||||
}
|
||||
|
||||
@@ -30,7 +32,7 @@
|
||||
|
||||
// it's OK to get here if no course was specified
|
||||
|
||||
$pathname = "$CFG->dataroot$PATH_INFO";
|
||||
$pathname = "$CFG->dataroot$pathinfo";
|
||||
$filename = $args[$numargs-1];
|
||||
|
||||
$mimetype = mimeinfo("type", $filename);
|
||||
@@ -47,7 +49,7 @@
|
||||
header("Content-type: $mimetype");
|
||||
readfile("$pathname");
|
||||
} else {
|
||||
error("Sorry, but the file you are looking for was not found", "course/view.php?id=$courseid");
|
||||
error("Sorry, but the file you are looking for was not found ($pathname)", "course/view.php?id=$courseid");
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
+204
-65
@@ -10,6 +10,9 @@
|
||||
require("../config.php");
|
||||
|
||||
require_variable($id);
|
||||
optional_variable($file, "");
|
||||
optional_variable($wdir, "");
|
||||
optional_variable($action, "");
|
||||
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
@@ -21,14 +24,6 @@
|
||||
error("Only teachers can edit files");
|
||||
}
|
||||
|
||||
if (!$CFG->zip) {
|
||||
$CFG->zip = "/usr/bin/zip";
|
||||
}
|
||||
|
||||
if (!$CFG->unzip) {
|
||||
$CFG->unzip = "/usr/bin/unzip";
|
||||
}
|
||||
|
||||
function html_footer() {
|
||||
global $course;
|
||||
echo "</td></tr></table></body></html>";
|
||||
@@ -71,7 +66,6 @@
|
||||
|
||||
// End of configuration and access control
|
||||
|
||||
|
||||
require("mimetypes.php");
|
||||
|
||||
$regexp="\\.\\.";
|
||||
@@ -81,34 +75,35 @@
|
||||
$action = "";
|
||||
}
|
||||
|
||||
|
||||
if (!match_referer("$baseweb/files/index.php")) { // To stop spoofing
|
||||
$action="cancel";
|
||||
$wdir="/";
|
||||
}
|
||||
|
||||
if (!$wdir) {
|
||||
$wdir="/";
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case "upload":
|
||||
html_header($course, $wdir);
|
||||
if ($save) {
|
||||
if (!is_uploaded_file($userfile['tmp_name']) and $userfile['size'] > 0) {
|
||||
echo "<P>Error: That was not a valid file.";
|
||||
if (!empty($_FILES['userfile'])) {
|
||||
$userfile = $_FILES['userfile'];
|
||||
} else {
|
||||
$save = false;
|
||||
}
|
||||
if (!empty($save)) {
|
||||
if (!is_uploaded_file($userfile['tmp_name']) or $userfile['size'] == 0) {
|
||||
notify(get_string("uploadnofilefound"));
|
||||
} else {
|
||||
$userfile_name = clean_filename($userfile['name']);
|
||||
if ($userfile_name) {
|
||||
$newfile = "$basedir$wdir/$userfile_name";
|
||||
if (move_uploaded_file($userfile['tmp_name'], $newfile)) {
|
||||
echo "Uploaded $userfile_name (".$userfile['type'].") to $wdir";
|
||||
chmod($newfile, 0666);
|
||||
$a = NULL;
|
||||
$a->file = "$userfile_name (".$userfile['type'].")";
|
||||
$a->directory = $wdir;
|
||||
print_string("uploadedfileto", "", $a);
|
||||
} else {
|
||||
echo "A problem occurred while uploading '$userfile_name'";
|
||||
echo " (possibly it was too large)";
|
||||
notify(get_string("uploadproblem", "", $userfile_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,23 +113,28 @@
|
||||
$upload_max_filesize = get_max_upload_file_size();
|
||||
$filesize = display_size($upload_max_filesize);
|
||||
|
||||
echo "<P>Upload a file (maximum size $filesize) into <B>$wdir</B>:";
|
||||
$struploadafile = get_string("uploadafile");
|
||||
$struploadthisfile = get_string("uploadthisfile");
|
||||
$strmaxsize = get_string("maxsize", "", $filesize);
|
||||
$strcancel = get_string("cancel");
|
||||
|
||||
echo "<P>$struploadafile ($strmaxsize) --> <B>$wdir</B>";
|
||||
echo "<TABLE><TR><TD COLSPAN=2>";
|
||||
echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"post\" ACTION=index.php>";
|
||||
echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$upload_max_filesize\">";
|
||||
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
|
||||
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
|
||||
echo " <INPUT TYPE=hidden NAME=action VALUE=upload>";
|
||||
echo " <INPUT NAME=\"userfile\" TYPE=\"file\" size=\"50\">";
|
||||
echo " <INPUT NAME=\"userfile\" TYPE=\"file\" size=\"60\">";
|
||||
echo " </TD><TR><TD WIDTH=10>";
|
||||
echo " <INPUT TYPE=submit NAME=save VALUE=\"Upload this file\">";
|
||||
echo " <INPUT TYPE=submit NAME=save VALUE=\"$struploadthisfile\">";
|
||||
echo "</FORM>";
|
||||
echo "</TD><TD WIDTH=100%>";
|
||||
echo "<FORM ACTION=index.php METHOD=get>";
|
||||
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
|
||||
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
|
||||
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
|
||||
echo " <INPUT TYPE=submit VALUE=\"Cancel\">";
|
||||
echo " <INPUT TYPE=submit VALUE=\"$strcancel\">";
|
||||
echo "</FORM>";
|
||||
echo "</TD></TR></TABLE>";
|
||||
}
|
||||
@@ -142,7 +142,7 @@
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
if ($confirm) {
|
||||
if (!empty($confirm)) {
|
||||
html_header($course, $wdir);
|
||||
foreach ($USER->filelist as $file) {
|
||||
$fullfile = $basedir.$file;
|
||||
@@ -156,7 +156,7 @@
|
||||
|
||||
} else {
|
||||
html_header($course, $wdir);
|
||||
if (setfilelist($HTTP_POST_VARS)) {
|
||||
if (setfilelist($_POST)) {
|
||||
echo "<P ALIGN=CENTER>You are about to delete:</P>";
|
||||
print_simple_box_start("center");
|
||||
printfilelist($USER->filelist);
|
||||
@@ -174,10 +174,9 @@
|
||||
|
||||
case "move":
|
||||
html_header($course, $wdir);
|
||||
if ($count = setfilelist($HTTP_POST_VARS)) {
|
||||
if ($count = setfilelist($_POST)) {
|
||||
$USER->fileop = $action;
|
||||
$USER->filesource = $wdir;
|
||||
save_session("USER");
|
||||
echo "<P align=center>$count files selected for moving. Now go to the destination and press \"Move files to here\".</P>";
|
||||
}
|
||||
displaydir($wdir);
|
||||
@@ -186,7 +185,7 @@
|
||||
|
||||
case "paste":
|
||||
html_header($course, $wdir);
|
||||
if ($USER->fileop == "move") {
|
||||
if (isset($USER->fileop) and $USER->fileop == "move") {
|
||||
foreach ($USER->filelist as $file) {
|
||||
$shortfile = basename($file);
|
||||
$oldfile = $basedir.$file;
|
||||
@@ -202,7 +201,7 @@
|
||||
break;
|
||||
|
||||
case "rename":
|
||||
if ($name) {
|
||||
if (!empty($name)) {
|
||||
html_header($course, $wdir);
|
||||
$name = clean_filename($name);
|
||||
if (file_exists($basedir.$wdir."/".$name)) {
|
||||
@@ -237,12 +236,12 @@
|
||||
break;
|
||||
|
||||
case "mkdir":
|
||||
if ($name) {
|
||||
if (!empty($name)) {
|
||||
html_header($course, $wdir);
|
||||
$name = clean_filename($name);
|
||||
if (file_exists($basedir.$wdir."/".$name)) {
|
||||
if (file_exists("$basedir$wdir/$name")) {
|
||||
echo "Error: $name already exists!";
|
||||
} else if (!mkdir($basedir.$wdir."/".$name, 0750)) {
|
||||
} else if (! make_upload_directory("$course->id/$wdir/$name")) {
|
||||
echo "Error: could not create $name";
|
||||
}
|
||||
displaydir($wdir);
|
||||
@@ -279,20 +278,31 @@
|
||||
displaydir($wdir);
|
||||
|
||||
} else {
|
||||
$streditfile = get_string("edit", "", "<B>$file</B>");
|
||||
$fileptr = fopen($basedir.$file, "r");
|
||||
$contents = fread($fileptr, filesize($basedir.$file));
|
||||
fclose($fileptr);
|
||||
|
||||
echo "<P>Editing <B>$file</B>:";
|
||||
if (mimeinfo("type", $file) == "text/html") {
|
||||
if ($usehtmleditor = can_use_richtext_editor()) {
|
||||
$onsubmit = "onsubmit=\"copyrichtext(document.form.text);\"";
|
||||
} else {
|
||||
$onsubmit = "";
|
||||
}
|
||||
} else {
|
||||
$usehtmleditor = false;
|
||||
$onsubmit = "";
|
||||
}
|
||||
|
||||
print_heading("$streditfile");
|
||||
|
||||
echo "<TABLE><TR><TD COLSPAN=2>";
|
||||
echo "<FORM ACTION=index.php METHOD=post NAME=form>";
|
||||
echo "<FORM ACTION=\"index.php\" METHOD=\"post\" NAME=\"form\" $onsubmit>";
|
||||
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
|
||||
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
|
||||
echo " <INPUT TYPE=hidden NAME=file VALUE=\"$file\">";
|
||||
echo " <INPUT TYPE=hidden NAME=action VALUE=edit>";
|
||||
echo "<TEXTAREA ROWS=20 COLS=60 NAME=text>";
|
||||
echo htmlspecialchars($contents);
|
||||
echo "</TEXTAREA>";
|
||||
print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents);
|
||||
echo "</TD></TR><TR><TD>";
|
||||
echo " <INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\">";
|
||||
echo "</FORM>";
|
||||
@@ -304,27 +314,45 @@
|
||||
echo " <INPUT TYPE=submit VALUE=\"".get_string("cancel")."\">";
|
||||
echo "</FORM>";
|
||||
echo "</TD></TR></TABLE>";
|
||||
|
||||
if ($usehtmleditor) {
|
||||
print_richedit_javascript("form", "text", "yes");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
html_footer();
|
||||
break;
|
||||
|
||||
case "zip":
|
||||
if ($name) {
|
||||
if (!empty($name)) {
|
||||
html_header($course, $wdir);
|
||||
$name = clean_filename($name);
|
||||
$files = "";
|
||||
foreach ($USER->filelist as $file) {
|
||||
$files .= basename($file);
|
||||
$files .= " ";
|
||||
if (empty($CFG->zip)) { // Use built-in php-based zip function
|
||||
$files = array();
|
||||
foreach ($USER->filelist as $file) {
|
||||
$files[] = "$basedir/$wdir$file";
|
||||
}
|
||||
include_once('../lib/pclzip/pclzip.lib.php');
|
||||
$archive = new PclZip("$basedir/$wdir/$name");
|
||||
if (($list = $archive->create($files,'',"$basedir/$wdir/")) == 0) {
|
||||
error($archive->errorInfo(true));
|
||||
}
|
||||
} else { // Use external zip program
|
||||
$files = "";
|
||||
foreach ($USER->filelist as $file) {
|
||||
$files .= basename($file);
|
||||
$files .= " ";
|
||||
}
|
||||
$command = "cd $basedir/$wdir ; $CFG->zip -r $name $files";
|
||||
Exec($command);
|
||||
}
|
||||
$command = "cd $basedir/$wdir ; $CFG->zip -r $name $files";
|
||||
Exec($command);
|
||||
clearfilelist();
|
||||
displaydir($wdir);
|
||||
|
||||
} else {
|
||||
html_header($course, $wdir, "form.name");
|
||||
if (setfilelist($HTTP_POST_VARS)) {
|
||||
if (setfilelist($_POST)) {
|
||||
echo "<P ALIGN=CENTER>You are about create a zip file containing:</P>";
|
||||
print_simple_box_start("center");
|
||||
printfilelist($USER->filelist);
|
||||
@@ -357,20 +385,60 @@
|
||||
|
||||
case "unzip":
|
||||
html_header($course, $wdir);
|
||||
if ($file) {
|
||||
echo "<P ALIGN=CENTER>Unzipping $file:</P>";
|
||||
print_simple_box_start("center");
|
||||
echo "<PRE>";
|
||||
if (!empty($file)) {
|
||||
$strname = get_string("name");
|
||||
$strsize = get_string("size");
|
||||
$strmodified = get_string("modified");
|
||||
$strstatus = get_string("status");
|
||||
$strok = get_string("ok");
|
||||
$strunpacking = get_string("unpacking", "", $file);
|
||||
|
||||
echo "<P ALIGN=CENTER>$strunpacking:</P>";
|
||||
|
||||
$file = basename($file);
|
||||
$command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
|
||||
passthru($command);
|
||||
echo "</PRE>";
|
||||
print_simple_box_end();
|
||||
|
||||
if (empty($CFG->unzip)) { // Use built-in php-based unzip function
|
||||
include_once('../lib/pclzip/pclzip.lib.php');
|
||||
$archive = new PclZip("$basedir/$wdir/$file");
|
||||
if (!$list = $archive->extract("$basedir/$wdir")) {
|
||||
error($archive->errorInfo(true));
|
||||
} else { // print some output
|
||||
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=640>";
|
||||
echo "<tr><th align=left>$strname</th>";
|
||||
echo "<th align=right>$strsize</th>";
|
||||
echo "<th align=right>$strmodified</th>";
|
||||
echo "<th align=right>$strstatus</th></tr>";
|
||||
foreach ($list as $item) {
|
||||
echo "<tr>";
|
||||
$item['filename'] = str_replace("$basedir/$wdir/", "", $item['filename']);
|
||||
print_cell("left", $item['filename']);
|
||||
if (! $item['folder']) {
|
||||
print_cell("right", display_size($item['size']));
|
||||
} else {
|
||||
echo "<td> </td>";
|
||||
}
|
||||
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
|
||||
print_cell("right", $filedate);
|
||||
print_cell("right", $item['status']);
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
} else { // Use external unzip program
|
||||
print_simple_box_start("center");
|
||||
echo "<PRE>";
|
||||
$command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
|
||||
passthru($command);
|
||||
echo "</PRE>";
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
echo "<CENTER><FORM ACTION=index.php METHOD=get>";
|
||||
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
|
||||
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
|
||||
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
|
||||
echo " <INPUT TYPE=submit VALUE=\"OK\">";
|
||||
echo " <INPUT TYPE=submit VALUE=\"$strok\">";
|
||||
echo "</FORM>";
|
||||
echo "</CENTER>";
|
||||
} else {
|
||||
@@ -379,6 +447,73 @@
|
||||
html_footer();
|
||||
break;
|
||||
|
||||
case "listzip":
|
||||
html_header($course, $wdir);
|
||||
if (!empty($file)) {
|
||||
$strname = get_string("name");
|
||||
$strsize = get_string("size");
|
||||
$strmodified = get_string("modified");
|
||||
$strok = get_string("ok");
|
||||
$strlistfiles = get_string("listfiles", "", $file);
|
||||
|
||||
echo "<P ALIGN=CENTER>$strlistfiles:</P>";
|
||||
$file = basename($file);
|
||||
|
||||
include_once('../lib/pclzip/pclzip.lib.php');
|
||||
$archive = new PclZip("$basedir/$wdir/$file");
|
||||
if (!$list = $archive->listContent("$basedir/$wdir")) {
|
||||
notify($archive->errorInfo(true));
|
||||
|
||||
} else {
|
||||
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=640>";
|
||||
echo "<tr><th align=left>$strname</th><th align=right>$strsize</th><th align=right>$strmodified</th></tr>";
|
||||
foreach ($list as $item) {
|
||||
echo "<tr>";
|
||||
print_cell("left", $item['filename']);
|
||||
if (! $item['folder']) {
|
||||
print_cell("right", display_size($item['size']));
|
||||
} else {
|
||||
echo "<td> </td>";
|
||||
}
|
||||
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
|
||||
print_cell("right", $filedate);
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
echo "<br><center><form action=index.php method=get>";
|
||||
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
|
||||
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
|
||||
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
|
||||
echo " <INPUT TYPE=submit VALUE=\"$strok\">";
|
||||
echo "</FORM>";
|
||||
echo "</CENTER>";
|
||||
} else {
|
||||
displaydir($wdir);
|
||||
}
|
||||
html_footer();
|
||||
break;
|
||||
|
||||
case "restore":
|
||||
html_header($course, $wdir);
|
||||
if (!empty($file)) {
|
||||
echo "<P ALIGN=CENTER>".get_string("youaregoingtorestorefrom")."</P>";
|
||||
print_simple_box_start("center");
|
||||
echo $file;
|
||||
print_simple_box_end();
|
||||
echo "<BR>";
|
||||
//MODIFY RELATIVE PATH TO restore.php
|
||||
$restore_path = "../contrib/stronk7/backup/restore.php";
|
||||
//END MODIFY
|
||||
notice_yesno (get_string("areyousuretorestorethis"),
|
||||
$restore_path."?file=".$id.$wdir."/".$file,
|
||||
"index.php?id=$id&wdir=$wdir&action=cancel");
|
||||
} else {
|
||||
displaydir($wdir);
|
||||
}
|
||||
html_footer();
|
||||
break;
|
||||
|
||||
case "cancel";
|
||||
clearfilelist();
|
||||
|
||||
@@ -438,7 +573,6 @@ function setfilelist($VARS) {
|
||||
$USER->filelist[] = rawurldecode($val);
|
||||
}
|
||||
}
|
||||
save_session("USER");
|
||||
return $count;
|
||||
}
|
||||
|
||||
@@ -447,7 +581,6 @@ function clearfilelist() {
|
||||
|
||||
$USER->filelist = array ();
|
||||
$USER->fileop = "";
|
||||
save_session("USER");
|
||||
}
|
||||
|
||||
|
||||
@@ -519,6 +652,8 @@ function displaydir ($wdir) {
|
||||
$strrename = get_string("rename");
|
||||
$stredit = get_string("edit");
|
||||
$strunzip = get_string("unzip");
|
||||
$strlist = get_string("list");
|
||||
$strrestore= get_string("restore");
|
||||
|
||||
|
||||
echo "<FORM ACTION=\"index.php\" METHOD=post NAME=dirform>";
|
||||
@@ -538,7 +673,7 @@ function displaydir ($wdir) {
|
||||
|
||||
$count = 0;
|
||||
|
||||
if ($dirlist) {
|
||||
if (!empty($dirlist)) {
|
||||
asort($dirlist);
|
||||
foreach ($dirlist as $dir) {
|
||||
|
||||
@@ -562,7 +697,7 @@ function displaydir ($wdir) {
|
||||
}
|
||||
|
||||
|
||||
if ($filelist) {
|
||||
if (!empty($filelist)) {
|
||||
asort($filelist);
|
||||
foreach ($filelist as $file) {
|
||||
|
||||
@@ -599,7 +734,11 @@ function displaydir ($wdir) {
|
||||
if ($icon == "text.gif" || $icon == "html.gif") {
|
||||
$edittext = "<A HREF=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=edit\">$stredit</A>";
|
||||
} else if ($icon == "zip.gif") {
|
||||
$edittext = "<A HREF=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=unzip\">$strunzip</A>";
|
||||
$edittext = "<A HREF=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=unzip\">$strunzip</A> ";
|
||||
$edittext .= "<A HREF=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=listzip\">$strlist</A> ";
|
||||
if (!empty($CFG->backup_version) && isadmin()) {
|
||||
$edittext .= "<A HREF=\"index.php?id=$id&wdir=$wdir&file=$filesafe&action=restore\">$strrestore</A> ";
|
||||
}
|
||||
} else {
|
||||
$edittext = "";
|
||||
}
|
||||
@@ -611,7 +750,7 @@ function displaydir ($wdir) {
|
||||
echo "</TABLE>";
|
||||
echo "<HR WIDTH=640 ALIGN=CENTER NOSHADE SIZE=1>";
|
||||
|
||||
if (!$wdir) {
|
||||
if (empty($wdir)) {
|
||||
$wdir = "/";
|
||||
}
|
||||
|
||||
@@ -624,13 +763,13 @@ function displaydir ($wdir) {
|
||||
"delete" => "$strdeletecompletely",
|
||||
"zip" => "$strcreateziparchive"
|
||||
);
|
||||
if ($count) {
|
||||
if (!empty($count)) {
|
||||
choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()");
|
||||
}
|
||||
|
||||
echo "</FORM>";
|
||||
echo "<TD ALIGN=center>";
|
||||
if (($USER->fileop == "move") && $USER->filesource <> $wdir) {
|
||||
if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {
|
||||
echo "<FORM ACTION=index.php METHOD=get>";
|
||||
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
|
||||
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
|
||||
|
||||
+5
-3
@@ -4,6 +4,7 @@ function mimeinfo($element, $filename) {
|
||||
$mimeinfo = array (
|
||||
"xxx" => array ("type"=>"document/unknown", "icon"=>"unknown.gif"),
|
||||
"zip" => array ("type"=>"application/zip", "icon"=>"zip.gif"),
|
||||
"jpe" => array ("type"=>"image/jpeg", "icon"=>"image.gif"),
|
||||
"jpeg" => array ("type"=>"image/jpeg", "icon"=>"image.gif"),
|
||||
"jpg" => array ("type"=>"image/jpeg", "icon"=>"image.gif"),
|
||||
"gif" => array ("type"=>"image/gif", "icon"=>"image.gif"),
|
||||
@@ -16,18 +17,19 @@ function mimeinfo($element, $filename) {
|
||||
"wav" => array ("type"=>"audio/wav", "icon"=>"audio.gif"),
|
||||
"mp3" => array ("type"=>"audio/mp3", "icon"=>"audio.gif"),
|
||||
"au" => array ("type"=>"audio/au", "icon"=>"audio.gif"),
|
||||
"swf" => array ("type"=>"application/x-shockwave-flash", "icon"=>"image.gif"),
|
||||
"swf" => array ("type"=>"application/x-shockwave-flash", "icon"=>"flash.gif"),
|
||||
"pdf" => array ("type"=>"application/pdf", "icon"=>"pdf.gif"),
|
||||
"doc" => array ("type"=>"application/msword", "icon"=>"word.gif"),
|
||||
"ppt" => array ("type"=>"application/vnd.ms-powerpoint", "icon"=>"powerpoint.gif"),
|
||||
"xls" => array ("type"=>"application/vnd.ms-excel", "icon"=>"excel.gif")
|
||||
"xls" => array ("type"=>"application/vnd.ms-excel", "icon"=>"excel.gif"),
|
||||
"avi" => array ("type"=>"video/x-ms-wm", "icon"=>"avi.gif")
|
||||
);
|
||||
|
||||
if (eregi("\.([a-z0-9]+)$", $filename, $match)) {
|
||||
$result = $mimeinfo[strtolower($match[1])][$element];
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
} else {
|
||||
return $mimeinfo["xxx"][$element]; // By default
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user