Compare commits
1569 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 585b76a0e8 | |||
| 15e6b71bc0 | |||
| 94c265fe95 | |||
| 9f3c4120f9 | |||
| 734b4d4dd1 | |||
| 94cf182211 | |||
| 2c7def765e | |||
| 63ae91cc6d | |||
| f7c44f3873 | |||
| 58331043d0 | |||
| 08dc6e642a | |||
| 6a22b20efd | |||
| ccb472e7b9 | |||
| eccbfc92ae | |||
| d4e9a98087 | |||
| 1b44161802 | |||
| 66fd7a7612 | |||
| 60a18dc226 | |||
| 7209121b5d | |||
| f154315266 | |||
| 189bb2de50 | |||
| 35cff7a641 | |||
| f0e4cbcabd | |||
| 464b3d80fa | |||
| 08450fe007 | |||
| 6387e05acd | |||
| fd21a93e5f | |||
| 548a5a4ae3 | |||
| f45aff70d9 | |||
| 63b33f502d | |||
| 8f79558997 | |||
| 31820054f2 | |||
| 536273ae99 | |||
| e331f94902 | |||
| 8a53bb7c91 | |||
| 97634109b7 | |||
| c7aebb6755 | |||
| e8b45d3e1d | |||
| 9059cb4550 | |||
| 078c8b402b | |||
| 0a22085fdb | |||
| 14942a2508 | |||
| 0abc6db872 | |||
| 0771778fff | |||
| cbca4dbf6c | |||
| 0e55fb3512 | |||
| 3747744140 | |||
| 0b0bfed7f3 | |||
| 2a1245108c | |||
| 591f3a61ab | |||
| b893b91a47 | |||
| e018b8db42 | |||
| 0e8422bf22 | |||
| 551f60bd3b | |||
| dec87682bf | |||
| 38e533a43c | |||
| 0ed613096c | |||
| 6778021371 | |||
| d3228e8238 | |||
| b17ce9a429 | |||
| 2758b9a780 | |||
| 3fb558da2f | |||
| 5c32a46383 | |||
| 4b76cb6fc0 | |||
| 7c6e10fe39 | |||
| 68d6a45263 | |||
| 517e069dec | |||
| ed1b0d012c | |||
| cb8faf0f12 | |||
| 0854d3f00e | |||
| d3b68faff0 | |||
| 7684e6314d | |||
| a6b6baf25e | |||
| 7551972d69 | |||
| 6f5fd34644 | |||
| 4e2d942e71 | |||
| 8ea0f9c792 | |||
| 70adc76b61 | |||
| ca45180f23 | |||
| 9b80ac3538 | |||
| bb6010edaa | |||
| 2c1868ca6b | |||
| 0a08be2397 | |||
| 6a4bd1e861 | |||
| 524c0c8fab | |||
| 6468df8aca | |||
| fb10b05479 | |||
| 86def10b64 | |||
| 9e1889cdae | |||
| 08bae0231a | |||
| 351b7cd179 | |||
| ed997a6b9c | |||
| 94ff81261d | |||
| 58bf9beea3 | |||
| 0844c5d93b | |||
| 26e8984b51 | |||
| 2f599e1732 | |||
| c67c987c80 | |||
| b1f3971caf | |||
| dfaa493161 | |||
| 3e02d264ab | |||
| 670fd620d8 | |||
| d47d910b13 | |||
| 5874bee4d1 | |||
| e74d5d31af | |||
| 9913f77ed1 | |||
| ef201b4775 | |||
| 36d07602b7 | |||
| 2a154e890e | |||
| 2bef07cd85 | |||
| 5ab05fb15f | |||
| 3236902cdd | |||
| c1d1f1679e | |||
| 871836deb7 | |||
| d242777c73 | |||
| ea80372129 | |||
| ce896718cf | |||
| 13db6cc1e4 | |||
| 997dc05600 | |||
| e588753478 | |||
| 52ffec20aa | |||
| c254ed8511 | |||
| 8900fdf11d | |||
| 4dc9acd3db | |||
| 2d08c94d20 | |||
| 3bbc889109 | |||
| eecbfe6e80 | |||
| 65be953852 | |||
| c8842694e2 | |||
| 207828729e | |||
| e5f7002f2f | |||
| 00f60cd1cb | |||
| 659cae579e | |||
| 8d0aa2442d | |||
| 8389c869ee | |||
| 7bbd75dc6e | |||
| 186fa912d9 | |||
| 30c56fe4dc | |||
| 21c24eb64f | |||
| a55d206ce7 | |||
| 578629dabe | |||
| f362682471 | |||
| 3dd102788f | |||
| a4166d5966 | |||
| d7f64fa590 | |||
| c5b4af2e5d | |||
| 3fa7bee5ce | |||
| e7bbc17fa2 | |||
| 2dc8d0e158 | |||
| e9e0641372 | |||
| 6343168321 | |||
| 3c5591c51c | |||
| 7afc1d07f4 | |||
| 137a439ac6 | |||
| 4984973b93 | |||
| 3ded4d989d | |||
| e9a0e86e70 | |||
| 10487fa6da | |||
| 58ea1ced21 | |||
| d6f8bc5b15 | |||
| 4d6eee8d65 | |||
| 6652a915eb | |||
| 72876267d2 | |||
| 391cd0eb8e | |||
| dc62cb9ecc | |||
| f55102c501 | |||
| f866f7be99 | |||
| 91e727f9ae | |||
| 1afe433c80 | |||
| f0f4244474 | |||
| e278eb4830 | |||
| dde95d41ec | |||
| 3310c48044 | |||
| 13ced7fb17 | |||
| 2bfb2f1f05 | |||
| 2ec2175f1e | |||
| 1f7448fc9d | |||
| da693b58b8 | |||
| 4ba7849b64 | |||
| 01911fa4b2 | |||
| 7545ecdb86 | |||
| 0ed6f1fc6b | |||
| 11274206e0 | |||
| f543e2acf7 | |||
| 794fc9a9a3 | |||
| 1bd430af60 | |||
| 910fa9c611 | |||
| 11f95c99ad | |||
| 17178a4ec3 | |||
| 54a252ba51 | |||
| 2771076cab | |||
| 80eb2b104b | |||
| 11925184b7 | |||
| 4c264c7ff8 | |||
| a5725844ff | |||
| 458544ed1d | |||
| 6b1b51c095 | |||
| 7541ac282a | |||
| 65c75c3ca7 | |||
| 20dd99627c | |||
| c070c4021e | |||
| 48ab51a5ff | |||
| 58dcf7ad08 | |||
| bda3445de9 | |||
| 5ed1079984 | |||
| 321fcad3ae | |||
| e731779d7a | |||
| 9688dc4e27 | |||
| b8d4faed6b | |||
| 570d5b907d | |||
| e98a1b9ef3 | |||
| e5a33e0082 | |||
| a919ee17b3 | |||
| 20d03127ad | |||
| 2e14f03a63 | |||
| 1e095f1636 | |||
| 7a67c58424 | |||
| fdc61d3e9f | |||
| 246eb27d88 | |||
| 83ad6e2213 | |||
| 71ebb06911 | |||
| 0746cf3e40 | |||
| c98be5a96f | |||
| d20c043713 | |||
| 4f353aadf5 | |||
| 16b963e777 | |||
| d970b5a0b2 | |||
| 6d643c9d6d | |||
| 2c4bd0a648 | |||
| 645beec03b | |||
| 0db6d34e6d | |||
| 6b465e1867 | |||
| 5420407e1e | |||
| 9660a6ddf2 | |||
| 8ae9a7dffc | |||
| f499bdf505 | |||
| d0c276727d | |||
| 3eb9c93999 | |||
| 86e44df6b0 | |||
| d30f1d1ad9 | |||
| f3aac02c26 | |||
| 2116a8a428 | |||
| f8471a1a96 | |||
| bebd1968b2 | |||
| ed3b8f3d0c | |||
| 978af5c28b | |||
| 1cc44fbf90 | |||
| 17e4bb1533 | |||
| aede0ebcc0 | |||
| 5f65bc5b94 | |||
| 4a906d7333 | |||
| 281ec00e8f | |||
| d685fe5705 | |||
| c26f59b6fc | |||
| 9e931faa98 | |||
| f6dde04372 | |||
| e4fd076246 | |||
| 5407ff018b | |||
| 6fd30e78c7 | |||
| d33eb04648 | |||
| a81b97bf9b | |||
| a5cf0536aa | |||
| 827ea538e5 | |||
| adb4cdc5a8 | |||
| ff90e9be5f | |||
| acb05e1d85 | |||
| a19e31a1d6 | |||
| a1b3e19dd4 | |||
| 8905e7b645 | |||
| b28a21b88b | |||
| 35e8af0edf | |||
| a607365fc8 | |||
| ce07f4dc34 | |||
| 48c52be77a | |||
| c4e643d335 | |||
| 1ba4c3e132 | |||
| eed0327fd9 | |||
| e8f4d7e395 | |||
| 9159c64a7d | |||
| 1f30b89fd8 | |||
| 985ea691ac | |||
| 205e71d01a | |||
| 55534cfdd2 | |||
| 832ca9bd1b | |||
| c2f2f33541 | |||
| d29877ac8c | |||
| 44ceee90e9 | |||
| bd9a7b89a7 | |||
| 1b268daa33 | |||
| 490c14fe8a | |||
| 53726ba409 | |||
| ee6689b003 | |||
| 29252268ca | |||
| bd09b95b81 | |||
| 3db9b3c2b1 | |||
| 30914826c9 | |||
| 32d746f1d7 | |||
| 02bb190c1d | |||
| 11a30670cb | |||
| fc98a031c3 | |||
| 5afa13193d | |||
| 14715db3ee | |||
| 28febd2534 | |||
| 282e599572 | |||
| 626b76b38f | |||
| 4dd6dd7155 | |||
| a41ba92752 | |||
| c9d4eba186 | |||
| 9988024f6e | |||
| 1fe0ed0b7d | |||
| 3ecc34b2d5 | |||
| 186c4de5ac | |||
| 7a26b64a13 | |||
| 43a4458850 | |||
| 6fcb1a4e2d | |||
| 66714f7c98 | |||
| 5623276da8 | |||
| af9ce11eec | |||
| f34dfc143f | |||
| 8a881c78de | |||
| 4618409cfd | |||
| 6644a4f4e5 | |||
| 916071c464 | |||
| a01d104cdf | |||
| 5710f8575c | |||
| 0962e21070 | |||
| 0594a0aaee | |||
| 624c7abf1a | |||
| 0871252e6b | |||
| 311ea49f58 | |||
| 111c351849 | |||
| aebdc0bdb3 | |||
| 91fa457ea2 | |||
| c2d04f05a0 | |||
| a63215000d | |||
| 6fec177f09 | |||
| a1cc49c6b1 | |||
| fa868b8a3d | |||
| 78298a17dd | |||
| 4890c92d15 | |||
| a3b2abed80 | |||
| e26612356b | |||
| 40a15c546e | |||
| f8cfb1230f | |||
| f461eacc8e | |||
| 67574a93c5 | |||
| a6a781458e | |||
| 32e854e51f | |||
| 713f0c63dd | |||
| ab147736c1 | |||
| 2a5e3d244b | |||
| d8347a0ab7 | |||
| c9c2c21b84 | |||
| 4f8ac26792 | |||
| 8f5ef63f5d | |||
| 9e10147777 | |||
| 58da996994 | |||
| 9c76f3b45e | |||
| ffd15ec8f6 | |||
| f1bd9b5ecf | |||
| d916897125 | |||
| ef7b0cc319 | |||
| 03daf74013 | |||
| 1eff062408 | |||
| c472c4bb50 | |||
| f296008fe5 | |||
| 782532955d | |||
| f6ea800797 | |||
| 1fe2c24de3 | |||
| 0e47869e99 | |||
| 6708fa8b98 | |||
| c6a4075609 | |||
| 9430296726 | |||
| ddc33af359 | |||
| 907a481674 | |||
| 7021c8441d | |||
| 50d0bb2e24 | |||
| 56352ac96f | |||
| 4811aacb5a | |||
| 2008bbe5de | |||
| 816219141b | |||
| aad4873cc6 | |||
| 369865830c | |||
| ea5a1c3bf6 | |||
| ecf7fad11a | |||
| f3c789cd94 | |||
| 63fc9bd4fd | |||
| 74f7fe1b30 | |||
| ad619206e1 | |||
| d7df0a5d84 | |||
| 1ee448b935 | |||
| 62556bfefa | |||
| 087f51bde0 | |||
| 7677bef81e | |||
| cebf5d77a3 | |||
| 1b053c41a4 | |||
| 4512e31e51 | |||
| d6ab69f11b | |||
| 0088748449 | |||
| 71b750ed86 | |||
| b632c1b6c9 | |||
| 022747163e | |||
| 038b5bd550 | |||
| 270c2f9a0d | |||
| c1abb7586f | |||
| e2f8d8a212 | |||
| a3b9814156 | |||
| b79595db64 | |||
| 38d6367287 | |||
| 936eeefdcb | |||
| ea3c67c5cb | |||
| 27ea59826f | |||
| c0207b1ba7 | |||
| e0acc94f9f | |||
| fc637ec2c1 | |||
| 04d79b7a0e | |||
| 9ddb243f13 | |||
| 8f92c1f78b | |||
| 01eaffcf75 | |||
| f995637ed3 | |||
| 14f79d5a2f | |||
| ccd48da98d | |||
| 82ecf200b7 | |||
| 0e87d49e09 | |||
| 98cb031e96 | |||
| 7e49db8100 | |||
| fe5f3d08ac | |||
| ede88ab3be | |||
| 3d4646688f | |||
| 59780d2e8f | |||
| 38f3f5f1a1 | |||
| c2508a1608 | |||
| 0bc5c5f8c6 | |||
| f32f73c0a6 | |||
| 765235a121 | |||
| 0975cc6e50 | |||
| ab3f9fc74e | |||
| c102e3aade | |||
| 8d8105fdf7 | |||
| 4ce19d978c | |||
| ab62d48e88 | |||
| 6242b7c12b | |||
| e629fc4ed0 | |||
| bb4bab500b | |||
| 34f06f743b | |||
| cfce2efbf3 | |||
| 1659924e8d | |||
| 88e2f1c4bc | |||
| e21d53b06b | |||
| 42e9c00f18 | |||
| 08576b0d0a | |||
| 740e1c8bd7 | |||
| 7f5e32ce55 | |||
| a227d4c0d9 | |||
| 013df172c0 | |||
| 9724b07ebc | |||
| 53938064c5 | |||
| 0a3158d669 | |||
| 9e1a55242f | |||
| f98f1a922e | |||
| 4334697e9e | |||
| 000b78f3f0 | |||
| ea4e7a0226 | |||
| 30b646c765 | |||
| bcdb377366 | |||
| 06e22959d1 | |||
| d9ab63d7e9 | |||
| 3b32b74f43 | |||
| b8a2e4a095 | |||
| 6f36f19a62 | |||
| 4d4938c15e | |||
| 296c5450fd | |||
| d74e9bf395 | |||
| e783513693 | |||
| 50d3025947 | |||
| d2f18a8694 | |||
| c15c851c3b | |||
| d53e1e9535 | |||
| dd0070851d | |||
| 339726d0d0 | |||
| 5c90d8094c | |||
| 04d1cad3bf | |||
| b09b58f052 | |||
| 357eefcdbe | |||
| 66d4805a81 | |||
| 5e41141993 | |||
| 03901b0c62 | |||
| b8f671b379 | |||
| 59a745a6ad | |||
| 3f134ab610 | |||
| 5cfbedea89 | |||
| df599bc11f | |||
| 8b722fe0b0 | |||
| 278ecb2567 | |||
| c86003482a | |||
| d7b02b694e | |||
| 53bdf7e60a | |||
| 6b18f14151 | |||
| be664f9a44 | |||
| 2b5db7a39f | |||
| fecac81cac | |||
| db9f04b35d | |||
| e3a08c6eaa | |||
| ed3a874632 | |||
| a2b4c8cb94 | |||
| 9f7d599561 | |||
| 4175366743 | |||
| 080ed4ba60 | |||
| b227269e56 | |||
| d8898325db | |||
| 94cbbdbd2e | |||
| f954aeaecd | |||
| f0421951ed | |||
| 405350262e | |||
| c92941d7a4 | |||
| 3a8093f895 | |||
| 293a2545b1 | |||
| 98e13c2eea | |||
| 227323aecf | |||
| adea20f6dc | |||
| 0c1d63a43e | |||
| e30a701156 | |||
| 95a7a2b866 | |||
| 369f3834ca | |||
| be5709b7fb | |||
| b1c418839e | |||
| 300ce0c64d | |||
| 1b5d15ba9d | |||
| 5c5d465c97 | |||
| 8ab96578ab | |||
| ccbbdc7319 | |||
| 0c89fe886d | |||
| 9bd0d5f805 | |||
| 182ac1d6d8 | |||
| 8ba998c60e | |||
| f547727478 | |||
| f5f4cc3fe7 | |||
| 3e6a1aa58e | |||
| 690b1d1324 | |||
| d6ad2b61f1 | |||
| af1a463811 | |||
| b55b207c27 | |||
| 7bff26bed6 | |||
| 173ac66759 | |||
| 7604731552 | |||
| 75ec296d45 | |||
| 14a3c9f3bc | |||
| fa2d7d3201 | |||
| 6be5bdfb8e | |||
| d6b6304fc3 | |||
| 5db97707d3 | |||
| 9d6bdd5874 | |||
| d4e4739aed | |||
| 5dd81daaed | |||
| 29ad04a314 | |||
| 4516dce1a3 | |||
| 0fbc5579fb | |||
| 9455d7c920 | |||
| bfaa2a61dc | |||
| 46203368b5 | |||
| 5fffec5d49 | |||
| 9275a2bae5 | |||
| 9051fd4e30 | |||
| 949e8de8e7 | |||
| 69329d504a | |||
| cb2bf96fe9 | |||
| ec5e30a4e9 | |||
| 39477c96a9 | |||
| a746e49818 | |||
| 6c9aa9b38b | |||
| 890204da8c | |||
| 49aa2ee116 | |||
| acfc18d8e8 | |||
| 82a6cc3f44 | |||
| 7bb1b32039 | |||
| 996177940e | |||
| a948673c75 | |||
| 85caf1b299 | |||
| 047e7670aa | |||
| 3824b03f06 | |||
| 4b4d9ef4fa | |||
| 654a2dae51 | |||
| 66b3a7bcec | |||
| e7504c319b | |||
| c562b0f504 | |||
| bab754c727 | |||
| 7300023df8 | |||
| 3983345254 | |||
| 047901cbd0 | |||
| e0ade9dbe7 | |||
| 6d07659acf | |||
| f35daade0d | |||
| e9a903a539 | |||
| 5a60b8a69a | |||
| 91cb9645d4 | |||
| c9262623e7 | |||
| 6489172657 | |||
| 64ca832445 | |||
| f9348b84bc | |||
| d994fe68bc | |||
| a28baeb99c | |||
| e52c8d89f6 | |||
| f845a2fba9 | |||
| 3475eeac11 | |||
| 7a15af7d90 | |||
| b972485c21 | |||
| 1c9a35efa2 | |||
| 3e5f98212d | |||
| ae1a7e05a6 | |||
| 3ed692737c | |||
| be1448f47b | |||
| 86f404fa52 | |||
| 8c4ca06f88 | |||
| 33c34c5705 | |||
| 0972aa2291 | |||
| 8b2a37e7b1 | |||
| c1139b492e | |||
| 94000d7320 | |||
| aaf8bbd470 | |||
| c8db08b82e | |||
| b81e38ec0b | |||
| 2a5bbf81ca | |||
| 3f710c6be5 | |||
| 3416e63f61 | |||
| f86a5be206 | |||
| 8ac075addf | |||
| d15518f149 | |||
| 9c8bcc6562 | |||
| 2cf92c01fb | |||
| 4575e76e98 | |||
| 5d53aa0544 | |||
| 22c2af60e8 | |||
| 4a6a7074ce | |||
| f92b08d9e1 | |||
| d42e5b0034 | |||
| c279331f64 | |||
| be176082f4 | |||
| 2c30fce4a2 | |||
| 17be8562d7 | |||
| 0cb3c46479 | |||
| f300eadf46 | |||
| 901c3d48a6 | |||
| bcb667b7f5 | |||
| 9040c8d4e9 | |||
| 99f36270c0 | |||
| 5a3cafc899 | |||
| ca9b92d39f | |||
| f57cdf69c8 | |||
| 18778321e8 | |||
| 56db843241 | |||
| d9d18969f0 | |||
| c309d41688 | |||
| 2ac2ce803e | |||
| a8482189a7 | |||
| 9e87c6033e | |||
| 692866105a | |||
| b5c8f2f808 | |||
| ba4aea2b35 | |||
| 3dc2b907da | |||
| 168eda8b3a | |||
| fa366ea698 | |||
| d67aacd867 | |||
| 33d2459c8d | |||
| ff82f12d5e | |||
| 0e2c2828fa | |||
| decfd5028c | |||
| ab54cc74d8 | |||
| 65743c17e0 | |||
| 84dc99bbe9 | |||
| 5be691946f | |||
| 675b1a05ea | |||
| d3d791f208 | |||
| 0e544a84e6 | |||
| 79a9b69e28 | |||
| 8f4a3ae2f1 | |||
| 3dd4e13cd6 | |||
| f00d4c451b | |||
| 18077e8b96 | |||
| 78fb3bf3df | |||
| fd0e2fec76 | |||
| 4d7325ef33 | |||
| 220a6d19b1 | |||
| 8826b45a5a | |||
| 1ec0ef254c | |||
| 941802c3d1 | |||
| 95fb95cb3e | |||
| 07e27f4746 | |||
| 9b672f584f | |||
| 8049c822ec | |||
| bf2de3499f | |||
| 8432e9ba39 | |||
| 5e17bdd0eb | |||
| 5ae009ad6d | |||
| a35ce8ef14 | |||
| 6730788f48 | |||
| 27e05b35a9 | |||
| b521e9ed8a | |||
| e0a411d4a4 | |||
| 0229dc83ea | |||
| 39dfcf7138 | |||
| 0b7c820a73 | |||
| dc51efed7e | |||
| df2a9e2a0a | |||
| d65bb1547b | |||
| d0d840eaed | |||
| 7e65c42f39 | |||
| 6b843dfac1 | |||
| d091ee027f | |||
| d18387534d | |||
| 9276c875dd | |||
| f1d52ce1aa | |||
| 9dc8c1b014 | |||
| 264d665380 | |||
| 4658b598b4 | |||
| 4ebe85b6a5 | |||
| 3e117fb6af | |||
| f5687e385b | |||
| b5ea0a4a52 | |||
| 8658d5c5b0 | |||
| 22edc02cf9 | |||
| 3f1e6d3c73 | |||
| 53d3f7fd89 | |||
| ba702c6731 | |||
| b8dc2b75a4 | |||
| 6d5d43bab3 | |||
| 285b024ebf | |||
| 26de0996d9 | |||
| 18ef2fc61e | |||
| 73733d1b4b | |||
| f0a794d200 | |||
| 235b0335ef | |||
| fea7cdb0ba | |||
| c319e83622 | |||
| 890aec679c | |||
| 377002f981 | |||
| c5e1dedb3c | |||
| b85226a64e | |||
| c05ce94476 | |||
| 2fa04d6d4b | |||
| f113b4cc91 | |||
| 883ceaf293 | |||
| d282117166 | |||
| d2b41f28a8 | |||
| 4d3e308a52 | |||
| a54217c8fd | |||
| fa0516e1c4 | |||
| 5b6d891d19 | |||
| 936649fc69 | |||
| 6a981df540 | |||
| 60eb215831 | |||
| 789d840942 | |||
| 8a898cb994 | |||
| a6c905fdac | |||
| fb179457ce | |||
| 9263acf92a | |||
| ecf8aad8ca | |||
| 225ff8f476 | |||
| 2d00ab58bf | |||
| dc2c453d63 | |||
| f3566b2674 | |||
| 5cc576de2f | |||
| 1ee938f8ef | |||
| 40a6466542 | |||
| f7cf45ab80 | |||
| 3e04a3cae9 | |||
| e967a609ae | |||
| 6a51c3b132 | |||
| 1dd5f6455f | |||
| 1ac07fdbcd | |||
| 19f28a9a35 | |||
| 6dbe0406b6 | |||
| 5738a677f2 | |||
| 7271bdaf04 | |||
| bd955d4add | |||
| 668932588a | |||
| 5a5534d815 | |||
| 52d4f11037 | |||
| 593eb8ee75 | |||
| 994190c63b | |||
| f2bb3ae677 | |||
| c992ccef67 | |||
| 56c256f030 | |||
| 3d3e3df555 | |||
| 69cf3d1ffb | |||
| da367cb720 | |||
| 8ab536ef8c | |||
| 6984aea08f | |||
| e2d53c3d9e | |||
| f62b5930a7 | |||
| 1a30e1bc5c | |||
| 1946941cd7 | |||
| 3e6c7834ed | |||
| b097747f75 | |||
| 93c366d35d | |||
| 9dbf0647b4 | |||
| 4698d64435 | |||
| b4cc78ec68 | |||
| bb28536f44 | |||
| f0f110ff74 | |||
| e7282f1fe6 | |||
| 23d08ac7be | |||
| 16614d8106 | |||
| 32261099c9 | |||
| e0a046d040 | |||
| 2a2113d1be | |||
| 4efbaec111 | |||
| 5fcd786eca | |||
| aef130f71e | |||
| d7d14a80ef | |||
| f1b73b438f | |||
| 1107dde0a1 | |||
| 11bdc5ab49 | |||
| ed3e48f765 | |||
| 9964700f5b | |||
| 17f1039b58 | |||
| 36d703a877 | |||
| 08b6eeeae3 | |||
| e3a87a68b9 | |||
| ad2c8da954 | |||
| f6453c1cde | |||
| c5f4b371fe | |||
| cf0352fa3b | |||
| 50726e2969 | |||
| 05a3688962 | |||
| 564c1a9392 | |||
| 1665e2d3b6 | |||
| fbedee57ef | |||
| e262e268b2 | |||
| 3ff4e0d771 | |||
| 8450217132 | |||
| b2bc7cc85c | |||
| 8a4cb9dd5e | |||
| 74a05d3fc8 | |||
| cb6400a485 | |||
| c525a81701 | |||
| 7938b1cced | |||
| 1444c9d07e | |||
| 54e0d9a55c | |||
| 9ddbe2cfb8 | |||
| cbf2ebdeee | |||
| 37c9edcbdf | |||
| 5dc7db71af | |||
| 868f172373 | |||
| 4bdb55f50b | |||
| 0c6d0ae8ed | |||
| 05b11fcb66 | |||
| 8d6e06a18a | |||
| ed2d5284f7 | |||
| 2be702e457 | |||
| 7c23e5eff3 | |||
| eeaf6aa373 | |||
| d44522b5f7 | |||
| 068deeb136 | |||
| 6bd8edfbde | |||
| 88b020ce95 | |||
| 999fb96f7b | |||
| f7bd77baf5 | |||
| 67c2776bae | |||
| dc82ac6eff | |||
| 0319f6ccac | |||
| 13ffbef897 | |||
| c15475c93b | |||
| 73c4f0de0e | |||
| c7d6dce97d | |||
| 45158bdb9d | |||
| 766acf6ce4 | |||
| 5d2fb0f679 | |||
| 583c8c1ebe | |||
| cf20428733 | |||
| 7e9b2809a9 | |||
| ed277edea0 | |||
| 0c3cdd4d79 | |||
| ae74081cc3 | |||
| 847af02833 | |||
| 176c6e8a23 | |||
| bcb2b60ff9 | |||
| 59a1e0f320 | |||
| 204f51c760 | |||
| 0d3b5bdc16 | |||
| 165ea8e3bb | |||
| 5f4d28ccf9 | |||
| 2b9cc5a966 | |||
| 363d415464 | |||
| 4d3769bf61 | |||
| bc97420bd4 | |||
| a5b7f1ab73 | |||
| a3eed2b0c0 | |||
| c695bf2783 | |||
| a8419f1a9d | |||
| 00c2507ab0 | |||
| 285286acf3 | |||
| 765e3e8e82 | |||
| 3e1f8e095c | |||
| 40f43aa1fc | |||
| d7381358f8 | |||
| 530239bbc9 | |||
| 92c1df4735 | |||
| 07053e3df5 | |||
| 86a42c8ac9 | |||
| 8caa580efd | |||
| 618689ef22 | |||
| 6237517812 | |||
| 5b8f6bcc0b | |||
| 2328f76997 | |||
| f58505164c | |||
| 0384e168e8 | |||
| 14b34c4af3 | |||
| 6dd47a844f | |||
| b310a2d7c0 | |||
| 7542409d39 | |||
| 5af229ea58 | |||
| 16ee776952 | |||
| e8fe560958 | |||
| 0600c266e9 | |||
| 4f5ffe5a7e | |||
| e5f0e7d200 | |||
| b9015c2c2b | |||
| fc025aeae5 | |||
| 3f7c4ee5c4 | |||
| dca17878da | |||
| 5db5737b4f | |||
| 7293bdf4cb | |||
| 44e65ebf62 | |||
| 5b6219a750 | |||
| 72d707a346 | |||
| 075e3c715d | |||
| 7fdfade8dc | |||
| 470b711740 | |||
| e1be3139a4 | |||
| cfa16a536e | |||
| 860f345ceb | |||
| 833711e3b8 | |||
| 204666c569 | |||
| 00ff61c64a | |||
| 0b777b60c6 | |||
| 071680021c | |||
| 04a9e1a834 | |||
| 5b243bb55d | |||
| 60414b0b11 | |||
| f337e9c2c9 | |||
| 6c9f235d93 | |||
| dd377953f7 | |||
| 2559de3be6 | |||
| 504e7efe76 | |||
| 138b92ce7f | |||
| 7d23e00836 | |||
| 05719ae21a | |||
| 2637d1d193 | |||
| 62d19b5336 | |||
| 4df7a2ef4f | |||
| 8b32d8e829 | |||
| b0f0e1bb3a | |||
| 7fdb5ee675 | |||
| fc9aacd2d7 | |||
| 7006fb7609 | |||
| aeb10b1c28 | |||
| c9cde2149e | |||
| ac11681809 | |||
| ddd8279beb | |||
| 6a729d0756 | |||
| 99a4959494 | |||
| c912cc7258 | |||
| 86b73f8e9c | |||
| 946db1620f | |||
| a488df2a95 | |||
| 4e0af3b107 | |||
| b7f00cff12 | |||
| ea7f759cbf | |||
| 297178bc87 | |||
| 82b7f28a61 | |||
| d40f5b74e6 | |||
| 214f6d7493 | |||
| a88c2ffdaa | |||
| 5775ef80c0 | |||
| 0eea4f9355 | |||
| 8d531749c3 | |||
| 6233a11b29 | |||
| 0a440a8682 | |||
| c6d734d3f9 | |||
| 2ec308a8b5 | |||
| 29308ee5da | |||
| eabc30d78b | |||
| 66064c5262 | |||
| 1c8bf4e4c2 | |||
| 64fa3a1f8f | |||
| be350cb127 | |||
| 0abcfef0c9 | |||
| ed8bd3952b | |||
| 25977a0eaf | |||
| abc011e5cc | |||
| 1bb997ecc3 | |||
| 200640a52c | |||
| 2494fa8c7b | |||
| 6931f8a7b5 | |||
| d6948ebc6a | |||
| 91cd49491c | |||
| c9a6c442a3 | |||
| 25da458902 | |||
| f8c7c3ae32 | |||
| cc4dae1350 | |||
| 1b2335b2c6 | |||
| ac1b88eab8 | |||
| 58520f98b0 | |||
| 3563da4aad | |||
| 15ad5491a4 | |||
| ec7125dc19 | |||
| 8353edcdf1 | |||
| b1b887fd84 | |||
| ba1674a11c | |||
| 9132d15eca | |||
| b97e501d33 | |||
| 4ead5c7e3c | |||
| a8e3b790b5 | |||
| e0af2ed26c | |||
| a964e03d4f | |||
| 0cec6e0c68 | |||
| f8ed98f83b | |||
| 6aac29e4ef | |||
| be8e377c91 | |||
| 3bdac46d14 | |||
| a08b933a00 | |||
| ccc64d9cf0 | |||
| 22dd4e275a | |||
| ecfa2d90ff | |||
| 6e7e89849a | |||
| 33dfd09c2d | |||
| 4e5fa682b5 | |||
| 1c47be2472 | |||
| 566e9d1313 | |||
| 26deeb61ab | |||
| c635d2acc8 | |||
| ce9dd0470a | |||
| 907e321018 | |||
| a7502277f2 | |||
| 5203f7252e | |||
| d5ca7a5706 | |||
| afeec49db6 | |||
| dbb552852a | |||
| 7e17fa336e | |||
| fc3a00b2dc | |||
| a3fd4aeea7 | |||
| eaad116912 | |||
| 522437d506 | |||
| 8473f41780 | |||
| d5694b16bb | |||
| ff302bdbb9 | |||
| ce32e5047d | |||
| 50371de63b | |||
| 257d6684ca | |||
| 4d502df33f | |||
| 9008efba33 | |||
| 3e328cac4e | |||
| ab8eeb7b5a | |||
| 5c451f237d | |||
| d062a31039 | |||
| 58d4c2f1c0 | |||
| 974fc258fb | |||
| 25c052dbd7 | |||
| 4b50cb9857 | |||
| 79aa617250 | |||
| 5ed7235b17 | |||
| 2548ed0c9c | |||
| abe74df9d9 | |||
| 5642a74c63 | |||
| a723bf77c4 | |||
| 4904f5c7a5 | |||
| e38cd94623 | |||
| 4c75fbc5bb | |||
| 84f78756c8 | |||
| 095c40469a | |||
| cb60bc9eda | |||
| 811c6b01e0 | |||
| 210caf54a8 | |||
| 6480900924 | |||
| c5de7683ad | |||
| 63aaa32f88 | |||
| 49aeee2bf6 | |||
| a863e9a119 | |||
| 53bbf98533 | |||
| f6ae5aee7c | |||
| 55271966bf | |||
| 2266595f2f | |||
| 33d78656e4 | |||
| 76cf7cce29 | |||
| b4c11424e2 | |||
| 7f5f3d5f28 | |||
| 43ba326a82 | |||
| b3469a7e13 | |||
| 4761566c54 | |||
| 9333d66af5 | |||
| cd7bc967e3 | |||
| 00a00321ae | |||
| 430196f1a0 | |||
| dab7fce2aa | |||
| 19907e0cfa | |||
| 2be1f0f6bb | |||
| 81bfdff8dd | |||
| 81d923af09 | |||
| 619b3ca8db | |||
| 52fbb269fd | |||
| 1e27409e63 | |||
| 35c9a930f3 | |||
| 717d379f57 | |||
| 98ee46df71 | |||
| cb00cf26de | |||
| 013c9869e1 | |||
| a11abf14cb | |||
| ef4ad6c66e | |||
| a7d006a0d9 | |||
| 6900784f92 | |||
| d6756ebbbc | |||
| a87249f196 | |||
| 868282ddc0 | |||
| 7b6da3346c | |||
| a75f4ef3e3 | |||
| d1453ce26e | |||
| 4aa2dc193f | |||
| 1dcf42a4ba | |||
| a4a66fc93b | |||
| 338efed0ca | |||
| d2957326c8 | |||
| 81e19d3595 | |||
| b7144a35b3 | |||
| 3202bd7416 | |||
| 9e4ae46a4b | |||
| 4a0f06d551 | |||
| a5f1acc2b4 | |||
| ac6fa5eb90 | |||
| c4c1a7737f | |||
| 375f8d33f8 | |||
| 5612af0dba | |||
| e80944a42a | |||
| 08403fd61c | |||
| 02bd2e0d38 | |||
| 36d2ca6559 | |||
| 7a92a518b3 | |||
| a62cc62551 | |||
| 794d8721c0 | |||
| c75d22a17c | |||
| e7b43fe5a2 | |||
| 3b0d855c3c | |||
| eebf6e2a47 | |||
| 5ee185d12e | |||
| b35f76841d | |||
| 011508b2b0 | |||
| e1a0eb49d6 | |||
| 09846a54ad | |||
| 06d7ef9cd3 | |||
| 14156d6b54 | |||
| 104838c9db | |||
| 1a632495f7 | |||
| 6ededd5f41 | |||
| 36103b02fa | |||
| c1427112a1 | |||
| cba041369f | |||
| a559555e6c | |||
| 244f618892 | |||
| 27bb711fe9 | |||
| d77bd5ecbe | |||
| 24b3c8307f | |||
| bad6da7acc | |||
| 70e10c77f3 | |||
| 9523ad0ab7 | |||
| ee20235449 | |||
| 17afefef30 | |||
| d0131dbd89 | |||
| 64b489a10d | |||
| 8ed7f23e33 | |||
| 08f256c416 | |||
| 27278d2346 | |||
| bb4bfe13df | |||
| c124578f93 | |||
| 2e2892ce89 | |||
| 896c18e842 | |||
| a3752a0b13 | |||
| fc0e5e988e | |||
| 4ea6f1f0ef | |||
| 8bb10719d6 | |||
| 2fa4b6d68e | |||
| 9e65d861f7 | |||
| 92db621b5d | |||
| 119fb86673 | |||
| 056ac15288 | |||
| be4dd6c79b | |||
| 9743ed49b9 | |||
| eafe828b26 | |||
| 16ba1b0cf2 | |||
| 6d1ad6b3e1 | |||
| e56fb50a4a | |||
| 519b6676c8 | |||
| 0c46637a1a | |||
| 326cf96333 | |||
| 2bb2aa4dbb | |||
| fc4a2fffc6 | |||
| b173ea77d9 | |||
| 441df375b6 | |||
| 1adb0ebb50 | |||
| 5a948984c4 | |||
| 6df78935f8 | |||
| 45b20961da | |||
| 14975c1946 | |||
| d9b9b40a71 | |||
| d9c7b58af6 | |||
| 990e04d823 | |||
| b8e8419bfc | |||
| 791ad685b2 | |||
| 6142a99373 | |||
| 72c475f9ab | |||
| 1ea47ba4c0 | |||
| 89d2e91d13 | |||
| 3941cc43f1 | |||
| f545230234 | |||
| d0d5d320b1 | |||
| 4217056ab9 | |||
| c90933facf | |||
| edc62676a2 | |||
| f2ee9706a2 | |||
| 42cf57fb26 | |||
| 59a24c227e | |||
| 77db689064 | |||
| 4e5813e6f2 | |||
| 53cda2de31 | |||
| c1ef755c30 | |||
| 8b435d0993 | |||
| 4912df1582 | |||
| 6e45019417 | |||
| d8ee4dfa6e | |||
| 8f09118ae0 | |||
| 176307a26a | |||
| 58af55c35e | |||
| afac1a0781 | |||
| a1353477c4 | |||
| 3ae767d8ba | |||
| bdadff33ff | |||
| 94beeb79c7 | |||
| 056a54babe | |||
| 04038968be | |||
| 6d3da6bf92 | |||
| b3ebb9802e | |||
| 12a113f24e | |||
| 8f5c5184aa | |||
| 9d6a3d1513 | |||
| 5f3315e78e | |||
| 5f084a4ecb | |||
| 2115a30667 | |||
| dee938a59e | |||
| 582e15dfd2 | |||
| d2219dda26 | |||
| cf8781f41c | |||
| 2fca979ee3 | |||
| 85ab48b33f | |||
| 3929ee53cd | |||
| cf6e361c02 | |||
| 8909a7a075 | |||
| 0fb90ef70b | |||
| b21ca22e1f | |||
| cfb5feb8b5 | |||
| bc304733e8 | |||
| 90cef3dc05 | |||
| b4deed5688 | |||
| 11b9b76181 | |||
| e3f5d9654a | |||
| 8ead149149 | |||
| 08d82f5688 | |||
| 1a78d381ff | |||
| 2c00ee97df | |||
| 1a35d7472f | |||
| 4d85a640dd | |||
| c8693d4dc1 | |||
| 3d5f5f6021 | |||
| 8ab940c495 | |||
| 0fe0327175 | |||
| cd73c31074 | |||
| 995a53787b | |||
| 6f04b5d626 | |||
| 522803d42a | |||
| 815673e92f | |||
| 69a4aef1e1 | |||
| d0796153bf | |||
| 0fe09ea8fe | |||
| 8490c5350e | |||
| 8ca956147b | |||
| 04139219e7 | |||
| 24bcd2e3b1 | |||
| 393150a996 | |||
| 903740173f | |||
| ce97dd9102 | |||
| 2efdf88b94 | |||
| ff3cf1e507 | |||
| aaef7468ac | |||
| fb529d5c10 | |||
| 6a1a00bc50 | |||
| fb87e8ae3b | |||
| 60a4797402 | |||
| cdedf35b0f | |||
| b3c26633e5 | |||
| 1e73338065 | |||
| d184f8f9b7 | |||
| 537e8dedfa | |||
| 1463bdc4ee | |||
| 6ba839a768 | |||
| 42ae2fccb2 | |||
| d770f41a00 | |||
| e9a5857b7d | |||
| 57a676ee7a | |||
| a48ae8ec5d | |||
| fa9ad7b620 | |||
| c10cac4e4a | |||
| e4e1faa6ab | |||
| b72d8a7b98 | |||
| fbaf314c87 | |||
| eb8a6e6c60 | |||
| 5bdacd72ef | |||
| 46bdf8d1a8 | |||
| 05bab49047 | |||
| f6b74139d7 | |||
| 44445b034f | |||
| 85c9758459 | |||
| f75cf3a13d | |||
| 41b08f2d96 | |||
| 366c49848f | |||
| 5d735c5281 | |||
| f91a5b733a | |||
| 6d3bcb44dd | |||
| 41c88b8cda | |||
| 228d5ecb07 | |||
| 38161091d6 | |||
| 67945637f3 | |||
| 0646497a1e | |||
| 69eedfa2fe | |||
| 6c5efa9157 | |||
| 7d1b0eee29 | |||
| 0cd2561466 | |||
| 4e3dad540c | |||
| 7135ffca51 | |||
| 6a021d6fc4 | |||
| 211e9c6d3f | |||
| 071aeb9926 | |||
| d5defbf5a8 | |||
| a17ca7ba09 | |||
| 31248c5d9c | |||
| dd861fbc33 | |||
| 3aa5023ef9 | |||
| c92718aa13 | |||
| f991a28d5c | |||
| 76980fca70 | |||
| 481425fadb | |||
| 8453485495 | |||
| 5cf2c57a22 | |||
| f2723764f7 | |||
| 2b22a5f423 | |||
| 745a099abf | |||
| b687218970 | |||
| 92a1d319fc | |||
| 98547f476f | |||
| dddcaf6358 | |||
| 98a6fc4a3b | |||
| 7499f511c8 | |||
| 359ee558f0 | |||
| 7b5f66308c | |||
| 81c9dd751a | |||
| 0a48ba0c0b | |||
| 915e268e62 | |||
| 5fc40f4208 | |||
| aa37778ca3 | |||
| 482b3d1677 | |||
| f018ef4a52 | |||
| e8fc2358ca | |||
| 7e33b18807 | |||
| 219927349a | |||
| f6d8678098 | |||
| 71494eb0b1 | |||
| 3e6e9eaa52 | |||
| 442e308648 | |||
| 48f66dd36e | |||
| c0d1c8f9cb | |||
| f46a06d08c | |||
| 6d7ab89b65 | |||
| 2e978de3d1 | |||
| a999da51c5 | |||
| 150692da89 | |||
| d01930668d | |||
| 809baca60a | |||
| 594676271f | |||
| a8f56ba982 | |||
| aa4847c757 | |||
| 29cf643cad | |||
| c546706479 | |||
| 3d94c5e08e | |||
| 3724757d96 | |||
| 11551df2c3 | |||
| d09ab40142 | |||
| 435d7bdba9 | |||
| 7e340b3e8d | |||
| 384a9cbda9 | |||
| 8b405ab59b | |||
| 6543cbde7a | |||
| 6e0fd47067 | |||
| 90f36eaf96 | |||
| 13beed44aa | |||
| 1db25b8950 | |||
| 4288cc0e90 | |||
| fdd91b7098 | |||
| 7da47c8128 | |||
| 2e8b9f7325 | |||
| 9a873b571d | |||
| eab9dead49 | |||
| 3a267ca3a0 | |||
| b1e96ca8b2 | |||
| 360342a41f | |||
| ce249c4de5 | |||
| a32126839c | |||
| 020eae6335 | |||
| d5d95c5e02 | |||
| 038ee13b04 | |||
| d6beb4690a | |||
| 893194c625 | |||
| 55c7250333 | |||
| b4f675e1d5 | |||
| 96e3537213 | |||
| 7823acb0c9 | |||
| 5e691be585 | |||
| b7049c9222 | |||
| 8941942a02 | |||
| e685d5838d | |||
| 70efa359e2 | |||
| edc0fe896d | |||
| fbaa57cbf8 | |||
| 2ee13c5c8b | |||
| a7212cb9c7 | |||
| e63938ba8a | |||
| 6597b34eeb | |||
| c6ed8589e0 | |||
| bebdb9b162 | |||
| 677ab5e475 | |||
| 4a4b110509 | |||
| 5e919c34ee | |||
| 00f65b4e5d | |||
| 4ad8ec74e7 | |||
| 8e48cb7180 | |||
| 6a3ba4e585 | |||
| b16832dd09 | |||
| e88133dc12 | |||
| 841d2ca4c9 | |||
| 319e0b83a5 | |||
| 210f57ff8a | |||
| 7ee7b84e9d | |||
| 7cc3f26d18 | |||
| 8ac54989eb | |||
| 867354f9ae | |||
| b27db1be63 | |||
| b39a4fec6a | |||
| a358f9b4e2 | |||
| cde191082a | |||
| fcad0318e9 | |||
| 2f40c9ea94 | |||
| d5f05bd60e | |||
| 94707762b5 | |||
| bcdb15f066 | |||
| 0846150380 | |||
| f39432cafe | |||
| 8809b99a1f | |||
| aaf277889b | |||
| f7266dd323 | |||
| ee41a6a7c8 | |||
| 8b378edc14 | |||
| e3dccebf8d | |||
| e21b7f0a57 | |||
| 74812cb716 | |||
| 7931e74e44 | |||
| 612f6992c5 | |||
| 30a16e7e83 | |||
| 8b6f55ee7a | |||
| 2b0e9d6ef9 | |||
| 8336513809 | |||
| 0b0ff32d3c | |||
| 45bddb6e6d | |||
| 5a27d062ee | |||
| 551f994986 | |||
| 1e5d9d5d5f | |||
| 1914e3a8f3 | |||
| 650044d9a2 | |||
| fb38e114e7 | |||
| 6d19ce3361 | |||
| 2bf84bba09 | |||
| 6bfe184be4 | |||
| b85eb9fa4a | |||
| c5c60abd3e | |||
| 0c3f1da5b6 | |||
| a27b6c2c52 | |||
| cdb4e23f90 | |||
| e19f971389 | |||
| 47405f9b6f | |||
| e04584907b | |||
| 3dff7f538b | |||
| bef2f86f04 | |||
| cf5a890bd6 | |||
| 244d9553ca | |||
| f8c11d0afc | |||
| bdd77c8326 | |||
| c470dada5b | |||
| 472bce6d12 | |||
| aeb50096a1 | |||
| 8af53beeec | |||
| ede4316c01 | |||
| 49fa880ef6 | |||
| 7063eb9fbb | |||
| abbad4af13 | |||
| 40c6886f95 | |||
| 49ce7ff03c | |||
| a4fbad6e80 | |||
| 646a6d9481 | |||
| 936450330a | |||
| ac331d6a4a | |||
| 29858f020e | |||
| 625faf10a3 | |||
| f9144364f4 | |||
| e19c5c1018 | |||
| 516c425215 | |||
| 28215f3286 | |||
| d815125160 | |||
| 56ce5f0965 | |||
| 0e319f934d | |||
| 35c114a9dc | |||
| 8d62aacbda | |||
| 4a7cd55555 | |||
| 8608db739d | |||
| 4c8aa550dd | |||
| 290084cfdc | |||
| cc2c883f80 | |||
| 7914d49318 | |||
| 4776de0668 | |||
| 478c9e9380 | |||
| 1258810abc | |||
| ca005e23f7 | |||
| ec74fb3501 | |||
| bee3222be8 | |||
| 8241c5e324 | |||
| 47641637e5 | |||
| 8ee76d1ffe | |||
| 86bea5c65e | |||
| 7a158dac13 | |||
| b782e682f0 | |||
| 94f07cd524 | |||
| eee9477bfd | |||
| c2325b6ffd | |||
| c09019a4b5 | |||
| b1abcbd50a | |||
| ced48de808 | |||
| 01d786178d | |||
| 46387ff2ae | |||
| b34fc1be24 | |||
| c971067f91 | |||
| 64b0ce50b7 | |||
| 36f4fa0c2d | |||
| a1d04b878b | |||
| 3ab263074c | |||
| b024b748c7 | |||
| 22ee674191 | |||
| 0f132d1bee | |||
| c58f9a458e | |||
| d54a1b6712 | |||
| 3ffbc9a3e0 | |||
| 0741bdca11 | |||
| ba79369331 | |||
| 0a4025eaa5 | |||
| 1ce63d3fc2 | |||
| b9ecfd4957 | |||
| 16ef809654 |
-27
@@ -1,27 +0,0 @@
|
||||
# This file specifies intentionally untracked files that all Moodle git
|
||||
# repositories should ignore. It is recommended not to modify this file in your
|
||||
# local clone. Instead, use .git/info/exclude and add new records there as
|
||||
# needed.
|
||||
#
|
||||
# Example: if you deploy a contributed plugin mod/foobar into your site, put
|
||||
# the following line into .git/info/exclude file in your Moodle clone:
|
||||
# /mod/foobar/
|
||||
#
|
||||
# See gitignore(5) man page for more details
|
||||
#
|
||||
/config.php
|
||||
/lib/editor/tinymce/extra/tools/temp/
|
||||
*~
|
||||
*.swp
|
||||
/tags
|
||||
/TAGS
|
||||
/cscope.*
|
||||
/.patches/
|
||||
/.idea/
|
||||
/nbproject/
|
||||
CVS
|
||||
.DS_Store
|
||||
/.settings/
|
||||
/.project
|
||||
/.buildpath
|
||||
/.cache
|
||||
-674
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
+13
-6
@@ -1,18 +1,21 @@
|
||||
README $Id$
|
||||
------
|
||||
|
||||
QUICK INSTALL
|
||||
=============
|
||||
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
a few minutes:
|
||||
|
||||
1) Move the Moodle files into your web directory.
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create a single database for Moodle to store all
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
be taken to the install.php script, which will lead
|
||||
you through creating a config.php file and then
|
||||
you through creating a config.php file and then
|
||||
setting up Moodle, creating an admin account etc.
|
||||
|
||||
4) Set up a cron task to call the file admin/cron.php
|
||||
@@ -21,7 +24,11 @@ a few minutes:
|
||||
|
||||
For more information, see the INSTALL DOCUMENTATION:
|
||||
|
||||
http://docs.moodle.org/en/Installing_Moodle
|
||||
http://docs.moodle.org/en/Installing_Moodle
|
||||
|
||||
A local copy can also be found in
|
||||
|
||||
lang/en_utf8/help/install.html (or your language)
|
||||
|
||||
|
||||
Good luck and have fun!
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
------------------------
|
||||
Moodle Trademark License
|
||||
------------------------
|
||||
|
||||
The name Moodle™ is a registered trademark of the Moodle Trust.
|
||||
|
||||
A key part of the business model that allows us to produce and
|
||||
distribute Moodle as completely Free open source software is that
|
||||
we restrict the commercial use of the Moodle trademark to those
|
||||
who have contracted to support Moodle development (Moodle Partners).
|
||||
|
||||
If you are intending to use the name (and/or logo) to advertise
|
||||
generic Moodle™ services (eg Moodle Hosting, Moodle Support,
|
||||
Moodle Certification, Moodle Training, Moodle Consulting,
|
||||
Moodle Customisation, Moodle Courseware Development, Moodle
|
||||
Theme design, Moodle Integrations, Moodle Installations, etc)
|
||||
or as the name of a software package, then you must seek
|
||||
direct permission in writing from the Moodle Trust via the
|
||||
moodle.com helpdesk, in accordance with normal trademark
|
||||
restrictions.
|
||||
|
||||
There are no restrictions on how you use the name in other
|
||||
contexts (for example, if you use Moodle just to provide
|
||||
courses then you can use the name freely to refer to it.)
|
||||
|
||||
If you aren't sure of a particular case, please ask us via
|
||||
http://moodle.com/helpdesk: we'll be happy to either provide
|
||||
you with official permission in writing or help you fix
|
||||
your wording.
|
||||
|
||||
Martin Dougiamas
|
||||
Executive Director
|
||||
Moodle Trust
|
||||
http://moodle.com
|
||||
+9
-10
@@ -14,13 +14,14 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
|
||||
|
||||
$PAGE->set_url($returnurl);
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$authsavailable = get_list_of_plugins('auth');
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
$authsenabled = array();
|
||||
@@ -29,7 +30,7 @@ if (empty($CFG->auth)) {
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
|
||||
error(get_string('pluginnotinstalled', 'auth', $auth), $url);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -51,7 +52,6 @@ switch ($action) {
|
||||
if ($auth == $CFG->registerauth) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
session_gc(); // remove stale sessions
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
@@ -61,14 +61,13 @@ switch ($action) {
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
session_gc(); // remove stale sessions
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
}
|
||||
// move down the list
|
||||
if ($key < (count($authsenabled) - 1)) {
|
||||
@@ -83,7 +82,7 @@ switch ($action) {
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
}
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
@@ -98,6 +97,6 @@ switch ($action) {
|
||||
break;
|
||||
}
|
||||
|
||||
redirect($returnurl);
|
||||
|
||||
redirect ($returnurl);
|
||||
|
||||
?>
|
||||
|
||||
+26
-26
@@ -7,7 +7,8 @@ require_once '../config.php';
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
|
||||
$auth = required_param('auth', PARAM_SAFEDIR);
|
||||
$PAGE->set_pagetype('admin-auth-' . $auth);
|
||||
|
||||
$CFG->pagepath = 'auth/' . $auth;
|
||||
|
||||
admin_externalpage_setup('authsetting'.$auth);
|
||||
|
||||
@@ -18,6 +19,7 @@ $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
|
||||
// save configuration changes
|
||||
if ($frm = data_submitted() and confirm_sesskey()) {
|
||||
$frm = stripslashes_recursive($frm);
|
||||
|
||||
$authplugin->validate_form($frm, $err);
|
||||
|
||||
@@ -31,7 +33,9 @@ if ($frm = data_submitted() and confirm_sesskey()) {
|
||||
if (preg_match('/^lockconfig_(.+?)$/', $name, $matches)) {
|
||||
$plugin = "auth/$auth";
|
||||
$name = $matches[1];
|
||||
set_config($name, $value, $plugin);
|
||||
if (!set_config($name, $value, $plugin)) {
|
||||
error("Problem saving config $name as $value for plugin $plugin");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect($returnurl);
|
||||
@@ -43,13 +47,10 @@ if ($frm = data_submitted() and confirm_sesskey()) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$frmlegacystyle = get_config('auth/'.$auth);
|
||||
$frmnewstyle = get_config('auth_'.$auth);
|
||||
$frm = (object)array_merge((array)$frmlegacystyle, (array)$frmnewstyle);
|
||||
$frm = get_config("auth/$auth");
|
||||
}
|
||||
|
||||
$user_fields = $authplugin->userfields;
|
||||
//$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "institution", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
|
||||
/// Get the auth title (from core or own auth lang files)
|
||||
$authtitle = $authplugin->get_title();
|
||||
@@ -57,28 +58,28 @@ $user_fields = $authplugin->userfields;
|
||||
$authdescription = $authplugin->get_description();
|
||||
|
||||
// output configuration form
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
// choose an authentication method
|
||||
echo "<form id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
|
||||
echo "<form $CFG->frametarget id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
|
||||
echo "<div>\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"auth\" value=\"".$auth."\" />\n";
|
||||
|
||||
// auth plugin description
|
||||
echo $OUTPUT->box_start();
|
||||
echo $OUTPUT->heading($authtitle);
|
||||
echo $OUTPUT->box_start('informationbox');
|
||||
print_simple_box_start('center', '80%');
|
||||
print_heading($authtitle);
|
||||
print_simple_box_start('center', '80%', '', 5, 'informationbox');
|
||||
echo $authdescription;
|
||||
echo $OUTPUT->box_end();
|
||||
print_simple_box_end();
|
||||
echo "<hr />\n";
|
||||
$authplugin->config_form($frm, $err, $user_fields);
|
||||
echo $OUTPUT->box_end();
|
||||
print_simple_box_end();
|
||||
echo '<p style="text-align: center"><input type="submit" value="' . get_string("savechanges") . "\" /></p>\n";
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
@@ -88,12 +89,12 @@ exit;
|
||||
// other options
|
||||
// Note: lockconfig_ fields have special handling.
|
||||
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
|
||||
global $OUTPUT;
|
||||
|
||||
echo '<tr><td colspan="3">';
|
||||
if ($retrieveopts) {
|
||||
echo $OUTPUT->heading(get_string('auth_data_mapping', 'auth'));
|
||||
print_heading(get_string('auth_data_mapping', 'auth'));
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('auth_fieldlocks', 'auth'));
|
||||
print_heading(get_string('auth_fieldlocks', 'auth'));
|
||||
}
|
||||
echo '</td></tr>';
|
||||
|
||||
@@ -134,11 +135,10 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
|
||||
$fieldname = get_string('language');
|
||||
} elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
|
||||
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
|
||||
} elseif ($fieldname == 'url') {
|
||||
$fieldname = get_string('webpage');
|
||||
} else {
|
||||
$fieldname = get_string($fieldname);
|
||||
}
|
||||
|
||||
if ($retrieveopts) {
|
||||
$varname = 'field_map_' . $field;
|
||||
|
||||
@@ -149,23 +149,23 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
|
||||
echo "<input id=\"lockconfig_{$varname}\" name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\" />";
|
||||
echo '<div style="text-align: right">';
|
||||
echo '<label for="menulockconfig_field_updatelocal_'.$field.'">'.get_string('auth_updatelocal', 'auth') . '</label> ';
|
||||
echo html_writer::select($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, false);
|
||||
choose_from_menu($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, "");
|
||||
echo '<br />';
|
||||
if ($updateopts) {
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
echo html_writer::select($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, false);
|
||||
choose_from_menu($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, "");
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
}
|
||||
echo '</td>';
|
||||
if (!empty($helptext)) {
|
||||
@@ -176,4 +176,4 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+13
-19
@@ -1,28 +1,29 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
|
||||
// block.php - allows admin to edit all local configuration variables for a block
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
|
||||
if(!$blockrecord = blocks_get_record($blockid)) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
error('This block does not exist');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('blocksetting'.$blockrecord->name);
|
||||
|
||||
$block = block_instance($blockrecord->name);
|
||||
if($block === false) {
|
||||
print_error('blockcannotinistantiate', 'error');
|
||||
error('Problem in instantiating block object');
|
||||
}
|
||||
|
||||
// Define the data we're going to silently include in the instance config form here,
|
||||
// so we can strip them from the submitted data BEFORE handling it.
|
||||
$hiddendata = array(
|
||||
'block' => $blockid,
|
||||
'sesskey' => sesskey()
|
||||
'sesskey' => $USER->sesskey
|
||||
);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
@@ -30,10 +31,10 @@
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
print_error('blockcannotconfig', 'error');
|
||||
error('This block does not support global configuration');
|
||||
}
|
||||
$remove = array_keys($hiddendata);
|
||||
foreach($remove as $item) {
|
||||
@@ -49,14 +50,11 @@
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo $OUTPUT->heading($strblockname);
|
||||
print_heading($strblockname);
|
||||
|
||||
echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
|
||||
'It must be updated by a developer to use a settings.php file.');
|
||||
|
||||
echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
|
||||
print_simple_box(get_string('configwarning', 'admin'), 'center', '50%');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
@@ -65,12 +63,8 @@
|
||||
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
|
||||
}
|
||||
echo '</p>';
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
include($CFG->dirroot.'/blocks/'. $block->name() .'/config_global.html');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$block->config_print();
|
||||
echo '</form>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+106
-78
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure blocks (hide/show, delete and configure)
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
|
||||
admin_externalpage_setup('manageblocks');
|
||||
|
||||
@@ -12,6 +14,7 @@
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
|
||||
/// Print headings
|
||||
|
||||
@@ -23,64 +26,79 @@
|
||||
$strsettings = get_string('settings');
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) && confirm_sesskey()) {
|
||||
if (!$block = $DB->get_record('block', array('id'=>$hide))) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
if (!$block = get_record('block', 'id', $hide)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
|
||||
set_field('block', 'visible', '0', 'id', $block->id); // Hide block
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($show) && confirm_sesskey() ) {
|
||||
if (!$block = $DB->get_record('block', array('id'=>$show))) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
if (!$block = get_record('block', 'id', $show)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
|
||||
set_field('block', 'visible', '1', 'id', $block->id); // Show block
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($multiple) && confirm_sesskey()) {
|
||||
if (!$block = blocks_get_record($multiple)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
admin_externalpage_print_header();
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', "block_$block->name")) {
|
||||
$strblockname = get_string('pluginname', "block_$block->name");
|
||||
} else {
|
||||
if (!block_is_compatible($block->name)) {
|
||||
$strblockname = $block->name;
|
||||
}
|
||||
else {
|
||||
$blockobject = block_instance($block->name);
|
||||
$strblockname = $blockobject->get_title();
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete='.$block->id.'&confirm=1', 'blocks.php');
|
||||
echo $OUTPUT->footer();
|
||||
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php');
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// Inform block it's about to be deleted
|
||||
if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
|
||||
$blockobject = block_instance($block->name);
|
||||
if ($blockobject) {
|
||||
$blockobject->before_delete(); //only if we can create instance, block might have been already removed
|
||||
}
|
||||
$blockobject = block_instance($block->name);
|
||||
if ($blockobject) {
|
||||
$blockobject->before_delete(); //only if we can create instance, block might have been already removed
|
||||
}
|
||||
|
||||
// First delete instances and then block
|
||||
$instances = $DB->get_records('block_instances', array('blockname' => $block->name));
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
blocks_delete_instance($instance, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete block
|
||||
$DB->delete_records('block', array('id'=>$block->id));
|
||||
if (!delete_records('block', 'id', $block->id)) {
|
||||
notify("Error occurred while deleting the $strblockname record from blocks table");
|
||||
}
|
||||
|
||||
drop_plugin_tables($block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false); // old obsoleted table names
|
||||
drop_plugin_tables('block_'.$block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false);
|
||||
@@ -88,7 +106,7 @@
|
||||
// Delete the capabilities that were defined by this block
|
||||
capabilities_cleanup('block/'.$block->name);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
// remove entent handlers and dequeue pending events
|
||||
events_uninstall('block/'.$block->name);
|
||||
|
||||
$a->block = $strblockname;
|
||||
@@ -97,56 +115,59 @@
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
admin_externalpage_print_header();
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
/// Main display starts here
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (!$blocks = $DB->get_records('block', array(), 'name ASC')) {
|
||||
print_error('noblocks', 'error'); // Should never happen
|
||||
if (false === ($blocks = get_records('block'))) {
|
||||
error('No blocks found!'); // Should never happen
|
||||
}
|
||||
|
||||
$incompatible = array();
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
notify('Block '. $block->name .' is not compatible with the current version of Moodle and needs to be updated by a programmer.');
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
if(($blockobject = block_instance($block->name)) === false) {
|
||||
// Failed to load
|
||||
continue;
|
||||
}
|
||||
$blockbyname[$blockobject->get_title()] = $block->id;
|
||||
$blockobjects[$block->id] = $blockobject;
|
||||
}
|
||||
|
||||
if(empty($blockbyname)) {
|
||||
error('One or more blocks are registered in the database, but they all failed to load!');
|
||||
}
|
||||
|
||||
ksort($blockbyname);
|
||||
|
||||
/// Print the table of all blocks
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'multiple', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
foreach ($blocks as $blockid=>$block) {
|
||||
$blockname = $block->name;
|
||||
foreach ($blockbyname as $blockname => $blockid) {
|
||||
|
||||
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blockobject = false;
|
||||
$strblockname = '<span class="notifyproblem">'.$blockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = $block->version;
|
||||
$blockobject = $blockobjects[$blockid];
|
||||
$block = $blocks[$blockid];
|
||||
|
||||
} else {
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = '???';
|
||||
if (file_exists("$CFG->dirroot/blocks/$blockname/version.php")) {
|
||||
include("$CFG->dirroot/blocks/$blockname/version.php");
|
||||
}
|
||||
|
||||
if (!$blockobject = block_instance($block->name)) {
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
$strblockname = get_string('pluginname', 'block_'.$blockname);
|
||||
}
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if ($blockobject and $blockobject->has_config()) {
|
||||
if ($blockobject->has_config()) {
|
||||
if (file_exists($CFG->dirroot.'/blocks/'.$block->name.'/settings.php')) {
|
||||
$settings = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=blocksetting'.$block->name.'">'.$strsettings.'</a>';
|
||||
} else {
|
||||
@@ -157,11 +178,15 @@
|
||||
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
|
||||
// and it should not show up on course search page
|
||||
|
||||
$totalcount = $DB->count_records('block_instances', array('blockname'=>$blockname));
|
||||
$count = $DB->count_records('block_instances', array('blockname'=>$blockname, 'pagetypepattern'=>'course-view-*'));
|
||||
$totalcount = count_records('block_instance', 'blockid', $blockid);
|
||||
|
||||
$count = count_records_sql('SELECT COUNT(*)
|
||||
FROM '.$CFG->prefix.'block_instance
|
||||
WHERE blockid = '.$blockid.' AND
|
||||
pagetype = \'course-view\'');
|
||||
|
||||
if ($count>0) {
|
||||
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&sesskey=".sesskey()."\" ";
|
||||
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&sesskey={$USER->sesskey}\" ";
|
||||
$blocklist .= "title=\"$strshowblockcourse\" >$totalcount</a>";
|
||||
}
|
||||
else {
|
||||
@@ -169,30 +194,32 @@
|
||||
}
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if (!$blockobject) {
|
||||
// ignore
|
||||
$visible = '';
|
||||
} else if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.sesskey().'" title="'.$strhide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon" alt="'.$strhide.'" /></a>';
|
||||
if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon" alt="'.$strhide.'" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.sesskey().'" title="'.$strshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon" alt="'.$strshow.'" /></a>';
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon" alt="'.$strshow.'" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
|
||||
if ($block->version == $plugin->version) {
|
||||
$version = $block->version;
|
||||
} else {
|
||||
$version = "$block->version ($plugin->version)";
|
||||
if ($blockobject->instance_allow_multiple()) {
|
||||
if($blocks[$blockid]->multiple) {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('yes').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
else {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('no').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$multiple = '';
|
||||
}
|
||||
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$strblockname.'</span>',
|
||||
'<span'.$class.'>'.$blockobject->get_title().'</span>',
|
||||
$blocklist,
|
||||
'<span'.$class.'>'.$version.'</span>',
|
||||
'<span'.$class.'>'.$blockobject->get_version().'</span>',
|
||||
$visible,
|
||||
$multiple,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
@@ -200,8 +227,8 @@
|
||||
|
||||
$table->print_html();
|
||||
|
||||
if (!empty($incompatible)) {
|
||||
echo $OUTPUT->heading(get_string('incompatibleblocks', 'blockstable', 'admin'));
|
||||
if(!empty($incompatible)) {
|
||||
print_heading(get_string('incompatibleblocks', 'admin'));
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
@@ -209,19 +236,20 @@
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('class', 'incompatibleblockstable generaltable');
|
||||
$table->set_attribute('id', 'incompatible');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
$table->add_data(array(
|
||||
$block->name,
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>',
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>',
|
||||
));
|
||||
}
|
||||
$table->print_html();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
/// Create "blog" forums in each course and copy blog entries from these courses' participants in these forums
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/blog/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('bloglevelupgrade');
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
|
||||
$go = optional_param('go', 0, PARAM_BOOL);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('bloglevelupgrade', 'admin'));
|
||||
|
||||
$strbloglevelupgrade = get_string('bloglevelupgradeinfo', 'admin');
|
||||
|
||||
if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
|
||||
$optionsyes = array('go'=>1, 'sesskey'=>sesskey());
|
||||
echo $OUTPUT->confirm($strbloglevelupgrade, new moodle_url('bloglevelupgrade.php', $optionsyes), 'index.php');
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
$i = 0;
|
||||
|
||||
// If $CFG->bloglevel is set to BLOG_GROUP_LEVEL or BLOG_COURSE_LEVEL, create a new "blog" forum in each course
|
||||
// whose enrolled students have written blog entries, copy these entries in that forum and switch off blogs at site level
|
||||
|
||||
if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
|
||||
$pbar = new progress_bar('bloglevelupgrade', 500, true);
|
||||
|
||||
$bloggers = $DB->get_records_sql("SELECT userid FROM {post} WHERE module = 'blog' GROUP BY userid");
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
$a = new stdClass();
|
||||
$a->userscount = 0;
|
||||
$a->blogcount = 0;
|
||||
|
||||
foreach ($bloggers as $blogger) {
|
||||
$courses = enrol_get_users_courses($blogger->userid, true, 'groupmode,groupmodeforce');
|
||||
$blogentries = $DB->get_records('post', array('module' => 'blog', 'userid' => $blogger->userid));
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$forum = forum_get_course_forum($course->id, 'blog');
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
|
||||
if ($CFG->bloglevel == BLOG_GROUP_LEVEL && $course->groupmode != NOGROUPS) {
|
||||
// Unless the course is set to separate groups forced, force the forum to Separate groups
|
||||
if (!($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce)) {
|
||||
$cm->groupmode = SEPARATEGROUPS;
|
||||
$DB->update_record('course_modules', $cm);
|
||||
}
|
||||
|
||||
$groups = groups_get_user_groups($course->id, $blogger->userid);
|
||||
foreach ($groups[0] as $groupid) { // [0] is for all groupings combined
|
||||
$a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid);
|
||||
}
|
||||
} else {
|
||||
$a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm);
|
||||
}
|
||||
}
|
||||
|
||||
$a->userscount = $i . '/' . count($bloggers);
|
||||
$pbar->update($i, count($bloggers), get_string('bloglevelupgradeprogress', 'admin', $a));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
function bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid=-1) {
|
||||
$count = 0;
|
||||
|
||||
$forumcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
foreach ($blogentries as $blogentry) {
|
||||
$discussion = new stdClass();
|
||||
$discussion->course = $forum->course;
|
||||
$discussion->forum = $forum->id;
|
||||
$discussion->name = $blogentry->subject;
|
||||
$discussion->intro = $blogentry->summary;
|
||||
$discussion->assessed = $forum->assessed;
|
||||
$discussion->messageformat = $forum->introformat;
|
||||
$discussion->messagetrust = 0;
|
||||
$discussion->attachments = 0;
|
||||
$discussion->mailnow = false;
|
||||
$discussion->timemodified = $blogentry->created;
|
||||
$discussion->itemid = null;
|
||||
$discussion->groupid = $groupid;
|
||||
$message = '';
|
||||
|
||||
$discussionid = forum_add_discussion($discussion, null, $message);
|
||||
|
||||
// Copy file attachment records
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($sitecontext->id, 'blog', 'attachment', $blogentry->id);
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $storedfile) {
|
||||
$newfile = new stdClass();
|
||||
$newfile->component = 'mod_forum';
|
||||
$newfile->filearea = 'attachment';
|
||||
$newfile->itemid = $discussion->firstpost;
|
||||
$newfile->contextid = $forumcontext->id;
|
||||
$fs->create_file_from_storedfile($newfile, $storedfile->get_id());
|
||||
}
|
||||
}
|
||||
|
||||
$files = $fs->get_area_files($sitecontext->id, 'blog', 'post', $blogentry->id);
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $storedfile) {
|
||||
$newfile = new stdClass();
|
||||
$newfile->component = 'mod_forum';
|
||||
$newfile->filearea = 'post';
|
||||
$newfile->itemid = $discussion->firstpost;
|
||||
$newfile->contextid = $forumcontext->id;
|
||||
$fs->create_file_from_storedfile($newfile, $storedfile->get_id());
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
// END OF LOOP
|
||||
|
||||
// set conversion flag - switches to new plugin automatically
|
||||
set_config('bloglevel_upgrade_complete', 1);
|
||||
// Finally switch bloglevel to 0 (disabled)
|
||||
set_config('bloglevel', 0);
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automated backups CLI cron
|
||||
*
|
||||
* This script executes
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2010 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Execute automated backups.
|
||||
|
||||
This script executes automated backups completely and is designed to be
|
||||
called via cron.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/automated_backups.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
if (CLI_MAINTENANCE) {
|
||||
echo "CLI maintenance mode active, backup execution suspended.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (moodle_needs_upgrading()) {
|
||||
echo "Moodle upgrade pending, backup execution suspended.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if (!empty($CFG->showcronsql)) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
$CFG->debugdisplay = true;
|
||||
}
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
/// emulate normal session
|
||||
cron_setup_user();
|
||||
|
||||
/// Start output log
|
||||
$timenow = time();
|
||||
|
||||
mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
|
||||
// Run automated backups if required.
|
||||
require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php');
|
||||
require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php');
|
||||
backup_cron_automated_helper::run_automated_backup(backup_cron_automated_helper::RUN_IMMEDIATLY);
|
||||
|
||||
mtrace("Automated cron backups completed correctly");
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI cron
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Execute periodic cron actions.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/cron.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cron_run();
|
||||
@@ -1,635 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script creates config.php file and prepares database.
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - environment check is not present yet
|
||||
* - su to apache account or sudo before execution
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$help =
|
||||
"Command line Moodle installer, creates config.php and initializes database.
|
||||
Please note you must execute this script with the same uid as apache
|
||||
or use chmod/chown after installation.
|
||||
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--chmod=OCTAL-MODE Permissions of new directories created within dataroot.
|
||||
Default is 2777. You may want to change it to 2770
|
||||
or 2750 or 750. See chmod man page for details.
|
||||
--lang=CODE Installation and default site language.
|
||||
--wwwroot=URL Web address for the Moodle site,
|
||||
required in non-interactive mode.
|
||||
--dataroot=DIR Location of the moodle data folder,
|
||||
must not be web accessible. Default is moodledata
|
||||
in the parent directory.
|
||||
--dbtype=TYPE Database type. Default is mysqli
|
||||
--dbhost=HOST Database host. Default is localhost
|
||||
--dbname=NAME Database name. Default is moodle
|
||||
--dbuser=USERNAME Database user. Default is root
|
||||
--dbpass=PASSWORD Database password. Default is blank
|
||||
--dbsocket Use database sockets. Available for some databases only.
|
||||
--prefix=STRING Table prefix for above database tables. Default is mdl_
|
||||
--fullname=STRING The fullname of the site
|
||||
--shortname=STRING The shortname of the site
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin
|
||||
--adminpass=PASSWORD Password for the moodle admin account,
|
||||
required in non-interactive mode.
|
||||
--non-interactive No interactive questions, installation fails if any
|
||||
problem encountered.
|
||||
--agree-license Indicates agreement with software license,
|
||||
required in non-interactive mode.
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/install.php --lang=cs
|
||||
"; //TODO: localize, mark as needed in install - to be translated later when everything is finished
|
||||
|
||||
|
||||
// Nothing to do if config.php exists
|
||||
$configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
|
||||
if (file_exists($configfile)) {
|
||||
require($configfile);
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false), array('h'=>'help'));
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
echo "\n\n";
|
||||
}
|
||||
|
||||
cli_error(get_string('clialreadyinstalled', 'install'));
|
||||
}
|
||||
|
||||
$olddir = getcwd();
|
||||
|
||||
// change directory so that includes bellow work properly
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
|
||||
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
|
||||
// This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
|
||||
if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
|
||||
@date_default_timezone_set(@date_default_timezone_get());
|
||||
}
|
||||
|
||||
// make sure PHP errors are displayed - helps with diagnosing of problems
|
||||
@error_reporting(E_ALL);
|
||||
@ini_set('display_errors', '1');
|
||||
// we need a lot of memory
|
||||
@ini_set('memory_limit', '128M');
|
||||
|
||||
/** Used by library scripts to check they are being called by Moodle */
|
||||
define('MOODLE_INTERNAL', true);
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.2.8") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).\n";
|
||||
echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
|
||||
die;
|
||||
}
|
||||
|
||||
// set up configuration
|
||||
$CFG = new stdClass();
|
||||
$CFG->lang = 'en';
|
||||
$CFG->dirroot = dirname(dirname(dirname(__FILE__)));
|
||||
$CFG->libdir = "$CFG->dirroot/lib";
|
||||
$CFG->wwwroot = "http://localhost";
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata');
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
|
||||
$CFG->admin = array_pop($parts);
|
||||
|
||||
require($CFG->dirroot.'/version.php');
|
||||
$CFG->target_release = $release;
|
||||
|
||||
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
|
||||
//the problem is that we need specific version of quickforms and hacked excel files :-(
|
||||
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
|
||||
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/setuplib.php');
|
||||
require_once($CFG->libdir.'/textlib.class.php');
|
||||
require_once($CFG->libdir.'/weblib.php');
|
||||
require_once($CFG->libdir.'/dmllib.php');
|
||||
require_once($CFG->libdir.'/moodlelib.php');
|
||||
require_once($CFG->libdir.'/deprecatedlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
//Database types
|
||||
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
|
||||
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
|
||||
'oci' => moodle_database::get_driver_instance('oci', 'native'),
|
||||
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
|
||||
'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
|
||||
);
|
||||
foreach ($databases as $type=>$database) {
|
||||
if ($database->driver_installed() !== true) {
|
||||
unset($databases[$type]);
|
||||
}
|
||||
}
|
||||
if (empty($databases)) {
|
||||
$defaultdb = '';
|
||||
} else {
|
||||
reset($databases);
|
||||
$defaultdb = key($databases);
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'chmod' => '2777',
|
||||
'lang' => $CFG->lang,
|
||||
'wwwroot' => '',
|
||||
'dataroot' => $CFG->dataroot,
|
||||
'dbtype' => $defaultdb,
|
||||
'dbhost' => 'localhost',
|
||||
'dbname' => 'moodle',
|
||||
'dbuser' => 'root',
|
||||
'dbpass' => '',
|
||||
'dbsocket' => false,
|
||||
'prefix' => 'mdl_',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'non-interactive' => false,
|
||||
'agree-license' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
$interactive = empty($options['non-interactive']);
|
||||
|
||||
// set up language
|
||||
$lang = clean_param($options['lang'], PARAM_SAFEDIR);
|
||||
if (file_exists($CFG->dirroot.'/install/lang/'.$lang)) {
|
||||
$CFG->lang = $lang;
|
||||
}
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
//Print header
|
||||
echo get_string('cliinstallheader', 'install', $CFG->target_release)."\n";
|
||||
|
||||
//Fist select language
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
$languages = get_string_manager()->get_list_of_translations();
|
||||
// format the langs nicely - 3 per line
|
||||
$c = 0;
|
||||
$langlist = '';
|
||||
foreach ($languages as $key=>$lang) {
|
||||
$c++;
|
||||
$length = iconv_strlen($lang, 'UTF-8');
|
||||
$padded = $lang.str_repeat(' ', 38-$length);
|
||||
$langlist .= $padded;
|
||||
if ($c % 3 == 0) {
|
||||
$langlist .= "\n";
|
||||
}
|
||||
}
|
||||
$default = $CFG->lang;
|
||||
cli_heading(get_string('availablelangs', 'install'));
|
||||
echo $langlist."\n";
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->lang);
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, $default);
|
||||
$input = clean_param($input, PARAM_SAFEDIR);
|
||||
|
||||
if (!file_exists($CFG->dirroot.'/install/lang/'.$input)) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
} while ($error !== '');
|
||||
$CFG->lang = $input;
|
||||
} else {
|
||||
// already selected and verified
|
||||
}
|
||||
|
||||
// Set directorypermissions first
|
||||
$chmod = octdec(clean_param($options['chmod'], PARAM_INT));
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading('Data directories permission'); // todo localize
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', decoct($chmod));
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, decoct($chmod));
|
||||
$input = octdec(clean_param($input, PARAM_INT));
|
||||
if (empty($input)) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
} while ($error !== '');
|
||||
$chmod = $input;
|
||||
|
||||
} else {
|
||||
if (empty($chmod)) {
|
||||
$a = (object)array('option' => 'chmod', 'value' => decoct($chmod));
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
$CFG->directorypermissions = $chmod;
|
||||
|
||||
//We need wwwroot before we test dataroot
|
||||
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
|
||||
$wwwroot = trim($wwwroot, '/');
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('wwwroot', 'install'));
|
||||
if (strpos($wwwroot, 'http') === 0) {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $wwwroot);
|
||||
} else {
|
||||
$wwwroot = null;
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, $wwwroot);
|
||||
$input = clean_param($input, PARAM_URL);
|
||||
$input = trim($input, '/');
|
||||
if (strpos($input, 'http') !== 0) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
} while ($error !== '');
|
||||
$wwwroot = $input;
|
||||
|
||||
} else {
|
||||
if (strpos($wwwroot, 'http') !== 0) {
|
||||
$a = (object)array('option'=>'wwwroot', 'value'=>$wwwroot);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
$CFG->wwwroot = $wwwroot;
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
|
||||
|
||||
//We need dataroot before lang download
|
||||
if (!empty($options['dataroot'])) {
|
||||
$CFG->dataroot = $options['dataroot'];
|
||||
}
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
$i=0;
|
||||
while(is_dataroot_insecure()) {
|
||||
$parrent = dirname($CFG->dataroot);
|
||||
$i++;
|
||||
if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
|
||||
$CFG->dataroot = ''; //can not find secure location for dataroot
|
||||
break;
|
||||
}
|
||||
$CFG->dataroot = dirname($parrent).'/moodledata';
|
||||
}
|
||||
cli_heading(get_string('dataroot', 'install'));
|
||||
$error = '';
|
||||
do {
|
||||
if ($CFG->dataroot !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->dataroot);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
echo $error;
|
||||
$CFG->dataroot = cli_input($prompt, $CFG->dataroot);
|
||||
if ($CFG->dataroot === '') {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else if (is_dataroot_insecure()) {
|
||||
$CFG->dataroot = '';
|
||||
$error = get_string('pathsunsecuredataroot', 'install')."\n";
|
||||
} else {
|
||||
if (install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
|
||||
$error = '';
|
||||
} else {
|
||||
$a = (object)array('dataroot' => $CFG->dataroot);
|
||||
$error = get_string('pathserrcreatedataroot', 'install', $a)."\n";
|
||||
}
|
||||
}
|
||||
|
||||
} while ($error !== '');
|
||||
|
||||
} else {
|
||||
if (is_dataroot_insecure()) {
|
||||
cli_error(get_string('pathsunsecuredataroot', 'install'));
|
||||
}
|
||||
if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
|
||||
$a = (object)array('dataroot' => $CFG->dataroot);
|
||||
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
|
||||
}
|
||||
}
|
||||
|
||||
//download lang pack with optional notification
|
||||
if ($CFG->lang != 'en') {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
|
||||
if ($cd->install() == COMPONENT_ERROR) {
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/2.0/'.$CFG->lang.'.zip';
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
cli_problem(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
} else {
|
||||
// install parent lang if defined
|
||||
if ($parentlang = get_parent_language()) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// switch the string_manager instance to stop using install/lang/
|
||||
$CFG->early_install_lang = false;
|
||||
$CFG->langotherroot = $CFG->dataroot.'/lang';
|
||||
$CFG->langlocalroot = $CFG->dataroot.'/lang';
|
||||
get_string_manager(true);
|
||||
|
||||
// ask for db type - show only drivers available
|
||||
if ($interactive) {
|
||||
$options['dbtype'] = strtolower($options['dbtype']);
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasetypehead', 'install'));
|
||||
foreach ($databases as $type=>$database) {
|
||||
echo " $type \n";
|
||||
}
|
||||
if (!empty($databases[$options['dbtype']])) {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbtype']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbtype = cli_input($prompt, $options['dbtype'], array_keys($databases));
|
||||
|
||||
} else {
|
||||
if (empty($databases[$options['dbtype']])) {
|
||||
$a = (object)array('option'=>'dbtype', 'value'=>$options['dbtype']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
$CFG->dbtype = $options['dbtype'];
|
||||
}
|
||||
$database = $databases[$CFG->dbtype];
|
||||
|
||||
|
||||
// ask for db host
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasehost', 'install'));
|
||||
if ($options['dbhost'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbhost']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbhost = cli_input($prompt, $options['dbhost']);
|
||||
|
||||
} else {
|
||||
$CFG->dbhost = $options['dbhost'];
|
||||
}
|
||||
|
||||
// ask for db name
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasename', 'install'));
|
||||
if ($options['dbname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbname = cli_input($prompt, $options['dbname']);
|
||||
|
||||
} else {
|
||||
$CFG->dbname = $options['dbname'];
|
||||
}
|
||||
|
||||
// ask for db prefix
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('dbprefix', 'install'));
|
||||
//TODO: solve somehow the prefix trouble for oci
|
||||
if ($options['prefix'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['prefix']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->prefix = cli_input($prompt, $options['prefix']);
|
||||
|
||||
} else {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
}
|
||||
|
||||
// ask for db user
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseuser', 'install'));
|
||||
if ($options['dbuser'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbuser']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbuser = cli_input($prompt, $options['dbuser']);
|
||||
|
||||
} else {
|
||||
$CFG->dbuser = $options['dbuser'];
|
||||
}
|
||||
|
||||
// ask for db password
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasepass', 'install'));
|
||||
do {
|
||||
if ($options['dbpass'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbpass']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
|
||||
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
} while ($hint_database !== '');
|
||||
|
||||
} else {
|
||||
$CFG->dbpass = $options['dbpass'];
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
if ($hint_database !== '') {
|
||||
cli_error(get_string('dbconnectionerror', 'install'));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for fullname
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('fullsitename', 'moodle'));
|
||||
|
||||
if ($options['fullname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['fullname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
|
||||
do {
|
||||
$options['fullname'] = cli_input($prompt, $options['fullname']);
|
||||
} while (empty($options['fullname']));
|
||||
} else {
|
||||
if (empty($options['fullname'])) {
|
||||
$a = (object)array('option'=>'fullname', 'value'=>$options['fullname']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for shortname
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('shortsitename', 'moodle'));
|
||||
|
||||
if ($options['shortname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['shortname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
|
||||
do {
|
||||
$options['shortname'] = cli_input($prompt, $options['shortname']);
|
||||
} while (empty($options['shortname']));
|
||||
} else {
|
||||
if (empty($options['shortname'])) {
|
||||
$a = (object)array('option'=>'shortname', 'value'=>$options['shortname']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for admin user name
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminusername', 'install'));
|
||||
if (!empty($options['adminuser'])) {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['adminuser']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
do {
|
||||
$options['adminuser'] = cli_input($prompt, $options['adminuser']);
|
||||
} while (empty($options['adminuser']) or $options['adminuser'] === 'guest');
|
||||
} else {
|
||||
if (empty($options['adminuser']) or $options['adminuser'] === 'guest') {
|
||||
$a = (object)array('option'=>'adminuser', 'value'=>$options['adminuser']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
// ask for admin user password
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminpassword', 'install'));
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
do {
|
||||
$options['adminpass'] = cli_input($prompt);
|
||||
} while (empty($options['adminpass']) or $options['adminpass'] === 'admin');
|
||||
} else {
|
||||
if (empty($options['adminpass']) or $options['adminpass'] === 'admin') {
|
||||
$a = (object)array('option'=>'adminpass', 'value'=>$options['adminpass']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
if (!$options['agree-license']) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('copyrightnotice'));
|
||||
echo "Moodle - Modular Object-Oriented Dynamic Learning Environment\n";
|
||||
echo get_string('gpl3')."\n\n";
|
||||
echo get_string('doyouagree')."\n";
|
||||
$prompt = get_string('cliyesnoprompt', 'admin');
|
||||
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
|
||||
if ($input == get_string('clianswerno', 'admin')) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!$options['agree-license']) {
|
||||
cli_error(get_string('climustagreelicense', 'install'));
|
||||
}
|
||||
}
|
||||
|
||||
// Finally we have all info needed for config.php
|
||||
$configphp = install_generate_configphp($database, $CFG);
|
||||
umask(0137);
|
||||
if (($fh = fopen($configfile, 'w')) !== false) {
|
||||
fwrite($fh, $configphp);
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
if (!file_exists($configfile)) {
|
||||
cli_error('Can not create config file.');
|
||||
}
|
||||
|
||||
// remember selected language
|
||||
$installlang = $CFG->lang;
|
||||
// return back to original dir before executing setup.php which changes the dir again
|
||||
chdir($olddir);
|
||||
// We have config.php, it is a real php script from now on :-)
|
||||
require($configfile);
|
||||
|
||||
// use selected language
|
||||
$CFG->lang = $installlang;
|
||||
$SESSION->lang = $CFG->lang;
|
||||
|
||||
install_cli_database($options, $interactive);
|
||||
|
||||
echo get_string('cliinstallfinished', 'install')."\n";
|
||||
exit(0); // 0 means success
|
||||
@@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This installs Moodle into empty database, config.php must already exist.
|
||||
*
|
||||
* This script is intended for advanced usage such as in Debian packages.
|
||||
* - sudo to www-data (apache account) before
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2010 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$help =
|
||||
"Advanced command line Moodle database installer.
|
||||
Please note you must execute this script with the same uid as apache.
|
||||
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--lang=CODE Installation and default site language. Default is en.
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
|
||||
--adminpass=PASSWORD Password for the moodle admin account.
|
||||
--agree-license Indicates agreement with software license.
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/install_database.php --lang=cs --adminpass=soMePass123 --agree-license
|
||||
";
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.2.8") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install latest Moodle 1.9.x instead.\n");
|
||||
die(1);
|
||||
}
|
||||
|
||||
// Nothing to do if config.php does not exist
|
||||
$configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
|
||||
if (!file_exists($configfile)) {
|
||||
fwrite(STDERR, 'config.php does not exist, can not continue'); // do not localize
|
||||
fwrite(STDERR, "\n");
|
||||
die(1);
|
||||
}
|
||||
|
||||
// Include necessary libs
|
||||
require($configfile);
|
||||
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
// make sure no tables are installed yet
|
||||
if ($DB->get_tables() ) {
|
||||
cli_error(get_string('clitablesexist', 'install'));
|
||||
}
|
||||
|
||||
$CFG->early_install_lang = true;
|
||||
get_string_manager(true);
|
||||
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'lang' => 'en',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'agree-license' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if (!$options['agree-license']) {
|
||||
cli_error('You have to agree to the license. --help prints out the help'); // TODO: localize
|
||||
}
|
||||
|
||||
if ($options['adminpass'] === true or $options['adminpass'] === '') {
|
||||
cli_error('You have to specify admin password. --help prints out the help'); // TODO: localize
|
||||
}
|
||||
|
||||
$options['lang'] = clean_param($options['lang'], PARAM_SAFEDIR);
|
||||
if (!file_exists($CFG->dirroot.'/install/lang/'.$options['lang'])) {
|
||||
$options['lang'] = 'en';
|
||||
}
|
||||
$CFG->lang = $options['lang'];
|
||||
|
||||
//download lang pack with optional notification
|
||||
if ($CFG->lang != 'en') {
|
||||
make_upload_directory('lang');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
|
||||
if ($cd->install() == COMPONENT_ERROR) {
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/2.0/'.$CFG->lang.'.zip';
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
cli_problem(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
} else {
|
||||
// install parent lang if defined
|
||||
if ($parentlang = get_parent_language()) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// switch the string_manager instance to stop using install/lang/
|
||||
$CFG->early_install_lang = false;
|
||||
get_string_manager(true);
|
||||
|
||||
|
||||
install_cli_database($options, true);
|
||||
|
||||
echo get_string('cliinstallfinished', 'install')."\n";
|
||||
exit(0); // 0 means success
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Enable or disable maintenance mode
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'disable'=>false, 'help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Maintenance mode settings.
|
||||
Current status displayed if not option specified.
|
||||
|
||||
Options:
|
||||
--enable Enable maintenance mode
|
||||
--disable Disable maintenance mode
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
|
||||
|
||||
if ($options['enable']) {
|
||||
set_config('maintenance_enabled', 1);
|
||||
echo get_string('sitemaintenanceon', 'admin')."\n";
|
||||
exit(0);
|
||||
} else if ($options['disable']) {
|
||||
set_config('maintenance_enabled', 0);
|
||||
echo get_string('sitemaintenanceoff', 'admin')."\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!empty($CFG->maintenance_enabled)) {
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
} else {
|
||||
echo get_string('clistatusdisabled', 'admin')."\n";
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL engine conversion tool.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This function is designed for MySQL databases only!');
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'engine'=>false),
|
||||
array('h'=>'help', 'l'=>'list'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"MySQL engine conversions script.
|
||||
|
||||
It is recommended to stop the web server before the conversion.
|
||||
Do not use MyISAM if possible, because it is not ACID compliant
|
||||
and does not support transactions.
|
||||
|
||||
Options:
|
||||
--engine=ENGINE Convert MySQL tables to different engine
|
||||
-l, --list Show table information
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB
|
||||
";
|
||||
|
||||
if (!empty($options['engine'])) {
|
||||
$engine = clean_param($options['engine'], PARAM_ALPHA);
|
||||
|
||||
echo "Converting tables to '$engine' for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$converted = 0;
|
||||
$skipped = 0;
|
||||
foreach ($rs as $table) {
|
||||
if ($table->engine === $engine) {
|
||||
echo str_pad($table->name, 40). " - NO CONVERSION NEEDED\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
$DB->change_database_structure("ALTER TABLE {$table->name} TYPE = $engine");
|
||||
echo "DONE\n";
|
||||
$converted++;
|
||||
}
|
||||
$rs->close();
|
||||
echo "Converted: $converted, skipped: $skipped\n";
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
echo "List of tables for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$counts = array();
|
||||
foreach ($rs as $table) {
|
||||
if (isset($counts[$table->engine])) {
|
||||
$counts[$table->engine]++;
|
||||
} else {
|
||||
$counts[$table->engine] = 1;
|
||||
}
|
||||
echo str_pad($table->engine, 10);
|
||||
echo $table->name . "\n";
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo "\n";
|
||||
echo "Table engines summary for $CFG->wwwroot:\n";
|
||||
foreach ($counts as $engine => $count) {
|
||||
echo "$engine: $count\n";
|
||||
}
|
||||
exit(0); // success
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script allows you to reset any local user password.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Reset local user passwords, useful especially for admin acounts.
|
||||
|
||||
There are no security checks here because anybody who is able to
|
||||
execute this file may execute any PHP too.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/reset_password.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
cli_heading('Password reset'); // TODO: localize
|
||||
$prompt = "enter username (manual authentication only)"; // TODO: localize
|
||||
$username = cli_input($prompt);
|
||||
|
||||
if (!$user = $DB->get_record('user', array('auth'=>'manual', 'username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
|
||||
cli_error("Can not find user '$username'");
|
||||
}
|
||||
|
||||
$prompt = "Enter new password"; // TODO: localize
|
||||
$password = cli_input($prompt);
|
||||
|
||||
$errmsg = '';//prevent eclipse warning
|
||||
if (!check_password_policy($password, $errmsg)) {
|
||||
cli_error($errmsg);
|
||||
}
|
||||
|
||||
$hashedpassword = hash_internal_user_password($password);
|
||||
|
||||
$DB->set_field('user', 'password', $hashedpassword, array('id'=>$user->id));
|
||||
|
||||
echo "Password changed\n";
|
||||
|
||||
exit(0); // 0 means success
|
||||
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script creates config.php file and prepares database.
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - environment check is not present yet
|
||||
* - su to apache account or sudo before execution
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('non-interactive'=>false, 'help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
$interactive = empty($options['non-interactive']);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Command line Moodle upgrade.
|
||||
Please note you must execute this script with the same uid as apache!
|
||||
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--non-interactive No interactive questions or confirmations
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/upgrade.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
cli_error(get_string('missingconfigversion', 'debug'));
|
||||
}
|
||||
|
||||
require("$CFG->dirroot/version.php"); // defines $version and $release
|
||||
$CFG->target_release = $release; // used during installation and upgrades
|
||||
|
||||
if ($version < $CFG->version) {
|
||||
cli_error(get_string('downgradedcore', 'error'));
|
||||
}
|
||||
|
||||
$newversion = "$release ($version)";
|
||||
|
||||
// test environment first
|
||||
if (!check_moodle_environment($version, $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
echo html_to_text(get_string('upgradesure', 'admin', $newversion))."\n";
|
||||
$prompt = get_string('cliyesnoprompt', 'admin');
|
||||
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
|
||||
if ($input == get_string('clianswerno', 'admin')) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) {
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
set_config('release', $release);
|
||||
|
||||
// unconditionally upgrade
|
||||
upgrade_noncore(true);
|
||||
|
||||
// log in as admin - we need doanything permission when applying defaults
|
||||
$admins = get_admins();
|
||||
$admin = reset($admins);
|
||||
session_set_user($admin);
|
||||
|
||||
// apply all default settings, just in case do it twice to fill all defaults
|
||||
admin_apply_default_settings(NULL, false);
|
||||
admin_apply_default_settings(NULL, false);
|
||||
|
||||
echo get_string('cliupgradefinished', 'admin')."\n";
|
||||
exit(0); // 0 means success
|
||||
+531
-74
@@ -1,86 +1,543 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
/// 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
|
||||
set_time_limit(0);
|
||||
$starttime = microtime();
|
||||
|
||||
/**
|
||||
* Web cron
|
||||
*
|
||||
* 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).
|
||||
* It is strongly recommended to add password protection via admin settings.
|
||||
*
|
||||
* eg wget -q -O /dev/null 'http: *moodle.somewhere.edu/admin/cron.php?password=SeCreT666'
|
||||
*
|
||||
* It is also possible to use CLI script admin/cli/cron.php instead,
|
||||
* you can not call this script from command line any more.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
/// The following is a hack necessary to allow this script to work well
|
||||
/// from the command line.
|
||||
|
||||
// This is a fake CLI script, it is a really ugly hack which emulates
|
||||
// CLI via web interface, please do not use this hack elsewhere
|
||||
define('CLI_SCRIPT', true);
|
||||
define('WEB_CRON_EMULATED_CLI', 'defined'); // ugly ugly hack, do not use elsewhere please
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
define('FULLME', 'cron');
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// extra safety
|
||||
session_get_instance()->write_close();
|
||||
/// Do not set moodle cookie because we do not need it here, it is better to emulate session
|
||||
$nomoodlecookie = true;
|
||||
|
||||
// check if execution allowed
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
// This script can only be run via the cli.
|
||||
print_error('cronerrorclionly', 'admin');
|
||||
exit;
|
||||
}
|
||||
// This script is being called via the web, so check the password if there is one.
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$pass = optional_param('password', '', PARAM_RAW);
|
||||
if ($pass != $CFG->cronremotepassword) {
|
||||
// wrong password.
|
||||
print_error('cronerrorpassword', 'admin');
|
||||
exit;
|
||||
/// The current directory in PHP version 4.3.0 and above isn't necessarily the
|
||||
/// directory of the script when run from the command line. The require_once()
|
||||
/// would fail, so we'll have to chdir()
|
||||
|
||||
if (!isset($_SERVER['REMOTE_ADDR']) && isset($_SERVER['argv'][0])) {
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
}
|
||||
}
|
||||
|
||||
// send mime type and encoding
|
||||
if (check_browser_version('MSIE')) {
|
||||
//ugly IE hack to work around downloading instead of viewing
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
// execute the cron
|
||||
cron_run();
|
||||
/// Extra debugging (set in config.php)
|
||||
if (!empty($CFG->showcronsql)) {
|
||||
$db->debug = true;
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
$CFG->displaydebug = true;
|
||||
}
|
||||
|
||||
// finish the IE hack
|
||||
if (check_browser_version('MSIE')) {
|
||||
echo "</xmp>";
|
||||
}
|
||||
/// extra safety
|
||||
@session_write_close();
|
||||
|
||||
/// check if execution allowed
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) { // if the script is accessed via the web.
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
// This script can only be run via the cli.
|
||||
print_error('cronerrorclionly', 'admin');
|
||||
exit;
|
||||
}
|
||||
// This script is being called via the web, so check the password if there is one.
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$pass = optional_param('password', '', PARAM_RAW);
|
||||
if($pass != $CFG->cronremotepassword) {
|
||||
// wrong password.
|
||||
print_error('cronerrorpassword', 'admin');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// emulate normal session
|
||||
$SESSION = new object();
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
|
||||
/// ignore admins timezone, language and locale - use site deafult instead!
|
||||
$USER->timezone = $CFG->timezone;
|
||||
$USER->lang = '';
|
||||
$USER->theme = '';
|
||||
course_setup(SITEID);
|
||||
|
||||
/// send mime type and encoding
|
||||
if (check_browser_version('MSIE')) {
|
||||
//ugly IE hack to work around downloading instead of viewing
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
/// no more headers and buffers
|
||||
while(@ob_end_flush());
|
||||
|
||||
/// increase memory limit (PHP 5.2 does different calculation, we need more memory now)
|
||||
@raise_memory_limit('128M');
|
||||
|
||||
/// Start output log
|
||||
|
||||
$timenow = time();
|
||||
|
||||
mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
|
||||
/// Run all cron jobs for each module
|
||||
|
||||
mtrace("Starting activity modules");
|
||||
get_mailer('buffer');
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron) AND visible = 1 ")) {
|
||||
foreach ($mods as $mod) {
|
||||
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
|
||||
if (file_exists($libfile)) {
|
||||
include_once($libfile);
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(1);
|
||||
}
|
||||
if ($cron_function()) {
|
||||
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
|
||||
mtrace("Error: could not update timestamp for $mod->fullname");
|
||||
}
|
||||
}
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
|
||||
}
|
||||
/// Reset possible changes by modules to time_limit. MDL-11597
|
||||
@set_time_limit(0);
|
||||
mtrace("done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get_mailer('close');
|
||||
mtrace("Finished activity modules");
|
||||
|
||||
mtrace("Starting blocks");
|
||||
if ($blocks = get_records_select("block", "cron > 0 AND (($timenow - lastcron) > cron) AND visible = 1")) {
|
||||
// we will need the base class.
|
||||
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
|
||||
foreach ($blocks as $block) {
|
||||
$blockfile = $CFG->dirroot.'/blocks/'.$block->name.'/block_'.$block->name.'.php';
|
||||
if (file_exists($blockfile)) {
|
||||
require_once($blockfile);
|
||||
$classname = 'block_'.$block->name;
|
||||
$blockobj = new $classname;
|
||||
if (method_exists($blockobj,'cron')) {
|
||||
mtrace("Processing cron function for ".$block->name.'....','');
|
||||
if ($blockobj->cron()) {
|
||||
if (!set_field('block','lastcron',$timenow,'id',$block->id)) {
|
||||
mtrace('Error: could not update timestamp for '.$block->name);
|
||||
}
|
||||
}
|
||||
/// Reset possible changes by blocks to time_limit. MDL-11597
|
||||
@set_time_limit(0);
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mtrace('Finished blocks');
|
||||
|
||||
mtrace('Starting admin reports');
|
||||
// Admin reports do not have a database table that lists them. Instead a
|
||||
// report includes cron.php with function report_reportname_cron() if it wishes
|
||||
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
|
||||
// actually do anything occasionally.
|
||||
$reports = get_list_of_plugins($CFG->admin.'/report');
|
||||
foreach($reports as $report) {
|
||||
$cronfile = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$report.'/cron.php';
|
||||
if (file_exists($cronfile)) {
|
||||
require_once($cronfile);
|
||||
$cronfunction = 'report_'.$report.'_cron';
|
||||
mtrace('Processing cron function for '.$report.'...', '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(true);
|
||||
}
|
||||
$cronfunction();
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
mtrace('Finished admin reports');
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages(true);
|
||||
}
|
||||
|
||||
mtrace('Removing expired enrolments ...', ''); // See MDL-8785
|
||||
$timenow = time();
|
||||
$somefound = false;
|
||||
// The preferred way saves memory, dmllib.php
|
||||
// find courses where limited enrolment is enabled
|
||||
global $CFG;
|
||||
$rs_enrol = get_recordset_sql("SELECT ra.roleid, ra.userid, ra.contextid
|
||||
FROM {$CFG->prefix}course c
|
||||
INNER JOIN {$CFG->prefix}context cx ON cx.instanceid = c.id
|
||||
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.contextid = cx.id
|
||||
WHERE cx.contextlevel = '".CONTEXT_COURSE."'
|
||||
AND ra.timeend > 0
|
||||
AND ra.timeend < '$timenow'
|
||||
AND c.enrolperiod > 0
|
||||
");
|
||||
while ($oldenrolment = rs_fetch_next_record($rs_enrol)) {
|
||||
role_unassign($oldenrolment->roleid, $oldenrolment->userid, 0, $oldenrolment->contextid);
|
||||
$somefound = true;
|
||||
}
|
||||
rs_close($rs_enrol);
|
||||
if($somefound) {
|
||||
mtrace('Done');
|
||||
} else {
|
||||
mtrace('none found');
|
||||
}
|
||||
|
||||
|
||||
mtrace('Starting main gradebook job ...');
|
||||
grade_cron();
|
||||
mtrace('done.');
|
||||
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
/// to randomly choose the percentage of times we should run these jobs.
|
||||
|
||||
srand ((double) microtime() * 10000000);
|
||||
$random100 = rand(0,100);
|
||||
|
||||
if ($random100 < 20) { // Approximately 20% of the time.
|
||||
mtrace("Running clean-up tasks...");
|
||||
|
||||
/// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
if ($CFG->longtimenosee) { // value in days
|
||||
$cuttime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
||||
FROM {$CFG->prefix}user_lastaccess
|
||||
WHERE courseid != ".SITEID."
|
||||
AND timeaccess < $cuttime ");
|
||||
while ($assign = rs_fetch_next_record($rs)) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (role_unassign(0, $assign->userid, 0, $context->id)) {
|
||||
mtrace("Deleted assignment for user $assign->userid from course $assign->courseid");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
/// Execute the same query again, looking for remaining records and deleting them
|
||||
/// if the user hasn't moodle/course:view in the CONTEXT_COURSE context (orphan records)
|
||||
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
||||
FROM {$CFG->prefix}user_lastaccess
|
||||
WHERE courseid != ".SITEID."
|
||||
AND timeaccess < $cuttime ");
|
||||
while ($assign = rs_fetch_next_record($rs)) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (!has_capability('moodle/course:view', $context, $assign->userid)) {
|
||||
delete_records('user_lastaccess', 'userid', $assign->userid, 'courseid', $assign->courseid);
|
||||
mtrace("Deleted orphan user_lastaccess for user $assign->userid from course $assign->courseid");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// Delete users who haven't confirmed within required period
|
||||
|
||||
if (!empty($CFG->deleteunconfirmed)) {
|
||||
$cuttime = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
$rs = get_recordset_sql ("SELECT id, firstname, lastname
|
||||
FROM {$CFG->prefix}user
|
||||
WHERE confirmed = 0
|
||||
AND firstaccess > 0
|
||||
AND firstaccess < $cuttime");
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// Delete users who haven't completed profile within required period
|
||||
|
||||
if (!empty($CFG->deleteunconfirmed)) {
|
||||
$cuttime = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
$rs = get_recordset_sql ("SELECT id, username
|
||||
FROM {$CFG->prefix}user
|
||||
WHERE confirmed = 1
|
||||
AND lastaccess > 0
|
||||
AND lastaccess < $cuttime
|
||||
AND deleted = 0
|
||||
AND (lastname = '' OR firstname = '' OR email = '')");
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted not fully setup user $user->username ($user->id)");
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// 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);
|
||||
if (delete_records_select("log", "time < '$loglifetime'")) {
|
||||
mtrace("Deleted old log records");
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// Delete old cached texts
|
||||
|
||||
if (!empty($CFG->cachetext)) { // Defined in config.php
|
||||
$cachelifetime = time() - $CFG->cachetext - 60; // Add an extra minute to allow for really heavy sites
|
||||
if (delete_records_select('cache_text', "timemodified < '$cachelifetime'")) {
|
||||
mtrace("Deleted old cache_text records");
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
if (!empty($CFG->notifyloginfailures)) {
|
||||
notify_login_failures();
|
||||
mtrace('Notified login failured');
|
||||
}
|
||||
flush();
|
||||
|
||||
sync_metacourses();
|
||||
mtrace('Synchronised metacourses');
|
||||
|
||||
//
|
||||
// generate new password emails for users
|
||||
//
|
||||
mtrace('checking for create_password');
|
||||
if (count_records('user_preferences', 'name', 'create_password', 'value', '1')) {
|
||||
mtrace('creating passwords for new users');
|
||||
$newusers = get_records_sql("SELECT u.id as id, u.email, u.firstname,
|
||||
u.lastname, u.username,
|
||||
p.id as prefid
|
||||
FROM {$CFG->prefix}user u
|
||||
JOIN {$CFG->prefix}user_preferences p ON u.id=p.userid
|
||||
WHERE p.name='create_password' AND p.value=1 AND u.email !='' ");
|
||||
|
||||
foreach ($newusers as $newuserid => $newuser) {
|
||||
$newuser->emailstop = 0; // send email regardless
|
||||
// email user
|
||||
if (setnew_password_and_mail($newuser)) {
|
||||
// remove user pref
|
||||
delete_records('user_preferences', 'id', $newuser->prefid);
|
||||
} else {
|
||||
trigger_error("Could not create and mail new user password!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($CFG->usetags)){
|
||||
require_once($CFG->dirroot.'/tag/lib.php');
|
||||
tag_cron();
|
||||
mtrace ('Executed tag cron');
|
||||
}
|
||||
|
||||
// Accesslib stuff
|
||||
cleanup_contexts();
|
||||
mtrace ('Cleaned up contexts');
|
||||
gc_cache_flags();
|
||||
mtrace ('Cleaned cache flags');
|
||||
// If you suspect that the context paths are somehow corrupt
|
||||
// replace the line below with: build_context_path(true);
|
||||
build_context_path();
|
||||
mtrace ('Built context paths');
|
||||
|
||||
mtrace("Finished clean-up tasks...");
|
||||
|
||||
} // End of occasional clean-up tasks
|
||||
|
||||
|
||||
if (empty($CFG->disablescheduledbackups)) { // Defined in config.php
|
||||
//Execute backup's cron
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("192M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
// if we are running from Apache, give httpd a hint that
|
||||
// it can recycle the process after it's done. Apache's
|
||||
// memory management is truly awful but we can help it.
|
||||
@apache_child_terminate();
|
||||
}
|
||||
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
|
||||
file_exists("$CFG->dirroot/backup/backuplib.php") and
|
||||
file_exists("$CFG->dirroot/backup/lib.php") and
|
||||
file_exists("$CFG->libdir/blocklib.php")) {
|
||||
include_once("$CFG->dirroot/backup/backup_scheduled.php");
|
||||
include_once("$CFG->dirroot/backup/backuplib.php");
|
||||
include_once("$CFG->dirroot/backup/lib.php");
|
||||
require_once ("$CFG->libdir/blocklib.php");
|
||||
mtrace("Running backups if required...");
|
||||
|
||||
if (! schedule_backup_cron()) {
|
||||
mtrace("ERROR: Something went wrong while performing backup tasks!!!");
|
||||
} else {
|
||||
mtrace("Backup tasks finished.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablerssfeeds)) { //Defined in admin/variables page
|
||||
include_once("$CFG->libdir/rsslib.php");
|
||||
mtrace("Running rssfeeds if required...");
|
||||
|
||||
if ( ! cron_rss_feeds()) {
|
||||
mtrace("Something went wrong while generating rssfeeds!!!");
|
||||
} else {
|
||||
mtrace("Rssfeeds finished");
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the enrolment cron, if any
|
||||
if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
|
||||
$plugins = array($CFG->enrol);
|
||||
}
|
||||
require_once($CFG->dirroot .'/enrol/enrol.class.php');
|
||||
foreach ($plugins as $p) {
|
||||
$enrol = enrolment_factory::factory($p);
|
||||
if (method_exists($enrol, 'cron')) {
|
||||
$enrol->cron();
|
||||
}
|
||||
if (!empty($enrol->log)) {
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
unset($enrol);
|
||||
}
|
||||
|
||||
/// Run the auth cron, if any
|
||||
$auths = get_enabled_auth_plugins();
|
||||
|
||||
mtrace("Running auth crons if required...");
|
||||
foreach ($auths as $auth) {
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
if (method_exists($authplugin, 'cron')) {
|
||||
mtrace("Running cron for auth/$auth...");
|
||||
$authplugin->cron();
|
||||
if (!empty($authplugin->log)) {
|
||||
mtrace($authplugin->log);
|
||||
}
|
||||
}
|
||||
unset($authplugin);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
// check we're not before our runtime
|
||||
$timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour*60*60 + $CFG->statsruntimestartminute*60;
|
||||
|
||||
if (time() > $timetocheck) {
|
||||
// process max 31 days per cron execution
|
||||
if (stats_cron_daily(31)) {
|
||||
if (stats_cron_weekly()) {
|
||||
if (stats_cron_monthly()) {
|
||||
stats_clean_old();
|
||||
}
|
||||
}
|
||||
}
|
||||
@set_time_limit(0);
|
||||
} else {
|
||||
mtrace('Next stats run after:'. userdate($timetocheck));
|
||||
}
|
||||
}
|
||||
|
||||
// run gradebook import/export/report cron
|
||||
if ($gradeimports = get_list_of_plugins('grade/import')) {
|
||||
foreach ($gradeimports as $gradeimport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php');
|
||||
$cron_function = 'grade_import_'.$gradeimport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook import function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradeexports = get_list_of_plugins('grade/export')) {
|
||||
foreach ($gradeexports as $gradeexport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php');
|
||||
$cron_function = 'grade_export_'.$gradeexport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook export function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradereports = get_list_of_plugins('grade/report')) {
|
||||
foreach ($gradereports as $gradereport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php');
|
||||
$cron_function = 'grade_report_'.$gradereport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook report function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// run any customized cronjobs, if any
|
||||
// looking for functions in lib/local/cron.php
|
||||
if (file_exists($CFG->dirroot.'/local/cron.php')) {
|
||||
mtrace('Processing customized cron script ...', '');
|
||||
include_once($CFG->dirroot.'/local/cron.php');
|
||||
mtrace('done.');
|
||||
}
|
||||
|
||||
|
||||
//Unset session variables and destroy it
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
|
||||
mtrace("Cron script completed correctly");
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
|
||||
/// finish the IE hack
|
||||
if (check_browser_version('MSIE')) {
|
||||
echo "</xmp>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+26
-15
@@ -1,13 +1,10 @@
|
||||
<?PHP
|
||||
// dbperformance.php - shows latest ADOdb stats for the current server
|
||||
<?PHP // $Id$
|
||||
// dbperformance.php - shows latest ADOdb stats for the current server
|
||||
|
||||
// disable moodle specific debug messages and any errors in output
|
||||
define('NO_DEBUG_DISPLAY', true);
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
error('TODO: rewrite db perf code'); // TODO: rewrite
|
||||
require_once('../config.php');
|
||||
|
||||
// disable moodle specific debug messages that would be breaking the frames
|
||||
disable_debugging();
|
||||
|
||||
$topframe = optional_param('topframe', 0, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', 0, PARAM_BOOL);
|
||||
@@ -15,18 +12,32 @@ error('TODO: rewrite db perf code'); // TODO: rewrite
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
$strdatabaseperformance = get_string("databaseperformance");
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
$navigation = build_navigation(array(
|
||||
array('name'=>$stradministration, 'link'=>'index.php', 'type'=>'misc'),
|
||||
array('name'=>$strdatabaseperformance, 'link'=>null, 'type'=>'misc')));
|
||||
if (!empty($topframe)) {
|
||||
$PAGE->set_url('/admin/dbperformance.php');
|
||||
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
|
||||
$PAGE->navbar->add($strdatabaseperformance);
|
||||
$PAGE->set_title("$site->shortname: $strdatabaseperformance");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
echo $OUTPUT->header();
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname", $navigation);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($bottomframe) or !empty($do)) {
|
||||
$perf =&NewPerfMonitor($db);
|
||||
$perf->UI($pollsecs=5);
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<head>
|
||||
<title><?php echo "$site->shortname: $strdatabaseperformance" ?></title>
|
||||
</head>
|
||||
|
||||
<frameset rows="80,*">
|
||||
<frame src="dbperformance.php?topframe=true">
|
||||
<frame src="dbperformance.php?bottomframe=true">
|
||||
</frameset>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class database_export_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbexport', 'dbtransfer'));
|
||||
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>5, 'cols'=>60));
|
||||
|
||||
$this->add_action_buttons(false, get_string('exportdata', 'dbtransfer'));
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class database_transfer_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbtransfer', 'dbtransfer'));
|
||||
|
||||
$supported = array (
|
||||
'mysqli/native',
|
||||
'pgsql/native',
|
||||
'mssql/native',
|
||||
'oci/native',
|
||||
'sqlite3/pdo',
|
||||
);
|
||||
$drivers = array();
|
||||
foreach($supported as $driver) {
|
||||
list($dbtype, $dblibrary) = explode('/', $driver);
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary);
|
||||
if ($targetdb->driver_installed() !== true) {
|
||||
continue;
|
||||
}
|
||||
$drivers[$driver] = $driver;
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'driver', get_string('dbtype', 'install'), $drivers);
|
||||
$mform->addElement('text', 'dbhost', get_string('dbhost', 'install'));
|
||||
$mform->addElement('text', 'dbname', get_string('database', 'install'));
|
||||
$mform->addElement('text', 'dbuser', get_string('user'));
|
||||
$mform->addElement('text', 'dbpass', get_string('password'));
|
||||
$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
|
||||
|
||||
$mform->addRule('dbhost', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbname', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbuser', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbpass', get_string('required'), 'required', null);
|
||||
$mform->addRule('prefix', get_string('required'), 'required', null);
|
||||
|
||||
$this->add_action_buttons(false, get_string('transferdata', 'dbtransfer'));
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
require('../../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('database_export_form.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('dbexport');
|
||||
|
||||
//create form
|
||||
$form = new database_export_form();
|
||||
|
||||
if ($data = $form->get_data()) {
|
||||
dbtransfer_export_xml_database($data->description, $DB);
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
// TODO: add some more info here
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
require('../../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('database_transfer_form.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('dbtransfer');
|
||||
|
||||
// Create the form
|
||||
$form = new database_transfer_form();
|
||||
|
||||
// If we have valid input.
|
||||
if ($data = $form->get_data()) {
|
||||
// Connect to the other database.
|
||||
list($dbtype, $dblibrary) = explode('/', $data->driver);
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary);
|
||||
if (!$targetdb->connect($data->dbhost, $data->dbuser, $data->dbpass, $data->dbname, $data->prefix, null)) {
|
||||
throw new dbtransfer_exception('notargetconectexception', null, "$CFG->wwwroot/$CFG->admin/dbtransfer/");
|
||||
}
|
||||
if ($targetdb->get_tables()) {
|
||||
throw new dbtransfer_exception('targetdatabasenotempty', null, "$CFG->wwwroot/$CFG->admin/dbtransfer/");
|
||||
}
|
||||
|
||||
// Start output.
|
||||
echo $OUTPUT->header();
|
||||
$data->dbtype = $dbtype;
|
||||
echo $OUTPUT->heading(get_string('transferringdbto', 'dbtransfer', $data));
|
||||
|
||||
// Do the transfer.
|
||||
$feedback = new html_list_progress_trace();
|
||||
dbtransfer_transfer_database($DB, $targetdb, $feedback);
|
||||
$feedback->finished();
|
||||
|
||||
// Finish up.
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// Otherwise display the settings form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('transferdbtoserver', 'dbtransfer'));
|
||||
echo '<p>', get_string('transferdbintro', 'dbtransfer'), "</p>\n\n";
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
- exporting to server file >2GB fails in 32bit operating systems - needs warning
|
||||
- we may run out of disk space exporting to srever file - we must verify the file is not truncated; read from the end of file?
|
||||
- when sending file >4GB - FAT32 limit, Apache limit, browser limit - needs warning
|
||||
- there must be some form of progress bar during export, transfer - new tracking class could be passed around
|
||||
- command line operation - could work around some 2G/4G limits in PHP; useful for cron full backups
|
||||
- by default allow exporting into empty database only (no tables with the same prefix yet)
|
||||
- all dangerous operation (like deleting of all data) should be confirmed by key found in special file in dataroot
|
||||
(user would need file access to dataroot which might prevent various "accidents")
|
||||
- implement "Export/import running" notification in lib/setup.php (similar to new upgrade flag in config table)
|
||||
- gzip compression when storing xml file - the xml is very verbose and full of repeated tags (zip is not suitable here at all)
|
||||
this could help us keep the files bellow 2G (expected ratio is > 10:1)
|
||||
|
||||
*/
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/dtllib.php');
|
||||
|
||||
|
||||
function dbtransfer_export_xml_database($description, $mdb) {
|
||||
@set_time_limit(0);
|
||||
|
||||
session_get_instance()->write_close(); // release session
|
||||
|
||||
header('Content-Type: application/xhtml+xml');
|
||||
header('Content-Disposition: attachment; filename=database.xml');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
|
||||
header('Pragma: public');
|
||||
|
||||
while(@ob_flush());
|
||||
|
||||
$var = new file_xml_database_exporter('php://output', $mdb);
|
||||
$var->export_database($description);
|
||||
|
||||
// no more output
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
function dbtransfer_transfer_database($sourcedb, $targetdb, $feedback = null) {
|
||||
@set_time_limit(0);
|
||||
|
||||
session_get_instance()->write_close(); // release session
|
||||
|
||||
$var = new database_mover($sourcedb, $targetdb, true, $feedback);
|
||||
$var->export_database(null);
|
||||
}
|
||||
+14
-19
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?PHP //$Id$
|
||||
|
||||
// Deletes the moodledata directory, COMPLETELY!!
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
@@ -13,36 +13,31 @@
|
||||
$sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
$reallysure = optional_param('reallysure', 0, PARAM_BOOL);
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('Purge moodledata');
|
||||
admin_externalpage_print_header();
|
||||
print_heading('Purge moodledata');
|
||||
|
||||
if (empty($sure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
|
||||
|
||||
$formcontinue = new single_button(new moodle_url('delete.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button('index.php', get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?',
|
||||
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!data_submitted() or empty($reallysure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
|
||||
$formcontinue = new single_button(new moodle_url('delete.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button('index.php', get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm('Are you REALLY REALLY completely sure you want to delete everything inside the directory '.
|
||||
$deletedir .' (this includes all user images, and any other course files that have been created) ?',
|
||||
$formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?',
|
||||
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('wrongcall', 'error');
|
||||
error('This script was called wrongly');
|
||||
}
|
||||
|
||||
/// OK, here goes ...
|
||||
@@ -50,8 +45,8 @@
|
||||
delete_subdirectories($deletedir);
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
echo $OUTPUT->continue_button($CFG->wwwroot);
|
||||
echo $OUTPUT->footer();
|
||||
print_continue($CFG->wwwroot);
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
|
||||
@@ -83,4 +78,4 @@ function delete_subdirectories($rootdir) {
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Allows admin to configure editors.
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$editor = optional_param('editor', '', PARAM_SAFEDIR);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$available_editors = editors_get_available();
|
||||
if (!empty($editor) and empty($available_editors[$editor])) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
|
||||
$active_editors = explode(',', $CFG->texteditors);
|
||||
foreach ($active_editors as $key=>$active) {
|
||||
if (empty($available_editors[$active])) {
|
||||
unset($active_editors[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
|
||||
$return = true;
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
// remove from enabled list
|
||||
$key = array_search($editor, $active_editors);
|
||||
unset($active_editors[$key]);
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
// add to enabled list
|
||||
if (!in_array($editor, $active_editors)) {
|
||||
$active_editors[] = $editor;
|
||||
$active_editors = array_unique($active_editors);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($editor, $active_editors);
|
||||
// check auth plugin is valid
|
||||
if ($key !== false) {
|
||||
// move down the list
|
||||
if ($key < (count($active_editors) - 1)) {
|
||||
$fsave = $active_editors[$key];
|
||||
$active_editors[$key] = $active_editors[$key + 1];
|
||||
$active_editors[$key + 1] = $fsave;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key = array_search($editor, $active_editors);
|
||||
// check auth is valid
|
||||
if ($key !== false) {
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
$fsave = $active_editors[$key];
|
||||
$active_editors[$key] = $active_editors[$key - 1];
|
||||
$active_editors[$key - 1] = $fsave;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// at least one editor must be active
|
||||
if (empty($active_editors)) {
|
||||
$active_editors = array('textarea');
|
||||
}
|
||||
|
||||
set_config('texteditors', implode(',', $active_editors));
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
+86
-100
@@ -1,120 +1,106 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
<?PHP // $Id$
|
||||
// enrol.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
/**
|
||||
* Enrol config manipulation script.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage enrol
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
|
||||
$CFG->pagepath = 'enrol';
|
||||
|
||||
$action = required_param('action', PARAM_ACTION);
|
||||
$enrol = required_param('enrol', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
admin_externalpage_setup('enrolment');
|
||||
|
||||
$PAGE->set_url('/admin/enrol.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_sesskey();
|
||||
|
||||
$enabled = enrol_get_plugins(true);
|
||||
$all = enrol_get_plugins(false);
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols'));
|
||||
/// Save settings
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
if (!isset($all[$enrol])) {
|
||||
break;
|
||||
if ($frm = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled[] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (!isset($enabled[$enrol])) {
|
||||
break;
|
||||
if (empty($frm->enable)) {
|
||||
$frm->enable = array();
|
||||
}
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled = array_flip($enabled);
|
||||
$current = $enabled[$enrol];
|
||||
if ($current == 0) {
|
||||
break; //already at the top
|
||||
if (empty($frm->default)) {
|
||||
$frm->default = '';
|
||||
}
|
||||
$enabled = array_flip($enabled);
|
||||
$enabled[$current] = $enabled[$current - 1];
|
||||
$enabled[$current - 1] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
if (!isset($enabled[$enrol])) {
|
||||
break;
|
||||
if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) {
|
||||
$frm->enable[] = $frm->default;
|
||||
}
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled = array_flip($enabled);
|
||||
$current = $enabled[$enrol];
|
||||
if ($current == count($enabled) - 1) {
|
||||
break; //already at the end
|
||||
asort($frm->enable);
|
||||
$frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first
|
||||
set_config('enrol_plugins_enabled', implode(',', $frm->enable));
|
||||
set_config('enrol', $frm->default);
|
||||
redirect("enrol.php", get_string("changessaved"), 1);
|
||||
}
|
||||
|
||||
/// Print the form
|
||||
|
||||
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$options = array();
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
|
||||
|
||||
echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
|
||||
$table = new stdClass();
|
||||
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
|
||||
$table->align = array('left', 'center', 'center', 'center');
|
||||
$table->size = array('60%', '', '', '15%');
|
||||
$table->width = '700';
|
||||
$table->data = array();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
|
||||
foreach ($modules as $module) {
|
||||
|
||||
// skip if directory is empty
|
||||
if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
|
||||
continue;
|
||||
}
|
||||
$enabled = array_flip($enabled);
|
||||
$enabled[$current] = $enabled[$current + 1];
|
||||
$enabled[$current + 1] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
|
||||
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
|
||||
$name = get_string("enrolname", "enrol_$module");
|
||||
$plugin = enrolment_factory::factory($module);
|
||||
$enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
|
||||
if (in_array($module, $enabledplugins)) {
|
||||
$enable .= ' checked="checked"';
|
||||
}
|
||||
if ($module == 'manual') {
|
||||
$enable .= ' disabled="disabled"';
|
||||
}
|
||||
$enable .= ' />';
|
||||
if (method_exists($plugin, 'print_entry')) {
|
||||
$default = '<input type="radio" name="default" value="'.$module.'"';
|
||||
if ($CFG->enrol == $module) {
|
||||
$default .= ' checked="checked"';
|
||||
}
|
||||
$default .= ' />';
|
||||
} else {
|
||||
$strplugin = $enrol;
|
||||
$default = '';
|
||||
}
|
||||
$table->data[$name] = array($name, $enable, $default,
|
||||
'<a href="enrol_config.php?enrol='.$module.'">'.$str->edit.'</a>');
|
||||
}
|
||||
asort($table->data);
|
||||
|
||||
if (!$confirm) {
|
||||
$uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
print_table($table);
|
||||
|
||||
} else { // Delete everything!!
|
||||
uninstall_plugin('enrol', $enrol);
|
||||
echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n";
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
$a->plugin = $strplugin;
|
||||
$a->directory = "$CFG->dirroot/enrol/$enrol";
|
||||
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
|
||||
redirect($return);
|
||||
?>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once("../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('enrolment');
|
||||
|
||||
$enrol = required_param('enrol', PARAM_ALPHA);
|
||||
$CFG->pagepath = 'enrol/' . $enrol;
|
||||
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory($enrol);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
if ($enrolment->process_config($frm)) {
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
} else {
|
||||
$frm = $CFG;
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
|
||||
unset($options);
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
echo "<input type=\"hidden\" name=\"enrol\" value=\"".$enrol."\" />";
|
||||
|
||||
/// Print current enrolment type description
|
||||
print_simple_box_start("center", "80%");
|
||||
print_heading($options[$enrol]);
|
||||
|
||||
print_simple_box_start("center", "60%", '', 5, 'informationbox');
|
||||
print_string("description", "enrol_$enrol");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<p class=\"centerpara\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></p>\n";
|
||||
print_simple_box_end();
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
+18
-19
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php //$Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -52,18 +52,18 @@
|
||||
$strmisc = get_string('miscellaneous');
|
||||
|
||||
/// Print the header stuff
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
/// Print the component download link
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.sesskey().'">'.$strupdate.'</a></div>';
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.$USER->sesskey.'">'.$strupdate.'</a></div>';
|
||||
|
||||
echo $OUTPUT->heading($strenvironment);
|
||||
print_heading($strenvironment);
|
||||
|
||||
/// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
/// Create component installer and execute it
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
@@ -72,23 +72,23 @@
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest= $CFG->dataroot.'/';
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error', $a), 'errorbox');
|
||||
print_simple_box(get_string($cd->get_error(), 'error', $a), 'center', '', '', 5, 'errorbox');
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error'), 'errorbox');
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center', '', '', 5, 'errorbox');
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error'));
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center');
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
echo $OUTPUT->box(get_string('componentinstalled', 'admin'));
|
||||
print_simple_box(get_string('componentinstalled', 'admin'), 'center');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start of main box
|
||||
echo $OUTPUT->box_start();
|
||||
print_simple_box_start('center');
|
||||
|
||||
echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
///Iterate over each version, adding bigger than current
|
||||
///Iterate over each version, adding bigged than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
@@ -120,18 +120,17 @@
|
||||
}
|
||||
|
||||
/// Print form and popup menu
|
||||
echo '<div style="text-align:center"> ';
|
||||
$select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
|
||||
$select->label = $strmoodleversion;
|
||||
echo $OUTPUT->render($select);
|
||||
echo '<div style="text-align:center">'.$strmoodleversion.' ';
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/environment.php?version=",
|
||||
$versions, 'selectversion', $version, '');
|
||||
echo '</div>';
|
||||
|
||||
/// End of main box
|
||||
echo $OUTPUT->box_end();
|
||||
print_simple_box_end();
|
||||
|
||||
/// Gather and show results
|
||||
$status = check_moodle_environment($version, $environment_results);
|
||||
|
||||
/// Print footer
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
|
||||
+23
-82
@@ -80,6 +80,7 @@
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
@@ -121,11 +122,6 @@
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ctyperecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.9">
|
||||
@@ -139,6 +135,7 @@
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.0" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
@@ -180,13 +177,6 @@
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ctyperecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_check_no_rqp_questions" level="optional">
|
||||
@@ -200,7 +190,7 @@
|
||||
<ON_OK message="questioncwqpfsok" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="required">
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
</FEEDBACK>
|
||||
@@ -214,24 +204,24 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="postgres" version="8.0" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.2.8" level="required">
|
||||
<PHP version="5.2.0" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -239,9 +229,9 @@
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<PHP_EXTENSION name="curl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrequired" />
|
||||
<ON_CHECK message="curlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -259,68 +249,19 @@
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_check_no_rqp_questions" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="qtyperqpwillberemovedanyway" />
|
||||
<ON_OK message="qtyperqpwillberemoved" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php // $Id$
|
||||
// filter.php
|
||||
// Edit text filter settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$filterfull = required_param('filter', PARAM_PATH);
|
||||
$forcereset = optional_param('reset', 0, PARAM_BOOL);
|
||||
|
||||
$filtername = substr($filterfull, strpos( $filterfull, '/' )+1 ) ;
|
||||
|
||||
admin_externalpage_setup('filtersetting'.str_replace('/', '', $filterfull));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters";
|
||||
|
||||
|
||||
// get translated strings for use on page
|
||||
$txt = new Object;
|
||||
$txt->managefilters = get_string( 'managefilters' );
|
||||
$txt->administration = get_string( 'administration' );
|
||||
$txt->configuration = get_string( 'configuration' );
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
// if reset pressed let filter config page handle it
|
||||
if ($config = data_submitted() and !$forcereset) {
|
||||
|
||||
// check session key
|
||||
if (!confirm_sesskey()) {
|
||||
error( get_string('confirmsesskeybad', 'error' ) );
|
||||
}
|
||||
|
||||
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
|
||||
if (file_exists($configpath)) {
|
||||
require_once($configpath);
|
||||
$functionname = $filtername.'_process_config';
|
||||
if (function_exists($functionname)) {
|
||||
$functionname($config);
|
||||
$saved = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($saved)) {
|
||||
// run through submitted data
|
||||
// reject if does not start with filter_
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, stripslashes($value));
|
||||
}
|
||||
}
|
||||
|
||||
reset_text_filters_cache();
|
||||
|
||||
redirect($returnurl);
|
||||
exit;
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
$filtername = ucfirst($filtername);
|
||||
admin_externalpage_print_header();
|
||||
print_heading( $filtername );
|
||||
|
||||
print_simple_box(get_string("configwarning", "admin"), "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center",'');
|
||||
|
||||
?>
|
||||
<form action="filter.php?filter=<?php echo urlencode($filterfull); ?>" method="post">
|
||||
<div style="text-align: center">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
|
||||
<?php include "$CFG->dirroot/$filterfull/filterconfig.html"; ?>
|
||||
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
<input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
+75
-258
@@ -1,285 +1,102 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
require_once('../config.php');
|
||||
|
||||
/**
|
||||
* Processes actions from the admin_setting_managefilters object (defined in
|
||||
* adminlib.php).
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package administration
|
||||
*//** */
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
|
||||
admin_externalpage_setup('managefilters');
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters";
|
||||
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
$fitlernames = filter_get_all_installed();
|
||||
$newfilters = $fitlernames;
|
||||
foreach ($filters as $filter => $notused) {
|
||||
unset($newfilters[$filter]);
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
/// Process actions ============================================================
|
||||
|
||||
if ($action) {
|
||||
if (!isset($filters[$filterpath]) && !isset($newfilters[$filterpath])) {
|
||||
throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath);
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
// get a list of installed filters
|
||||
$installedfilters = array();
|
||||
$filterlocations = array('mod','filter');
|
||||
foreach ($filterlocations as $filterlocation) {
|
||||
$plugins = get_list_of_plugins($filterlocation);
|
||||
foreach ($plugins as $plugin) {
|
||||
$pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php";
|
||||
if (is_readable($pluginpath)) {
|
||||
$installedfilters["$filterlocation/$plugin"] = "$filterlocation/$plugin";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all the currently selected filters
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$activefilters = explode(',', $CFG->textfilters);
|
||||
} else {
|
||||
$activefilters = array();
|
||||
}
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case 'setstate':
|
||||
if ($newstate = optional_param('newstate', '', PARAM_INTEGER)) {
|
||||
filter_set_global_state($filterpath, $newstate);
|
||||
if ($newstate == TEXTFILTER_DISABLED) {
|
||||
filter_set_applies_to_strings($filterpath, false);
|
||||
}
|
||||
unset($newfilters[$filterpath]);
|
||||
case 'hide':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
break;
|
||||
}
|
||||
// just delete it
|
||||
unset($activefilters[$key]);
|
||||
break;
|
||||
|
||||
case 'show':
|
||||
// check filterpath is valid
|
||||
if (!array_key_exists($filterpath, $installedfilters)) {
|
||||
error("Filter $filterpath is not currently installed", $url);
|
||||
} elseif (array_search($filterpath,$activefilters)) {
|
||||
// filterpath is already active - doubleclick??
|
||||
} else {
|
||||
// add it to installed filters
|
||||
$activefilters[] = $filterpath;
|
||||
$activefilters = array_unique($activefilters);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'setapplyto':
|
||||
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
|
||||
filter_set_applies_to_strings($filterpath, $applytostrings);
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
if ($oldpos <= count($filters)) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
|
||||
}
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $filterpath is not currently active", $url);
|
||||
} elseif ($key>=(count($activefilters)-1)) {
|
||||
// cannot be moved any further down - doubleclick??
|
||||
} else {
|
||||
// swap with $key+1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key+1];
|
||||
$activefilters[$key+1] = $fsave;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
if ($oldpos >= 1) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
|
||||
}
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $filterpath is not currently active", $url);
|
||||
} elseif ($key<1) {
|
||||
//cannot be moved any further up - doubleclick??
|
||||
} else {
|
||||
// swap with $key-1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key-1];
|
||||
$activefilters[$key-1] = $fsave;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if (!empty($filternames[$filterpath])) {
|
||||
$filtername = $filternames[$filterpath];
|
||||
} else {
|
||||
$filtername = $filterpath;
|
||||
}
|
||||
|
||||
if (substr($filterpath, 0, 4) == 'mod/') {
|
||||
$mod = basename($filterpath);
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->module = get_string('modulename', $mod);
|
||||
print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$title = get_string('deletefilterareyousure', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
|
||||
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
$title = get_string('deletingfilter', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
// Delete all data for this plugin.
|
||||
filter_delete_all_for_filter($filterpath);
|
||||
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->directory = $filterpath;
|
||||
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Add any missing filters to the DB table.
|
||||
foreach ($newfilters as $filter => $notused) {
|
||||
filter_set_global_state($filter, TEXTFILTER_DISABLED);
|
||||
}
|
||||
// save, reset cache and return
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
reset_text_filters_cache();
|
||||
redirect($returnurl);
|
||||
|
||||
// Reset caches and return
|
||||
if ($action) {
|
||||
reset_text_filters_cache();
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
/// End of process actions =====================================================
|
||||
|
||||
/// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
|
||||
|
||||
$activechoices = array(
|
||||
TEXTFILTER_DISABLED => get_string('disabled', 'filters'),
|
||||
TEXTFILTER_OFF => get_string('offbutavailable', 'filters'),
|
||||
TEXTFILTER_ON => get_string('on', 'filters'),
|
||||
);
|
||||
$applytochoices = array(
|
||||
0 => get_string('content', 'filters'),
|
||||
1 => get_string('contentandheadings', 'filters'),
|
||||
);
|
||||
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
$filternames = filter_get_all_installed();
|
||||
$newfilters = $filternames;
|
||||
foreach ($filters as $filter => $notused) {
|
||||
unset($newfilters[$filter]);
|
||||
}
|
||||
$stringfilters = filter_get_string_filters();
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
|
||||
$table->align = array('left', 'left', 'center', 'left', 'left');
|
||||
$table->width = '100%';
|
||||
$table->data = array();
|
||||
|
||||
$lastactive = null;
|
||||
foreach ($filters as $filter => $filterinfo) {
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
$lastactive = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
// iterate through filters adding to display table
|
||||
$firstrow = true;
|
||||
foreach ($filters as $filter => $filterinfo) {
|
||||
$applytostrings = isset($stringfilters[$filter]) && $filterinfo->active != TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($filterinfo, $firstrow, $filter == $lastactive, $applytostrings);
|
||||
$table->data[] = $row;
|
||||
if ($filterinfo->active == TEXTFILTER_DISABLED) {
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
} else {
|
||||
$table->rowclasses[] = '';
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
foreach ($newfilters as $filter => $filtername) {
|
||||
$filterinfo = new stdClass;
|
||||
$filterinfo->filter = $filter;
|
||||
$filterinfo->active = TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($filterinfo, false, false, false);
|
||||
$table->data[] = $row;
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
}
|
||||
|
||||
echo html_writer::table($table);
|
||||
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
/// Display helper functions ===================================================
|
||||
|
||||
function filters_action_url($filterpath, $action) {
|
||||
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
|
||||
}
|
||||
|
||||
function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) {
|
||||
global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!!
|
||||
$row = array();
|
||||
$filter = $filterinfo->filter;
|
||||
|
||||
// Filter name
|
||||
if (!empty($filternames[$filter])) {
|
||||
$row[] = $filternames[$filter];
|
||||
} else {
|
||||
$row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>';
|
||||
}
|
||||
|
||||
// Disable/off/on
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Re-order
|
||||
$updown = '';
|
||||
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" /> ';
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
if (!$isfirstrow) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
if (!$islastactive) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
}
|
||||
$row[] = $updown;
|
||||
|
||||
// Apply to strings.
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
|
||||
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Settings link, if required
|
||||
if (filter_has_global_settings($filter)) {
|
||||
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' .
|
||||
str_replace('/', '',$filter) . '">' . get_string('settings') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if (substr($filter, 0, 4) != 'mod/') {
|
||||
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
?>
|
||||
|
||||
-1336
File diff suppressed because it is too large
Load Diff
+12
-41
@@ -1,20 +1,19 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
/** This expects the output from a command like
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
|
||||
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
|
||||
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
|
||||
*/
|
||||
|
||||
die('TODO: MDL-19380');
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$FULLME='cron';
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->libdir.'/eventslib.php');
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
|
||||
|
||||
$site = get_site();
|
||||
@@ -30,7 +29,7 @@ while(!feof($fd)) {
|
||||
$bits = explode('/',$file);
|
||||
$a->filename = $bits[count($bits)-1];
|
||||
|
||||
if (!$log = $DB->get_record("log", array("module"=>"upload", "info"=>$file, "action"=>"upload"))) {
|
||||
if (!$log = get_record("log","module","upload","info",$file,"action","upload")) {
|
||||
$a->action = clam_handle_infected_file($file,0,false);
|
||||
clam_replace_infected_file($file);
|
||||
notify_admins_unknown($file,$a);
|
||||
@@ -38,9 +37,9 @@ while(!feof($fd)) {
|
||||
}
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
$user = $DB->get_record("user", array("id"=>$log->userid));
|
||||
$course = $DB->get_record("course", array("id"=>$log->course));
|
||||
|
||||
$user = get_record("user","id",$log->userid);
|
||||
$course = get_record("course","id",$log->course);
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
@@ -60,17 +59,7 @@ function notify_user($user,$subject,$a) {
|
||||
return false;
|
||||
}
|
||||
$body = get_string('virusfoundlater','moodle',$a);
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userto = $user;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
email_to_user($user,get_admin(),$subject,$body);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,37 +69,19 @@ function notify_admins($user,$subject,$a) {
|
||||
|
||||
$body = get_string('virusfoundlateradmin','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = $admin;
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function notify_admins_unknown($file,$a) {
|
||||
|
||||
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = $admin;
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,4 +114,4 @@ function validate_line($line) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+64
-292
@@ -1,13 +1,15 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
ob_start(); //for whitespace test
|
||||
require_once('../config.php');
|
||||
|
||||
// extra whitespace test - intentionally breaks cookieless mode
|
||||
$extraws = '';
|
||||
while (ob_get_level()) {
|
||||
while (true) {
|
||||
$extraws .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
if (!@ob_end_clean()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -22,11 +24,11 @@
|
||||
$solution = optional_param('solution', 0, PARAM_SAFEDIR); //in fact it is class name alhanumeric and _
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
$site = get_site();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo <<<STYLES
|
||||
<style type="text/css">
|
||||
@@ -98,13 +100,12 @@ STYLES;
|
||||
}
|
||||
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
|
||||
function health_find_problems() {
|
||||
global $OUTPUT;
|
||||
|
||||
echo $OUTPUT->heading(get_string('healthcenter'));
|
||||
print_heading(get_string('healthcenter'));
|
||||
|
||||
$issues = array(
|
||||
SEVERITY_CRITICAL => array(),
|
||||
@@ -138,7 +139,7 @@ function health_find_problems() {
|
||||
echo '</div>';
|
||||
}
|
||||
else {
|
||||
echo $OUTPUT->heading(get_string('healthproblemsdetected'));
|
||||
print_heading(get_string('healthproblemsdetected'));
|
||||
$severities = array(SEVERITY_CRITICAL, SEVERITY_SIGNIFICANT, SEVERITY_ANNOYANCE, SEVERITY_NOTICE);
|
||||
foreach($severities as $severity) {
|
||||
if(!empty($issues[$severity])) {
|
||||
@@ -157,7 +158,6 @@ function health_find_problems() {
|
||||
}
|
||||
|
||||
function health_print_solution($classname) {
|
||||
global $OUTPUT;
|
||||
$problem = new $classname;
|
||||
$data = array(
|
||||
'title' => $problem->title(),
|
||||
@@ -166,8 +166,8 @@ function health_print_solution($classname) {
|
||||
'solution' => $problem->solution()
|
||||
);
|
||||
|
||||
echo $OUTPUT->heading(get_string('healthcenter'));
|
||||
echo $OUTPUT->heading(get_string('healthproblemsolution'));
|
||||
print_heading(get_string('healthcenter'));
|
||||
print_heading(get_string('healthproblemsolution'));
|
||||
echo '<dl class="healthissues '.$data['severity'].'">';
|
||||
echo '<dt>'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'].'</dd>';
|
||||
@@ -196,6 +196,32 @@ class problem_base {
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000001 extends problem_base {
|
||||
function title() {
|
||||
return 'Invalid value for $CFG->dirroot';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
if (!empty($dirroot) && $dirroot != $CFG->dirroot) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> file contains the setting <strong>$CFG->dirroot = "'.$CFG->dirroot.'"</strong>, which is incorrect. Unless you correct this problem, Moodle will not function correctly, if at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
return 'You need to edit your <strong>config.php</strong> file. Find the line which reads <pre>$CFG->dirroot = \''.$CFG->dirroot.'\';</pre> and change it to read <pre>$CFG->dirroot = \''.$dirroot.'\'</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000002 extends problem_base {
|
||||
function title() {
|
||||
return 'Extra characters at the end of config.php or other library function';
|
||||
@@ -249,8 +275,8 @@ class problem_000004 extends problem_base {
|
||||
return 'cron.php is not set up to run automatically';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
$lastcron = $DB->get_field_sql('SELECT max(lastcron) FROM {modules}');
|
||||
global $CFG;
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM '.$CFG->prefix.'modules');
|
||||
return (time() - $lastcron > 3600 * 24);
|
||||
}
|
||||
function severity() {
|
||||
@@ -327,10 +353,8 @@ class problem_000008 extends problem_base {
|
||||
return 'PHP: memory_limit cannot be controlled by Moodle';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
|
||||
$oldmemlimit = @ini_get('memory_limit');
|
||||
if (empty($oldmemlimit)) {
|
||||
if(empty($oldmemlimit)) {
|
||||
// PHP not compiled with memory limits, this means that it's
|
||||
// probably limited to 8M or in case of Windows not at all.
|
||||
// We can ignore it for now - there is not much to test anyway
|
||||
@@ -338,9 +362,8 @@ class problem_000008 extends problem_base {
|
||||
return false;
|
||||
}
|
||||
$oldmemlimit = get_real_size($oldmemlimit);
|
||||
//now lets change the memory limit to something higher
|
||||
$newmemlimit = ($oldmemlimit + 1024*1024*5);
|
||||
raise_memory_limit($newmemlimit);
|
||||
//now lets change the memory limit to something unique below 128M==134217728
|
||||
@ini_set('memory_limit', 134217720);
|
||||
$testmemlimit = get_real_size(@ini_get('memory_limit'));
|
||||
//verify the change had any effect at all
|
||||
if ($oldmemlimit == $testmemlimit) {
|
||||
@@ -351,7 +374,7 @@ class problem_000008 extends problem_base {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
reduce_memory_limit($oldmemlimit);
|
||||
@ini_set('memory_limit', $oldmemlimit);
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
@@ -388,7 +411,7 @@ class problem_000009 extends problem_base {
|
||||
return 'You should change the password of the user <strong>'.$CFG->dbuser.'</strong> both in your database and in your Moodle <strong>config.php</strong> immediately!'.($CFG->dbuser != 'root'?'':' It would also be a good idea to change the user account from root to something else, because this would lessen the impact in the event that your database is compromised anyway.');
|
||||
}
|
||||
}
|
||||
/* // not implemented in 2.0 yet
|
||||
|
||||
class problem_000010 extends problem_base {
|
||||
function title() {
|
||||
return 'Uploaded files: slasharguments disabled or not working';
|
||||
@@ -473,292 +496,41 @@ class problem_000010 extends problem_base {
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
class problem_000012 extends problem_base {
|
||||
class problem_000011 extends problem_base {
|
||||
function title() {
|
||||
return 'Random questions data consistency';
|
||||
return 'Session errors detected';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
return $DB->record_exists_select('question', "qtype = 'random' AND parent <> id", array());
|
||||
global $CFG;
|
||||
return isset($CFG->session_error_counter);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>For random questions, question.parent should equal question.id. ' .
|
||||
'There are some questions in your database for which this is not true. ' .
|
||||
'One way that this could have happened is for random questions restored from backup before ' .
|
||||
'<a href="http://tracker.moodle.org/browse/MDL-5482">MDL-5482</a> was fixed.</p>';
|
||||
global $CFG;
|
||||
if (isset($CFG->session_error_counter)) {
|
||||
return 'Session problems were detected. Total count: '.$CFG->session_error_counter;
|
||||
} else {
|
||||
return 'No session errors detected.';
|
||||
}
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the SQL</p>' .
|
||||
'<pre>UPDATE ' . $CFG->prefix . 'question SET parent = id WHERE qtype = \'random\' and parent <> id;</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000013 extends problem_base {
|
||||
function title() {
|
||||
return 'Multi-answer questions data consistency';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
$positionexpr = $DB->sql_position($DB->sql_concat("','", "q.id", "','"),
|
||||
$DB->sql_concat("','", "qma.sequence", "','"));
|
||||
return $DB->record_exists_sql("
|
||||
SELECT * FROM {question} q
|
||||
JOIN {question_multianswer} qma ON $positionexpr > 0
|
||||
WHERE qma.question <> q.parent") ||
|
||||
$DB->record_exists_sql("
|
||||
SELECT * FROM {question} q
|
||||
JOIN {question} parent_q ON parent_q.id = q.parent
|
||||
WHERE q.category <> parent_q.category");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>For each sub-question whose id is listed in ' .
|
||||
'question_multianswer.sequence, its question.parent field should equal ' .
|
||||
'question_multianswer.question; and each sub-question should be in the same ' .
|
||||
'category as its parent. There are questions in your database for ' .
|
||||
'which this is not the case. One way that this could have happened is ' .
|
||||
'for multi-answer questions restored from backup before ' .
|
||||
'<a href="http://tracker.moodle.org/browse/MDL-14750">MDL-14750</a> was fixed.</p>';
|
||||
}
|
||||
function solution() {
|
||||
return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the ' .
|
||||
'code in question_multianswer_fix_subquestion_parents_and_categories in ' .
|
||||
'<a href="http://cvs.moodle.org/moodle/question/type/multianswer/db/upgrade.php?revision=1.1.10.2&view=markup">/question/type/multianswer/db/upgrade.php' .
|
||||
'from the 1.9 stable branch</a>.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000014 extends problem_base {
|
||||
function title() {
|
||||
return 'Only multianswer and random questions should be the parent of another question';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
return $DB->record_exists_sql("
|
||||
SELECT * FROM {question} q
|
||||
JOIN {question} parent_q ON parent_q.id = q.parent
|
||||
WHERE parent_q.qtype NOT IN ('random', 'multianswer')");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>You have questions that violate this in your databse. ' .
|
||||
'You will need to investigate to determine how this happened.</p>';
|
||||
}
|
||||
function solution() {
|
||||
return '<p>It is impossible to give a solution without knowing more about ' .
|
||||
' how the problem was caused. You may be able to get help from the ' .
|
||||
'<a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a>.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000015 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories should belong to a valid context';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
return $DB->record_exists_sql("
|
||||
SELECT qc.*, (SELECT COUNT(1) FROM {question} q WHERE q.category = qc.id) AS numquestions
|
||||
FROM {question_categories} qc
|
||||
LEFT JOIN {context} con ON qc.contextid = con.id
|
||||
WHERE con.id IS NULL");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $DB;
|
||||
$problemcategories = $DB->get_records_sql("
|
||||
SELECT qc.id, qc.name, qc.contextid, (SELECT COUNT(1) FROM {question} q WHERE q.category = qc.id) AS numquestions
|
||||
FROM {question_categories} qc
|
||||
LEFT JOIN {context} con ON qc.contextid = con.id
|
||||
WHERE con.id IS NULL
|
||||
ORDER BY numquestions DESC, qc.name");
|
||||
$table = '<table><thead><tr><th>Cat id</th><th>Category name</th>' .
|
||||
"<th>Context id</th><th>Num Questions</th></tr></thead><tbody>\n";
|
||||
foreach ($problemcategories as $cat) {
|
||||
$table .= "<tr><td>$cat->id</td><td>" . s($cat->name) . "</td><td>" .
|
||||
$cat->contextid ."</td><td>$cat->numquestions</td></tr>\n";
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
return '<p>All question categories are linked to a context id, and, ' .
|
||||
'the context they are linked to must exist. The following categories ' .
|
||||
'belong to a non-existant category:</p>' . $table . '<p>Any of these ' .
|
||||
'categories that contain no questions can just be deleted form the database. ' .
|
||||
'Other categories will require more thought.</p>';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>You can delete the empty categories by executing the following SQL:</p><pre>
|
||||
DELETE FROM ' . $CFG->prefix . 'question_categories
|
||||
WHERE
|
||||
NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'question q WHERE q.category = ' . $CFG->prefix . 'question_categories.id)
|
||||
AND NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'context con WHERE contextid = con.id)
|
||||
</pre><p>Any remaining categories that contain questions will require more thought. ' .
|
||||
'People in the <a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a> may be able to help.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000016 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories should belong to the same context as their parent';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
return $DB->record_exists_sql("
|
||||
SELECT parent_qc.id AS parent, child_qc.id AS child, child_qc.contextid
|
||||
FROM {question_categories} child_qc
|
||||
JOIN {question_categories} parent_qc ON child_qc.parent = parent_qc.id
|
||||
WHERE child_qc.contextid <> parent_qc.contextid");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $DB;
|
||||
$problemcategories = $DB->get_records_sql("
|
||||
SELECT
|
||||
parent_qc.id AS parentid, parent_qc.name AS parentname, parent_qc.contextid AS parentcon,
|
||||
child_qc.id AS childid, child_qc.name AS childname, child_qc.contextid AS childcon
|
||||
FROM {question_categories} child_qc
|
||||
JOIN {question_categories} parent_qc ON child_qc.parent = parent_qc.id
|
||||
WHERE child_qc.contextid <> parent_qc.contextid");
|
||||
$table = '<table><thead><tr><th colspan="3">Child category</th><th colspan="3">Parent category</th></tr><tr>' .
|
||||
'<th>Id</th><th>Name</th><th>Context id</th>' .
|
||||
'<th>Id</th><th>Name</th><th>Context id</th>' .
|
||||
"</tr></thead><tbody>\n";
|
||||
foreach ($problemcategories as $cat) {
|
||||
$table .= "<tr><td>$cat->childid</td><td>" . s($cat->childname) .
|
||||
"</td><td>$cat->childcon</td><td>$cat->parentid</td><td>" . s($cat->parentname) .
|
||||
"</td><td>$cat->parentcon</td></tr>\n";
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
return '<p>When one question category is the parent of another, then they ' .
|
||||
'should both belong to the same context. This is not true for the following categories:</p>' .
|
||||
$table;
|
||||
}
|
||||
function solution() {
|
||||
return '<p>An automated solution is difficult. It depends whether the ' .
|
||||
'parent or child category is in the wrong pace.' .
|
||||
'People in the <a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a> may be able to help.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000017 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories tree structure';
|
||||
}
|
||||
function find_problems() {
|
||||
global $DB;
|
||||
static $answer = null;
|
||||
|
||||
if (is_null($answer)) {
|
||||
$categories = $DB->get_records('question_categories', array(), 'id');
|
||||
|
||||
// Look for missing parents.
|
||||
$missingparent = array();
|
||||
foreach ($categories as $category) {
|
||||
if ($category->parent != 0 && !array_key_exists($category->parent, $categories)) {
|
||||
$missingparent[$category->id] = $category;
|
||||
}
|
||||
if (optional_param('resetsesserrorcounter', 0, PARAM_BOOL)) {
|
||||
if (get_field('config', 'name', 'name', 'session_error_counter')) {
|
||||
delete_records('config', 'name', 'session_error_counter');
|
||||
}
|
||||
|
||||
// Look for loops.
|
||||
$loops = array();
|
||||
while (!empty($categories)) {
|
||||
$current = array_pop($categories);
|
||||
$thisloop = array($current->id => $current);
|
||||
while (true) {
|
||||
if (isset($thisloop[$current->parent])) {
|
||||
// Loop detected
|
||||
$loops[$current->id] = $thisloop;
|
||||
break;
|
||||
} else if (!isset($categories[$current->parent])) {
|
||||
// Got to the top level, or a category we already know is OK.
|
||||
break;
|
||||
} else {
|
||||
// Continue following the path.
|
||||
$current = $categories[$current->parent];
|
||||
$thisloop[$current->id] = $current;
|
||||
unset($categories[$current->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$answer = array($missingparent, $loops);
|
||||
return 'Error counter was cleared.';
|
||||
} else {
|
||||
return '<p>Session errors can be caused by:<ul><li>unresolved problem in server software (aka random switching of users),</li><li>blocked or modified cookies,</li><li>deleting of active session files.</li></ul></p><p><a href="'.me().'&resetsesserrorcounter=1">Reset counter.</a></p>';
|
||||
}
|
||||
|
||||
return $answer;
|
||||
}
|
||||
function exists() {
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
return !empty($missingparent) || !empty($loops);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
|
||||
$description = '<p>The question categories should be arranged into tree ' .
|
||||
' structures by the question_categories.parent field. Sometimes ' .
|
||||
' this tree structure gets messed up.</p>';
|
||||
|
||||
if (!empty($missingparent)) {
|
||||
$description .= '<p>The following categories are missing their parents:</p><ul>';
|
||||
foreach ($missingparent as $cat) {
|
||||
$description .= "<li>Category $cat->id: " . s($cat->name) . "</li>\n";
|
||||
}
|
||||
$description .= "</ul>\n";
|
||||
}
|
||||
|
||||
if (!empty($loops)) {
|
||||
$description .= '<p>The following categories form a loop of parents:</p><ul>';
|
||||
foreach ($loops as $loop) {
|
||||
$description .= "<li><ul>\n";
|
||||
foreach ($loop as $cat) {
|
||||
$description .= "<li>Category $cat->id: " . s($cat->name) . " has parent $cat->parent</li>\n";
|
||||
}
|
||||
$description .= "</ul></li>\n";
|
||||
}
|
||||
$description .= "</ul>\n";
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
|
||||
$solution = '<p>Consider executing the following SQL queries. These fix ' .
|
||||
'the problem by moving some categories to the top level.</p>';
|
||||
|
||||
if (!empty($missingparent)) {
|
||||
$solution .= "<pre>UPDATE " . $CFG->prefix . "question_categories\n" .
|
||||
" SET parent = 0\n" .
|
||||
" WHERE id IN (" . implode(',', array_keys($missingparent)) . ");</pre>\n";
|
||||
}
|
||||
|
||||
if (!empty($loops)) {
|
||||
$solution .= "<pre>UPDATE " . $CFG->prefix . "question_categories\n" .
|
||||
" SET parent = 0\n" .
|
||||
" WHERE id IN (" . implode(',', array_keys($loops)) . ");</pre>\n";
|
||||
}
|
||||
|
||||
return $solution;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class problem_00000x extends problem_base {
|
||||
function title() {
|
||||
return '';
|
||||
@@ -787,4 +559,4 @@ TODO:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+619
-384
File diff suppressed because it is too large
Load Diff
+29
-31
@@ -1,45 +1,43 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toinodb');
|
||||
admin_externalpage_setup('toinodb');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB');
|
||||
admin_externalpage_print_header();
|
||||
print_heading('Convert all MySQL tables from MYISAM to InnoDB');
|
||||
|
||||
if ($DB->get_dbfamily() != 'mysql') {
|
||||
if ($CFG->dbfamily != 'mysql') {
|
||||
notice('This function is for MySQL databases only!', 'index.php');
|
||||
}
|
||||
}
|
||||
|
||||
if (data_submitted() and $confirm and confirm_sesskey()) {
|
||||
if (data_submitted() and $confirm and confirm_sesskey()) {
|
||||
|
||||
echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
|
||||
notify('Please be patient and wait for this to complete...', 'notifysuccess');
|
||||
|
||||
if ($tables = $DB->get_tables()) {
|
||||
$DB->set_debug(true);
|
||||
foreach ($tables as $table) {
|
||||
$fulltable = $DB->get_prefix().$table;
|
||||
$DB->change_database_structure("ALTER TABLE $fulltable TYPE=INNODB");
|
||||
}
|
||||
$DB->set_debug(false);
|
||||
}
|
||||
echo $OUTPUT->notification('... done.', 'notifysuccess');
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
} else {
|
||||
$optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
|
||||
$formcontinue = new single_button(new moodle_url('/admin/innodb.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url('/admin/index.php'), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
if ($tables = $db->MetaTables()) {
|
||||
$db->debug = true;
|
||||
foreach ($tables as $table) {
|
||||
execute_sql("ALTER TABLE $table TYPE=INNODB; ");
|
||||
}
|
||||
$db->debug = false;
|
||||
}
|
||||
notify('... done.', 'notifysuccess');
|
||||
print_continue('index.php');
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
} else {
|
||||
$optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
|
||||
notice_yesno('Are you sure you want convert all your tables to the InnoDB format?',
|
||||
'innodb.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+1370
File diff suppressed because it is too large
Load Diff
Executable
+259
@@ -0,0 +1,259 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* This script enables Moodle translators to edit /docs and /help language
|
||||
* files directly via WWW interface.
|
||||
*
|
||||
* Author: mudrd8mz@uxit.pedf.cuni.cz (http://moodle.cz)
|
||||
* Based on: lang.php in 1.4.3+ release
|
||||
* Thanks: Jaime Villate for important bug fixing, koen roggemans for his job and all moodlers
|
||||
* for intensive testing of this my first contribution
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('langedit');
|
||||
|
||||
//
|
||||
// Some local configuration
|
||||
//
|
||||
$fileeditorrows = 12; // number of textareas' rows
|
||||
$fileeditorcols = 100; // dtto cols
|
||||
$fileeditorinline = 1; // shall be textareas put in one row?
|
||||
$filemissingmark = ' (***)'; // mark to add to non-existing filenames in selection form
|
||||
$fileoldmark = ' (old?)'; // mark to add to filenames in selection form id english version is newer
|
||||
// or to filenames with filesize() == 0
|
||||
$filetemplate = ''; // template for new files, i.e. '$Id$';
|
||||
|
||||
$currentfile = optional_param('currentfile', 'docs/README.txt', PARAM_PATH);
|
||||
|
||||
$strlanguage = get_string("language");
|
||||
$strcurrentlanguage = get_string("currentlanguage");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$stredithelpdocs = get_string('edithelpdocs', 'admin');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
notify('NOTICE: This interface is obsolete now and will be removed. You should use
|
||||
improved <a href="lang.php?mode=helpfiles">lang.php</a> interface.');
|
||||
|
||||
$currentlang = current_language();
|
||||
$langdir = "$CFG->dataroot/lang/$currentlang";
|
||||
$enlangdir = "$CFG->dirroot/lang/en_utf8";
|
||||
|
||||
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
// Shall I save POSTed data?
|
||||
|
||||
if (isset($_POST['currentfile'])) {
|
||||
if (confirm_sesskey()) {
|
||||
if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_reporting(0); // Error reporting turned off due to non-existing files
|
||||
|
||||
// Generate selection for all help and documentation files
|
||||
|
||||
// Get all files from /docs directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the docs files.
|
||||
$options["docs/$file"] = "docs/$file";
|
||||
// add mark if file doesn't exist or is empty
|
||||
if (( !file_exists("$langdir/docs/$file")) || (filesize("$langdir/docs/$file") == 0)) {
|
||||
$options["docs/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/docs/$file") < filemtime("$CFG->dirroot/lang/en_utf8/docs/$file")) {
|
||||
$options["docs/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all files from /help directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
$options["help/$file"] = "help/$file";
|
||||
if (( !file_exists("$langdir/help/$file")) || (filesize("$CFG->dirroot/lang/en_utf8/help/$file") == 0)) {
|
||||
$options["help/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/help/$file") < filemtime("$langdir/help/$file")) {
|
||||
$options["help/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr><td align=\"center\">";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=", $options, "choosefile", $currentfile, "", "", "", true);
|
||||
echo "</td></tr></table>";
|
||||
|
||||
// Generate textareas
|
||||
|
||||
if (!empty($currentfile)) {
|
||||
|
||||
if (!file_exists("$langdir/$currentfile")) {
|
||||
//check if directory exist
|
||||
$pathparts = explode('/',$currentfile);
|
||||
$checkpath = $langdir;
|
||||
for ($a=0; $a < count($pathparts)-1 ; $a++) {
|
||||
$checkpath .= "/".$pathparts[$a];
|
||||
if(!file_exists($checkpath)){
|
||||
if(!mkdir($checkpath)){
|
||||
echo ("Cannot create directory: $checkpath");
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// file doesn't exist - let's check webserver's permission to create it
|
||||
//
|
||||
if (!touch("$langdir/$currentfile")) {
|
||||
//
|
||||
// webserver is unable to create new file
|
||||
//
|
||||
echo "<p align=\"center\"><font color=red>".get_string("filemissing", "", "
|
||||
$langdir/$currentfile")."</font></p>";
|
||||
$editable = false;
|
||||
} else {
|
||||
//
|
||||
// webserver can create new file - we can delete it now and let
|
||||
// the langdoc_save_file() create it again if its filesize() > 0
|
||||
//
|
||||
$editable = true;
|
||||
unlink("$langdir/$currentfile");
|
||||
}
|
||||
} elseif ($f = fopen("$langdir/$currentfile","r+")) {
|
||||
//
|
||||
// file exists and is writeable - good for you, translator ;-)
|
||||
//
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
} else {
|
||||
//
|
||||
// file exists but it is not writeable by web server process :-(
|
||||
//
|
||||
$editable = false;
|
||||
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")
|
||||
."</font></p>";
|
||||
}
|
||||
|
||||
//en_utf8 in dataroot is not editable
|
||||
if ($currentlang == 'en_utf8') {
|
||||
$editable = false;
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr valign=\"center\"><td align=\"center\">\n";
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"\">\n";
|
||||
echo htmlspecialchars(file_get_contents("$enlangdir/$currentfile"));
|
||||
echo "</textarea>\n";
|
||||
//link_to_popup_window("/lang/en_utf8/$currentfile", "popup", get_string("preview"));
|
||||
$preview_url = langdoc_preview_url($currentfile);
|
||||
if ($preview_url) {
|
||||
link_to_popup_window($preview_url.'&forcelang=en_utf8', 'popup', get_string('preview'));
|
||||
}
|
||||
echo "</td>\n";
|
||||
if ($fileeditorinline == 1) {
|
||||
echo "</tr>\n<tr valign=\"center\">\n";
|
||||
}
|
||||
echo "<td align=\"center\">\n";
|
||||
|
||||
if ($editable) {
|
||||
echo "<form id=\"$currentfile\" action=\"langdoc.php\" method=\"post\">";
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"filedata\">\n";
|
||||
if (file_exists("$langdir/$currentfile")) {
|
||||
echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
|
||||
} else {
|
||||
echo ($filetemplate);
|
||||
}
|
||||
echo "</textarea>\n";
|
||||
$preview_url = langdoc_preview_url($currentfile);
|
||||
if ($preview_url) {
|
||||
link_to_popup_window($preview_url, 'popup', get_string('preview'));
|
||||
}
|
||||
echo '<div align="center"><input type="submit" value="'.get_string('savechanges').': lang/'.$currentlang.'/'.$currentfile.'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
echo "</td>\n</tr>\n</table>";
|
||||
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
function langdoc_save_file($path, $file, $content) {
|
||||
|
||||
// $path is a full pathname to the file
|
||||
// $file is the file to overwrite.
|
||||
// $content are data to write
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
if (!$f = fopen("$path/$file","w")) {
|
||||
error_reporting($CFG->debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
$content = str_replace("\r", "",$content); // Remove linefeed characters
|
||||
$content = preg_replace("/\n{3,}/", "\n\n", $content); // Collapse runs of blank lines
|
||||
$content = trim($content); // Delete leading/trailing whitespace
|
||||
|
||||
fwrite($f, stripslashes($content));
|
||||
|
||||
fclose($f);
|
||||
|
||||
// Remove file if its empty
|
||||
|
||||
if (filesize("$path/$file") == 0) {
|
||||
unlink("$path/$file");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a preview URL for the file, if available.
|
||||
*
|
||||
* Documentation will be moved into moodle.org wiki and current version 1.6 does not
|
||||
* seem to be able to display local documentation. Thus, return empty URL for doc files.
|
||||
* See lib/moodlelib.php document_file() - it still relies on old pre-UTF8 lang/ location.
|
||||
*/
|
||||
function langdoc_preview_url($currentfile) {
|
||||
if (substr($currentfile, 0, 5) == 'help/') {
|
||||
$currentfile = substr($currentfile, 5);
|
||||
$currentpathexp = explode('/', $currentfile);
|
||||
if (count($currentpathexp) > 1) {
|
||||
$url = '/help.php?module='.implode('/',array_slice($currentpathexp,0,count($currentpathexp)-1)).'&file='.end($currentpathexp);
|
||||
} else {
|
||||
$url = '/help.php?module=moodle&file='.$currentfile;
|
||||
}
|
||||
} else {
|
||||
$url = '';
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
+348
-348
@@ -1,387 +1,387 @@
|
||||
<?php
|
||||
<?php //$Id$
|
||||
///This file only manages the installation of 1.6 lang packs.
|
||||
///in downloads.moodle.org, they are store in separate directory /lang16
|
||||
///in local server, they are stored in $CFG->dataroot/lang
|
||||
///This helps to avoid confusion.
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
/**
|
||||
* Fetches language packages from download.moodle.org server
|
||||
*
|
||||
* Language packages are available at http://download.moodle.org/langpack/2.0/
|
||||
* in ZIP format together with a file languages.md5 containing their hashes
|
||||
* and meta info.
|
||||
* Locally, language packs are saved into $CFG->dataroot/lang/
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2005 Yu Zhang
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
admin_externalpage_setup('langimport');
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
$mode = optional_param('mode', 0, PARAM_INT); //phase
|
||||
$pack = optional_param('pack', '', PARAM_FILE); //pack to install
|
||||
$displaylang = $pack;
|
||||
$uninstalllang = optional_param('uninstalllang', '', PARAM_FILE);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$sitelang = optional_param('sitelangconfig', '', PARAM_FILE);
|
||||
|
||||
$thisversion = '2.0'; // TODO this information should be taken from version.php or similar source
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
admin_externalpage_setup('langimport');
|
||||
$strlang = get_string('langimport','admin');
|
||||
$strlanguage = get_string('language');
|
||||
$strthislanguage = get_string('thislanguage');
|
||||
$title = $strlang;
|
||||
|
||||
if (!empty($CFG->skiplangupgrade)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string('langimportdisabled', 'admin'));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$mode = optional_param('mode', 0, PARAM_INT); // action
|
||||
$pack = optional_param('pack', array(), PARAM_SAFEDIR); // pack to install
|
||||
$uninstalllang = optional_param('uninstalllang', '', PARAM_LANG); // installed pack to uninstall
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL); // uninstallation confirmation
|
||||
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
//reset and diagnose lang cache permissions
|
||||
remove_dir($CFG->dataroot.'/cache/languages');
|
||||
if (file_exists($CFG->dataroot.'/cache/languages')) {
|
||||
print_error('cannotdeletelangcache', 'error');
|
||||
}
|
||||
get_string_manager()->reset_caches();
|
||||
|
||||
$notice_ok = array();
|
||||
$notice_error = array();
|
||||
|
||||
if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($pack)) {
|
||||
set_time_limit(0);
|
||||
make_upload_directory('temp');
|
||||
make_upload_directory('lang');
|
||||
|
||||
if (is_array($pack)) {
|
||||
$packs = $pack;
|
||||
} else {
|
||||
$packs = array($pack);
|
||||
//reset and diagnose lang cache permissions
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
if (file_exists($CFG->dataroot.'/cache/languages')) {
|
||||
error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
|
||||
foreach ($packs as $pack) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/'.$thisversion, $pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install();
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/'.$thisversion.'/'.$pack.'.zip';
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
print_error($cd->get_error(), 'error', 'langimport.php', $a);
|
||||
$notice_ok = array();
|
||||
$notice_error = array();
|
||||
|
||||
switch ($mode){
|
||||
|
||||
case INSTALLATION_OF_SELECTED_LANG: ///installation of selected language pack
|
||||
|
||||
if (confirm_sesskey()) {
|
||||
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new object();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a), 'langimport.php');
|
||||
} else {
|
||||
error(get_string($cd->get_error(), 'error'), 'langimport.php');
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackinstalled','admin',$pack);
|
||||
break;
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', 'langimport.php');
|
||||
notify('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackinstalled','admin',$pack);
|
||||
if ($parentlang = get_parent_language($pack)) {
|
||||
// install also parent pack if specified
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/'.$thisversion,
|
||||
$parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
break;
|
||||
|
||||
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
|
||||
|
||||
if ($uninstalllang == 'en_utf8') {
|
||||
$notice_error[] = 'en_utf8 can not be uninstalled!';
|
||||
|
||||
} else if (!$confirm && confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode='.DELETION_OF_SELECTED_LANG.'&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
'langimport.php');
|
||||
print_footer();
|
||||
die;
|
||||
|
||||
} else if (confirm_sesskey()) {
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$uninstalllang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$uninstalllang;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)){
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
//delete the direcotries
|
||||
if ($rm1 or $rm2) {
|
||||
$notice_ok[] = get_string('langpackremoved','admin');
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
$notice_error[] = 'An error has occurred, language pack is not completely uninstalled, please check file permissions';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case UPDATE_ALL_LANG: //1 click update for all updatable language packs
|
||||
|
||||
//0th pull a list from download.moodle.org,
|
||||
//key = langname, value = md5
|
||||
$md5array = array();
|
||||
$updated = 0; //any packs updated?
|
||||
$alllangs = array_keys(get_list_of_languages(false, true)); //get all available langs
|
||||
$lang16 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
|
||||
$packs = array(); //all the packs that needs updating
|
||||
|
||||
|
||||
if (!$availablelangs = get_remote_list_of_languages()) {
|
||||
print_error('cannotdownloadlanguageupdatelist');
|
||||
}
|
||||
|
||||
//and build an associative array
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
//filtering out non-16 and unofficial packs
|
||||
foreach ($alllangs as $clang) {
|
||||
if (!array_key_exists($clang, $md5array)) {
|
||||
$notice_ok[] = get_string('langpackupdateskipped', 'admin', $clang);
|
||||
continue;
|
||||
}
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||
|
||||
if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
|
||||
$lang16[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
//then filter out packs that have the same md5 key
|
||||
foreach ($lang16 as $clang) {
|
||||
if (!is_installed_lang($clang, $md5array[$clang])){
|
||||
$packs[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
@mkdir ($CFG->dataroot.'/temp/');
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
foreach ($packs as $pack){ //for each of the remaining in the list, we
|
||||
if ($pack == 'en_utf8') { // no update for en_utf8
|
||||
continue;
|
||||
}
|
||||
|
||||
//1. delete old director(ies)
|
||||
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$pack;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)) {
|
||||
if (!remove_dir($dest1)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest1.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->notification('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == DELETION_OF_SELECTED_LANG and !empty($uninstalllang)) {
|
||||
if ($uninstalllang == 'en') {
|
||||
$notice_error[] = 'English language pack can not be uninstalled';
|
||||
|
||||
} else if (!$confirm and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode='.DELETION_OF_SELECTED_LANG.'&uninstalllang='.$uninstalllang.'&confirm=1',
|
||||
'langimport.php');
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
} else if (confirm_sesskey()) {
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$uninstalllang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$uninstalllang;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)){
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
if ($rm1 or $rm2) {
|
||||
$notice_ok[] = get_string('langpackremoved','admin');
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
$notice_error[] = 'An error has occurred, language pack is not completely uninstalled, please check file permissions';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == UPDATE_ALL_LANG) {
|
||||
set_time_limit(0);
|
||||
|
||||
if (!$availablelangs = get_remote_list_of_languages()) {
|
||||
print_error('cannotdownloadlanguageupdatelist', 'error');
|
||||
}
|
||||
$md5array = array(); // (string)langcode => (string)md5
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
// filter out unofficial packs
|
||||
$currentlangs = array_keys(get_string_manager()->get_list_of_translations(true));
|
||||
$updateablelangs = array();
|
||||
foreach ($currentlangs as $clang) {
|
||||
if (!array_key_exists($clang, $md5array)) {
|
||||
$notice_ok[] = get_string('langpackupdateskipped', 'admin', $clang);
|
||||
continue;
|
||||
}
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||
|
||||
if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
|
||||
$updateablelangs[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
// then filter out packs that have the same md5 key
|
||||
$neededlangs = array(); // all the packs that needs updating
|
||||
foreach ($updateablelangs as $ulang) {
|
||||
if (!is_installed_lang($ulang, $md5array[$ulang])) {
|
||||
$neededlangs[] = $ulang;
|
||||
}
|
||||
}
|
||||
|
||||
make_upload_directory('temp');
|
||||
make_upload_directory('lang');
|
||||
|
||||
$updated = false; // any packs updated?
|
||||
foreach ($neededlangs as $pack) {
|
||||
if ($pack == 'en') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// delete old directories
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$pack;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)) {
|
||||
if (!remove_dir($dest1)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest1.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (file_exists($dest2)) {
|
||||
if (!remove_dir($dest2)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest2.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// copy and unzip new version
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/'.$thisversion, $pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install();
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/'.$thisversion.'/'.$pack.'.zip';
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
print_error($cd->get_error(), 'error', 'langimport.php', $a);
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', 'langimport.php');
|
||||
if (file_exists($dest2)) {
|
||||
if (!remove_dir($dest2)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest2.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
// should not get here
|
||||
break;
|
||||
//2. copy & unzip into new
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackupdated', 'admin', $pack);
|
||||
$updated = true;
|
||||
break;
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
error(get_string($cd->get_error(), 'error', $a)); // not probable
|
||||
} else {
|
||||
error(get_string($cd->get_error(), 'error')); // not probable
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
//Print error string or whatever you want to do
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackupdated', 'admin', $pack);
|
||||
$updated = true;
|
||||
//Print/do whatever you want
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
$notice_ok[] = get_string('langupdatecomplete','admin');
|
||||
if ($updated) {
|
||||
$notice_ok[] = get_string('langupdatecomplete','admin');
|
||||
} else {
|
||||
$notice_ok[] = get_string('nolangupdateneeded','admin');
|
||||
}
|
||||
|
||||
break;
|
||||
} //close of main switch
|
||||
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$installedlangs = get_list_of_languages(true, true);
|
||||
|
||||
if ($availablelangs = get_remote_list_of_languages()) {
|
||||
$remote = 1;
|
||||
} else {
|
||||
$notice_ok[] = get_string('nolangupdateneeded','admin');
|
||||
$remote = 0; //flag for reading from remote or local
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
}
|
||||
get_string_manager()->reset_caches();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('langimport', 'admin'));
|
||||
|
||||
$installedlangs = get_string_manager()->get_list_of_translations(true);
|
||||
|
||||
$missingparents = array();
|
||||
foreach ($installedlangs as $installedlang => $unused) {
|
||||
$parent = get_parent_language($installedlang);
|
||||
if (empty($parent) or ($parent === 'en')) {
|
||||
continue;
|
||||
if (!$remote) {
|
||||
print_box_start();
|
||||
print_string('remotelangnotavailable', 'admin', $CFG->dataroot.'/lang/');
|
||||
print_box_end();
|
||||
}
|
||||
if (!isset($installedlangs[$parent])) {
|
||||
$missingparents[$installedlang] = $parent;
|
||||
|
||||
if ($notice_ok) {
|
||||
$info = implode('<br />', $notice_ok);
|
||||
notify($info, 'notifysuccess');
|
||||
}
|
||||
}
|
||||
|
||||
if ($availablelangs = get_remote_list_of_languages()) {
|
||||
$remote = true;
|
||||
} else {
|
||||
$remote = false;
|
||||
$availablelangs = array();
|
||||
echo $OUTPUT->box_start();
|
||||
print_string('remotelangnotavailable', 'admin', $CFG->dataroot.'/lang/');
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if ($notice_error) {
|
||||
$info = implode('<br />', $notice_error);
|
||||
notify($info, 'notifyproblem');
|
||||
}
|
||||
|
||||
if ($notice_ok) {
|
||||
$info = implode('<br />', $notice_ok);
|
||||
echo $OUTPUT->notification($info, 'notifysuccess');
|
||||
}
|
||||
print_box_start();
|
||||
echo '<table summary="">';
|
||||
echo '<tr><td align="center" valign="top">';
|
||||
echo '<form id="uninstallform" action="langimport.php?mode='.DELETION_OF_SELECTED_LANG.'" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
|
||||
if ($notice_error) {
|
||||
$info = implode('<br />', $notice_error);
|
||||
echo $OUTPUT->notification($info, 'notifyproblem');
|
||||
}
|
||||
/// display installed langs here
|
||||
|
||||
if ($missingparents) {
|
||||
foreach ($missingparents as $l=>$parent) {
|
||||
$a = new stdClass();
|
||||
$a->lang = $installedlangs[$l];
|
||||
$a->parent = $parent;
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == $parent) {
|
||||
$shortlang = $alang[0];
|
||||
$a->parent = $alang[2].' ('.$shortlang.')';
|
||||
}
|
||||
echo '<label for="uninstalllang">'.get_string('installedlangs','admin')."</label><br />\n";
|
||||
echo '<select name="uninstalllang" id="uninstalllang" size="15">';
|
||||
foreach ($installedlangs as $clang =>$ilang){
|
||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.get_string('uninstall','admin').'" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if ($remote) {
|
||||
echo '<form id="updateform" action="langimport.php?mode='.UPDATE_ALL_LANG.'" method="post">';
|
||||
echo '<div>';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
/// Display option to change site language
|
||||
|
||||
/// display to be installed langs here
|
||||
|
||||
echo '</td><td align="center" valign="top">';
|
||||
//availabe langs table
|
||||
$empty = 1; //something to pring
|
||||
|
||||
/// if this language pack is not already installed, then we allow installation
|
||||
|
||||
echo '<form id="installform" method="post" action="langimport.php?mode='.INSTALLATION_OF_SELECTED_LANG.'">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
echo '<label for="pack">'.get_string('availablelangs','admin')."</label><br />\n";
|
||||
if ($remote) {
|
||||
echo '<select name="pack" id="pack" size="15">';
|
||||
}
|
||||
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (trim($alang[0]) != "en_utf8") {
|
||||
if ($remote) {
|
||||
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
|
||||
$shortlang = substr($alang[0], 0, -5);
|
||||
} else {
|
||||
$shortlang = $alang[0];
|
||||
}
|
||||
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
||||
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$shortlang.')</option>';
|
||||
}
|
||||
} else { //print list in local format, and instruction to install
|
||||
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang16/'.$alang[0].'.zip">'.get_string('download','admin').'</a></td></tr>';
|
||||
}
|
||||
$empty = 0;
|
||||
}
|
||||
$info = get_string('missinglangparent', 'admin', $a);
|
||||
echo $OUTPUT->notification($info, 'notifyproblem');
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
echo html_writer::start_tag('table');
|
||||
echo html_writer::start_tag('tr');
|
||||
|
||||
// list of installed languages
|
||||
$url = new moodle_url('/admin/langimport.php', array('mode' => DELETION_OF_SELECTED_LANG));
|
||||
echo html_writer::start_tag('td', array('valign' => 'top'));
|
||||
echo html_writer::start_tag('form', array('id' => 'uninstallform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::label(get_string('installedlangs','admin'), 'uninstalllang');
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::select($installedlangs, 'uninstalllang', '', false, array('size' => 15));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('uninstall','admin')));
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
if ($remote) {
|
||||
$url = new moodle_url('/admin/langimport.php', array('mode' => UPDATE_ALL_LANG));
|
||||
echo html_writer::start_tag('form', array('id' => 'updateform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::tag('fieldset', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('updatelangs','admin'))));
|
||||
echo html_writer::end_tag('form');
|
||||
}
|
||||
echo html_writer::end_tag('td');
|
||||
|
||||
// list of available languages
|
||||
$options = array();
|
||||
foreach ($availablelangs as $alang) {
|
||||
if (!empty($alang[0]) and trim($alang[0]) !== 'en' and !is_installed_lang($alang[0], $alang[1])) {
|
||||
$options[$alang[0]] = $alang[2].' ('.$alang[0].')';
|
||||
if ($remote) {
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.$THEME->larrow.' '.get_string('install','admin').'" />';
|
||||
}
|
||||
}
|
||||
if (!empty($options)) {
|
||||
echo html_writer::start_tag('td', array('valign' => 'top'));
|
||||
$url = new moodle_url('/admin/langimport.php', array('mode' => INSTALLATION_OF_SELECTED_LANG));
|
||||
echo html_writer::start_tag('form', array('id' => 'installform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::label(get_string('availablelangs','install'), 'pack');
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::select($options, 'pack[]', '', false, array('size' => 15, 'multiple' => 'multiple'));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('install','admin')));
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
echo html_writer::end_tag('td');
|
||||
}
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
echo html_writer::end_tag('tr');
|
||||
echo html_writer::end_tag('table');
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Local functions /////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* checks the md5 of the zip file, grabbed from download.moodle.org,
|
||||
* against the md5 of the local language file from last update
|
||||
* @param string $lang
|
||||
* @param string $md5check
|
||||
* @return bool
|
||||
*/
|
||||
function is_installed_lang($lang, $md5check) {
|
||||
global $CFG;
|
||||
$md5file = $CFG->dataroot.'/lang/'.$lang.'/'.$lang.'.md5';
|
||||
if (file_exists($md5file)){
|
||||
return (file_get_contents($md5file) == $md5check);
|
||||
if ($empty) {
|
||||
echo '<br />';
|
||||
print_string('nolanguagetodownload','admin');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of available language packs from download.moodle.org
|
||||
*
|
||||
* @return array|bool false if can not download
|
||||
*/
|
||||
function get_remote_list_of_languages() {
|
||||
$source = 'http://download.moodle.org/langpack/2.0/languages.md5';
|
||||
$availablelangs = array();
|
||||
//close available langs table
|
||||
echo '</td></tr></table>';
|
||||
print_box_end();
|
||||
|
||||
if ($content = download_file_content($source)) {
|
||||
$alllines = explode("\n", $content);
|
||||
foreach($alllines as $line) {
|
||||
if (!empty($line)){
|
||||
$availablelangs[] = explode(',', $line);
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
/**
|
||||
* Returns a list of available language packs from a
|
||||
* local copy shipped with standard moodle distro
|
||||
* this is for site that can't download components.
|
||||
* @return array
|
||||
*/
|
||||
function get_local_list_of_languages() {
|
||||
global $CFG;
|
||||
$source = $CFG->dirroot.'/lib/languages.md5';
|
||||
$availablelangs = array();
|
||||
if ($fp = fopen($source, 'r')) {
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
}
|
||||
|
||||
} else {
|
||||
/**
|
||||
* checks the md5 of the zip file, grabbed from download.moodle.org,
|
||||
* against the md5 of the local language file from last update
|
||||
* @param string $lang
|
||||
* @param string $md5check
|
||||
* @return bool
|
||||
*/
|
||||
function is_installed_lang($lang, $md5check) {
|
||||
global $CFG;
|
||||
$md5file = $CFG->dataroot.'/lang/'.$lang.'/'.$lang.'.md5';
|
||||
if (file_exists($md5file)){
|
||||
return (file_get_contents($md5file) == $md5check);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest list of available language packs from
|
||||
* moodle.org
|
||||
* @return array or false if can not download
|
||||
*/
|
||||
function get_remote_list_of_languages() {
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$availablelangs = array();
|
||||
|
||||
if ($content = download_file_content($source)) {
|
||||
$alllines = split("\n", $content);
|
||||
foreach($alllines as $line) {
|
||||
if (!empty($line)){
|
||||
$availablelangs[] = split(',', $line);
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows admin to configure licenses.
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/licenselib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$license = optional_param('license', '', PARAM_SAFEDIR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
$return = true;
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
license_manager::disable($license);
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
license_manager::enable($license);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides an overview of installed local plugins
|
||||
*
|
||||
* Displays the list of found local plugins, their version (if found) and
|
||||
* a link to delete the local plugin.
|
||||
*
|
||||
* @see http://docs.moodle.org/en/Development:Local_customisation
|
||||
* @package admin
|
||||
* @copyright 2010 David Mudrak <david.mudrak@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managelocalplugins');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('localplugindeleteconfirm', '', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('local', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['local'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
/// Print the table of all installed local plugins
|
||||
|
||||
$table = new flexible_table('localplugins_administration_table');
|
||||
$table->define_columns(array('name', 'version', 'delete'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'localplugins');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
foreach (get_plugin_list('local') as $plugin => $plugindir) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $plugin);
|
||||
} else {
|
||||
$strpluginname = $plugin;
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
textlib_get_instance()->asort($plugins);
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
|
||||
$version = get_config('local_' . $plugin);
|
||||
if (!empty($version->version)) {
|
||||
$version = $version->version;
|
||||
} else {
|
||||
$version = '?';
|
||||
}
|
||||
|
||||
$table->add_data(array($name, $version, $delete));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -22,7 +22,7 @@
|
||||
* - Run your admin/cron.php
|
||||
*
|
||||
* - Read /tmp/moodle-mailout.log
|
||||
*
|
||||
*
|
||||
*
|
||||
* This script will create logfiles in /tmp/ or in $TMPDIR if set.
|
||||
* On windows, use php -r 'print sys_get_temp_dir()' to see where the file is saved.
|
||||
@@ -63,7 +63,7 @@ fclose($stdin);
|
||||
*
|
||||
* Very useful for perl-like error-handling:
|
||||
*
|
||||
* do_something() or mdie("Something went wrong");
|
||||
* do_somethting() or mdie("Something went wrong");
|
||||
*
|
||||
* @param string $msg Error message
|
||||
* @param integer $errorcode Error code to emit
|
||||
@@ -74,4 +74,4 @@ function mdie($msg='', $errorcode=1) {
|
||||
exit($errorcode);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php // $Id$
|
||||
// Enables/disables maintenance mode
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
admin_externalpage_setup('maintenancemode');
|
||||
|
||||
//Check folder exists
|
||||
if (! make_upload_directory(SITEID)) { // Site folder
|
||||
error("Could not create site folder. The site administrator needs to fix the file permissions");
|
||||
}
|
||||
|
||||
$filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($form->action == "disable") {
|
||||
unlink($filename);
|
||||
redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
|
||||
} else {
|
||||
$file = fopen($filename, 'w');
|
||||
fwrite($file, stripslashes($form->text));
|
||||
fclose($file);
|
||||
redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the header stuff
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
/// Print the appropriate form
|
||||
|
||||
if (file_exists($filename)) { // We are in maintenance mode
|
||||
echo '<div style="margin-left:auto;margin-right:auto">';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<input type="hidden" name="action" value="disable" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<p><input type="submit" value="'.get_string('disable').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
} else { // We are not in maintenance mode
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
echo '<div style="text-align:center;margin-left:auto;margin-right:auto">';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="action" value="enable" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<p><input type="submit" value="'.get_string('enable').'" /></p>';
|
||||
echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
|
||||
echo '<table><tr><td>';
|
||||
print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
|
||||
echo '</td></tr></table>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,583 @@
|
||||
<?php
|
||||
/**
|
||||
* Adapted for Moodle from the AMFPHP Project at http://www.amfphp.org/
|
||||
* Creates the methodTable for a service class.
|
||||
*
|
||||
* @usage $this->methodTable = MethodTable::create($this);
|
||||
* @author Christophe Herreman
|
||||
* @since 05/01/2005
|
||||
* @version $id$
|
||||
*
|
||||
* Special contributions by Allessandro Crugnola and Ted Milker
|
||||
*/
|
||||
|
||||
if (!defined('T_ML_COMMENT')) {
|
||||
define('T_ML_COMMENT', T_COMMENT);
|
||||
} else {
|
||||
define('T_DOC_COMMENT', T_ML_COMMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string from start of haystack to first occurance of needle, or whole
|
||||
* haystack, if needle does not occur
|
||||
*
|
||||
* @access public
|
||||
* @param $haystack(String) Haystack to search in
|
||||
* @param $needle(String) Needle to look for
|
||||
*/
|
||||
function strrstr($haystack, $needle)
|
||||
{
|
||||
return substr($haystack, 0, strpos($haystack.$needle,$needle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return substring of haystack from end of needle onwards, or FALSE
|
||||
*
|
||||
* @access public
|
||||
* @param $haystack(String) Haystack to search in
|
||||
* @param $needle(String) Needle to look for
|
||||
*/
|
||||
function strstrafter($haystack, $needle)
|
||||
{
|
||||
return substr(strstr($haystack, $needle), strlen($needle));
|
||||
}
|
||||
|
||||
class MethodTable
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Since this class should only be accessed through the static create() method
|
||||
* this constructor should be made private. Unfortunately, this is not possible
|
||||
* in PHP4.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function MethodTable(){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the methodTable for a passed class.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param $sourcePath(String) The path to the file you want to parse
|
||||
* @param $containsClass(Bool) True if the file is a class definition (optional)
|
||||
*/
|
||||
function create($sourcePath, $containsClass = false){
|
||||
|
||||
$methodTable = array();
|
||||
if(!file_exists($sourcePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$source = file_get_contents($sourcePath);
|
||||
$tokens = (array)token_get_all($source);
|
||||
|
||||
$waitingForOpenParenthesis = false;
|
||||
$waitingForFunction = false;
|
||||
$waitingForClassName = false;
|
||||
$bufferingArgs = false;
|
||||
$argBuffer = "";
|
||||
$lastFunction = "";
|
||||
$lastFunctionComment = "";
|
||||
$lastComment = "";
|
||||
$classMethods = array();
|
||||
$realClassName = "";
|
||||
|
||||
if($containsClass) {
|
||||
$openBraces = -10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
$openBraces = 1;
|
||||
}
|
||||
|
||||
$waitingForEndEncapsedString = false;
|
||||
foreach($tokens as $token)
|
||||
{
|
||||
if (is_string($token)) {
|
||||
if($token == '{')
|
||||
{
|
||||
$openBraces++;
|
||||
}
|
||||
if($token == '}')
|
||||
{
|
||||
if($waitingForEndEncapsedString)
|
||||
{
|
||||
$waitingForEndEncapsedString = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastComment = '';
|
||||
$openBraces--;
|
||||
|
||||
if($openBraces == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($waitingForOpenParenthesis && $token == '(')
|
||||
{
|
||||
$bufferingArgs = true;
|
||||
$argBuffer = "";
|
||||
$waitingForOpenParenthesis = false;
|
||||
}
|
||||
elseif($bufferingArgs)
|
||||
{
|
||||
if($token != ')')
|
||||
{
|
||||
$argBuffer .= $token;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($lastFunction != $realClassName)
|
||||
{
|
||||
$classMethods[] = array("name" => $lastFunction,
|
||||
"comment" => $lastFunctionComment,
|
||||
"args" => $argBuffer);
|
||||
|
||||
$bufferingArgs = false;
|
||||
$argBuffer = "";
|
||||
$lastFunction = "";
|
||||
$lastFunctionComment = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// token array
|
||||
list($id, $text) = $token;
|
||||
|
||||
if($bufferingArgs)
|
||||
{
|
||||
$argBuffer .= $text;
|
||||
}
|
||||
switch ($id)
|
||||
{
|
||||
|
||||
case T_COMMENT:
|
||||
case T_ML_COMMENT: // we've defined this
|
||||
case T_DOC_COMMENT: // and this
|
||||
// no action on comments
|
||||
$lastComment = $text;
|
||||
break;
|
||||
case T_FUNCTION:
|
||||
if($openBraces >= 1)
|
||||
{
|
||||
$waitingForFunction = true;
|
||||
}
|
||||
break;
|
||||
case T_STRING:
|
||||
if($waitingForFunction)
|
||||
{
|
||||
$waitingForFunction = false;
|
||||
$waitingForOpenParenthesis = true;
|
||||
$lastFunction = $text;
|
||||
$lastFunctionComment = $lastComment;
|
||||
$lastComment = "";
|
||||
}
|
||||
if($waitingForClassName)
|
||||
{
|
||||
$waitingForClassName = false;
|
||||
$realClassName = $text;
|
||||
}
|
||||
break;
|
||||
case T_CLASS:
|
||||
$openBraces = 0;
|
||||
$waitingForClassName = true;
|
||||
break;
|
||||
case T_CURLY_OPEN:
|
||||
case T_DOLLAR_OPEN_CURLY_BRACES:
|
||||
$waitingForEndEncapsedString = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($classMethods as $key => $value) {
|
||||
$methodSignature = $value['args'];
|
||||
$methodName = $value['name'];
|
||||
$methodComment = $value['comment'];
|
||||
|
||||
$description = MethodTable::getMethodDescription($methodComment) . " " . MethodTable::getMethodCommentAttribute($methodComment, "desc");
|
||||
$description = trim($description);
|
||||
$access = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "access");
|
||||
$roles = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "roles");
|
||||
$instance = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "instance");
|
||||
$returns = MethodTable::getMethodReturnValue($methodComment);
|
||||
$pagesize = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "pagesize");
|
||||
$params = MethodTable::getMethodCommentArguments($methodComment);
|
||||
|
||||
|
||||
//description, arguments, access, [roles, [instance, [returns, [pagesize]]]]
|
||||
$methodTable[$methodName] = array();
|
||||
//$methodTable[$methodName]["signature"] = $methodSignature; //debug purposes
|
||||
$methodTable[$methodName]["description"] = ($description == "") ? "No description given." : $description;
|
||||
$methodTable[$methodName]["arguments"] = MethodTable::getMethodArguments($methodSignature, $params);
|
||||
$methodTable[$methodName]["access"] = ($access == "") ? "private" : $access;
|
||||
|
||||
if($roles != "") $methodTable[$methodName]["roles"] = $roles;
|
||||
if($instance != "") $methodTable[$methodName]["instance"] = $instance;
|
||||
if($returns != "") $methodTable[$methodName]["returns"] = $returns;
|
||||
if($pagesize != "") $methodTable[$methodName]["pagesize"] = $pagesize;
|
||||
}
|
||||
|
||||
return $methodTable;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getMethodCommentServices($comment)
|
||||
{
|
||||
$pieces = explode('@service', $comment);
|
||||
$args = array();
|
||||
if(is_array($pieces) && count($pieces) > 1)
|
||||
{
|
||||
for($i = 0; $i < count($pieces) - 1; $i++)
|
||||
{
|
||||
$ps = strrstr($pieces[$i + 1], '@');
|
||||
$ps = strrstr($ps, '*/');
|
||||
$args[] = MethodTable::cleanComment($ps);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getMethodCommentArguments($comment)
|
||||
{
|
||||
$pieces = explode('@param', $comment);
|
||||
$args = array();
|
||||
if(is_array($pieces) && count($pieces) > 1)
|
||||
{
|
||||
for($i = 0; $i < count($pieces) - 1; $i++)
|
||||
{
|
||||
$ps = strrstr($pieces[$i + 1], '@');
|
||||
$ps = strrstr($ps, '*/');
|
||||
$args[] = MethodTable::cleanComment($ps);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description from the comment.
|
||||
* The description is(are) the first line(s) in the comment.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
*/
|
||||
function getMethodDescription($comment){
|
||||
$comment = MethodTable::cleanComment(strrstr($comment, "@"));
|
||||
return trim($comment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodCommentAttribute($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
return MethodTable::cleanComment($pieces);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodCommentAttributeFirstLine($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, "*");
|
||||
$pieces = strrstr($pieces, "/");
|
||||
$pieces = strrstr($pieces, "-");
|
||||
$pieces = strrstr($pieces, "\n");
|
||||
$pieces = strrstr($pieces, "\r");
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
return MethodTable::cleanComment($pieces);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodReturnValue($comment){
|
||||
$result = array('type' => 'void', 'description' => '');
|
||||
$pieces = strstrafter($comment, '@returns');
|
||||
if(FALSE == $pieces) $pieces = strstrafter($comment, '@return');
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, "*");
|
||||
$pieces = strrstr($pieces, "/");
|
||||
$pieces = strrstr($pieces, "-");
|
||||
$pieces = strrstr($pieces, "\n");
|
||||
$pieces = strrstr($pieces, "\r");
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
$pieces = trim(MethodTable::cleanComment($pieces));
|
||||
@list($result['type'], $result['description']) = explode(' ', $pieces, 2);
|
||||
$result['type'] = MethodTable::standardizeType($result['type']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getMethodCommentAttributeFirstWord($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$val = MethodTable::cleanComment($pieces);
|
||||
return trim(strrstr($val, ' '));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with the arguments of a method.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $methodSignature(String) The method's signature;
|
||||
*/
|
||||
function getMethodArguments($methodSignature, $commentParams){
|
||||
if(strlen($methodSignature) == 0){
|
||||
//no arguments, return an empty array
|
||||
$result = array();
|
||||
}else{
|
||||
//clean the arguments before returning them
|
||||
$result = MethodTable::cleanArguments(explode(",", $methodSignature), $commentParams);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the function or method's return value.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $value(String) The "dirty" value.
|
||||
*/
|
||||
function cleanReturnValue($value){
|
||||
$result = array();
|
||||
$value = trim($value);
|
||||
|
||||
list($result['type'], $result['description']) = explode(' ', $value, 2);
|
||||
|
||||
$result['type'] = MethodTable::standardizeType($result['type']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes a string and returns the XMLRPC type that most closely matches it.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $type(String) The given type string.
|
||||
*/
|
||||
function standardizeType($type) {
|
||||
$type = strtolower($type);
|
||||
if('str' == $type || 'string' == $type) return 'string';
|
||||
if('int' == $type || 'integer' == $type) return 'int';
|
||||
if('bool' == $type || 'boolean' == $type) return 'boolean';
|
||||
|
||||
// Note that object is not a valid XMLRPC type
|
||||
if('object' == $type || 'class' == $type) return 'object';
|
||||
if('float' == $type || 'dbl' == $type || 'double' == $type || 'flt' == $type) return 'double';
|
||||
|
||||
// Note that null is not a valid XMLRPC type. The null type can have
|
||||
// only one value - null.
|
||||
if('null' == $type) return 'null';
|
||||
|
||||
// Note that mixed is not a valid XMLRPC type
|
||||
if('mixed' == $type) return 'mixed';
|
||||
if('array' == $type || 'arr' == $type) return 'array';
|
||||
if('assoc' == $type || 'struct' == $type) return 'struct';
|
||||
|
||||
// Note that this is not a valid XMLRPC type. As references cannot be
|
||||
// serialized or exported, there is no way this could be XML-RPCed.
|
||||
if('reference' == $type || 'ref' == $type) return 'reference';
|
||||
return 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the arguments array.
|
||||
* This method removes all whitespaces and the leading "$" sign from each argument
|
||||
* in the array.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $args(Array) The "dirty" array with arguments.
|
||||
*/
|
||||
function cleanArguments($args, $commentParams){
|
||||
$result = array();
|
||||
|
||||
if(!is_array($args)) return array();
|
||||
|
||||
foreach($args as $index => $arg){
|
||||
$arg = strrstr(str_replace(array('$','&$'), array('','&'), $arg), '=');
|
||||
if(!isset($commentParams[$index]))
|
||||
{
|
||||
$result[] = trim($arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = trim($arg);
|
||||
$end = trim(str_replace('$', '', $commentParams[$index]));
|
||||
|
||||
// Suppress Notice of 'Undefined offset' with @
|
||||
@list($word0, $word1, $tail) = preg_split("/[\s]+/", $end, 3);
|
||||
$word0 = strtolower($word0);
|
||||
$word1 = strtolower($word1);
|
||||
|
||||
$wordBase0 = ereg_replace('^[&$]+','',$word0);
|
||||
$wordBase1 = ereg_replace('^[&$]+','',$word1);
|
||||
$startBase = strtolower(ereg_replace('^[&$]+','',$start));
|
||||
|
||||
if ($wordBase0 == $startBase) {
|
||||
$type = str_replace(array('(',')'),'', $word1);
|
||||
} elseif($wordBase1 == $startBase) {
|
||||
$type = str_replace(array('(',')'),'', $word0);
|
||||
} elseif( ereg('(^[&$]+)|(\()([a-z0-9]+)(\)$)', $word0, $regs) ) {
|
||||
$tail = str_ireplace($word0, '', $end);
|
||||
$type = $regs[3];
|
||||
} else {
|
||||
// default to string
|
||||
$type = 'string';
|
||||
}
|
||||
|
||||
$type = MethodTable::standardizeType($type);
|
||||
/*
|
||||
if($type == 'str') {
|
||||
$type = 'string';
|
||||
} elseif($type == 'int' || $type == 'integer') {
|
||||
$type = 'int';
|
||||
} elseif($type == 'bool' || $type == 'boolean') {
|
||||
$type = 'boolean';
|
||||
} elseif($type == 'object' || $type == 'class') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
$type = 'object';
|
||||
} elseif($type == 'float' || $type == 'dbl' || $type == 'double' || $type == 'flt') {
|
||||
$type = 'double';
|
||||
} elseif($type == 'null') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
// The null type can have only one value - null. Why would
|
||||
// that be an argument to a function? Just in case:
|
||||
$type = 'null';
|
||||
} elseif($type == 'mixed') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
$type = 'mixed';
|
||||
} elseif($type == 'array' || $type == 'arr') {
|
||||
$type = 'array';
|
||||
} elseif($type == 'assoc') {
|
||||
$type = 'struct';
|
||||
} elseif($type == 'reference' || $type == 'ref') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
// As references cannot be serialized or exported, there is
|
||||
// no way this could be XML-RPCed.
|
||||
$type = 'reference';
|
||||
} else {
|
||||
$type = 'string';
|
||||
}
|
||||
*/
|
||||
$result[] = array('type' => $type, 'description' => $start . ' - ' . $tail);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleans the comment string by removing all comment start and end characters.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
*/
|
||||
function cleanComment($comment){
|
||||
$comment = str_replace("/**", "", $comment);
|
||||
$comment = str_replace("*/", "", $comment);
|
||||
$comment = str_replace("*", "", $comment);
|
||||
$comment = str_replace("\n", "\\n", trim($comment));
|
||||
$comment = eregi_replace("[\r\t\n ]+", " ", trim($comment));
|
||||
$comment = str_replace("\"", "\\\"", $comment);
|
||||
return $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function showCode($methodTable){
|
||||
|
||||
if(!is_array($methodTable)) $methodTable = array();
|
||||
|
||||
foreach($methodTable as $methodName=>$methodProps){
|
||||
$result .= "\n\t\"" . $methodName . "\" => array(";
|
||||
|
||||
foreach($methodProps as $key=>$value){
|
||||
$result .= "\n\t\t\"" . $key . "\" => ";
|
||||
|
||||
if($key=="arguments"){
|
||||
$result .= "array(";
|
||||
for($i=0; $i<count($value); $i++){
|
||||
$result .= "\"" . addslashes($value[$i]) . "\"";
|
||||
if($i<count($value)-1){
|
||||
$result .= ", ";
|
||||
}
|
||||
}
|
||||
$result .= ")";
|
||||
}else{
|
||||
$result .= "\"" . $value . "\"";
|
||||
}
|
||||
|
||||
$result .= ",";
|
||||
}
|
||||
|
||||
$result = substr($result, 0, -1);
|
||||
$result .= "\n\t),";
|
||||
}
|
||||
|
||||
$result = substr($result, 0, -1);
|
||||
$result = "\$this->methodTable = array(" . $result;
|
||||
$result .= "\n);";
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
// Allows the admin to control user logins from remote moodles.
|
||||
|
||||
@@ -16,10 +16,10 @@ require_login();
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
@@ -27,7 +27,7 @@ $sesskey = sesskey();
|
||||
$formerror = array();
|
||||
|
||||
// grab the mnet hosts and remove the localhost
|
||||
$mnethosts = $DB->get_records_menu('mnet_host', array(), 'name', 'id, name');
|
||||
$mnethosts = get_records_menu('mnet_host', '', '', 'name', 'id, name');
|
||||
if (array_key_exists($CFG->mnet_localhost_id, $mnethosts)) {
|
||||
unset($mnethosts[$CFG->mnet_localhost_id]);
|
||||
}
|
||||
@@ -36,38 +36,38 @@ if (array_key_exists($CFG->mnet_localhost_id, $mnethosts)) {
|
||||
|
||||
// process actions
|
||||
if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
|
||||
// boot if insufficient permission
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet');
|
||||
error(get_string('nomodifyacl','mnet'));
|
||||
}
|
||||
|
||||
// fetch the record in question
|
||||
$id = required_param('id', PARAM_INT);
|
||||
if (!$idrec = $DB->get_record('mnet_sso_access_control', array('id'=>$id))) {
|
||||
print_error('recordnoexists','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
if (!$idrec = get_record('mnet_sso_access_control', 'id', $id)) {
|
||||
error(get_string('recordnoexists','mnet'), "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case "delete":
|
||||
$DB->delete_records('mnet_sso_access_control', array('id'=>$id));
|
||||
redirect('access_control.php', get_string('deleteuserrecord', 'mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
delete_records('mnet_sso_access_control', 'id', $id);
|
||||
redirect('access_control.php', get_string('deleteuserrecord', 'mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
break;
|
||||
|
||||
case "acl":
|
||||
|
||||
|
||||
// require the access parameter, and it must be 'allow' or 'deny'
|
||||
$accessctrl = trim(strtolower(required_param('accessctrl', PARAM_ALPHA)));
|
||||
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
|
||||
print_error('invalidaccessparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
error(get_string('invalidaccessparam', 'mnet') , "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
if ($accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('uset'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
} elseif ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -84,7 +84,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
// check permissions and verify form input
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
error(get_string('nomodifyacl','mnet'), "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
if (empty($form->username)) {
|
||||
$formerror['username'] = get_string('enterausername','mnet');
|
||||
@@ -107,9 +107,9 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
if (!empty($username)) {
|
||||
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
|
||||
if ($form->accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user'=>$username, 'host'=>$mnethosts[$form->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array($username, $mnethosts[$form->mnet_host_id])));
|
||||
} elseif ($form->accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$username, 'host'=>$mnethosts[$form->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($username, $mnethosts[$form->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
}
|
||||
|
||||
// Explain
|
||||
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
|
||||
print_box(get_string('ssoacldescr','mnet'));
|
||||
// Are the needed bits enabled?
|
||||
$warn = '';
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
@@ -130,9 +130,12 @@ if (!is_enabled_auth('mnet')) {
|
||||
$warn .= '<p>' . get_string('authmnetdisabled','mnet').'</p>';
|
||||
}
|
||||
|
||||
if (get_config('auth/mnet', 'auto_add_remote_users') != true) {
|
||||
$warn .= '<p>' . get_string('authmnetautoadddisabled','mnet').'</p>';
|
||||
}
|
||||
if (!empty($warn)) {
|
||||
$warn = '<p>' . get_string('ssoaclneeds','mnet').'</p>' . $warn;
|
||||
echo $OUTPUT->box($warn);
|
||||
print_box($warn);
|
||||
}
|
||||
// output the ACL table
|
||||
$columns = array("username", "mnet_host_id", "access", "delete");
|
||||
@@ -148,52 +151,50 @@ foreach ($columns as $column) {
|
||||
} else {
|
||||
$columndir = $dir == "ASC" ? "DESC" : "ASC";
|
||||
$columnicon = $dir == "ASC" ? "down" : "up";
|
||||
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\" />";
|
||||
}
|
||||
$headings[$column] = "<a href=\"?sort=$column&dir=$columndir&\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
$headings['delete'] = '';
|
||||
$acl = $DB->get_records('mnet_sso_access_control', null, "$sort $dir", '*'); //, $page * $perpage, $perpage);
|
||||
$aclcount = $DB->count_records('mnet_sso_access_control');
|
||||
$acl = get_records('mnet_sso_access_control', '', '', "$sort $dir", '*'); //, $page * $perpage, $perpage);
|
||||
$aclcount = count_records('mnet_sso_access_control');
|
||||
|
||||
if (!$acl) {
|
||||
echo $OUTPUT->heading(get_string('noaclentries','mnet'));
|
||||
print_heading(get_string('noaclentries','mnet'));
|
||||
$table = NULL;
|
||||
} else {
|
||||
$table = new html_table();
|
||||
$table->head = $headings;
|
||||
$table->align = array('left', 'left', 'center');
|
||||
$table->width = "95%";
|
||||
foreach ($acl as $aclrecord) {
|
||||
if ($aclrecord->accessctrl == 'allow') {
|
||||
$accesscolumn = get_string('allow', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=deny&sesskey=".sesskey()."\">"
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=deny&sesskey={$USER->sesskey}\">"
|
||||
. get_string('deny', 'mnet') . "</a>)";
|
||||
} else {
|
||||
$accesscolumn = get_string('deny', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=allow&sesskey=".sesskey()."\">"
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=allow&sesskey={$USER->sesskey}\">"
|
||||
. get_string('allow', 'mnet') . "</a>)";
|
||||
}
|
||||
$deletecolumn = "<a href=\"?id={$aclrecord->id}&action=delete&sesskey=".sesskey()."\">"
|
||||
$deletecolumn = "<a href=\"?id={$aclrecord->id}&action=delete&sesskey={$USER->sesskey}\">"
|
||||
. get_string('delete') . "</a>";
|
||||
$table->data[] = array (s($aclrecord->username), $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn);
|
||||
$table->data[] = array ($aclrecord->username, $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($table)) {
|
||||
echo html_writer::table($table);
|
||||
print_table($table);
|
||||
echo '<p> </p>';
|
||||
$baseurl = new moodle_url('/admin/mnet/access_control.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
|
||||
echo $OUTPUT->paging_bar($aclcount, $page, $perpage, $baseurl);
|
||||
print_paging_bar($aclcount, $page, $perpage, "?sort=$sort&dir=$dir&perpage=$perpage&");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// output the add form
|
||||
echo $OUTPUT->box_start();
|
||||
print_simple_box_start('center','90%','','20');
|
||||
|
||||
?>
|
||||
<div class="mnetaddtoaclform">
|
||||
<div class="mnetaddtoaclform">
|
||||
<form id="mnetaddtoacl" method="post">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $sesskey; ?>" />
|
||||
<?php
|
||||
@@ -210,7 +211,7 @@ echo " " . get_string('remotehost', 'mnet') . ":\n";
|
||||
if (!empty($formerror['mnet_host_id'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo html_writer::select($mnethosts, 'mnet_host_id');
|
||||
choose_from_menu($mnethosts, 'mnet_host_id');
|
||||
|
||||
// choose an access level
|
||||
echo " " . get_string('accesslevel', 'mnet') . ":\n";
|
||||
@@ -219,7 +220,7 @@ if (!empty($formerror['accessctrl'])) {
|
||||
}
|
||||
$accessmenu['allow'] = get_string('allow', 'mnet');
|
||||
$accessmenu['deny'] = get_string('deny', 'mnet');
|
||||
echo html_writer::select($accessmenu, 'accessctrl');
|
||||
choose_from_menu($accessmenu, 'accessctrl');
|
||||
|
||||
// submit button
|
||||
echo '<input type="submit" value="' . get_string('addtoacl', 'mnet') . '" />';
|
||||
@@ -230,5 +231,7 @@ foreach ($formerror as $error) {
|
||||
echo "<br><span class=\"error\">$error<span>";
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* Library functions for mnet
|
||||
*
|
||||
* @author Donal McMullan donal@catalyst.net.nz
|
||||
* @version 0.0.1
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package mnet
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse a file to find out what functions/methods exist in it, and add entries
|
||||
* for the remote-call-enabled functions to the database.
|
||||
*
|
||||
* The path to a file, e.g. auth/mnet/auth.php can be thought of as
|
||||
* type/parentname/docname
|
||||
*
|
||||
* @param string $type mod, auth or enrol
|
||||
* @param string $parentname Implementation of type, e.g. 'mnet' in the
|
||||
* case of auth/mnet/auth.php
|
||||
* @return bool True on success, else false
|
||||
*/
|
||||
function mnet_get_functions($type, $parentname) {
|
||||
global $CFG;
|
||||
$dataobject = new stdClass();
|
||||
$docname = $type.'.php';
|
||||
$publishes = array();
|
||||
if ('mod' == $type) {
|
||||
$docname = 'rpclib.php';
|
||||
$relname = '/mod/'.$parentname.'/'.$docname;
|
||||
$filename = $CFG->dirroot.$relname;
|
||||
if (file_exists($filename)) include_once $filename;
|
||||
$mnet_publishes = $parentname.'_mnet_publishes';
|
||||
if (function_exists($mnet_publishes)) {
|
||||
(array)$publishes = $mnet_publishes();
|
||||
}
|
||||
} else {
|
||||
// auth or enrol
|
||||
$relname = '/'.$type.'/'.$parentname.'/'.$docname;
|
||||
$filename = $CFG->dirroot.$relname;
|
||||
if (file_exists($filename)) include_once $filename;
|
||||
$class = $type.($type=='enrol'? 'ment':'').'_plugin_'.$parentname;
|
||||
if (class_exists($class)) {
|
||||
$object = new $class();
|
||||
if (method_exists($object, 'mnet_publishes')) {
|
||||
(array)$publishes = $object->mnet_publishes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$methodServiceArray = array();
|
||||
foreach($publishes as $service) {
|
||||
if (is_array($service['methods'])) {
|
||||
foreach($service['methods'] as $methodname) {
|
||||
$methodServiceArray[$methodname][] = $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable functions that don't exist (any more) in the source
|
||||
// Should these be deleted? What about their permissions records?
|
||||
$rpcrecords = get_records_select('mnet_rpc', ' parent=\''.$parentname.'\' AND parent_type=\''.$type.'\' ', 'function_name ASC ');
|
||||
if (!empty($rpcrecords)) {
|
||||
foreach($rpcrecords as $rpc) {
|
||||
if (!array_key_exists($rpc->function_name, $methodServiceArray)) {
|
||||
$rpc->enabled = 0;
|
||||
update_record('mnet_rpc', $rpc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($filename)) return false;
|
||||
|
||||
if (extension_loaded('tokenizer')) {
|
||||
include_once "$CFG->dirroot/$CFG->admin/mnet/MethodTable.php";
|
||||
$functions = (array)MethodTable::create($filename,false);
|
||||
}
|
||||
|
||||
foreach($methodServiceArray as $method => $servicearray) {
|
||||
if (!empty($functions[$method])) {
|
||||
$details = $functions[$method];
|
||||
$profile = $details['arguments'];
|
||||
if (!isset($details['returns'])) {
|
||||
array_unshift($profile, array('type' => 'void', 'description' => 'No return value'));
|
||||
} else {
|
||||
array_unshift($profile, $details['returns']);
|
||||
}
|
||||
$dataobject->profile = serialize($profile);
|
||||
$dataobject->help = addslashes($details['description']);
|
||||
} else {
|
||||
$dataobject->profile = serialize(array(array('type' => 'void', 'description' => 'No return value')));
|
||||
$dataobject->help = '';
|
||||
}
|
||||
|
||||
$dataobject->function_name = $method;
|
||||
$dataobject->xmlrpc_path = $type.'/'.$parentname.'/'.$docname.'/'.$method;
|
||||
$dataobject->parent_type = $type;
|
||||
$dataobject->parent = $parentname;
|
||||
$dataobject->enabled = '0';
|
||||
|
||||
if ($record_exists = get_record('mnet_rpc', 'xmlrpc_path', $dataobject->xmlrpc_path)) {
|
||||
$dataobject->id = $record_exists->id;
|
||||
$dataobject->enabled = $record_exists->enabled;
|
||||
update_record('mnet_rpc', $dataobject);
|
||||
} else {
|
||||
$dataobject->id = insert_record('mnet_rpc', $dataobject, true);
|
||||
}
|
||||
|
||||
foreach($servicearray as $service) {
|
||||
$serviceobj = get_record('mnet_service', 'name', $service['name']);
|
||||
if (false == $serviceobj) {
|
||||
$serviceobj = new stdClass();
|
||||
$serviceobj->name = $service['name'];
|
||||
$serviceobj->apiversion = $service['apiversion'];
|
||||
$serviceobj->offer = 1;
|
||||
$serviceobj->id = insert_record('mnet_service', $serviceobj, true);
|
||||
}
|
||||
|
||||
if (false == get_record('mnet_service2rpc', 'rpcid', $dataobject->id, 'serviceid', $serviceobj->id)) {
|
||||
$obj = new stdClass();
|
||||
$obj->rpcid = $dataobject->id;
|
||||
$obj->serviceid = $serviceobj->id;
|
||||
insert_record('mnet_service2rpc', $obj, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function upgrade_RPC_functions($returnurl) {
|
||||
global $CFG;
|
||||
|
||||
$basedir = $CFG->dirroot.'/mod';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('mod', $dir);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$basedir = $CFG->dirroot.'/auth';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('auth', $dir);
|
||||
}
|
||||
}
|
||||
|
||||
$basedir = $CFG->dirroot.'/enrol';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('enrol', $dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => "$CFG->wwwroot/$CFG->admin/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => get_string('mnetsettings', 'mnet'), 'link' => "$CFG->wwwroot/$CFG->admin/mnet/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => get_string('deletehost', 'mnet'), 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$site->shortname: $strmnetsettings", "$site->fullname", $navigation);
|
||||
|
||||
print_heading(get_string('mnetsettings', 'mnet'));
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<table class="generalbox standard" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><span><?php print_string('deleteaserver', 'mnet'); ?>Deleting a Server</span></td>
|
||||
</tr>
|
||||
<?php
|
||||
if (count($warn) > 0){
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right" colspan="2"><?php print_string('receivedwarnings','mnet'); ?>:<br />
|
||||
<?php foreach($warn as $warning) echo $warning .'<br />'; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><?php print_string('reallydeleteserver','mnet'); ?>: "<?php echo $mnet_peer->name; ?>"?</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td width="80">
|
||||
<form method="post" action="delete.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="hostid" value="<?php echo $mnet_peer->id; ?>" />
|
||||
<input type="hidden" name="step" value="delete" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>"/>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="get" action="index.php">
|
||||
<input type="submit" name="ignore" value="<?php print_string('cancel'); ?>"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
||||
+44
-61
@@ -1,65 +1,48 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
require_login();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
/**
|
||||
* Page to allow the administrator to delete networked hosts, with a confirm message
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2007 Donal McMullan
|
||||
* @copyright 2007 Martin Langhoff
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$step = optional_param('step', 'verify', PARAM_ALPHA);
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
|
||||
require_login();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
$PAGE->set_url('/admin/mnet/delete.php');
|
||||
admin_externalpage_setup('mnetpeer' . $hostid);
|
||||
|
||||
require_sesskey();
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
if ('verify' == $step) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
|
||||
if ($live_users = $mnet_peer->count_live_sessions() > 0) {
|
||||
echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
$yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
|
||||
$nourl = new moodle_url('/admin/mnet/peers.php');
|
||||
echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet') . ': ' . $mnet_peer->name, $yesurl, $nourl);
|
||||
echo $OUTPUT->footer();
|
||||
} elseif ('delete' == $step) {
|
||||
$mnet_peer->delete();
|
||||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
$step = optional_param('step', 'verify', PARAM_ALPHA);
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$warn = array();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
redirect('index.php', get_string('postrequired','mnet') ,7);
|
||||
}
|
||||
|
||||
if ('verify' == $step) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$live_users = $mnet_peer->count_live_sessions();
|
||||
if ($live_users > 0) {
|
||||
$warn[] = get_string('usersareonline', 'mnet', $live_users);
|
||||
}
|
||||
include('delete.html');
|
||||
} elseif ('delete' == $step) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$mnet_peer->delete();
|
||||
redirect('peers.php', get_string('hostdeleted', 'mnet'), 5);
|
||||
}
|
||||
?>
|
||||
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
|
||||
<form id="assignform" method="post" action="">
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
<input type="hidden" name="host" value="<?php p($mnet_peer->id) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<table class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php print_string('existingusers', 'role', count($mnetenrolledusers)); ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php print_string('potentialusers', 'role', $availableusers->_numOfRows); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=false;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($mnetenrolledusers as $enrolleduser) {
|
||||
$fullname = fullname($enrolleduser, true);
|
||||
echo "<option value=\"$enrolleduser->id\">".s($fullname)." (".s($enrolleduser->rolename).")</option>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=false;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($enrolledusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
|
||||
} else {
|
||||
if ($availableusers->_numOfRows > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onfocus ="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
getElementById('assignform').previoussearch.value=1;
|
||||
getElementById('assignform').submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><?php print_string('otherenrolledusers', 'mnet'); ?>:<br />
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($remtenrolledusers as $enrolleduser) {
|
||||
$fullname = fullname($enrolleduser, true);
|
||||
print '<li>'
|
||||
. s($fullname) . ' (' . s($enrolleduser->rolename) . ') '
|
||||
. s($enrolleduser->enroltype)."</li>\n";
|
||||
}
|
||||
?></ul></td>
|
||||
<td valign="top"></td>
|
||||
<td valign="top"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,279 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/xmlrpc/client.php');
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
$mnethostid = required_param('host', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
if (!$mnet_peer->set_id($mnethostid)) {
|
||||
print_error('hostcoursenotfound','mnet');
|
||||
}
|
||||
|
||||
$course = get_record('mnet_enrol_course', 'id', $courseid, 'hostid', $mnet_peer->id);
|
||||
|
||||
if (empty($course)) {
|
||||
print_error('hostcoursenotfound','mnet');
|
||||
}
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 5000);
|
||||
|
||||
$add = optional_param('add', 0, PARAM_BOOL);
|
||||
$remove = optional_param('remove', 0, PARAM_BOOL);
|
||||
$showall = optional_param('showall', 0, PARAM_BOOL);
|
||||
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
|
||||
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
|
||||
$errors = array();
|
||||
|
||||
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
|
||||
|
||||
$baseurl = "remote_enrolment.php?courseid={$course->id}&host={$mnet_peer->id}";
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
|
||||
/// Process incoming role assignment
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
|
||||
$timemodified = time();
|
||||
|
||||
foreach ($frm->addselect as $adduser) {
|
||||
if (!$adduser = clean_param($adduser, PARAM_INT)) {
|
||||
continue;
|
||||
}
|
||||
if (! $enrolment->req_enrol_user($adduser, $course->id)) {
|
||||
$errors[] = "Could not add user with id $adduser to course {$course->id}!";
|
||||
}
|
||||
}
|
||||
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
if (! $enrolment->req_unenrol_user($removeuser, $course->id)) {
|
||||
$errors[] = "Could not remove user with id $removeuser from course {$course->id}!";
|
||||
}
|
||||
}
|
||||
} else if ($showall) {
|
||||
$searchtext = '';
|
||||
$previoussearch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepare data for users / enrolled users panes
|
||||
|
||||
|
||||
/// Create a new request object
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
/// Pass it the path to the method that we want to execute
|
||||
$mnet_request->set_method('enrol/mnet/enrol.php/course_enrolments');
|
||||
$mnet_request->add_param($course->remoteid, 'int');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$all_enrolled_users = $mnet_request->response;
|
||||
|
||||
unset($mnet_request);
|
||||
|
||||
$select = '';
|
||||
$all_enrolled_usernames = '';
|
||||
$timemodified = array();
|
||||
/// List all the users (homed on this server) who are enrolled on the course
|
||||
/// This will include mnet-enrolled users, and those who have enrolled
|
||||
/// themselves, etc.
|
||||
if (is_array($all_enrolled_users) && count($all_enrolled_users)) {
|
||||
foreach($all_enrolled_users as $username => $data) {
|
||||
$all_enrolled_usernames .= "'$username', ";
|
||||
}
|
||||
$select = ' u.username IN (' .substr($all_enrolled_usernames, 0, -2) .') AND ';
|
||||
} else {
|
||||
$all_enrolled_users = array();
|
||||
}
|
||||
|
||||
/// Synch our mnet_enrol_assignments with remote server
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
u.username,
|
||||
u.email,
|
||||
a.enroltype,
|
||||
a.id as enrolid,
|
||||
COALESCE(a.hostid, 0) as wehaverecord,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u
|
||||
LEFT JOIN
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
ON
|
||||
a.userid = u.id AND a.courseid={$courseid}
|
||||
WHERE
|
||||
$select
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$enrolledusers = get_records_sql($sql)) {
|
||||
$enrolledusers = array();
|
||||
}
|
||||
|
||||
foreach($enrolledusers as $user) {
|
||||
|
||||
$dataobj = new stdClass();
|
||||
$dataobj->userid = $user->id;
|
||||
$dataobj->hostid = $mnet_peer->id;
|
||||
$dataobj->courseid = $courseid;
|
||||
$dataobj->rolename = $all_enrolled_users[$user->username]['name'];
|
||||
$dataobj->enroltype = $all_enrolled_users[$user->username]['enrol'];
|
||||
|
||||
if ($user->wehaverecord == 0) {
|
||||
$dataobj->enroltime = $all_enrolled_users[$user->username]['timemodified'];
|
||||
$dataobj->id = insert_record('mnet_enrol_assignments', $dataobj);
|
||||
} elseif (array_key_exists($user->username, $all_enrolled_users)) {
|
||||
$dataobj->id = $user->enrolid;
|
||||
update_record('mnet_enrol_assignments', $dataobj);
|
||||
} elseif (is_array($all_enrolled_users) && count($all_enrolled_users)) {
|
||||
delete_record('mnet_enrol_assignments', 'id', $user->enrolid);
|
||||
}
|
||||
}
|
||||
unset($enrolledusers);
|
||||
|
||||
// Read about our remote enrolments in 2 sets
|
||||
// first, get the remote enrolments done via enrol/mnet $mnetenrolledusers
|
||||
// second, get the remote enrolments done with other plugins $remtenrolledusers
|
||||
// NOTE: both arrays are keyed on the userid!
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
a.rolename,
|
||||
a.enroltype,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
WHERE
|
||||
a.userid = u.id AND
|
||||
a.courseid={$courseid} AND
|
||||
a.enroltype = 'mnet' AND
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$mnetenrolledusers = get_records_sql($sql)) {
|
||||
$mnetenrolledusers = array();
|
||||
}
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
a.rolename,
|
||||
a.enroltype,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
WHERE
|
||||
a.userid = u.id AND
|
||||
a.courseid={$courseid} AND
|
||||
a.enroltype != 'mnet' AND
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$remtenrolledusers = get_records_sql($sql)) {
|
||||
$remtenrolledusers = array();
|
||||
}
|
||||
|
||||
$select = '';
|
||||
$exclude = array_merge(array_keys($mnetenrolledusers), array_keys($remtenrolledusers));
|
||||
$exclude[] = 0;
|
||||
$select = 'AND u.username!=\'guest\' AND u.id NOT IN ('. join(',',$exclude) .') ';
|
||||
unset($exclude);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
|
||||
if ($searchtext !== '') { // Search for a subset of remaining users
|
||||
$LIKE = sql_ilike();
|
||||
$FULLNAME = sql_fullname();
|
||||
|
||||
$select .= " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
}
|
||||
|
||||
$sql = ('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user u
|
||||
WHERE deleted = 0 AND confirmed = 1
|
||||
AND mnethostid = '.$CFG->mnet_localhost_id.' '
|
||||
.$select
|
||||
.'ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
$availableusers = get_recordset_sql($sql, 0, MAX_USERS_PER_PAGE);
|
||||
|
||||
|
||||
|
||||
/// Print the page
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
/// Get some language strings
|
||||
|
||||
$strpotentialusers = get_string('potentialusers', 'role');
|
||||
$strexistingusers = get_string('existingusers', 'role');
|
||||
$straction = get_string('assignroles', 'role');
|
||||
$strroletoassign = get_string('roletoassign', 'role');
|
||||
$strcurrentcontext = get_string('currentcontext', 'role');
|
||||
$strsearch = get_string('search');
|
||||
$strshowall = get_string('showall');
|
||||
$strparticipants = get_string('participants');
|
||||
$strsearchresults = get_string('searchresults');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box('<strong>' . s($mnet_peer->name) . ' : '
|
||||
. format_string($course->shortname) .' '. format_string($course->fullname)
|
||||
. '</strong><br />'
|
||||
. get_string("enrolcourseenrol_desc", "mnet"));
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
include(dirname(__FILE__).'/enr_course_enrol.html');
|
||||
|
||||
if (!empty($errors)) {
|
||||
$msg = '<p>';
|
||||
foreach ($errors as $e) {
|
||||
$msg .= $e.'<br />';
|
||||
}
|
||||
$msg .= '</p>';
|
||||
notify($msg);
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
$mnethost = required_param('host', PARAM_INT);
|
||||
$host = get_record('mnet_host', 'id', $mnethost);
|
||||
|
||||
$courses = $enrolment->fetch_remote_courses($mnethost);
|
||||
|
||||
/// Print the page
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box('<strong>' . s($host->name) . ' </strong><br />'
|
||||
. get_string("enrolcourses_desc", "mnet"));
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
|
||||
. '<table class="generaltable">';
|
||||
|
||||
$icon = "<img src=\"$CFG->pixpath/i/course.gif\"".
|
||||
" class=\"icon\" alt=\"".get_string("course")."\" />";
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$link = "$CFG->wwwroot/$CFG->admin/mnet/enr_course_enrol.php?"
|
||||
. "host={$mnethost}&courseid={$course->id}&sesskey={$USER->sesskey}";
|
||||
echo '<tr>'
|
||||
. "<td>$icon</td>"
|
||||
. "<td><a href=\"$link\">".format_string($course->fullname). "</a></td>"
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. '<td>'.format_string($course->shortname). ' - ' .format_string($course->cat_name).'</td>'
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. "<td align=\"left\" >{$course->summary}</td>"
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table></div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box(get_string("remoteenrolhosts_desc", "mnet"));
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
print_box(get_string('mnetdisabled','mnet'));
|
||||
}
|
||||
|
||||
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
|
||||
. '<table cellspacing="0" cellpadding="5" id="hosts" class="generaltable generalbox" >'
|
||||
. '<tr>'
|
||||
. '<th class="header c0"> '.get_string('host', 'mnet').' </th>'
|
||||
. '<th class="header c1"> '.get_string('enrolments', 'mnet').' </th>'
|
||||
. '<th class="header c2"> '.get_string('courses', 'mnet').' </th>'
|
||||
// . '<th class="header c3"> </th>'
|
||||
. '</tr>';
|
||||
$hosts = $enrolment->list_remote_servers();
|
||||
foreach ($hosts as $host) {
|
||||
$coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&sesskey={$USER->sesskey}";
|
||||
$coursecount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_course WHERE hostid={$host->id}");
|
||||
if (empty($coursecount)) {
|
||||
$coursecount = '?';
|
||||
}
|
||||
$enrolcount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_assignments WHERE hostid={$host->id}");
|
||||
|
||||
echo '<tr>'
|
||||
. "<td><a href=\"{$coursesurl}\">{$host->name}</a></td>"
|
||||
. "<td align=\"center\" >$enrolcount</td>"
|
||||
. "<td align=\"center\" >$coursecount - <a href=\"{$coursesurl}\">".get_string('editenrolments', 'mnet')."</a></td>"
|
||||
// TODO: teach report/log/index.php to show per-host-logs
|
||||
// . '<td align="center" ><a href="$CFG->wwwroot/$CFG->admin/report/log/index.php?course_host={$host->id}">'
|
||||
// . get_string('logs', 'mnet').'</a> </td>'
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table>'
|
||||
. '</div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
+48
-30
@@ -1,4 +1,4 @@
|
||||
<?PHP
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure mnet stuff
|
||||
|
||||
@@ -13,19 +13,23 @@
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$site = get_site();
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nocurl', 'mnet');
|
||||
print_error('nocurl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
@@ -39,29 +43,32 @@
|
||||
if (set_config('mnet_dispatcher_mode', $form->mode)) {
|
||||
redirect('index.php', get_string('changessaved'));
|
||||
} else {
|
||||
print_error('invalidaction', '', 'index.php');
|
||||
error('Invalid action parameter.', 'index.php');
|
||||
}
|
||||
}
|
||||
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
|
||||
$mnet->get_private_key();
|
||||
$SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])).':'.time();
|
||||
|
||||
$formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url('index.php', array()), get_string('no'));
|
||||
echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel);
|
||||
$MNET->get_private_key();
|
||||
$_SESSION['mnet_confirm_delete_key'] = md5(sha1($MNET->keypair['keypair_PEM'])).':'.time();
|
||||
notice_yesno(get_string("deletekeycheck", "mnet"),
|
||||
"index.php?sesskey=$USER->sesskey&confirm=".md5($MNET->public_key),
|
||||
"index.php",
|
||||
array('sesskey' => $USER->sesskey),
|
||||
NULL,
|
||||
'post',
|
||||
'get');
|
||||
exit;
|
||||
} else {
|
||||
// We're deleting
|
||||
|
||||
|
||||
if (!isset($SESSION->mnet_confirm_delete_key)) {
|
||||
|
||||
|
||||
if (!isset($_SESSION['mnet_confirm_delete_key'])) {
|
||||
// fail - you're being attacked?
|
||||
}
|
||||
|
||||
$key = '';
|
||||
$time = '';
|
||||
@list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
|
||||
$mnet->get_private_key();
|
||||
@list($key, $time) = explode(':',$_SESSION['mnet_confirm_delete_key']);
|
||||
$MNET->get_private_key();
|
||||
|
||||
if($time < time() - 60) {
|
||||
// fail - you're out of time.
|
||||
@@ -69,36 +76,45 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) {
|
||||
if ($key != md5(sha1($MNET->keypair['keypair_PEM']))) {
|
||||
// fail - you're being attacked?
|
||||
print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$mnet->replace_keys();
|
||||
$MNET->replace_keys();
|
||||
redirect('index.php', get_string('keydeleted','mnet'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC');
|
||||
$hosts = get_records_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
|
||||
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
?>
|
||||
<center>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td>
|
||||
<td colspan="2" class="header" cellpadding="0"><?php print_string('aboutyourhost', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('publickey', 'mnet'); ?>:</td>
|
||||
<td><pre><?php echo $mnet->public_key; ?></pre></td>
|
||||
<td><pre><?php echo $MNET->public_key; ?></pre></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('expires', 'mnet'); ?>:</td>
|
||||
<td><?php echo userdate($mnet->public_key_expires); ?></td>
|
||||
<td><?php echo userdate($MNET->public_key_expires); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('net', 'mnet'); ?>:</td>
|
||||
<td><input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="radio" name="mode" value="off" <?php echo ("off" == $CFG->mnet_dispatcher_mode)? 'checked="checked"' : '' ?> /> <?php print_string('off', 'mnet'); ?> <br />
|
||||
<input type="radio" name="mode" value="strict" <?php echo ("strict" == $CFG->mnet_dispatcher_mode)? 'checked="checked"' : '' ?> /> <?php print_string('on', 'mnet'); ?><br />
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@@ -111,14 +127,14 @@
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
<td colspan="2" class="header" cellpadding="0"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
|
||||
<td colspan="2" cellpadding="0"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
<td align="left"><input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<td align="left"><input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="deleteKey" value="" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>" />
|
||||
</td>
|
||||
@@ -128,6 +144,8 @@
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
echo $OUTPUT->footer();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetdetails');
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
?>
|
||||
<form method="post" action="peers.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="commit" />
|
||||
<input type="hidden" name="last_connect_time" value="<?php echo $mnet_peer->last_connect_time; ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo isset($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationid" value="<?php echo isset($mnet_peer->applicationid)? $mnet_peer->applicationid : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationname" value="<?php echo isset($mnet_peer->application->name)? $mnet_peer->application->name : '' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" width="635">
|
||||
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('site'); ?>:</td>
|
||||
<td valign="top"><input type="text" name="name" size="30" value="<?php echo $mnet_peer->name; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('hostname', 'mnet'); ?>:</td>
|
||||
<td valign="top"><input type="text" name="wwwroot" size="30" value="<?php echo $mnet_peer->wwwroot; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
if (empty($mnet_peer->public_key)) $mnet_peer->public_key = '';
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php
|
||||
print_string('publickey', 'mnet');
|
||||
echo ': <br />';
|
||||
helpbutton("publickey", get_string('publickey', 'mnet'), "mnet", true, true);
|
||||
?></td>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0) {
|
||||
$key = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application->xmlrpc_server_url);
|
||||
$mnet_peer->public_key = clean_param($key, PARAM_PEM);
|
||||
}
|
||||
?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if (empty($mnet_peer->public_key)) {
|
||||
print_string('nopubkey', 'mnet');
|
||||
}
|
||||
?><br />
|
||||
<textarea rows="17" cols="65" name="public_key" style="font-size: 8px;"><?php echo $mnet_peer->public_key; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('expires', 'mnet'); ?>:</td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if($mnet_peer->public_key_expires < time()) {
|
||||
print_string('expired', 'mnet');
|
||||
echo ' ';
|
||||
}
|
||||
echo userdate($mnet_peer->public_key_expires);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
if(!empty($currentkey)) {
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"></td>
|
||||
<td valign="top"><?php print_string('keymismatch', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('currentkey', 'mnet'); ?>:</td>
|
||||
<td valign="top"><pre style="font-size: 8px;"><?php echo $currentkey;?></pre></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('last_connect_time', 'mnet'); ?>:</td>
|
||||
<td valign="top"><?php echo ($mnet_peer->last_connect_time == 0)? get_string('never','mnet') : date('H:i:s d/m/Y',$mnet_peer->last_connect_time);?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0){
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('deleted'); ?>:</td>
|
||||
<td valign="top">
|
||||
<input type="radio" name="deleted" value="0" checked="checked" /> <?php print_string('reenableserver','mnet'); ?><br />
|
||||
<input type="radio" name="deleted" value="1" /> <?php print_string('yes'); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->ip_address) && '' != $mnet_peer->ip_address){
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('ipaddress', 'mnet');
|
||||
echo ': <br />';
|
||||
helpbutton("ipaddress", get_string('ipaddress', 'mnet'), "mnet", true, true);
|
||||
?>:</td>
|
||||
<td valign="top"><?php echo $mnet_peer->ip_address; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges"); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
print_tabs(array($tabs), 'mnetdetails');
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
?>
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('site'); ?>:</td>
|
||||
<td valign="top"><?php echo $mnet_peer->name; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top" colspan="2"><?php print_string('allhosts_no_options'); ?>:</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id && $mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetservices');
|
||||
print_simple_box_start("center", "");
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="mnet_services.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="<?php echo $mnet_peer->nextstep; ?>" />
|
||||
<input type="hidden" name="hostid" value="<?php echo ($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<?php
|
||||
foreach($myservices as $name => $versions) {
|
||||
$version = current($versions);
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<h3><?php echo get_string($name.'_name', $version['parent_type'].'_'.$version['parent'] , $mnet_peer->name); ?></h3>
|
||||
<?php echo get_string($name.'_description', $version['parent_type'].'_'.$version['parent'], $mnet_peer->name); ?>
|
||||
<?php
|
||||
$breakstring = '';
|
||||
foreach($versions as $version){
|
||||
if (count($versions) > 1) {
|
||||
$versionstring = '('.get_string('version','mnet') .' '.$version['apiversion'].')';
|
||||
} else {
|
||||
$versionstring = '';
|
||||
}
|
||||
|
||||
echo $breakstring;
|
||||
?>
|
||||
<input type="hidden" name="exists[<?php echo $version['serviceid']; ?>]" value="1" />
|
||||
<input type="checkbox" name="publish[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_publish']))? 'checked="checked" ': '' ; ?>/>
|
||||
<?php
|
||||
print_string('publish','mnet');
|
||||
echo $versionstring;
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
echo '<a href="#" title="'.get_string('issubscribed','mnet', $mnet_peer->name).'">√</a> ';
|
||||
}
|
||||
if (!empty($version['allhosts_publish'])) {
|
||||
print_string("enabled_for_all",'mnet',!empty($version['I_publish']));
|
||||
}
|
||||
echo '<br />';
|
||||
?>
|
||||
<input type="checkbox" name="subscribe[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_subscribe']))? 'checked="checked" ': '' ; ?>/>
|
||||
<?php
|
||||
print_string('subscribe','mnet');
|
||||
echo $versionstring;
|
||||
if (!empty($version['hostpublishes'])) {
|
||||
echo '<a href="#" title="'.get_string('ispublished','mnet', $mnet_peer->name).'">√</a> ';
|
||||
}
|
||||
if (!empty($version['allhosts_subscribe'])) {
|
||||
print_string("enabled_for_all",'mnet',!empty($version['I_subscribe']));
|
||||
}
|
||||
|
||||
echo '<br />';
|
||||
$breakstring = '. . . . . . . . . . . . . . . . . . . . . . . . <br>';
|
||||
} // end foreach
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} // end foreach
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="pubTreeLoc"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="subTreeLoc"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="formElements"><input type="hidden" name="outer" value="4" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
// force Go ahead with something we've been warned is strange
|
||||
$step = optional_param('step', NULL, PARAM_ALPHA);
|
||||
$hostid = optional_param('hostid', NULL, PARAM_INT);
|
||||
$nocertstring = '';
|
||||
$nocertmatch = '';
|
||||
$badcert = '';
|
||||
$certerror = '';
|
||||
$noipmatch = '';
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmneteditservices = get_string('reviewhostservices', 'mnet');
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$mnet_peer->set_id($hostid);
|
||||
$treevals = array();
|
||||
foreach($_POST['exists'] as $key => $value) {
|
||||
$host2service = get_record('mnet_host2service', 'hostid', $_POST['hostid'], 'serviceid', $key);
|
||||
$publish = (isset($_POST['publish'][$key]) && $_POST['publish'][$key] == 'on')? 1 : 0;
|
||||
$subscribe = (isset($_POST['subscribe'][$key]) && $_POST['subscribe'][$key] == 'on')? 1 : 0;
|
||||
|
||||
if ($publish != 1 && $subscribe != 1) {
|
||||
if (false == $host2service) {
|
||||
// We don't have or need a record - do nothing!
|
||||
} else {
|
||||
// We don't need the record - delete it
|
||||
delete_records('mnet_host2service', 'hostid', $_POST['hostid'], 'serviceid', $key);
|
||||
}
|
||||
} elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) {
|
||||
$host2service = new stdClass();
|
||||
$host2service->hostid = $_POST['hostid'];
|
||||
$host2service->serviceid = $key;
|
||||
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
|
||||
$host2service->id = insert_record('mnet_host2service', $host2service);
|
||||
} elseif ($host2service->publish != $publish || $host2service->subscribe != $subscribe) {
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
$tf = update_record('mnet_host2service', $host2service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($hostid)) {
|
||||
if (0 == $mnet_peer->id) $mnet_peer->set_id($hostid);
|
||||
$mnet_peer->nextstep = 'verify';
|
||||
|
||||
$id_list = $mnet_peer->id;
|
||||
if (!empty($CFG->mnet_all_hosts_id)) {
|
||||
$id_list .= ', '.$CFG->mnet_all_hosts_id;
|
||||
}
|
||||
|
||||
$concat = sql_concat('COALESCE(h2s.id,0) ', ' \'-\' ', ' svc.id');
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT
|
||||
$concat as id,
|
||||
svc.id as serviceid,
|
||||
svc.name,
|
||||
svc.offer,
|
||||
svc.apiversion,
|
||||
r.parent_type,
|
||||
r.parent,
|
||||
h2s.hostid,
|
||||
h2s.publish,
|
||||
h2s.subscribe
|
||||
FROM
|
||||
{$CFG->prefix}mnet_service2rpc s2r,
|
||||
{$CFG->prefix}mnet_rpc r,
|
||||
{$CFG->prefix}mnet_service svc
|
||||
LEFT JOIN
|
||||
{$CFG->prefix}mnet_host2service h2s
|
||||
ON
|
||||
h2s.hostid in ($id_list) AND
|
||||
h2s.serviceid = svc.id
|
||||
WHERE
|
||||
svc.offer = '1' AND
|
||||
s2r.serviceid = svc.id AND
|
||||
s2r.rpcid = r.id
|
||||
ORDER BY
|
||||
svc.name ASC";
|
||||
|
||||
$resultset = get_records_sql($query);
|
||||
|
||||
if (is_array($resultset)) {
|
||||
$resultset = array_values($resultset);
|
||||
} else {
|
||||
$resultset = array();
|
||||
}
|
||||
|
||||
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
|
||||
|
||||
$remoteservices = array();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
// Create a new request object
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
// Tell it the path to the method that we want to execute
|
||||
$mnet_request->set_method('system/listServices');
|
||||
$mnet_request->send($mnet_peer);
|
||||
if (is_array($mnet_request->response)) {
|
||||
foreach($mnet_request->response as $service) {
|
||||
$remoteservices[$service['name']][$service['apiversion']] = $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$myservices = array();
|
||||
foreach($resultset as $result) {
|
||||
$result->hostpublishes = false;
|
||||
$result->hostsubscribes = false;
|
||||
if (isset($remoteservices[$result->name][$result->apiversion])) {
|
||||
if ($remoteservices[$result->name][$result->apiversion]['publish'] == 1) {
|
||||
$result->hostpublishes = true;
|
||||
}
|
||||
if ($remoteservices[$result->name][$result->apiversion]['subscribe'] == 1) {
|
||||
$result->hostsubscribes = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($myservices[$result->name][$result->apiversion])) {
|
||||
$myservices[$result->name][$result->apiversion] = array('serviceid' => $result->serviceid,
|
||||
'name' => $result->name,
|
||||
'offer' => $result->offer,
|
||||
'apiversion' => $result->apiversion,
|
||||
'parent_type' => $result->parent_type,
|
||||
'parent' => $result->parent,
|
||||
'hostsubscribes' => $result->hostsubscribes,
|
||||
'hostpublishes' => $result->hostpublishes
|
||||
);
|
||||
}
|
||||
|
||||
// allhosts_publish allows us to tell the admin that even though he
|
||||
// is disabling a service, it's still available to the host because
|
||||
// he's also publishing it to 'all hosts'
|
||||
if ($result->hostid == $CFG->mnet_all_hosts_id && $CFG->mnet_all_hosts_id != $mnet_peer->id) {
|
||||
$myservices[$result->name][$result->apiversion]['allhosts_publish'] = $result->publish;
|
||||
$myservices[$result->name][$result->apiversion]['allhosts_subscribe'] = $result->subscribe;
|
||||
} elseif (!empty($result->hostid)) {
|
||||
$myservices[$result->name][$result->apiversion]['I_publish'] = $result->publish;
|
||||
$myservices[$result->name][$result->apiversion]['I_subscribe'] = $result->subscribe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
redirect('peers.php', get_string('nohostid','mnet'), '5');
|
||||
exit;
|
||||
}
|
||||
|
||||
include('./mnet_services.html');
|
||||
?>
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
admin_externalpage_print_header($adminroot);
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id) $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
print_tabs(array($tabs), 'mnetthemes');
|
||||
print_simple_box_start("center", "");
|
||||
|
||||
print_heading($strthemes);
|
||||
|
||||
|
||||
|
||||
$themes = get_list_of_plugins("theme");
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">";
|
||||
|
||||
if (count($report)) {
|
||||
echo '<tr>';
|
||||
echo '<td align="center" colspan="2">';
|
||||
echo '<span class="'.$report[1].'">'.$report[0].'</span>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
if (!$USER->screenreader) {
|
||||
echo "<tr class=\"generaltableheader\"><th scope=\"col\">$strtheme</th>";
|
||||
echo "<th scope=\"col\">$strinfo</th></tr>";
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
echo '<td align="center"><span class="informationbox">Choose this option to use your site\'s default theme: <strong>'.$CFG->theme.'</strong>.</span></td>';
|
||||
if ($mnet_peer->theme == '') {
|
||||
echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
|
||||
} else {
|
||||
echo '<td valign="top">';
|
||||
}
|
||||
echo '<p style="font-size:1.5em;font-style:bold;">Site Theme</p>';
|
||||
$options = null;
|
||||
$options['choose'] = $unlikely_name;// Something unlikely to ever be a theme name... initially $unlikely_name = 'ZoqZoqZ';
|
||||
$options['sesskey'] = $sesskey;
|
||||
$options['hostid'] = $mnet_peer->id;
|
||||
print_single_button('mnet_themes.php', $options, $strchoose);
|
||||
echo '</td>';
|
||||
echo "</tr>";
|
||||
|
||||
foreach ($themes as $theme) {
|
||||
|
||||
unset($THEME);
|
||||
|
||||
if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
|
||||
continue;
|
||||
}
|
||||
|
||||
include($CFG->themedir.'/'.$theme.'/config.php');
|
||||
|
||||
$readme = '';
|
||||
$screenshot = '';
|
||||
$screenshotpath = '';
|
||||
|
||||
if (file_exists($CFG->themedir.'/'.$theme.'/README.html')) {
|
||||
$readme = '<li>'.
|
||||
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
|
||||
} else if (file_exists($CFG->themedir.'/'.$theme.'/README.txt')) {
|
||||
$readme = '<li>'.
|
||||
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
|
||||
}
|
||||
if (file_exists("$theme/screenshot.png")) {
|
||||
$screenshotpath = "$theme/screenshot.png";
|
||||
} else if (file_exists("$theme/screenshot.jpg")) {
|
||||
$screenshotpath = "$theme/screenshot.jpg";
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
|
||||
// no point showing this if user is using screen reader
|
||||
if (!$USER->screenreader) {
|
||||
echo "<td align=\"center\">";
|
||||
if ($screenshotpath) {
|
||||
$screenshot = '<li><a href='.$CFG->wwwroot .'/theme/'. $theme.'/screenshot.jpg">'.$strscreenshot.'</a></li>';
|
||||
echo "<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object></td>";
|
||||
} else {
|
||||
echo '<object type="text/html" data="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'" height="200" width="400">'.$theme.'</object></td>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($mnet_peer->theme == $theme) {
|
||||
echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
|
||||
} else {
|
||||
echo '<td valign="top">';
|
||||
}
|
||||
|
||||
if (isset($THEME->sheets)) {
|
||||
echo '<p style="font-size:1.5em;font-style:bold;">'.$theme.'</p>';
|
||||
} else {
|
||||
echo '<p style="font-size:1.5em;font-style:bold;color:red;">'.$theme.' (Moodle 1.4)</p>';
|
||||
}
|
||||
|
||||
if ($screenshot or $readme) {
|
||||
echo '<ul>';
|
||||
if (!$USER->screenreader) {
|
||||
echo '<li><a href="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'">'.$strpreview.'</a></li>';
|
||||
}
|
||||
echo $screenshot.$readme;
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
$options = null;
|
||||
$options['choose'] = $theme;
|
||||
$options['sesskey'] = $sesskey;
|
||||
$options['hostid'] = $mnet_peer->id;
|
||||
print_single_button('mnet_themes.php', $options, $strchoose);
|
||||
echo '</td>';
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer($adminroot);
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', true);
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
if (is_int($hostid)) {
|
||||
$mnet_peer->set_id($hostid);
|
||||
}
|
||||
|
||||
$choose = optional_param("choose",'',PARAM_FILE); // set this theme as default
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strthemes = get_string("themes");
|
||||
$strpreview = get_string("preview");
|
||||
$strchoose = get_string("choose");
|
||||
$strinfo = get_string("info");
|
||||
$strtheme = get_string("theme");
|
||||
$strthemesaved = get_string("themesaved");
|
||||
$strscreenshot = get_string("screenshot");
|
||||
$stroldtheme = get_string("oldtheme");
|
||||
$report = array();
|
||||
$unlikely_name = 'ZoqZoqZ'; // Something unlikely to ever be a theme name
|
||||
|
||||
if ($choose) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($choose == $unlikely_name) {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = '';
|
||||
if ($mnet_peer->commit()) {
|
||||
$report = array(get_string('themesaved'), 'informationbox');
|
||||
} else {
|
||||
$report = array(get_string('themesavederror', 'mnet'), 'errorbox');
|
||||
}
|
||||
} elseif (!is_dir($CFG->themedir .'/'. $choose) || !file_exists($CFG->themedir .'/'. $choose .'/config.php')) {
|
||||
echo 'CHOOSE -'.$choose.' '. $CFG->themedir .'/'. $choose .'/config.php' ;
|
||||
$report = array('This theme is not installed!'.'3', 'errorbox');
|
||||
} else {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = addslashes($choose);
|
||||
if ($mnet_peer->commit()) {
|
||||
$report = array(get_string('themesaved').'1', 'informationbox');
|
||||
} else {
|
||||
$report = array(get_string('themesavederror', 'mnet').'2', 'errorbox');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include('./mnet_themes.html');
|
||||
?>
|
||||
@@ -1,167 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains two forms for adding/editing mnet hosts, used by peers.php
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
/**
|
||||
* The very basic first step add new host form - just wwwroot & application
|
||||
* The second form is loaded up with the information from this one.
|
||||
*/
|
||||
class mnet_simple_host_form extends moodleform {
|
||||
function definition() {
|
||||
global $DB;
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'));
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
$mform->addRule('wwwroot', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'),
|
||||
$DB->get_records_menu('mnet_application', array(), 'id,display_name'));
|
||||
$mform->addRule('applicationid', null, 'required', null, 'client');
|
||||
|
||||
$this->add_action_buttons(false, get_string('addhost', 'mnet'));
|
||||
}
|
||||
|
||||
function validation($data) {
|
||||
global $DB;
|
||||
|
||||
$wwwroot = $data['wwwroot'];
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($wwwroot, 0, 4)) != 'http') {
|
||||
$wwwroot = 'http://'.$wwwroot;
|
||||
}
|
||||
if ($host = $DB->get_record('mnet_host', array('wwwroot' => $wwwroot))) {
|
||||
global $CFG;
|
||||
return array('wwwroot' => get_string('hostexists', 'mnet', $CFG->wwwroot . '/admin/mnet/peers.php?hostid=' . $host->id));
|
||||
}
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The second step of the form - reviewing the host details
|
||||
* This is also the same form that is used for editing an existing host
|
||||
*/
|
||||
class mnet_review_host_form extends moodleform {
|
||||
function definition() {
|
||||
global $OUTPUT;
|
||||
|
||||
$mform = $this->_form;
|
||||
$mnet_peer = $this->_customdata['peer'];
|
||||
|
||||
$mform->addElement('hidden', 'last_connect_time');
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->addElement('hidden', 'applicationid');
|
||||
$mform->addElement('hidden', 'oldpublickey');
|
||||
|
||||
$mform->addElement('text', 'name', get_string('site'));
|
||||
$mform->setType('name', PARAM_NOTAGS);
|
||||
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'));
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
|
||||
$themes = array('' => get_string('forceno'));
|
||||
foreach (array_keys(get_plugin_list('theme')) as $themename) {
|
||||
$themes[$themename] = get_string('pluginname', 'theme_'.$themename);
|
||||
}
|
||||
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
|
||||
|
||||
$mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
|
||||
$mform->setType('public_key', PARAM_PEM);
|
||||
|
||||
if ($mnet_peer && !empty($mnet_peer->deleted)) {
|
||||
$radioarray = array();
|
||||
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
|
||||
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
}
|
||||
|
||||
// finished with form controls, now the static informational stuff
|
||||
if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
|
||||
$expires = '';
|
||||
if ($mnet_peer->public_key_expires < time()) {
|
||||
$expires = get_string('expired', 'mnet') . ' ';
|
||||
}
|
||||
$expires .= userdate($mnet_peer->public_key_expires);
|
||||
$mform->addElement('static', 'validuntil', get_string('expires', 'mnet'), $expires);
|
||||
|
||||
$lastconnect = '';
|
||||
if ($mnet_peer->last_connect_time == 0) {
|
||||
$lastconnect = get_string('never', 'mnet');
|
||||
} else {
|
||||
$lastconnect = date('H:i:s d/m/Y',$mnet_peer->last_connect_time);
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'lastconnect', get_string('last_connect_time', 'mnet'), $lastconnect);
|
||||
$mform->addElement('static', 'ipaddress', get_string('ipaddress', 'mnet'), $mnet_peer->ip_address);
|
||||
|
||||
if (isset($mnet_peer->currentkey)) { // key being published is not the same as our records
|
||||
$currentkeystr = '<b>' . get_string('keymismatch', 'mnet') . '</b><br /><br /> ' . $OUTPUT->box('<pre>' . $mnet_peer->currentkey . '</pre>');
|
||||
$mform->addElement('static', 'keymismatch', get_string('currentkey', 'mnet'), $currentkeystr);
|
||||
}
|
||||
|
||||
$credstr = '';
|
||||
if ($credentials = $mnet_peer->check_credentials($mnet_peer->public_key)) {
|
||||
foreach($credentials['subject'] as $key => $credential) {
|
||||
if (is_scalar($credential)) {
|
||||
$credstr .= str_pad($key, 16, " ", STR_PAD_LEFT).': '.$credential."\n";
|
||||
} else {
|
||||
$credstr .= str_pad($key, 16, " ", STR_PAD_LEFT).': '.var_export($credential,1)."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'), $OUTPUT->box('<pre>' . $credstr . '</pre>'));
|
||||
}
|
||||
|
||||
// finished with static stuff, print save button
|
||||
$this->add_action_buttons(false);
|
||||
}
|
||||
|
||||
function validation($data) {
|
||||
$errors = array();
|
||||
if ($data['oldpublickey'] == $data['public_key']) {
|
||||
return;
|
||||
}
|
||||
$mnet_peer = new mnet_peer(); // idiotic api
|
||||
$mnet_peer->wwwroot = $data['wwwroot']; // just hard-set this rather than bootstrap the object
|
||||
if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
|
||||
$errmsg = '';
|
||||
foreach ($mnet_peer->error as $err) {
|
||||
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
|
||||
}
|
||||
$errors['public_key'] = get_string('invalidpubkey', 'mnet', $errmsg);
|
||||
}
|
||||
unset($mnet_peer);
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
print_box(get_string('mnetdisabled','mnet'));
|
||||
}
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<form method="post" action="peers.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="updateregisterall" value="1" />
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('registerallhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('registerallhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1"><input type="checkbox" name="registerallhosts" <?php if (!empty($CFG->mnet_register_allhosts)) echo 'checked="checked" '; ?>/></td>
|
||||
<td class="cell c1"> <?php print_string('registerallhosts', 'mnet'); ?> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" colspan="2"><input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox standard" >
|
||||
<tr>
|
||||
<th class="header c0"><?php print_string('site'); ?></th>
|
||||
<th class="header c1"><?php print_string('system','mnet'); ?></th>
|
||||
<th class="header c2"><?php print_string('last_connect_time', 'mnet'); ?></th>
|
||||
<th class="header c3"></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach($hosts as $host) {
|
||||
|
||||
if ($host->last_connect_time == 0) {
|
||||
$last_connect = get_string('never');
|
||||
} else {
|
||||
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time);
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c0"><a href="peers.php?step=update&hostid=<?php echo $host->id; ?>"><?php echo $host->name; ?></a></td>
|
||||
<td class="cell c1"><a href="peers.php?step=update&hostid=<?php echo $host->id; ?>"><?php echo $host->wwwroot; ?></a></td>
|
||||
<td class="cell c2"><?php if ($host->id != $CFG->mnet_all_hosts_id) echo $last_connect; ?></td>
|
||||
<td class="cell c3">
|
||||
<?php if ($host->id != $CFG->mnet_all_hosts_id){ ?>
|
||||
<form method="post" action="delete.php">
|
||||
<div>
|
||||
<input type="hidden" name="hostid" value="<?php echo $host->id; ?>" />
|
||||
<input type="hidden" name="step" value="verify" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>"/>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<form method="post" action="peers.php">
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox standard" >
|
||||
|
||||
<tr>
|
||||
<th class="header c4" colspan="4">
|
||||
<?php print_string('addnewhost', 'mnet'); ?>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="input" />
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c0">wwwroot:</td>
|
||||
<td class="cell c1"><input type="text" name="wwwroot" value="" /></td>
|
||||
<td class="cell c2">
|
||||
<select name="applicationid">
|
||||
<?php
|
||||
foreach($applications as $application) {
|
||||
echo ' <option value="'.$application->id.'">'.$application->display_name."</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="cell c3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c4" align="right" colspan="4"><input type="submit" value="<?php print_string('addhost','mnet'); ?>" /></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
+152
-236
@@ -1,265 +1,181 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Page to allow the administrator to configure networked hosts, and add new ones
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2007 Donal McMullan
|
||||
* @copyright 2007 Martin Langhoff
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
// Allows the admin to configure other Moodle hosts info
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/mnet/lib.php');
|
||||
require_once($CFG->dirroot.'/admin/mnet/peer_forms.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
|
||||
/// Initialize variables.
|
||||
$hostid = optional_param('hostid', 0, PARAM_INT);
|
||||
$updra = optional_param('updateregisterall', 0, PARAM_INT);
|
||||
|
||||
// first process the register all hosts setting if required
|
||||
if (!empty($updra)) {
|
||||
set_config('mnet_register_allhosts', optional_param('registerallhosts', 0, PARAM_INT));
|
||||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
|
||||
}
|
||||
|
||||
$adminsection = 'mnetpeers';
|
||||
if ($hostid && $DB->get_field('mnet_host', 'deleted', array('id' => $hostid)) != 1) {
|
||||
$adminsection = 'mnetpeer' . $hostid;
|
||||
}
|
||||
|
||||
$PAGE->set_url('/admin/mnet/peers.php');
|
||||
admin_externalpage_setup($adminsection);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
admin_externalpage_print_header();
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
print_error('nocurl', 'mnet');
|
||||
admin_externalpage_print_header();
|
||||
print_error('nocurl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('xmlrpc_encode_request')) {
|
||||
print_error('xmlrpc-missing', 'mnet');
|
||||
}
|
||||
/// Initialize variables.
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
}
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
$step = optional_param('step', NULL, PARAM_ALPHA);
|
||||
$hostid = optional_param('hostid', NULL, PARAM_INT);
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
$simpleform = new mnet_simple_host_form(); // the one that goes on the bottom of the main page
|
||||
$reviewform = null; // set up later in different code branches, so mnet_peer can be passed to the constructor
|
||||
// Fetch some strings for the HTML templates
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
|
||||
// if the first form has been submitted, bootstrap the peer and load up the review form
|
||||
if ($formdata = $simpleform->get_data()) {
|
||||
// ensure we remove trailing slashes
|
||||
$formdata->wwwroot = trim($formdata->wwwroot);
|
||||
$formdata->wwwroot = rtrim($formdata->wwwroot, '/');
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) set_config('mnet_dispatcher_mode', 'off');
|
||||
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($formdata->wwwroot, 0, 4)) != 'http') {
|
||||
$formdata->wwwroot = 'http://'.$formdata->wwwroot;
|
||||
}
|
||||
/// If data submitted, process and store
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
|
||||
$mnet_peer->set_applicationid($formdata->applicationid);
|
||||
$application = $DB->get_field('mnet_application', 'name', array('id'=>$formdata->applicationid));
|
||||
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
|
||||
// bootstrap the second form straight with the data from the first form
|
||||
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
|
||||
$formdata->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
|
||||
$reviewform->set_data($mnet_peer);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box_start();
|
||||
$reviewform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
} else if ($simpleform->is_submitted()) { // validation failed
|
||||
$noreviewform = true;
|
||||
}
|
||||
if (!empty($form->wwwroot)) {
|
||||
// ensure we remove trailing slashes
|
||||
$form->wwwroot = preg_replace(':/$:', '', $form->wwwroot);
|
||||
|
||||
// editing a host - load up the review form
|
||||
if (!empty($hostid)) {
|
||||
// TODO print a nice little heading
|
||||
$mnet_peer->set_id($hostid);
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'mnetdetails';
|
||||
require_once($CFG->dirroot . '/admin/mnet/tabs.php');
|
||||
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
$mnet_peer->currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
|
||||
if ($mnet_peer->currentkey == $mnet_peer->public_key) {
|
||||
unset($mnet_peer->currentkey);
|
||||
} else {
|
||||
error_log($mnet_peer->currentkey);
|
||||
error_log($mnet_peer->public_key);
|
||||
error_log(md5($mnet_peer->currentkey));
|
||||
error_log(md5($mnet_peer->public_key));
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($form->wwwroot, 0, 4)) != 'http') {
|
||||
$form->wwwroot = 'http://'.$form->wwwroot;
|
||||
}
|
||||
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
|
||||
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
|
||||
$mnet_peer->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
|
||||
$reviewform->set_data((object)$mnet_peer);
|
||||
echo $OUTPUT->box_start();
|
||||
$reviewform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if(!function_exists('xmlrpc_encode_request')) {
|
||||
trigger_error("You must have xml-rpc enabled in your PHP build to use this feature.");
|
||||
error(get_string('xmlrpc-missing', 'mnet'),'peers.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($form->updateregisterall)) {
|
||||
if (!empty($form->registerallhosts)) {
|
||||
set_config('mnet_register_allhosts',1);
|
||||
} else {
|
||||
set_config('mnet_register_allhosts',0);
|
||||
}
|
||||
redirect('peers.php', get_string('changessaved'));
|
||||
} else {
|
||||
// no options for allhosts host - just let the tabs display and print a notification
|
||||
echo $OUTPUT->notification(get_string('allhosts_no_options', 'mnet'));
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
|
||||
if (!empty($form->id)) {
|
||||
$form->id = clean_param($form->id, PARAM_INT);
|
||||
$mnet_peer->set_id($form->id);
|
||||
} else {
|
||||
// PARAM_URL requires a genuine TLD (I think) This breaks my testing
|
||||
$temp_wwwroot = clean_param($form->wwwroot, PARAM_URL);
|
||||
if ($temp_wwwroot !== $form->wwwroot) {
|
||||
trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc.");
|
||||
error(get_string("invalidurl", 'mnet'),'peers.php');
|
||||
exit;
|
||||
}
|
||||
unset($temp_wwwroot);
|
||||
$mnet_peer->set_applicationid($form->applicationid);
|
||||
$application = get_field('mnet_application', 'name', 'id', $form->applicationid);
|
||||
$mnet_peer->bootstrap($form->wwwroot, null, $application);
|
||||
}
|
||||
|
||||
if (isset($form->name) && $form->name != $mnet_peer->name) {
|
||||
$form->name = clean_param($form->name, PARAM_NOTAGS);
|
||||
$mnet_peer->set_name($form->name);
|
||||
}
|
||||
|
||||
if (isset($form->deleted) && ($form->deleted == '0' || $form->deleted == '1')) {
|
||||
$mnet_peer->deleted = $form->deleted;
|
||||
}
|
||||
|
||||
if (isset($form->public_key)) {
|
||||
$form->public_key = clean_param($form->public_key, PARAM_PEM);
|
||||
if (empty($form->public_key)) {
|
||||
error(get_string("invalidpubkey", 'mnet'),'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
exit;
|
||||
} else {
|
||||
$oldkey = $mnet_peer->public_key;
|
||||
$mnet_peer->public_key = $form->public_key;
|
||||
$mnet_peer->public_key_expires = $mnet_peer->check_common_name($form->public_key);
|
||||
if ($mnet_peer->public_key_expires == false) {
|
||||
$mnet_peer->public_key == $oldkey;
|
||||
$errmsg = '<br />';
|
||||
foreach ($mnet_peer->error as $err) {
|
||||
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
|
||||
}
|
||||
error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PREVENT DUPLICATE RECORDS ///////////////////////////////////////////
|
||||
if ('input' == $form->step) {
|
||||
if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) {
|
||||
error(get_string("hostexists", 'mnet', $mnet_peer->id),'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ('input' == $form->step) {
|
||||
include('./mnet_review.html');
|
||||
} elseif ('commit' == $form->step) {
|
||||
$bool = $mnet_peer->commit();
|
||||
if ($bool) {
|
||||
redirect('peers.php?step=update&hostid='.$mnet_peer->id, get_string('changessaved'));
|
||||
} else {
|
||||
error('Invalid action parameter.', 'index.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// either we're in the second step of setting up a new host
|
||||
// or editing an existing host
|
||||
// try our best to set up the mnet_peer object to pass to the form definition
|
||||
// unless validation on simpleform failed, in which case fall through.
|
||||
if (empty($noreviewform) && $id = optional_param('id', 0, PARAM_INT)) {
|
||||
// we're editing an existing one, so set up the tabs
|
||||
$currenttab = 'mnetdetails';
|
||||
$mnet_peer->set_id($id);
|
||||
require_once($CFG->dirroot . '/admin/mnet/tabs.php');
|
||||
} else if (empty($noreviewform) && ($wwwroot = optional_param('wwwroot', '', PARAM_URL)) && ($applicationid = optional_param('applicationid', 0, PARAM_INT))) {
|
||||
$application = $DB->get_field('mnet_application', 'name', array('id'=>$applicationid));
|
||||
$mnet_peer->bootstrap($wwwroot, null, $application);
|
||||
}
|
||||
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer));
|
||||
if ($formdata = $reviewform->get_data()) {
|
||||
|
||||
$mnet_peer->set_applicationid($formdata->applicationid);
|
||||
$application = $DB->get_field('mnet_application', 'name', array('id'=>$formdata->applicationid));
|
||||
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
|
||||
|
||||
if (!empty($formdata->name) && $formdata->name != $mnet_peer->name) {
|
||||
$mnet_peer->set_name($formdata->name);
|
||||
}
|
||||
|
||||
if (empty($formdata->theme)) {
|
||||
$mnet_peer->force_theme = 0;
|
||||
$mnet_peer->theme = null;
|
||||
} elseif (is_int($hostid)) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
|
||||
if($currentkey == $mnet_peer->public_key) unset($currentkey);
|
||||
$form = new stdClass();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
include('./mnet_review.html');
|
||||
} else {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = $formdata->theme;
|
||||
include('./mnet_review_allhosts.html');
|
||||
}
|
||||
|
||||
$mnet_peer->deleted = $formdata->deleted;
|
||||
$mnet_peer->public_key = $formdata->public_key;
|
||||
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
|
||||
$mnet_peer->public_key_expires = $credentials['validTo_time_t'];
|
||||
|
||||
if ($mnet_peer->commit()) {
|
||||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $mnet_peer->id)), get_string('changessaved'));
|
||||
} else {
|
||||
print_error('invalidaction', 'error', 'index.php');
|
||||
}
|
||||
} else if ($reviewform->is_submitted()) { // submitted, but errors
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box_start();
|
||||
$reviewform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// normal flow - just display all hosts with links
|
||||
echo $OUTPUT->header();
|
||||
$hosts = mnet_get_hosts();
|
||||
|
||||
// print the table to display the register all hosts setting
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('registerallhosts', 'mnet'));
|
||||
|
||||
$registerrow = '';
|
||||
$registerstr = '';
|
||||
$registerurl = new moodle_url('/admin/mnet/peers.php', array('updateregisterall' => 1));
|
||||
if (!empty($CFG->mnet_register_allhosts)) {
|
||||
$registerrow = get_string('registerhostson', 'mnet');
|
||||
$registerurl->param('registerallhosts', 0);
|
||||
$registerstr = get_string('turnitoff', 'mnet');
|
||||
} else {
|
||||
$registerrow = get_string('registerhostsoff', 'mnet');
|
||||
$registerurl->param('registerallhosts', 1);
|
||||
$registerstr = get_string('turniton', 'mnet');
|
||||
$hosts = get_records_sql(' SELECT
|
||||
h.id,
|
||||
h.wwwroot,
|
||||
h.ip_address,
|
||||
h.name,
|
||||
h.public_key,
|
||||
h.public_key_expires,
|
||||
h.transport,
|
||||
h.portno,
|
||||
h.last_connect_time,
|
||||
h.last_log_id,
|
||||
h.applicationid,
|
||||
a.name as app_name,
|
||||
a.display_name as app_display_name,
|
||||
a.xmlrpc_server_url
|
||||
FROM
|
||||
'.$CFG->prefix.'mnet_host h,
|
||||
'.$CFG->prefix.'mnet_application a
|
||||
WHERE
|
||||
h.id != \''.$CFG->mnet_localhost_id.'\' AND
|
||||
h.deleted = \'0\' AND
|
||||
h.applicationid=a.id');
|
||||
|
||||
if (empty($hosts)) $hosts = array();
|
||||
$applications = get_records('mnet_application');
|
||||
include('./peers.html');
|
||||
}
|
||||
$registerrow .= $OUTPUT->single_button($registerurl, $registerstr);
|
||||
|
||||
// simple table with two rows of a single cell
|
||||
$table->data = array(
|
||||
array(
|
||||
get_string('registerallhostsexplain', 'mnet'),
|
||||
),
|
||||
array(
|
||||
$registerrow
|
||||
),
|
||||
);
|
||||
echo html_writer::table($table);
|
||||
|
||||
// print the list of all hosts, with little action links and buttons
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('site'),
|
||||
get_string('system', 'mnet'),
|
||||
get_string('last_connect_time', 'mnet'),
|
||||
'',
|
||||
);
|
||||
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
|
||||
$baseurl = new moodle_url('/admin/mnet/peers.php');
|
||||
foreach($hosts as $host) {
|
||||
$hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
|
||||
// process all hosts first since it's the easiest
|
||||
if ($host->id == $CFG->mnet_all_hosts_id) {
|
||||
$table->data[] = array(html_writer::tag('a', $host->name, array('href'=>$hosturl)), '', '', '');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($host->last_connect_time == 0) {
|
||||
$last_connect = get_string('never');
|
||||
} else {
|
||||
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time);
|
||||
}
|
||||
$table->data[] = array(
|
||||
html_writer::link($hosturl, $host->name),
|
||||
html_writer::link($hosturl, $host->wwwroot),
|
||||
$last_connect,
|
||||
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
|
||||
);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
// finally, print the initial form to add a new host
|
||||
echo $OUTPUT->box_start();
|
||||
echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
|
||||
$simpleform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// done
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to configure a list of profile fields that are sent/recieved
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 onwards Penny Leach <penny@liip.ch>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/mnet/profilefields_form.php');
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
require_login();
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
$form = new mnet_profile_form(null, array('hostid' => $hostid));
|
||||
|
||||
if ($data = $form->get_data()) {
|
||||
if (!isset($data->importdefault)) {
|
||||
$data->importdefault = 0;
|
||||
}
|
||||
if (!isset($data->exportdefault)) {
|
||||
$data->exportdefault = 0;
|
||||
}
|
||||
if (!isset($data->importfields)) {
|
||||
$data->importfields = array();
|
||||
}
|
||||
if (!isset($data->exportfields)) {
|
||||
$data->exportfields = array();
|
||||
}
|
||||
set_config('host' . $hostid . 'importdefault', $data->importdefault, 'mnet');
|
||||
set_config('host' . $hostid . 'importfields', implode(',', $data->importfields), 'mnet');
|
||||
set_config('host' . $hostid . 'exportdefault', $data->exportdefault, 'mnet');
|
||||
set_config('host' . $hostid . 'exportfields', implode(',', $data->exportfields), 'mnet');
|
||||
|
||||
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
|
||||
} elseif ($form->is_cancelled()) {
|
||||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $hostid)));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'mnetprofilefields';
|
||||
require_once('tabs.php');
|
||||
|
||||
echo $OUTPUT->heading(get_string('peerprofilefielddesc', 'mnet'), 4);
|
||||
|
||||
$data = new Stdclass;
|
||||
$data->importdefault = get_config('mnet', 'host' . $hostid . 'importdefault');
|
||||
$data->exportdefault = get_config('mnet', 'host' . $hostid . 'exportdefault');
|
||||
$data->importfields = get_config('mnet', 'host' . $hostid . 'importfields');
|
||||
$data->exportfields = get_config('mnet', 'host' . $hostid . 'exportfields');
|
||||
|
||||
if ($data->importfields === false) {
|
||||
$data->importdefault = true;
|
||||
} else {
|
||||
$data->importfields = explode(',', $data->importfields);
|
||||
}
|
||||
if ($data->exportfields === false) {
|
||||
$data->exportdefault = true;
|
||||
} else {
|
||||
$data->exportfields = explode(',', $data->exportfields);
|
||||
}
|
||||
|
||||
$form->set_data($data);
|
||||
$form->display();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to configure a list of profile fields that are sent/recieved
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 onwards Penny Leach <penny@liip.ch>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
/**
|
||||
* small form to allow the administrator to configure (override) which profile fields are sent/imported over mnet
|
||||
*/
|
||||
class mnet_profile_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$fields = mnet_profile_field_options();
|
||||
|
||||
// Fields to import ----------------------------------------------------
|
||||
$mform->addElement('header', 'import', get_string('importfields', 'mnet'));
|
||||
|
||||
$select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileimportfields));
|
||||
|
||||
// Fields to export ----------------------------------------------------
|
||||
$mform->addElement('header', 'export', get_string('exportfields', 'mnet'));
|
||||
|
||||
$select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileexportfields));
|
||||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* This page is for configuring which services are published/subscribed on a host
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/admin/mnet/services_form.php');
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
$mform = new mnet_services_form(null, array('peer' => $mnet_peer));
|
||||
if ($formdata = $mform->get_data()) {
|
||||
if (!isset($formdata->publish)) {
|
||||
$formdata->publish = array();
|
||||
}
|
||||
if (!isset($formdata->subscribe)) {
|
||||
$formdata->subscribe = array();
|
||||
}
|
||||
foreach($formdata->exists as $key => $value) {
|
||||
$host2service = $DB->get_record('mnet_host2service', array('hostid'=>$hostid, 'serviceid'=>$key));
|
||||
$publish = (array_key_exists($key, $formdata->publish)) ? $formdata->publish[$key] : 0;
|
||||
$subscribe = (array_key_exists($key, $formdata->subscribe)) ? $formdata->subscribe[$key] : 0;
|
||||
|
||||
if ($publish != 1 && $subscribe != 1) {
|
||||
if (false == $host2service) {
|
||||
// We don't have or need a record - do nothing!
|
||||
} else {
|
||||
// We don't need the record - delete it
|
||||
$DB->delete_records('mnet_host2service', array('hostid' => $hostid, 'serviceid'=>$key));
|
||||
}
|
||||
} elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) {
|
||||
$host2service = new stdClass();
|
||||
$host2service->hostid = $hostid;
|
||||
$host2service->serviceid = $key;
|
||||
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
|
||||
$host2service->id = $DB->insert_record('mnet_host2service', $host2service);
|
||||
} elseif ($host2service->publish != $publish || $host2service->subscribe != $subscribe) {
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
$DB->update_record('mnet_host2service', $host2service);
|
||||
}
|
||||
}
|
||||
$redirecturl = new moodle_url('/admin/mnet/services.php?hostid=' . $hostid);
|
||||
redirect($redirecturl, get_string('changessaved'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$currenttab = 'mnetservices';
|
||||
require_once($CFG->dirroot . '/admin/mnet/tabs.php');
|
||||
echo $OUTPUT->box_start();
|
||||
$s = mnet_get_service_info($mnet_peer, false); // basic data only
|
||||
$mform->set_data($s);
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* The form for configuring which services are subscribed and published on a host
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
class mnet_services_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$mnet_peer =& $this->_customdata['peer'];
|
||||
$myservices =& mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
|
||||
$count = 0;
|
||||
foreach ($myservices as $name => $versions) {
|
||||
$version = current($versions);
|
||||
$langmodule =
|
||||
($version['plugintype'] == 'mod'
|
||||
? ''
|
||||
: ($version['plugintype'] . '_'))
|
||||
. $version['pluginname']; // TODO there should be a moodle-wide way to do this
|
||||
|
||||
if ($count > 0) {
|
||||
$mform->addElement('html', '<hr />');
|
||||
}
|
||||
$mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
|
||||
|
||||
$mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
|
||||
|
||||
$pubstr = get_string('publish','mnet');
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
$pubstr .= ' <a class="notifysuccess" title="'.s(get_string('issubscribed','mnet', $mnet_peer->name)).'">√</a> ';
|
||||
}
|
||||
$mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
|
||||
|
||||
$substr = get_string('subscribe','mnet');
|
||||
if (!empty($version['hostpublishes'])) {
|
||||
$substr .= ' <a class="notifysuccess" title="'.s(get_string('ispublished','mnet', $mnet_peer->name)).'">√</a> ';
|
||||
}
|
||||
$mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid']. ']', $substr);
|
||||
$count++;
|
||||
}
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Tabs to be included on the pages for configuring a single host
|
||||
* $mnet_peer object must be set and bootstrapped
|
||||
* $currenttab string must be set
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @copyright 2007 Donal McMullan
|
||||
* @copyright 2007 Martin Langhoff
|
||||
* @copyright 2010 Penny Leach
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
$tabs = array();
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'services.php?hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
if ($mnet_peer->application->name == 'moodle' && $mnet_peer->id != $CFG->mnet_all_hosts_id) {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
$tabs[] = new tabobject('mnetprofilefields', 'profilefields.php?hostid=' . $mnet_peer->id, get_string('profilefields', 'mnet'), get_string('profilefields', 'mnet'), false);
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
}
|
||||
print_tabs(array($tabs), $currenttab);
|
||||
@@ -1,212 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A service browser for remote Moodles
|
||||
*
|
||||
* This script 'remotely' executes the reflection methods on a remote Moodle,
|
||||
* and publishes the details of the available services
|
||||
*
|
||||
* @package core
|
||||
* @subpackage mnet
|
||||
* @author Donal McMullan donal@catalyst.net.nz
|
||||
* @version 0.0.1
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package mnet
|
||||
*/
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
if ($CFG->mnet_dispatcher_mode === 'off') {
|
||||
print_error('mnetdisabled', 'mnet');
|
||||
}
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnettestclient');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
error_reporting(DEBUG_ALL);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
// optional drilling down parameters
|
||||
$hostid = optional_param('hostid', 0, PARAM_INT);
|
||||
$servicename = optional_param('servicename', '', PARAM_SAFEDIR);
|
||||
$methodid = optional_param('method', 0, PARAM_INT);
|
||||
|
||||
$hosts = $DB->get_records('mnet_host');
|
||||
$moodleapplicationid = $DB->get_field('mnet_application', 'id', array('name' => 'moodle'));
|
||||
|
||||
$url = new moodle_url('/admin/mnet/testclient.php');
|
||||
$PAGE->set_url($url);
|
||||
|
||||
echo $OUTPUT->heading(get_string('hostlist', 'mnet'));
|
||||
foreach ($hosts as $id => $host) {
|
||||
if (empty($host->wwwroot) || $host->wwwroot == $CFG->wwwroot) {
|
||||
continue;
|
||||
}
|
||||
$newurl = new moodle_url($url, array('hostid' => $host->id));
|
||||
echo '<p>' . html_writer::link($newurl, $host->wwwroot) . '</p>';
|
||||
}
|
||||
|
||||
if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
|
||||
$host = $hosts[$hostid];
|
||||
if ($host->applicationid != $moodleapplicationid) {
|
||||
echo $OUTPUT->notification(get_string('notmoodleapplication', 'mnet'));
|
||||
}
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_wwwroot($host->wwwroot);
|
||||
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
$mnet_request->set_method('system/listServices');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$services = $mnet_request->response;
|
||||
$yesno = array('No', 'Yes');
|
||||
$servicenames = array();
|
||||
|
||||
echo $OUTPUT->heading(get_string('servicesavailableonhost', 'mnet', $host->wwwroot));
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('serviceid', 'mnet'),
|
||||
get_string('service', 'mnet'),
|
||||
get_string('version', 'mnet'),
|
||||
get_string('theypublish', 'mnet'),
|
||||
get_string('theysubscribe', 'mnet'),
|
||||
get_string('options', 'mnet'),
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
$yesno = array(get_string('no'), get_string('yes'));
|
||||
|
||||
// this query is horrible and has to be remapped afterwards, because of the non-uniqueness
|
||||
// of the remoterep service (it has two plugins so far that use it)
|
||||
// it's possible to get a unique list back using a subquery with LIMIT but that would break oracle
|
||||
// so it's best to just do this small query and then remap the results afterwards
|
||||
$sql = '
|
||||
SELECT DISTINCT
|
||||
' . $DB->sql_concat('r.plugintype', "'_'", 'r.pluginname', "'_'", 's.name') . ' AS uniqueid,
|
||||
s.name,
|
||||
r.plugintype,
|
||||
r.pluginname
|
||||
FROM
|
||||
{mnet_service} s
|
||||
JOIN {mnet_remote_service2rpc} s2r ON s2r.serviceid = s.id
|
||||
JOIN {mnet_remote_rpc} r ON r.id = s2r.rpcid';
|
||||
|
||||
$serviceinfo = array();
|
||||
|
||||
foreach ($DB->get_records_sql($sql) as $result) {
|
||||
$serviceinfo[$result->name] = $result->plugintype . '_' . $result->pluginname;
|
||||
}
|
||||
|
||||
foreach ($services as $id => $servicedata) {
|
||||
if (array_key_exists($servicedata['name'], $serviceinfo)) {
|
||||
$service = $serviceinfo[$servicedata['name']];
|
||||
$servicedata['humanname'] = get_string($servicedata['name'].'_name', $service);
|
||||
} else {
|
||||
$servicedata['humanname'] = get_string('unknown', 'mnet');
|
||||
}
|
||||
$newurl = new moodle_url($url, array('hostid' => $host->id, 'servicename' => $servicedata['name']));
|
||||
$table->data[] = array(
|
||||
$servicedata['name'],
|
||||
$servicedata['humanname'],
|
||||
$servicedata['apiversion'],
|
||||
$yesno[$servicedata['publish']],
|
||||
$yesno[$servicedata['subscribe']],
|
||||
html_writer::link($newurl, get_string('listservices', 'mnet'))
|
||||
);
|
||||
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
|
||||
$mnet_request->set_method('system/listMethods');
|
||||
if (isset($servicename) && array_key_exists($servicename, $serviceinfo)) {
|
||||
echo $OUTPUT->heading(get_string('methodsavailableonhostinservice', 'mnet', (object)array('host' => $host->wwwroot, 'service' => $servicename)));
|
||||
$service = $serviceinfo[$servicename];
|
||||
$mnet_request->add_param($servicename, 'string');
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('methodsavailableonhost', 'mnet', $host->wwwroot));
|
||||
}
|
||||
|
||||
$mnet_request->send($mnet_peer);
|
||||
$methods = $mnet_request->response;
|
||||
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('method', 'mnet'),
|
||||
get_string('options', 'mnet'),
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
foreach ($methods as $id => $method) {
|
||||
$params = array('hostid' => $host->id, 'method' => $id+1);
|
||||
if (isset($servicename)) {
|
||||
$params['servicename'] = $servicename;
|
||||
}
|
||||
$newurl = new moodle_url($url, $params);
|
||||
$table->data[] = array(
|
||||
$method,
|
||||
html_writer::link($newurl, get_string('inspect', 'mnet'))
|
||||
);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
if (isset($methodid) && array_key_exists($methodid-1, $methods)) {
|
||||
$method = $methods[$methodid-1];
|
||||
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
$mnet_request->set_method('system/methodSignature');
|
||||
$mnet_request->add_param($method, 'string');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$signature = $mnet_request->response;
|
||||
|
||||
echo $OUTPUT->heading(get_string('methodsignature', 'mnet', $method));
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('position', 'mnet'),
|
||||
get_string('name', 'mnet'),
|
||||
get_string('type', 'mnet'),
|
||||
get_string('description', 'mnet'),
|
||||
);
|
||||
$table->data = array();
|
||||
|
||||
$params = $signature['parameters'];
|
||||
foreach ($params as $pos => $details) {
|
||||
$table->data[] = array(
|
||||
$pos,
|
||||
$details['name'],
|
||||
$details['type'],
|
||||
$details['description'],
|
||||
);
|
||||
}
|
||||
$table->data[] = array(
|
||||
get_string('returnvalue', 'mnet'),
|
||||
'',
|
||||
$signature['return']['type'],
|
||||
$signature['return']['description']
|
||||
);
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
$mnet_request->set_method('system/methodHelp');
|
||||
$mnet_request->add_param($method, 'string');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$help = $mnet_request->response;
|
||||
|
||||
echo $OUTPUT->heading(get_string('methodhelp', 'mnet', $method));
|
||||
echo(str_replace('\n', '<br />',$help));
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
@@ -13,7 +13,7 @@ echo $OUTPUT->header();
|
||||
<td class="cell c1" colspan="2">
|
||||
<form method="post" action="trustedhosts.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<textarea name="hostlist" cols="40" rows="20"><?php echo $trusted_hosts; ?></textarea><br />
|
||||
<input type="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</div>
|
||||
@@ -25,7 +25,7 @@ echo $OUTPUT->header();
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('testtrustedhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
if (!empty($test_ip_address)){
|
||||
?>
|
||||
<tr>
|
||||
@@ -48,13 +48,13 @@ echo $OUTPUT->header();
|
||||
<td class="cell c1" colspan="2"><?php print_string('testtrustedhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<form method="get" action="trustedhosts.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="text" name="testipaddress" value="<?php echo $test_ip_address; ?>" />
|
||||
<input type="submit" value="<?php print_string('go'); ?>" />
|
||||
</div>
|
||||
@@ -64,5 +64,5 @@ echo $OUTPUT->header();
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
echo $OUTPUT->footer();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
|
||||
@@ -13,11 +13,14 @@
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
$trusted_hosts = '';//array();
|
||||
$old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts');
|
||||
@@ -31,9 +34,13 @@
|
||||
$in_range = false;
|
||||
if (!empty($test_ip_address)) {
|
||||
foreach($old_trusted_hosts as $host) {
|
||||
if (address_in_subnet($test_ip_address, $host)) {
|
||||
list($network, $mask) = explode('/', $host.'/');
|
||||
if (empty($network)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
|
||||
if (ip_in_range($test_ip_address, $network, $mask)) {
|
||||
$in_range = true;
|
||||
$validated_by = $host;
|
||||
$validated_by = $network.'/'.$mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -61,3 +68,4 @@
|
||||
}
|
||||
|
||||
include('./trustedhosts.html');
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?PHP // $Id$
|
||||
// module.php - allows admin to edit all local configuration variables for a module
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
$module = optional_param('module', '', PARAM_SAFEDIR);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
admin_externalpage_setup('modsetting'.$module);
|
||||
// if the config.html contains a hidden form field giving
|
||||
// the module name then the form does not have to prefix all
|
||||
// its variable names, we will do it here.
|
||||
$moduleprefix = $module.'_';
|
||||
// let the module process the form data if it has to,
|
||||
// $config is passed to this function by reference
|
||||
$moduleconfig = $module.'_process_options';
|
||||
if (function_exists($moduleconfig)) {
|
||||
$moduleconfig($config);
|
||||
}
|
||||
} else {
|
||||
admin_externalpage_setup('managemodules');
|
||||
|
||||
$moduleprefix = '';
|
||||
}
|
||||
|
||||
unset($config->sesskey);
|
||||
unset($config->module);
|
||||
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($moduleprefix.$name, $value);
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
$module = required_param('module', PARAM_SAFEDIR);
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
admin_externalpage_setup('modsetting'.$module);
|
||||
|
||||
$strmodulename = get_string("modulename", $module);
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'mod/' . $module . '/config';
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_heading($strmodulename);
|
||||
|
||||
print_simple_box(get_string("configwarning", 'admin'), "center", "60%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
include("$CFG->dirroot/mod/$module/config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
+146
-73
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to manage activity modules
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
|
||||
// defines
|
||||
define('MODULE_TABLE','module_administration_table');
|
||||
@@ -32,84 +33,166 @@
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
if (!$module = $DB->get_record("modules", array("name"=>$hide))) {
|
||||
print_error('moduledoesnotexist', 'error');
|
||||
if (!$module = get_record("modules", "name", $hide)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
$DB->set_field("modules", "visible", "0", array("id"=>$module->id)); // Hide main module
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
// Remember the visibility status in visibleold
|
||||
// and hide...
|
||||
$sql = "UPDATE {course_modules}
|
||||
SET visibleold=visible, visible=0
|
||||
WHERE module=?";
|
||||
$DB->execute($sql, array($module->id));
|
||||
$sql = "UPDATE {$CFG->prefix}course_modules
|
||||
SET visibleold=visible,
|
||||
visible=0
|
||||
WHERE module={$module->id}";
|
||||
execute_sql($sql, false);
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just deleted something
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visibleold=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE visibleold=1 AND module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
if (!$module = $DB->get_record("modules", array("name"=>$show))) {
|
||||
print_error('moduledoesnotexist', 'error');
|
||||
if (!$module = get_record("modules", "name", $show)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
$DB->set_field("modules", "visible", "1", array("id"=>$module->id)); // Show main module
|
||||
$DB->set_field('course_modules', 'visible', '1', array('visibleold'=>1, 'module'=>$module->id)); // Get the previous saved visible state for the course module.
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field('course_modules', 'visible', '1', 'visibleold',
|
||||
'1', 'module', $module->id); // Get the previous saved visible state for the course module.
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just made something visible
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo = ''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visible=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE visible=1 AND module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
admin_externalpage_print_header();
|
||||
print_heading($stractivities);
|
||||
|
||||
if (get_string_manager()->string_exists('modulename', $delete)) {
|
||||
$strmodulename = get_string('modulename', $delete);
|
||||
} else {
|
||||
$strmodulename = $delete;
|
||||
}
|
||||
$strmodulename = get_string("modulename", "$delete");
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
"modules.php");
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "forum") {
|
||||
print_error("cannotdeleteforummodule", '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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete calendar events
|
||||
if (!delete_records("event", "modulename", $delete)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in calendar event table");
|
||||
}
|
||||
|
||||
// clear course.modinfo for courses
|
||||
// that used this module...
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
|
||||
// Now delete all the course module records
|
||||
if (!delete_records("course_modules", "module", $module->id)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in course_modules table");
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
// And the module configuration records
|
||||
if (!execute_sql("DELETE FROM {$CFG->prefix}config WHERE name LIKE '{$module->name}_%'")) {
|
||||
notify("Error occurred while deleting the $strmodulename records from the config table");
|
||||
}
|
||||
|
||||
// cleanup the gradebook
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_uninstalled_module($module->name);
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($module->name, "$CFG->dirroot/mod/$module->name/db/install.xml", false);
|
||||
|
||||
// Delete the capabilities that were defined by this module
|
||||
capabilities_cleanup('mod/'.$module->name);
|
||||
|
||||
// remove entent handlers and dequeue pending events
|
||||
events_uninstall('mod/'.$module->name);
|
||||
|
||||
// Perform any custom uninstall tasks
|
||||
if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
|
||||
require_once($CFG->dirroot . '/mod/' . $module->name . '/lib.php');
|
||||
$uninstallfunction = $module->name . '_uninstall';
|
||||
if (function_exists($uninstallfunction)) {
|
||||
if (! $uninstallfunction() ) {
|
||||
notify('Encountered a problem running uninstall function for '. $module->name.'!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uninstall_plugin('mod', $delete);
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
notice(get_string("moduledeletefiles", "", $a), "modules.php");
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
admin_externalpage_print_header();
|
||||
print_heading($stractivities);
|
||||
|
||||
/// Get and sort the existing modules
|
||||
|
||||
if (!$modules = $DB->get_records('modules', array(), 'name ASC')) {
|
||||
print_error('moduledoesnotexist', 'error');
|
||||
if (!$modules = get_records("modules")) {
|
||||
error("No modules found!!"); // Should never happen
|
||||
}
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$strmodulename = get_string("modulename", "$module->name");
|
||||
// Deal with modules which are lacking the language string
|
||||
if ($strmodulename == '[[modulename]]') {
|
||||
$strmodulename = $module->name;
|
||||
}
|
||||
$modulebyname[$strmodulename] = $module;
|
||||
}
|
||||
ksort($modulebyname, SORT_LOCALE_STRING);
|
||||
|
||||
/// Print the table of all modules
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(MODULE_TABLE);
|
||||
@@ -117,50 +200,41 @@
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
|
||||
$table->set_attribute('id', 'modules');
|
||||
$table->set_attribute('class', 'generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
foreach ($modulebyname as $modulename => $module) {
|
||||
|
||||
if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) {
|
||||
$strmodulename = '<span class="notifyproblem">'.$module->name.' ('.get_string('missingfromdisk').')</span>';
|
||||
$missing = true;
|
||||
} else {
|
||||
// took out hspace="\10\", because it does not validate. don't know what to replace with.
|
||||
$icon = "<img src=\"" . $OUTPUT->pix_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />";
|
||||
$strmodulename = $icon.' '.get_string('modulename', $module->name);
|
||||
$missing = false;
|
||||
}
|
||||
// took out hspace="\10\", because it does not validate. don't know what to replace with.
|
||||
$icon = "<img src=\"$CFG->modpixpath/$module->name/icon.gif\" class=\"icon\" alt=\"\" />";
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=".sesskey()."\">$strdelete</a>";
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") ||
|
||||
file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) {
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php")) {
|
||||
$settings = "<a href=\"settings.php?section=modsetting$module->name\">$strsettings</a>";
|
||||
} else if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
|
||||
$settings = "<a href=\"module.php?module=$module->name\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
|
||||
$count = $DB->count_records_select($module->name, "course<>0");
|
||||
$count = count_records_select("$module->name",'course<>0');
|
||||
if ($count>0) {
|
||||
$countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
|
||||
"&sesskey=".sesskey()."\" title=\"$strshowmodulecourse\">$count</a>";
|
||||
"&sesskey={$USER->sesskey}\" title=\"$strshowmodulecourse\">$count</a>";
|
||||
}
|
||||
else {
|
||||
$countlink = "$count";
|
||||
}
|
||||
|
||||
if ($missing) {
|
||||
$visible = '';
|
||||
$class = '';
|
||||
} else if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=".sesskey()."\" title=\"$strhide\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('i/hide') . "\" class=\"icon\" alt=\"$strhide\" /></a>";
|
||||
$class = '';
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" class=\"icon\" alt=\"$strhide\" /></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=".sesskey()."\" title=\"$strshow\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('i/show') . "\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = ' class="dimmed_text"';
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = " class=\"dimmed_text\"";
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$delete = "";
|
||||
@@ -168,9 +242,8 @@
|
||||
$class = "";
|
||||
}
|
||||
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$strmodulename.'</span>',
|
||||
'<span'.$class.'>'.$icon.' '.$modulename.'</span>',
|
||||
$countlink,
|
||||
'<span'.$class.'>'.$module->version.'</span>',
|
||||
$visible,
|
||||
@@ -181,6 +254,6 @@
|
||||
|
||||
$table->print_html();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+31
-28
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
<?php /// $Id$
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -12,54 +10,57 @@ admin_externalpage_setup('multilangupgrade');
|
||||
$go = optional_param('go', 0, PARAM_BOOL);
|
||||
|
||||
###################################################################
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo $OUTPUT->heading(get_string('multilangupgrade', 'admin'));
|
||||
print_heading(get_string('multilangupgrade', 'admin'));
|
||||
|
||||
$strmultilangupgrade = get_String('multilangupgradeinfo', 'admin');
|
||||
|
||||
if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
|
||||
$optionsyes = array('go'=>1, 'sesskey'=>sesskey());
|
||||
echo $OUTPUT->confirm($strmultilangupgrade, new moodle_url('multilangupgrade.php', $optionsyes), 'index.php');
|
||||
echo $OUTPUT->footer();
|
||||
notice_yesno($strmultilangupgrade, 'multilangupgrade.php', 'index.php', $optionsyes, null, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
if (!$tables = $DB->get_tables() ) { // No tables yet at all.
|
||||
print_error('notables', 'debug');
|
||||
if (!$tables = $db->Metatables() ) { // No tables yet at all.
|
||||
error("no tables");
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
print_simple_box_start('center');
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
while(@ob_end_flush());
|
||||
|
||||
echo '<strong>Progress:</strong>';
|
||||
$i = 0;
|
||||
$skiptables = array('config', 'user_students', 'user_teachers');
|
||||
$skiptables = array($CFG->prefix.'config', $CFG->prefix.'user_students', $CFG->prefix.'user_teachers');//, $CFG->prefix.'sessions2');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table,'pma') === 0) { // Not our tables
|
||||
if (($CFG->prefix && strpos($table, $CFG->prefix) !== 0)
|
||||
or strpos($table, $CFG->prefix.'pma') === 0) { // Not our tables
|
||||
continue;
|
||||
}
|
||||
if (in_array($table, $skiptables)) { // Don't process these
|
||||
continue;
|
||||
}
|
||||
$fulltable = $DB->get_prefix().$table;
|
||||
if ($columns = $DB->get_columns($table)) {
|
||||
if (!array_key_exists('id', $columns)) {
|
||||
if ($columns = $db->MetaColumns($table, false)) {
|
||||
if (!array_key_exists('id', $columns) and !array_key_exists('ID', $columns)) {
|
||||
continue; // moodle tables have id
|
||||
}
|
||||
foreach ($columns as $column => $data) {
|
||||
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
|
||||
// first find candidate records
|
||||
$sql = "SELECT id, $column FROM $fulltable WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'";
|
||||
if ($rs = $DB->get_recordset_sql($sql)) {
|
||||
foreach ($rs as $data) {
|
||||
$text = $data->$column;
|
||||
$id = $data->id;
|
||||
$rs = get_recordset_sql("SELECT id, $column FROM $table WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'");
|
||||
if ($rs) {
|
||||
while (!$rs->EOF) {
|
||||
$text = $rs->fields[$column];
|
||||
$id = $rs->fields['id'];
|
||||
|
||||
if ($i % 600 == 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
@@ -67,6 +68,7 @@ foreach ($tables as $table) {
|
||||
echo '.';
|
||||
}
|
||||
$i++;
|
||||
$rs->MoveNext();
|
||||
|
||||
if (empty($text) or is_numeric($text)) {
|
||||
continue; // nothing to do
|
||||
@@ -80,10 +82,11 @@ foreach ($tables as $table) {
|
||||
}
|
||||
|
||||
if ($newtext != $text) {
|
||||
$DB->execute("UPDATE $fulltable SET $column=? WHERE id=?", array($newtext, $id));
|
||||
$newtext = addslashes($newtext);
|
||||
execute_sql("UPDATE $table SET $column='$newtext' WHERE id=$id", false);
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
rs_close($rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,16 +96,16 @@ foreach ($tables as $table) {
|
||||
// set conversion flag - switches to new plugin automatically
|
||||
set_config('filter_multilang_converted', 1);
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
print_simple_box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
notify('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
notify('...finished', 'notifysuccess');
|
||||
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
print_continue('index.php');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
|
||||
|
||||
@@ -115,4 +118,4 @@ function multilangupgrade_impl($langblock) {
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+26
-27
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
if (!isset($CFG)) {
|
||||
|
||||
@@ -7,19 +7,19 @@ if (!isset($CFG)) {
|
||||
|
||||
admin_externalpage_setup('oacleanup');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
online_assignment_cleanup(true);
|
||||
echo $OUTPUT->footer();
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function online_assignment_cleanup($output=false) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG;
|
||||
|
||||
if ($output) {
|
||||
echo $OUTPUT->heading('Online Assignment Cleanup');
|
||||
print_heading('Online Assignment Cleanup');
|
||||
echo '<center>';
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ function online_assignment_cleanup($output=false) {
|
||||
/// We don't want to run this code if we are doing an upgrade from an assignment
|
||||
/// version earlier than 2005041400
|
||||
/// because the assignment type field will not exist
|
||||
$amv = $DB->get_field('modules', 'version', array('name'=>'assignment'));
|
||||
$amv = get_field('modules', 'version', 'name', 'assignment');
|
||||
if ((int)$amv < 2005041400) {
|
||||
if ($output) {
|
||||
echo '</center>';
|
||||
@@ -37,26 +37,22 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
|
||||
/// get the module id for assignments from db
|
||||
$arecord = $DB->get_record('modules', array('name', 'assignment'));
|
||||
$arecord = get_record('modules', 'name', 'assignment');
|
||||
$aid = $arecord->id;
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
$courses = $DB->get_records('course');
|
||||
$courses = get_records('course');
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$fullname = empty($course->fullname) ? 'Course: '.$course->id : $course->fullname;
|
||||
if ($output) echo $OUTPUT->heading($fullname);
|
||||
if ($output) print_heading($fullname);
|
||||
|
||||
/// retrieve a list of sections beyond what is currently being shown
|
||||
$sql = "SELECT *
|
||||
FROM {course_sections}
|
||||
WHERE course=? AND section>?
|
||||
ORDER BY section ASC";
|
||||
$params = array($course->id, $course->numsections);
|
||||
if (!($xsections = $DB->get_records_sql($sql, $params))) {
|
||||
$sql = 'SELECT * FROM '.$CFG->prefix.'course_sections WHERE course='.$course->id.' AND section>'.$course->numsections.' ORDER BY section ASC';
|
||||
if (!($xsections = get_records_sql($sql))) {
|
||||
if ($output) echo 'No extra sections<br />';
|
||||
continue;
|
||||
}
|
||||
@@ -74,13 +70,16 @@ function online_assignment_cleanup($output=false) {
|
||||
foreach ($instances as $instance) {
|
||||
/// is this an instance of an online assignment
|
||||
$sql = "SELECT a.id
|
||||
FROM {course_modules} cm, {assignment} a
|
||||
WHERE cm.id = ? AND cm.module = ? AND
|
||||
cm.instance = a.id AND a.assignmenttype = 'online'";
|
||||
$params = array($instance, $aid);
|
||||
FROM {$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}assignment a
|
||||
WHERE cm.id = '$instance' AND
|
||||
cm.module = '$aid' AND
|
||||
cm.instance = a.id AND
|
||||
a.assignmenttype = 'online'";
|
||||
|
||||
|
||||
/// if record exists then we need to move instance to it's correct section
|
||||
if ($DB->record_exists_sql($sql, $params)) {
|
||||
if (record_exists_sql($sql)) {
|
||||
|
||||
/// check the new section id
|
||||
/// the journal update erroneously stored it in course_sections->section
|
||||
@@ -88,14 +87,14 @@ function online_assignment_cleanup($output=false) {
|
||||
/// double check the new section
|
||||
if ($newsection > $course->numsections) {
|
||||
/// get the record for section 0 for this course
|
||||
if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
|
||||
if (!($zerosection = get_record('course_sections', 'course', $course->id, 'section', '0'))) {
|
||||
continue;
|
||||
}
|
||||
$newsection = $zerosection->id;
|
||||
}
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
|
||||
if (!($section = get_record('course_sections', 'id', $newsection))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'<br />';
|
||||
continue;
|
||||
}
|
||||
@@ -111,12 +110,12 @@ function online_assignment_cleanup($output=false) {
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
/// now we need to remove the instance from the old sequence
|
||||
|
||||
/// grab the old section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
|
||||
if (!($section = get_record('course_sections', 'id', $xsection->id))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$course->fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
@@ -133,7 +132,7 @@ function online_assignment_cleanup($output=false) {
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
|
||||
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
|
||||
@@ -144,7 +143,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
/// if the summary and sequence are empty then remove this section
|
||||
if (empty($xsection->summary) and empty($xsection->sequence)) {
|
||||
$DB->delete_records('course_sections', array('id'=>$xsection->id));
|
||||
delete_records('course_sections', 'id', $xsection->id);
|
||||
if ($output) echo 'Deleting empty section '.$xsection->section.'<br />';
|
||||
}
|
||||
}
|
||||
@@ -153,4 +152,4 @@ function online_assignment_cleanup($output=false) {
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once($CFG->libdir.'/pagelib.php');
|
||||
|
||||
define('PAGE_ADMIN', 'admin');
|
||||
|
||||
// Bounds for block widths
|
||||
// more flexible for theme designers taken from theme config.php
|
||||
$lmin = (empty($THEME->block_l_min_width)) ? 0 : $THEME->block_l_min_width;
|
||||
$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
|
||||
$rmin = (empty($THEME->block_r_min_width)) ? 0 : $THEME->block_r_min_width;
|
||||
$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;
|
||||
|
||||
define('BLOCK_L_MIN_WIDTH', $lmin);
|
||||
define('BLOCK_L_MAX_WIDTH', $lmax);
|
||||
define('BLOCK_R_MIN_WIDTH', $rmin);
|
||||
define('BLOCK_R_MAX_WIDTH', $rmax);
|
||||
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
|
||||
class page_admin extends page_base {
|
||||
|
||||
var $section;
|
||||
var $visiblepathtosection;
|
||||
|
||||
// hack alert!
|
||||
// this function works around the inability to store the section name
|
||||
// in default block, maybe we should "improve" the blocks a bit?
|
||||
function init_extra($section) {
|
||||
global $CFG;
|
||||
|
||||
if($this->full_init_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
// fetch the path parameter
|
||||
$this->section = $section;
|
||||
$current =& $adminroot->locate($section, true);
|
||||
$this->visiblepathtosection = array_reverse($current->visiblepath);
|
||||
|
||||
// all done
|
||||
$this->full_init_done = true;
|
||||
}
|
||||
|
||||
function blocks_get_default() {
|
||||
return 'admin_tree,admin_bookmarks';
|
||||
}
|
||||
|
||||
// seems reasonable that the only people that can edit blocks on the admin pages
|
||||
// are the admins... but maybe we want a role for this?
|
||||
function user_allowed_editing() {
|
||||
return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
}
|
||||
|
||||
// has to be fixed. i know there's a "proper" way to do this
|
||||
function user_is_editing() {
|
||||
global $USER;
|
||||
return $USER->adminediting;
|
||||
}
|
||||
|
||||
function url_get_path() {
|
||||
global $CFG;
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
$root =& $adminroot->locate($this->section);
|
||||
if (is_a($root, 'admin_externalpage')) {
|
||||
return $root->url;
|
||||
} else {
|
||||
return ($CFG->wwwroot . '/' . $CFG->admin . '/settings.php');
|
||||
}
|
||||
}
|
||||
|
||||
function url_get_parameters() { // only handles parameters relevant to the admin pagetype
|
||||
return array('section' => (isset($this->section) ? $this->section : ''));
|
||||
}
|
||||
|
||||
function blocks_get_positions() {
|
||||
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
|
||||
}
|
||||
|
||||
function blocks_default_position() {
|
||||
return BLOCK_POS_LEFT;
|
||||
}
|
||||
|
||||
function blocks_move_position(&$instance, $move) {
|
||||
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
|
||||
return BLOCK_POS_RIGHT;
|
||||
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
|
||||
return BLOCK_POS_LEFT;
|
||||
}
|
||||
return $instance->position;
|
||||
}
|
||||
|
||||
// does anything need to be done here?
|
||||
function init_quick($data) {
|
||||
parent::init_quick($data);
|
||||
}
|
||||
|
||||
function print_header($section = '', $focus='') {
|
||||
global $USER, $CFG, $SITE;
|
||||
|
||||
$this->init_full($section); // we're trusting that init_full() has already been called by now; it should have.
|
||||
// if not, print_header() has to be called with a $section parameter
|
||||
|
||||
// The search page currently doesn't handle block editing
|
||||
if ($this->section != 'search' and $this->user_allowed_editing()) {
|
||||
$buttons = '<div><form '.$CFG->frametarget.' method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<input type="hidden" name="section" value="'.$this->section.'" />'.
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></div></form></div>';
|
||||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
|
||||
$navlinks = array();
|
||||
foreach ($this->visiblepathtosection as $element) {
|
||||
$navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
|
||||
}
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
|
||||
}
|
||||
|
||||
function get_type() {
|
||||
return PAGE_ADMIN;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
// phpinfo.php - shows phpinfo for the current server
|
||||
|
||||
require_once("../config.php");
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
admin_externalpage_setup('phpinfo');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo '<div class="phpinfo">';
|
||||
|
||||
@@ -28,6 +28,6 @@
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
require_once($CFG->libdir . '/portfolio/forms.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$portfolio = optional_param('pf', '', PARAM_FORMAT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$sure = optional_param('sure', '', PARAM_ALPHA);
|
||||
|
||||
$display = true; // fall through to normal display
|
||||
|
||||
$pagename = 'manageportfolios';
|
||||
|
||||
if ($action == 'edit') {
|
||||
$pagename = 'portfoliosettings' . $portfolio;
|
||||
} else if ($action == 'delete') {
|
||||
$pagename = 'portfoliodelete';
|
||||
} else if (($action == 'newon') || ($action == 'newoff')) {
|
||||
$pagename = 'portfolionew';
|
||||
}
|
||||
|
||||
// Need to remember this for form
|
||||
$formaction = $action;
|
||||
|
||||
// Check what visibility to show the new repository
|
||||
if ($action == 'newon') {
|
||||
$action = 'new';
|
||||
$visible = 1;
|
||||
} else if ($action == 'newoff') {
|
||||
$action = 'new';
|
||||
$visible = 0;
|
||||
}
|
||||
|
||||
admin_externalpage_setup($pagename);
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$baseurl = "$CFG->wwwroot/$CFG->admin/portfolio.php";
|
||||
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/portfolio.php?sesskey=" . sesskey();
|
||||
$configstr = get_string('manageportfolios', 'portfolio');
|
||||
|
||||
$return = true; // direct back to the main page
|
||||
|
||||
/**
|
||||
* Helper function that generates a moodle_url object
|
||||
* relevant to the portfolio
|
||||
*/
|
||||
function portfolio_action_url($portfolio) {
|
||||
global $baseurl;
|
||||
return new moodle_url($baseurl, array('sesskey'=>sesskey(), 'pf'=>$portfolio));
|
||||
}
|
||||
|
||||
if (($action == 'edit') || ($action == 'new')) {
|
||||
if (($action == 'edit')) {
|
||||
$instance = portfolio_instance($portfolio);
|
||||
$plugin = $instance->get('plugin');
|
||||
|
||||
// Since visible is being passed to form
|
||||
// and used to set the value when a new
|
||||
// instance is created - we must also
|
||||
// place the currently visibility into the
|
||||
// form as well
|
||||
$visible = $instance->get('visible');
|
||||
} else {
|
||||
$instance = null;
|
||||
$plugin = $portfolio;
|
||||
}
|
||||
|
||||
$PAGE->set_pagetype('admin-portfolio-' . $plugin);
|
||||
|
||||
// Display the edit form for this instance
|
||||
$mform = new portfolio_admin_form('', array('plugin' => $plugin, 'instance' => $instance, 'portfolio' => $portfolio, 'action' => $formaction, 'visible' => $visible));
|
||||
// End setup, begin output
|
||||
if ($mform->is_cancelled()){
|
||||
redirect($baseurl);
|
||||
exit;
|
||||
} else if (($fromform = $mform->get_data()) && (confirm_sesskey())) {
|
||||
// Unset whatever doesn't belong in fromform
|
||||
foreach (array('pf', 'action', 'plugin', 'sesskey', 'submitbutton') as $key) {
|
||||
unset($fromform->{$key});
|
||||
}
|
||||
// This branch is where you process validated data.
|
||||
if ($action == 'edit') {
|
||||
$instance->set_config((array)$fromform);
|
||||
$instance->save();
|
||||
} else {
|
||||
portfolio_static_function($plugin, 'create_instance', $plugin, $fromform->name, $fromform);
|
||||
}
|
||||
$savedstr = get_string('instancesaved', 'portfolio');
|
||||
redirect($baseurl, $savedstr, 1);
|
||||
exit;
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('configplugin', 'portfolio'));
|
||||
echo $OUTPUT->box_start();
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
$return = false;
|
||||
}
|
||||
} else if (($action == 'hide') || ($action == 'show')) {
|
||||
require_sesskey();
|
||||
|
||||
$instance = portfolio_instance($portfolio);
|
||||
$current = $instance->get('visible');
|
||||
if (empty($current) && $instance->instance_sanity_check()) {
|
||||
print_error('cannotsetvisible', 'portfolio', $baseurl);
|
||||
}
|
||||
|
||||
if ($action == 'show') {
|
||||
$visible = 1;
|
||||
} else {
|
||||
$visible = 0;
|
||||
}
|
||||
|
||||
$instance->set('visible', $visible);
|
||||
$instance->save();
|
||||
$return = true;
|
||||
} else if ($action == 'delete') {
|
||||
$instance = portfolio_instance($portfolio);
|
||||
if ($sure) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
if ($instance->delete()) {
|
||||
$deletedstr = get_string('instancedeleted', 'portfolio');
|
||||
redirect($baseurl, $deletedstr, 1);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'portfolio', $baseurl);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('sure', 'portfolio', $instance->get('name')), $sesskeyurl . '&pf='.$portfolio.'&action=delete&sure=yes', $baseurl);
|
||||
$return = false;
|
||||
}
|
||||
} else {
|
||||
// If page is loaded directly
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('manageportfolios', 'portfolio'));
|
||||
|
||||
// Get strings that are used
|
||||
$strshow = get_string('on', 'portfolio');
|
||||
$strhide = get_string('off', 'portfolio');
|
||||
$strdelete = get_string('disabledinstance', 'portfolio');
|
||||
$strsettings = get_string('settings');
|
||||
|
||||
$actionchoicesforexisting = array(
|
||||
'show' => $strshow,
|
||||
'hide' => $strhide,
|
||||
'delete' => $strdelete
|
||||
);
|
||||
|
||||
$actionchoicesfornew = array(
|
||||
'newon' => $strshow,
|
||||
'newoff' => $strhide,
|
||||
'delete' => $strdelete
|
||||
);
|
||||
|
||||
$output = $OUTPUT->box_start('generalbox');
|
||||
|
||||
$plugins = get_plugin_list('portfolio');
|
||||
$plugins = array_keys($plugins);
|
||||
$instances = portfolio_instances(false, false);
|
||||
$usedplugins = array();
|
||||
|
||||
// to avoid notifications being sent out while admin is editing the page
|
||||
define('ADMIN_EDITING_PORTFOLIO', true);
|
||||
|
||||
$insane = portfolio_plugin_sanity_check($plugins);
|
||||
$insaneinstances = portfolio_instance_sanity_check($instances);
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('plugin', 'portfolio'), '', '');
|
||||
$table->data = array();
|
||||
|
||||
foreach ($instances as $i) {
|
||||
$settings = '<a href="' . $sesskeyurl . '&action=edit&pf=' . $i->get('id') . '">' . $strsettings .'</a>';
|
||||
// Set some commonly used variables
|
||||
$pluginid = $i->get('id');
|
||||
$plugin = $i->get('plugin');
|
||||
$pluginname = $i->get('name');
|
||||
|
||||
// Check if the instance is misconfigured
|
||||
if (array_key_exists($plugin, $insane) || array_key_exists($pluginid, $insaneinstances)) {
|
||||
if (!empty($insane[$plugin])) {
|
||||
$information = $insane[$plugin];
|
||||
} else if (!empty($insaneinstances[$pluginid])) {
|
||||
$information = $insaneinstances[$pluginid];
|
||||
}
|
||||
$table->data[] = array($pluginname, $strdelete . " " . $OUTPUT->help_icon($information, 'portfolio_' . $plugin), $settings);
|
||||
} else {
|
||||
if ($i->get('visible')) {
|
||||
$currentaction = 'show';
|
||||
} else {
|
||||
$currentaction = 'hide';
|
||||
}
|
||||
$select = new single_select(portfolio_action_url($pluginid, 'pf'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . $pluginid);
|
||||
$table->data[] = array($pluginname, $OUTPUT->render($select), $settings);
|
||||
}
|
||||
if (!in_array($plugin, $usedplugins)) {
|
||||
$usedplugins[] = $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
// Create insane plugin array
|
||||
$insaneplugins = array();
|
||||
if (!empty($plugins)) {
|
||||
foreach ($plugins as $p) {
|
||||
// Check if it can not have multiple instances and has already been used
|
||||
if (!portfolio_static_function($p, 'allows_multiple_instances') && in_array($p, $usedplugins)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if it is misconfigured - if so store in array then display later
|
||||
if (array_key_exists($p, $insane)) {
|
||||
$insaneplugins[] = $p;
|
||||
} else {
|
||||
$select = new single_select(portfolio_action_url($p, 'pf'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . $p);
|
||||
$table->data[] = array(portfolio_static_function($p, 'get_name'), $OUTPUT->render($select), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all the insane plugins
|
||||
if (!empty($insaneplugins)) {
|
||||
foreach ($insaneplugins as $p) {
|
||||
$table->data[] = array(portfolio_static_function($p, 'get_name'), $strdelete . " " . $OUTPUT->help_icon($insane[$p], 'portfolio_' . $p), '');
|
||||
}
|
||||
}
|
||||
|
||||
$output .= html_writer::table($table);
|
||||
|
||||
$output .= $OUTPUT->box_end();
|
||||
|
||||
echo $output;
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
// Redirect to base
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+12
-13
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/php -f
|
||||
<?php
|
||||
|
||||
<?php // $Id$
|
||||
define('FULLME','cron'); // prevent warnings
|
||||
//error_reporting(0);
|
||||
//ini_set('display_errors',0);
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
@@ -9,17 +9,16 @@ $address = $tmp[0];
|
||||
|
||||
// BOUNCE EMAILS TO NOREPLY
|
||||
if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
|
||||
$user = new stdClass();
|
||||
$user->email = $_ENV['SENDER'];
|
||||
|
||||
if (!validate_email($user->email)) {
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
$site = get_site();
|
||||
$subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
|
||||
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if ($fd) {
|
||||
while(!feof($fd)) {
|
||||
@@ -27,14 +26,14 @@ if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
|
||||
$user->id = 0; // to prevent anything annoying happening
|
||||
|
||||
|
||||
$from->firstname = null;
|
||||
$from->lastname = null;
|
||||
$from->email = '<>';
|
||||
$from->maildisplay = true;
|
||||
|
||||
|
||||
email_to_user($user,$from,$subject,$body);
|
||||
die ();
|
||||
}
|
||||
@@ -54,13 +53,13 @@ if ($modid == '0') { // special
|
||||
$modname = 'moodle';
|
||||
}
|
||||
else {
|
||||
$modname = $DB->get_field("modules", "name", array("id"=>$modid));
|
||||
$modname = get_field("modules","name","id",$modid);
|
||||
include_once('mod/'.$modname.'/lib.php');
|
||||
}
|
||||
$function = $modname.'_process_email';
|
||||
|
||||
if (!function_exists($function)) {
|
||||
die();
|
||||
die();
|
||||
}
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
@@ -71,10 +70,10 @@ while(!feof($fd)) {
|
||||
$body .= fgets($fd);
|
||||
}
|
||||
|
||||
$function($modargs,$body);
|
||||
|
||||
fclose($fd);
|
||||
$function($modargs,$body);
|
||||
|
||||
fclose($handle);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script triggers a full purging of system caches,
|
||||
* this is useful mostly for developers who did not disable the caching.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
admin_externalpage_setup('purgecaches');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if ($confirm) {
|
||||
require_sesskey();
|
||||
|
||||
// Valid request. Purge, and redisplay the form so it is easy to purge again
|
||||
// in the near future.
|
||||
purge_all_caches();
|
||||
redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
|
||||
|
||||
} else {
|
||||
// Show a confirm form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
|
||||
|
||||
$url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
|
||||
$button = new single_button($url, get_string('purgecaches','admin'), 'post');
|
||||
|
||||
// Cancel button takes them back to the page the were on, if possible,
|
||||
// otherwise to the site home page.
|
||||
$return = new moodle_url('/');
|
||||
if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
|
||||
if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
|
||||
$return = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to manage question types.
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
/// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/question:config', $systemcontext);
|
||||
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('manageqtypes');
|
||||
|
||||
/// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql("
|
||||
SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden
|
||||
FROM {question} GROUP BY qtype", array());
|
||||
$needed = array();
|
||||
foreach ($QTYPES as $qtypename => $qtype) {
|
||||
if (!isset($counts[$qtypename])) {
|
||||
$counts[$qtypename] = new stdClass;
|
||||
$counts[$qtypename]->numquestions = 0;
|
||||
$counts[$qtypename]->numhidden = 0;
|
||||
}
|
||||
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0;
|
||||
$counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
|
||||
}
|
||||
$needed['missingtype'] = true; // The system needs the missing question type.
|
||||
foreach ($QTYPES as $qtypename => $qtype) {
|
||||
foreach ($qtype->requires_qtypes() as $reqtype) {
|
||||
$needed[$reqtype] = true;
|
||||
}
|
||||
}
|
||||
foreach ($counts as $qtypename => $count) {
|
||||
if (!isset($QTYPES[$qtypename])) {
|
||||
$counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
|
||||
$counts['missingtype']->numhidden += $count->numhidden;
|
||||
}
|
||||
}
|
||||
|
||||
/// Work of the correct sort order.
|
||||
$config = get_config('question');
|
||||
$sortedqtypes = array();
|
||||
foreach ($QTYPES as $qtypename => $qtype) {
|
||||
$sortedqtypes[$qtypename] = $qtype->local_name();
|
||||
}
|
||||
$sortedqtypes = question_sort_qtype_array($sortedqtypes, $config);
|
||||
|
||||
/// Process actions ============================================================
|
||||
|
||||
// Disable.
|
||||
if (($disable = optional_param('disable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$disable])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $disable);
|
||||
}
|
||||
|
||||
set_config($disable . '_disabled', 1, 'question');
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
// Enable.
|
||||
if (($enable = optional_param('enable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$enable])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $enable);
|
||||
}
|
||||
|
||||
if (!$QTYPES[$enable]->menu_name()) {
|
||||
print_error('cannotenable', 'question', admin_url('qtypes.php'), $enable);
|
||||
}
|
||||
|
||||
unset_config($enable . '_disabled', 'question');
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
// Move up in order.
|
||||
if (($up = optional_param('up', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$up])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $up);
|
||||
}
|
||||
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
|
||||
question_save_qtype_order($neworder, $config);
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
// Move down in order.
|
||||
if (($down = optional_param('down', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$down])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $down);
|
||||
}
|
||||
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
|
||||
question_save_qtype_order($neworder, $config);
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missingtype') {
|
||||
print_error('cannotdeletemissingqtype', 'admin', admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
if (!isset($QTYPES[$delete])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $delete);
|
||||
}
|
||||
|
||||
$qtypename = $QTYPES[$delete]->local_name();
|
||||
if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
|
||||
print_error('cannotdeleteqtypeinuse', 'admin', admin_url('qtypes.php'), $qtypename);
|
||||
}
|
||||
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteqtypeneeded', 'admin', admin_url('qtypes.php'), $qtypename);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$qtypename = $QTYPES[$delete]->local_name();
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'admin', $qtypename));
|
||||
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'admin', $qtypename),
|
||||
admin_url('qtypes.php?delete=' . $delete . '&confirm=1'),
|
||||
admin_url('qtypes.php'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingqtype', 'admin', $qtypename));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
|
||||
}
|
||||
unset_config($delete . '_disabled', 'question');
|
||||
unset_config($delete . '_sortorder', 'question');
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, $QTYPES[$delete]->plugin_dir() . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qtype/' . $delete);
|
||||
|
||||
$a->qtype = $qtypename;
|
||||
$a->directory = $QTYPES[$delete]->plugin_dir();
|
||||
echo $OUTPUT->box(get_string('qtypedeletefiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button(admin_url('qtypes.php'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
/// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
|
||||
|
||||
/// Set up the table.
|
||||
$table = new flexible_table('qtypeadmintable');
|
||||
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
|
||||
'availableto', 'delete', 'settings'));
|
||||
$table->define_headers(array(get_string('questiontype', 'admin'), get_string('numquestions', 'admin'),
|
||||
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
|
||||
get_string('delete'), get_string('settings')));
|
||||
$table->set_attribute('id', 'qtypes');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
/// Add a row for each question type.
|
||||
$createabletypes = question_type_menu();
|
||||
foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$qtype = $QTYPES[$qtypename];
|
||||
$row = array();
|
||||
|
||||
// Question icon and name.
|
||||
$fakequestion = new stdClass;
|
||||
$fakequestion->qtype = $qtypename;
|
||||
$icon = print_question_icon($fakequestion, true);
|
||||
$row[] = $icon . ' ' . $localname;
|
||||
|
||||
// Number of questions of this type.
|
||||
if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
|
||||
if ($counts[$qtypename]->numhidden > 0) {
|
||||
$strcount = get_string('numquestionsandhidden', 'admin', $counts[$qtypename]);
|
||||
} else {
|
||||
$strcount = $counts[$qtypename]->numquestions;
|
||||
}
|
||||
if ($canviewreports) {
|
||||
$row[] = '<a href="' . admin_url('/report/questioninstances/index.php?qtype=' . $qtypename) .
|
||||
'" title="' . get_string('showdetails', 'admin') . '">' . $strcount . '</a>';
|
||||
} else {
|
||||
$strcount;
|
||||
}
|
||||
} else {
|
||||
$row[] = 0;
|
||||
}
|
||||
|
||||
// Question version number.
|
||||
$version = get_config('qtype_' . $qtypename, 'version');
|
||||
if ($version) {
|
||||
$row[] = $version;
|
||||
} else {
|
||||
$row[] = '<span class="disabled">' . get_string('nodatabase', 'admin') . '</span>';
|
||||
}
|
||||
|
||||
// Other question types required by this one.
|
||||
$requiredtypes = $qtype->requires_qtypes();
|
||||
$strtypes = array();
|
||||
if (!empty($requiredtypes)) {
|
||||
foreach ($requiredtypes as $required) {
|
||||
$strtypes[] = $QTYPES[$required]->local_name();
|
||||
}
|
||||
$row[] = implode(', ', $strtypes);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Are people allowed to create new questions of this type?
|
||||
$rowclass = '';
|
||||
if ($qtype->menu_name()) {
|
||||
$createable = isset($createabletypes[$qtypename]);
|
||||
$icons = enable_disable_button($qtypename, $createable);
|
||||
if (!$createable) {
|
||||
$rowclass = 'dimmed_text';
|
||||
}
|
||||
} else {
|
||||
$icons = '<img src="' . $OUTPUT->pix_url('spacer') . '" alt="" class="spacer" />';
|
||||
}
|
||||
|
||||
// Move icons.
|
||||
$icons .= icon_html('up', $qtypename, 't/up', get_string('up'), '');
|
||||
$icons .= icon_html('down', $qtypename, 't/down', get_string('down'), '');
|
||||
$row[] = $icons;
|
||||
|
||||
// Delete link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$row[] = '<a href="' . admin_url('qtypes.php?delete=' . $qtypename .
|
||||
'&sesskey=' . sesskey()) . '" title="' .
|
||||
get_string('uninstallqtype', 'admin') . '">' . get_string('delete') . '</a>';
|
||||
}
|
||||
|
||||
// Settings link, if available.
|
||||
if (file_exists($qtype->plugin_dir() . '/settings.php')) {
|
||||
$row[] = '<a href="' . admin_url('settings.php?section=qtypesetting' . $qtypename) .
|
||||
'">' . get_string('settings') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
}
|
||||
|
||||
$table->finish_output();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function admin_url($endbit) {
|
||||
global $CFG;
|
||||
return $CFG->wwwroot . '/' . $CFG->admin . '/' . $endbit;
|
||||
}
|
||||
|
||||
function enable_disable_button($qtypename, $createable) {
|
||||
if ($createable) {
|
||||
return icon_html('disable', $qtypename, 'i/hide', get_string('enabled', 'question'), get_string('disable'));
|
||||
} else {
|
||||
return icon_html('enable', $qtypename, 'i/show', get_string('disabled', 'question'), get_string('enable'));
|
||||
}
|
||||
}
|
||||
|
||||
function icon_html($action, $qtypename, $icon, $alt, $tip) {
|
||||
global $OUTPUT;
|
||||
if ($tip) {
|
||||
$tip = 'title="' . $tip . '" ';
|
||||
}
|
||||
$html = ' <form action="' . admin_url('qtypes.php') . '" method="post"><div>';
|
||||
$html .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
$html .= '<input type="image" name="' . $action . '" value="' . $qtypename .
|
||||
'" src="' . $OUTPUT->pix_url($icon) . '" alt="' . $alt . '" ' . $tip . '/>';
|
||||
$html .= '</div></form>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php // $Id$
|
||||
// register.php - allows admin to register their site on moodle.org
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
error("No admins");
|
||||
}
|
||||
|
||||
if (!$admin->country and $CFG->country) {
|
||||
$admin->country = $CFG->country;
|
||||
}
|
||||
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strregistration = get_string("registration");
|
||||
$strregistrationinfo = get_string("registrationinfo");
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strregistration, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$site->shortname: $strregistration", $site->fullname, $navigation);
|
||||
|
||||
print_heading($strregistration);
|
||||
|
||||
print_simple_box($strregistrationinfo, "center", "70%");
|
||||
|
||||
|
||||
/// Print the form
|
||||
|
||||
echo "<form id=\"mform1\" class=\"mform\" action=\"http://moodle.org/register/\" method=\"post\">\n";
|
||||
echo '<fieldset id="registration">';
|
||||
echo '<legend>Registration Information</legend>';
|
||||
|
||||
echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
|
||||
echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
|
||||
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\" />\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\" />\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>URL</label></div>';
|
||||
echo '<div class="felement ftext">'.$CFG->wwwroot.'</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("currentversion").'</label></div>';
|
||||
echo '<div class="felement ftext">'."$CFG->release ($CFG->version)".'</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="sitename">'.get_string("fullsitename").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo '<input size="50" id="sitename" type="text" name="sitename" value="'.format_string($site->fullname).'" />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menucountry">'.get_string("country").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
choose_from_menu (get_list_of_countries(), "country", $admin->country, get_string("selectacountry")."...", "", "");
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menupublic">'."<a href=\"http://moodle.org/sites/?country=$admin->country\" title=\"".get_string("publicdirectorytitle")."\">".get_string("publicdirectory")."</a>".'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
$options[0] = get_string("publicdirectory0");
|
||||
$options[1] = get_string("publicdirectory1");
|
||||
$options[2] = get_string("publicdirectory2");
|
||||
choose_from_menu ($options, "public", "2", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menucontact">'.get_string("registrationcontact").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
$options[0] = get_string("registrationcontactno");
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
choose_from_menu ($options, "contact", "1", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("statistics")."<br />(".get_string("notpublic").')'.'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
|
||||
$count = count_records('course')-1;
|
||||
echo get_string("courses").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courses\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('user', 'deleted', 0);
|
||||
echo get_string("users").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"users\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
// total number of role assignments
|
||||
$count = count_records('role_assignments');
|
||||
echo get_string('roleassignments', 'role').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"roleassignments\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
// first find all distinct roles with mod/course:update
|
||||
// please change the name and strings to something appropriate to reflect the new data collected
|
||||
$sql = "SELECT COUNT(DISTINCT u.id)
|
||||
FROM {$CFG->prefix}role_capabilities rc,
|
||||
{$CFG->prefix}role_assignments ra,
|
||||
{$CFG->prefix}user u
|
||||
WHERE (rc.capability = 'moodle/course:update' or rc.capability='moodle/site:doanything')
|
||||
AND rc.roleid = ra.roleid
|
||||
AND u.id = ra.userid";
|
||||
|
||||
$count = count_records_sql($sql);
|
||||
echo get_string("teachers").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courseupdaters\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('forum_posts');
|
||||
echo get_string("posts", 'forum').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"posts\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('question');
|
||||
echo get_string("questions", 'quiz').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"questions\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('resource');
|
||||
echo get_string("modulenameplural", "resource").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"resources\" value=\"$count\" />\n";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="adminname">'.get_string("administrator").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<input size=\"50\" type=\"text\" id=\"adminname\" name=\"adminname\" value=\"".fullname($admin, true)."\" />";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="adminemail">'.get_string("email").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<input size=\"50\" type=\"text\" id=\"adminemail\" name=\"adminemail\" value=\"$admin->email\" />";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menumailme">'.get_string("registrationemail").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
$options[0] = get_string("registrationno");
|
||||
$options[1] = get_string("registrationyes");
|
||||
choose_from_menu ($options, "mailme", "1", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="felement fsubmit"><input name="submitbutton" value="'.get_string('registrationsend').'" type="submit" id="id_submitbutton" /></div>';
|
||||
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "</form>\n";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* The administrator is redirect to this page from the hub to confirm that the
|
||||
* site has been registered. It is an administration page. The administrator
|
||||
* should be using the same browser during all the registration process.
|
||||
* This page save the token that the hub gave us, in order to call the hub
|
||||
* directory later by web service.
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
|
||||
$newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
|
||||
$url = optional_param('url', '', PARAM_URL);
|
||||
$hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
$token = optional_param('token', '', PARAM_TEXT);
|
||||
$error = optional_param('error', '', PARAM_ALPHANUM);
|
||||
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
if (!empty($error) and $error == 'urlalreadyexist') {
|
||||
throw new moodle_exception('urlalreadyregistered', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
//check that we are waiting a confirmation from this hub, and check that the token is correct
|
||||
$registrationmanager = new registration_manager();
|
||||
$registeredhub = $registrationmanager->get_unconfirmedhub($url);
|
||||
if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
|
||||
$hublink = html_writer::tag('a', $hubname, array('href' => $url));
|
||||
|
||||
$registeredhub->token = $newtoken;
|
||||
$registeredhub->confirmed = 1;
|
||||
$registeredhub->hubname = $hubname;
|
||||
$registrationmanager->update_registeredhub($registeredhub);
|
||||
|
||||
//display notficiation message
|
||||
$notificationmessage = $OUTPUT->notification(
|
||||
get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
|
||||
echo $notificationmessage;
|
||||
|
||||
//display continue button
|
||||
$registrationpage = new moodle_url('/admin/registration/index.php');
|
||||
$continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue', 'hub')));
|
||||
$continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align'));
|
||||
echo $continuebutton;
|
||||
|
||||
if (!extension_loaded('xmlrpc')) {
|
||||
//display notice about xmlrpc
|
||||
$xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
|
||||
$xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
|
||||
echo $OUTPUT->notification($xmlrpcnotification);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
} else {
|
||||
throw new moodle_exception('wrongtoken', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,467 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* The forms needed by registration pages.
|
||||
*/
|
||||
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
|
||||
/**
|
||||
* This form display a unregistration form.
|
||||
*/
|
||||
class site_unregistration_form extends moodleform {
|
||||
|
||||
public function definition() {
|
||||
$mform = & $this->_form;
|
||||
$mform->addElement('header', 'site', get_string('unregister', 'hub'));
|
||||
|
||||
$huburl = $this->_customdata['huburl'];
|
||||
$hubname = $this->_customdata['hubname'];
|
||||
|
||||
$unregisterlabel = get_string('unregister', 'hub');
|
||||
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
|
||||
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
|
||||
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
|
||||
' ' . get_string('unpublishalluploadedcourses', 'hub'));
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
$mform->addElement('hidden', 'unregistration', 1);
|
||||
$mform->setType('unregistration', PARAM_INT);
|
||||
$mform->addElement('hidden', 'huburl', $huburl);
|
||||
$mform->setType('huburl', PARAM_URL);
|
||||
$mform->addElement('hidden', 'hubname', $hubname);
|
||||
$mform->setType('hubname', PARAM_TEXT);
|
||||
|
||||
$this->add_action_buttons(true, $unregisterlabel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This form display a clean registration data form.
|
||||
*/
|
||||
class site_clean_registration_data_form extends moodleform {
|
||||
|
||||
public function definition() {
|
||||
$mform = & $this->_form;
|
||||
$mform->addElement('header', 'site', get_string('unregister', 'hub'));
|
||||
|
||||
$huburl = $this->_customdata['huburl'];
|
||||
$hubname = $this->_customdata['hubname'];
|
||||
|
||||
|
||||
$unregisterlabel = get_string('forceunregister', 'hub');
|
||||
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
$mform->addElement('hidden', 'unregistration', 1);
|
||||
$mform->setType('unregistration', PARAM_INT);
|
||||
$mform->addElement('hidden', 'cleanregdata', 1);
|
||||
$mform->setType('cleanregdata', PARAM_INT);
|
||||
$mform->addElement('hidden', 'huburl', $huburl);
|
||||
$mform->setType('huburl', PARAM_URL);
|
||||
$mform->addElement('hidden', 'hubname', $hubname);
|
||||
$mform->setType('hubname', PARAM_TEXT);
|
||||
|
||||
$this->add_action_buttons(true, $unregisterlabel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This form display a hub selector.
|
||||
* The hub list is retrieved from Moodle.org hub directory.
|
||||
* Also displayed, a text field to enter private hub url + its password
|
||||
*/
|
||||
class hub_selector_form extends moodleform {
|
||||
|
||||
public function definition() {
|
||||
global $CFG, $OUTPUT;
|
||||
$mform = & $this->_form;
|
||||
$mform->addElement('header', 'site', get_string('selecthub', 'hub'));
|
||||
|
||||
//retrieve the hub list on the hub directory by web service
|
||||
$function = 'hubdirectory_get_hubs';
|
||||
$params = array();
|
||||
$serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php";
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, 'publichubdirectory');
|
||||
try {
|
||||
$hubs = $xmlrpcclient->call($function, $params);
|
||||
} catch (Exception $e) {
|
||||
$error = $OUTPUT->notification(get_string('errorhublisting', 'hub', $e->getMessage()));
|
||||
$mform->addElement('static', 'errorhub', '', $error);
|
||||
$hubs = array();
|
||||
}
|
||||
|
||||
//remove moodle.org from the hub list
|
||||
foreach ($hubs as $key => $hub) {
|
||||
if ($hub['url'] == HUB_MOODLEORGHUBURL) {
|
||||
unset($hubs[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
//Public hub list
|
||||
$options = array();
|
||||
foreach ($hubs as $hub) {
|
||||
//to not display a name longer than 100 character (too big)
|
||||
if (strlen($hub['name']) > 100) {
|
||||
$hubname = substr($hub['name'], 0, 100);
|
||||
$hubname = $hubname . "...";
|
||||
} else {
|
||||
$hubname = $hub['name'];
|
||||
}
|
||||
$options[$hub['url']] = $hubname;
|
||||
$mform->addElement('hidden', clean_param($hub['url'], PARAM_ALPHANUMEXT), $hubname);
|
||||
$mform->setType(clean_param($hub['url'], PARAM_ALPHANUMEXT), PARAM_ALPHANUMEXT);
|
||||
}
|
||||
if (!empty($hubs)) {
|
||||
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
|
||||
$options, array("size" => 15));
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
|
||||
|
||||
//Private hub
|
||||
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addElement('text', 'password', get_string('password'),
|
||||
array('class' => 'registration_textfield'));
|
||||
|
||||
$this->add_action_buttons(false, get_string('selecthub', 'hub'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the unlisted URL is a URL
|
||||
*/
|
||||
function validation($data, $files) {
|
||||
global $CFG;
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
$unlistedurl = $this->_form->_submitValues['unlistedurl'];
|
||||
|
||||
if (!empty($unlistedurl)) {
|
||||
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
|
||||
if (empty($unlistedurltotest)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The site registration form. Information will be sent to a given hub.
|
||||
*/
|
||||
class site_registration_form extends moodleform {
|
||||
|
||||
public function definition() {
|
||||
global $CFG, $DB;
|
||||
|
||||
$strrequired = get_string('required');
|
||||
$mform = & $this->_form;
|
||||
$huburl = $this->_customdata['huburl'];
|
||||
$hubname = $this->_customdata['hubname'];
|
||||
$password = $this->_customdata['password'];
|
||||
$admin = get_admin();
|
||||
$site = get_site();
|
||||
|
||||
//retrieve config for this hub and set default if they don't exist
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
|
||||
if ($sitename === false) {
|
||||
$sitename = $site->fullname;
|
||||
}
|
||||
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
|
||||
if ($sitedescription === false) {
|
||||
$sitedescription = $site->summary;
|
||||
}
|
||||
$contactname = get_config('hub', 'site_contactname_' . $cleanhuburl);
|
||||
if ($contactname === false) {
|
||||
$contactname = fullname($admin, true);
|
||||
}
|
||||
$contactemail = get_config('hub', 'site_contactemail_' . $cleanhuburl);
|
||||
if ($contactemail === false) {
|
||||
$contactemail = $admin->email;
|
||||
}
|
||||
$contactphone = get_config('hub', 'site_contactphone_' . $cleanhuburl);
|
||||
if ($contactphone === false) {
|
||||
$contactphone = $admin->phone1;
|
||||
}
|
||||
$imageurl = get_config('hub', 'site_imageurl_' . $cleanhuburl);
|
||||
$privacy = get_config('hub', 'site_privacy_' . $cleanhuburl);
|
||||
$address = get_config('hub', 'site_address_' . $cleanhuburl);
|
||||
$region = get_config('hub', 'site_region_' . $cleanhuburl);
|
||||
$country = get_config('hub', 'site_country_' . $cleanhuburl);
|
||||
if ($country === false) {
|
||||
$country = $admin->country;
|
||||
}
|
||||
$language = get_config('hub', 'site_language_' . $cleanhuburl);
|
||||
if ($language === false) {
|
||||
$language = current_language();
|
||||
}
|
||||
$geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
|
||||
$contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
|
||||
$emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
|
||||
$coursesnumber = get_config('hub', 'site_coursesnumber_' . $cleanhuburl);
|
||||
$usersnumber = get_config('hub', 'site_usersnumber_' . $cleanhuburl);
|
||||
$roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl);
|
||||
$postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
|
||||
$questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
|
||||
$resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
|
||||
$mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
|
||||
|
||||
//hidden parameters
|
||||
$mform->addElement('hidden', 'huburl', $huburl);
|
||||
$mform->setType('huburl', PARAM_URL);
|
||||
$mform->addElement('hidden', 'hubname', $hubname);
|
||||
$mform->setType('hubname', PARAM_TEXT);
|
||||
$mform->addElement('hidden', 'password', $password);
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
//the input parameters
|
||||
$mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub'));
|
||||
|
||||
$mform->addElement('text', 'name', get_string('sitename', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addRule('name', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->setDefault('name', $sitename);
|
||||
$mform->addHelpButton('name', 'sitename', 'hub');
|
||||
|
||||
$options = array();
|
||||
$registrationmanager = new registration_manager();
|
||||
$options[HUB_SITENOTPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENOTPUBLISHED);
|
||||
$options[HUB_SITENAMEPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENAMEPUBLISHED);
|
||||
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
|
||||
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
|
||||
$mform->setDefault('privacy', $privacy);
|
||||
$mform->addHelpButton('privacy', 'privacy', 'hub');
|
||||
unset($options);
|
||||
|
||||
$mform->addElement('textarea', 'description', get_string('sitedesc', 'hub'),
|
||||
array('rows' => 8, 'cols' => 41));
|
||||
$mform->addRule('description', $strrequired, 'required', null, 'client');
|
||||
$mform->setDefault('description', $sitedescription);
|
||||
$mform->setType('description', PARAM_TEXT);
|
||||
$mform->addHelpButton('description', 'sitedesc', 'hub');
|
||||
|
||||
$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
|
||||
$mform->addHelpButton('urlstring', 'siteurl', 'hub');
|
||||
|
||||
$languages = get_string_manager()->get_list_of_languages();
|
||||
textlib_get_instance()->asort($languages);
|
||||
$mform->addElement('select', 'language', get_string('sitelang', 'hub'),
|
||||
$languages);
|
||||
$mform->setType('language', PARAM_ALPHANUMEXT);
|
||||
$mform->addHelpButton('language', 'sitelang', 'hub');
|
||||
$mform->setDefault('language', $language);
|
||||
|
||||
$mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
|
||||
$mform->addElement('hidden', 'moodleversion', $CFG->version);
|
||||
$mform->setType('moodleversion', PARAM_INT);
|
||||
$mform->addHelpButton('versionstring', 'siteversion', 'hub');
|
||||
|
||||
$mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
|
||||
$mform->addElement('hidden', 'moodlerelease', $CFG->release);
|
||||
$mform->setType('moodlerelease', PARAM_TEXT);
|
||||
$mform->addHelpButton('releasestring', 'siterelease', 'hub');
|
||||
|
||||
$mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'),
|
||||
array('rows' => 4, 'cols' => 41));
|
||||
$mform->setType('address', PARAM_TEXT);
|
||||
$mform->setDefault('address', $address);
|
||||
$mform->addHelpButton('address', 'postaladdress', 'hub');
|
||||
|
||||
//TODO: use the region array I generated
|
||||
// $mform->addElement('select', 'region', get_string('selectaregion'), array('-' => '-'));
|
||||
// $mform->setDefault('region', $region);
|
||||
$mform->addElement('hidden', 'regioncode', '-');
|
||||
$mform->setType('regioncode', PARAM_ALPHANUMEXT);
|
||||
|
||||
$countries = get_string_manager()->get_list_of_countries();
|
||||
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
|
||||
$mform->setDefault('countrycode', $country);
|
||||
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');
|
||||
|
||||
$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setDefault('geolocation', $geolocation);
|
||||
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
|
||||
|
||||
$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addRule('contactname', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('contactname', PARAM_TEXT);
|
||||
$mform->setDefault('contactname', $contactname);
|
||||
$mform->addHelpButton('contactname', 'siteadmin', 'hub');
|
||||
|
||||
$mform->addElement('text', 'contactphone', get_string('sitephone', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('contactphone', PARAM_TEXT);
|
||||
$mform->addHelpButton('contactphone', 'sitephone', 'hub');
|
||||
|
||||
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('contactemail', PARAM_TEXT);
|
||||
$mform->setDefault('contactemail', $contactemail);
|
||||
$mform->addHelpButton('contactemail', 'siteemail', 'hub');
|
||||
|
||||
$options = array();
|
||||
$options[0] = get_string("registrationcontactno");
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
|
||||
$mform->setDefault('contactable', $contactable);
|
||||
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
|
||||
unset($options);
|
||||
|
||||
$options = array();
|
||||
$options[0] = get_string("registrationno");
|
||||
$options[1] = get_string("registrationyes");
|
||||
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
|
||||
$mform->setDefault('emailalert', $emailalert);
|
||||
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
|
||||
unset($options);
|
||||
|
||||
//TODO site logo
|
||||
$mform->addElement('hidden', 'imageurl', ''); //TODO: temporary
|
||||
$mform->setType('imageurl', PARAM_URL);
|
||||
/// Display statistic that are going to be retrieve by the hub
|
||||
$coursecount = $DB->count_records('course') - 1;
|
||||
$usercount = $DB->count_records('user', array('deleted' => 0));
|
||||
$roleassigncount = $DB->count_records('role_assignments');
|
||||
$postcount = $DB->count_records('forum_posts');
|
||||
$questioncount = $DB->count_records('question');
|
||||
$resourcecount = $DB->count_records('resource');
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
$participantnumberaverage = number_format(average_number_of_participants(), 2);
|
||||
$modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
|
||||
|
||||
if (HUB_MOODLEORGHUBURL != $huburl) {
|
||||
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->setDefault('courses', true);
|
||||
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('checkbox', 'users', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->setDefault('users', true);
|
||||
|
||||
$mform->addElement('checkbox', 'roleassignments', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->setDefault('roleassignments', true);
|
||||
|
||||
$mform->addElement('checkbox', 'posts', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->setDefault('posts', true);
|
||||
|
||||
$mform->addElement('checkbox', 'questions', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->setDefault('questions', true);
|
||||
|
||||
$mform->addElement('checkbox', 'resources', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->setDefault('resources', true);
|
||||
|
||||
$mform->addElement('checkbox', 'participantnumberaverage', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->setDefault('participantnumberaverage', true);
|
||||
|
||||
$mform->addElement('checkbox', 'modulenumberaverage', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->setDefault('modulenumberaverage', true);
|
||||
} else {
|
||||
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->addElement('hidden', 'courses', true);
|
||||
$mform->setType('courses', PARAM_FLOAT);
|
||||
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('static', 'userslabel', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->addElement('hidden', 'users', true);
|
||||
$mform->setType('users', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'roleassignmentslabel', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->addElement('hidden', 'roleassignments', true);
|
||||
$mform->setType('roleassignments', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'postslabel', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->addElement('hidden', 'posts', true);
|
||||
$mform->setType('posts', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'questionslabel', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->addElement('hidden', 'questions', true);
|
||||
$mform->setType('questions', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'resourceslabel', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->addElement('hidden', 'resources', true);
|
||||
$mform->setType('resources', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'participantnumberaveragelabel', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->addElement('hidden', 'participantnumberaverage', true);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'modulenumberaveragelabel', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->addElement('hidden', 'modulenumberaverage', true);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
}
|
||||
|
||||
//check if it's a first registration or update
|
||||
$hubregistered = $registrationmanager->get_registeredhub($huburl);
|
||||
|
||||
if (!empty($hubregistered)) {
|
||||
$buttonlabel = get_string('updatesite', 'hub',
|
||||
!empty($hubname) ? $hubname : $huburl);
|
||||
$mform->addElement('hidden', 'update', true);
|
||||
$mform->setType('update', PARAM_BOOL);
|
||||
} else {
|
||||
$buttonlabel = get_string('registersite', 'hub',
|
||||
!empty($hubname) ? $hubname : $huburl);
|
||||
}
|
||||
|
||||
$this->add_action_buttons(false, $buttonlabel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* Thsi page displays a hub selector or a hub URL + password. Then it will redirect to
|
||||
* the site registration form (with the selected hub as parameter)
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/' . $CFG->admin . '/registration/forms.php');
|
||||
|
||||
admin_externalpage_setup('registrationselector');
|
||||
|
||||
$hubselectorform = new hub_selector_form();
|
||||
$fromform = $hubselectorform->get_data();
|
||||
|
||||
//// Redirect to the registration form if an URL has been choosen ////
|
||||
|
||||
$selectedhuburl = optional_param('publichub', false, PARAM_URL);
|
||||
$unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
|
||||
$password = optional_param('password', '', PARAM_RAW);
|
||||
|
||||
if (!empty($unlistedhuburl)) {
|
||||
if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
|
||||
$huburl = $unlistedhuburl;
|
||||
}
|
||||
} else if (!empty($selectedhuburl)) {
|
||||
$huburl = $selectedhuburl;
|
||||
}
|
||||
|
||||
|
||||
//redirect
|
||||
if (!empty($huburl) and confirm_sesskey()) {
|
||||
$hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
|
||||
$params = array('sesskey' => sesskey(), 'huburl' => $huburl,
|
||||
'password' => $password, 'hubname' => $hubname);
|
||||
redirect(new moodle_url($CFG->wwwroot."/" . $CFG->admin . "/registration/register.php",
|
||||
$params));
|
||||
}
|
||||
|
||||
|
||||
//// OUTPUT ////
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
|
||||
$hubselectorform->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,168 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* On this page the administrator select if he wants to register on Moodle.org or
|
||||
* a specific hub
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
|
||||
require_once($CFG->dirroot . '/course/publish/lib.php');
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
$renderer = $PAGE->get_renderer('core', 'register');
|
||||
|
||||
$unregistration = optional_param('unregistration', 0, PARAM_INT);
|
||||
$cleanregdata = optional_param('cleanregdata', 0, PARAM_BOOL);
|
||||
$confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
$huburl = optional_param('huburl', '', PARAM_URL);
|
||||
$cancel = optional_param('cancel', null, PARAM_ALPHA);
|
||||
|
||||
$registrationmanager = new registration_manager();
|
||||
$publicationmanager = new course_publish_manager();
|
||||
$errormessage = '';
|
||||
if (empty($cancel) and $unregistration and $confirm and confirm_sesskey()) {
|
||||
|
||||
$hub = $registrationmanager->get_registeredhub($huburl);
|
||||
|
||||
//unpublish course and unregister the site by web service
|
||||
if (!$cleanregdata) {
|
||||
|
||||
//check if we need to unpublish courses
|
||||
//enrollable courses
|
||||
$unpublishalladvertisedcourses = optional_param('unpublishalladvertisedcourses', 0, PARAM_INT);
|
||||
$hubcourseids = array();
|
||||
if ($unpublishalladvertisedcourses) {
|
||||
$enrollablecourses = $publicationmanager->get_publications($huburl, null, 1);
|
||||
if (!empty($enrollablecourses)) {
|
||||
foreach ($enrollablecourses as $enrollablecourse) {
|
||||
$hubcourseids[] = $enrollablecourse->hubcourseid;
|
||||
}
|
||||
}
|
||||
}
|
||||
//downloadable courses
|
||||
$unpublishalluploadedcourses = optional_param('unpublishalluploadedcourses', 0, PARAM_INT);
|
||||
if ($unpublishalluploadedcourses) {
|
||||
$downloadablecourses = $publicationmanager->get_publications($huburl, null, 0);
|
||||
if (!empty($downloadablecourses)) {
|
||||
foreach ($downloadablecourses as $downloadablecourse) {
|
||||
$hubcourseids[] = $downloadablecourse->hubcourseid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//unpublish the courses by web service
|
||||
if (!empty($hubcourseids)) {
|
||||
$function = 'hub_unregister_courses';
|
||||
$params = array('courseids' => $hubcourseids);
|
||||
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
//delete the published courses
|
||||
if (!empty($enrollablecourses)) {
|
||||
$publicationmanager->delete_hub_publications($huburl, 1);
|
||||
}
|
||||
if (!empty($downloadablecourses)) {
|
||||
$publicationmanager->delete_hub_publications($huburl, 0);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errormessage = $e->getMessage();
|
||||
$errormessage .= html_writer::empty_tag('br') .
|
||||
get_string('errorunpublishcourses', 'hub');
|
||||
$confirm = false;
|
||||
$cleanregdata = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//course unpublish went ok, unregister the site now
|
||||
if ($confirm) {
|
||||
$function = 'hub_unregister_site';
|
||||
$params = array();
|
||||
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
} catch (Exception $e) {
|
||||
if (!$cleanregdata) {
|
||||
$errormessage = $e->getMessage();
|
||||
$confirm = false;
|
||||
$cleanregdata = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check that we are still processing the unregistration,
|
||||
//it could have been unset if an exception were previsouly catched
|
||||
if ($confirm) {
|
||||
$registrationmanager->delete_registeredhub($huburl);
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//do not check sesskey if confirm = false because this script is linked into email message
|
||||
if (!empty($errormessage)) {
|
||||
echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
|
||||
}
|
||||
if (empty($cancel) and $unregistration and !$confirm) {
|
||||
$hub = $registrationmanager->get_registeredhub($huburl);
|
||||
echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', $hub->hubname), 3, 'main');
|
||||
if ($cleanregdata) {
|
||||
$siteunregistrationform = new site_clean_registration_data_form('',
|
||||
array('huburl' => $huburl, 'hubname' => $hub->hubname));
|
||||
} else {
|
||||
$siteunregistrationform = new site_unregistration_form('',
|
||||
array('huburl' => $huburl, 'hubname' => $hub->hubname));
|
||||
}
|
||||
$siteunregistrationform->display();
|
||||
} else {
|
||||
$registeredonmoodleorg = false;
|
||||
$moodleorghub = $registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL);
|
||||
if (!empty($moodleorghub)) {
|
||||
$registeredonmoodleorg = true;
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
|
||||
echo $renderer->registrationselector($registeredonmoodleorg);
|
||||
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
$hubs = $registrationmanager->get_registered_on_hubs();
|
||||
if (!empty($hubs)) {
|
||||
echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
|
||||
echo $renderer->registeredonhublisting($hubs);
|
||||
}
|
||||
} else { //display notice about xmlrpc
|
||||
$xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
|
||||
$xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
|
||||
echo $OUTPUT->notification($xmlrpcnotification);
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,269 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
|
||||
//// SITE PRIVACY /////
|
||||
|
||||
/**
|
||||
* Site privacy: private
|
||||
*/
|
||||
define('HUB_SITENOTPUBLISHED', 'notdisplayed');
|
||||
|
||||
/**
|
||||
* Site privacy: public
|
||||
*/
|
||||
define('HUB_SITENAMEPUBLISHED', 'named');
|
||||
|
||||
/**
|
||||
* Site privacy: public and global
|
||||
*/
|
||||
define('HUB_SITELINKPUBLISHED', 'linked');
|
||||
|
||||
/**
|
||||
*
|
||||
* Site registration library
|
||||
*
|
||||
* @package course
|
||||
* @copyright 2010 Moodle Pty Ltd (http://moodle.com)
|
||||
* @author Jerome Mouneyrac
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class registration_manager {
|
||||
|
||||
/**
|
||||
* Automatically update the registration on all hubs
|
||||
*/
|
||||
public function cron() {
|
||||
global $CFG;
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
//check if the last registration cron update was less than a week ago
|
||||
$lastcron = get_config('registration', 'crontime');
|
||||
if ($lastcron === false or $lastcron < strtotime("-7 day")) { //set to a week, see MDL-23704
|
||||
$function = 'hub_update_site_info';
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
|
||||
//update all hub where the site is registered on
|
||||
$hubs = $this->get_registered_on_hubs();
|
||||
foreach ($hubs as $hub) {
|
||||
//update the registration
|
||||
$siteinfo = $this->get_site_info($hub->huburl);
|
||||
$params = array('siteinfo' => $siteinfo);
|
||||
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
|
||||
} catch (Exception $e) {
|
||||
$errorparam = new stdClass();
|
||||
$errorparam->errormessage = $e->getMessage();
|
||||
$errorparam->hubname = $hub->hubname;
|
||||
mtrace(get_string('errorcron', 'hub', $errorparam));
|
||||
}
|
||||
}
|
||||
set_config('crontime', time(), 'registration');
|
||||
}
|
||||
} else {
|
||||
mtrace(get_string('errorcronnoxmlrpc', 'hub'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the site register on a hub, he must call this function
|
||||
* @param object $hub where the site is registered on
|
||||
* @return integer id of the record
|
||||
*/
|
||||
public function add_registeredhub($hub) {
|
||||
global $DB;
|
||||
$id = $DB->insert_record('registration_hubs', $hub);
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* When a site unregister from a hub, he must call this function
|
||||
* @param string $huburl the huburl to delete
|
||||
*/
|
||||
public function delete_registeredhub($huburl) {
|
||||
global $DB;
|
||||
$DB->delete_records('registration_hubs', array('huburl' => $huburl));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a hub on which the site is registered for a given url or token
|
||||
* Mostly use to check if the site is registered on a specific hub
|
||||
* @param string $huburl
|
||||
* @param string $token
|
||||
* @return object the hub
|
||||
*/
|
||||
public function get_registeredhub($huburl = null, $token = null) {
|
||||
global $DB;
|
||||
|
||||
$params = array();
|
||||
if (!empty($huburl)) {
|
||||
$params['huburl'] = $huburl;
|
||||
}
|
||||
if (!empty($token)) {
|
||||
$params['token'] = $token;
|
||||
}
|
||||
$params['confirmed'] = 1;
|
||||
$token = $DB->get_record('registration_hubs', $params);
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hub which has not confirmed that the site is registered on,
|
||||
* but for which a request has been sent
|
||||
* @param string $huburl
|
||||
* @return object the hub
|
||||
*/
|
||||
public function get_unconfirmedhub($huburl) {
|
||||
global $DB;
|
||||
|
||||
$params = array();
|
||||
$params['huburl'] = $huburl;
|
||||
$params['confirmed'] = 0;
|
||||
$token = $DB->get_record('registration_hubs', $params);
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a registered hub (mostly use to update the confirmation status)
|
||||
* @param object $communication the hub
|
||||
*/
|
||||
public function update_registeredhub($communication) {
|
||||
global $DB;
|
||||
$DB->update_record('registration_hubs', $communication);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all hubs where the site is registered on
|
||||
*/
|
||||
public function get_registered_on_hubs() {
|
||||
global $DB;
|
||||
$hubs = $DB->get_records('registration_hubs', array('confirmed' => 1));
|
||||
return $hubs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return site information for a specific hub
|
||||
* @param string $huburl
|
||||
* @return array site info
|
||||
*/
|
||||
public function get_site_info($huburl) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$siteinfo = array();
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
$siteinfo['name'] = get_config('hub', 'site_name_' . $cleanhuburl);
|
||||
$siteinfo['description'] = get_config('hub', 'site_description_' . $cleanhuburl);
|
||||
$siteinfo['contactname'] = get_config('hub', 'site_contactname_' . $cleanhuburl);
|
||||
$siteinfo['contactemail'] = get_config('hub', 'site_contactemail_' . $cleanhuburl);
|
||||
$siteinfo['contactphone'] = get_config('hub', 'site_contactphone_' . $cleanhuburl);
|
||||
$siteinfo['imageurl'] = get_config('hub', 'site_imageurl_' . $cleanhuburl);
|
||||
$siteinfo['privacy'] = get_config('hub', 'site_privacy_' . $cleanhuburl);
|
||||
$siteinfo['street'] = get_config('hub', 'site_address_' . $cleanhuburl);
|
||||
$siteinfo['regioncode'] = get_config('hub', 'site_region_' . $cleanhuburl);
|
||||
$siteinfo['countrycode'] = get_config('hub', 'site_country_' . $cleanhuburl);
|
||||
$siteinfo['geolocation'] = get_config('hub', 'site_geolocation_' . $cleanhuburl);
|
||||
$siteinfo['contactable'] = get_config('hub', 'site_contactable_' . $cleanhuburl);
|
||||
$siteinfo['emailalert'] = get_config('hub', 'site_emailalert_' . $cleanhuburl);
|
||||
if (get_config('hub', 'site_coursesnumber_' . $cleanhuburl) == -1) {
|
||||
$coursecount = -1;
|
||||
} else {
|
||||
$coursecount = $DB->count_records('course') - 1;
|
||||
}
|
||||
$siteinfo['courses'] = $coursecount;
|
||||
if (get_config('hub', 'site_usersnumber_' . $cleanhuburl) == -1) {
|
||||
$usercount = -1;
|
||||
} else {
|
||||
$usercount = $DB->count_records('user', array('deleted' => 0));
|
||||
}
|
||||
$siteinfo['users'] = $usercount;
|
||||
|
||||
if (get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl) == -1) {
|
||||
$roleassigncount = -1;
|
||||
} else {
|
||||
$roleassigncount = $DB->count_records('role_assignments');
|
||||
}
|
||||
$siteinfo['enrolments'] = $roleassigncount;
|
||||
if (get_config('hub', 'site_postsnumber_' . $cleanhuburl) == -1) {
|
||||
$postcount = -1;
|
||||
} else {
|
||||
$postcount = $DB->count_records('forum_posts');
|
||||
}
|
||||
$siteinfo['posts'] = $postcount;
|
||||
if (get_config('hub', 'site_questionsnumber_' . $cleanhuburl) == -1) {
|
||||
$questioncount = -1;
|
||||
} else {
|
||||
$questioncount = $DB->count_records('question');
|
||||
}
|
||||
$siteinfo['questions'] = $questioncount;
|
||||
if (get_config('hub', 'site_resourcesnumber_' . $cleanhuburl) == -1) {
|
||||
$resourcecount = -1;
|
||||
} else {
|
||||
$resourcecount = $DB->count_records('resource');
|
||||
}
|
||||
$siteinfo['resources'] = $resourcecount;
|
||||
//TODO
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
if (get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl) == -1) {
|
||||
$participantnumberaverage = -1;
|
||||
} else {
|
||||
$participantnumberaverage = average_number_of_participants();
|
||||
}
|
||||
$siteinfo['participantnumberaverage'] = $participantnumberaverage;
|
||||
if (get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl) == -1) {
|
||||
$modulenumberaverage = -1;
|
||||
} else {
|
||||
$modulenumberaverage = average_number_of_courses_modules();
|
||||
}
|
||||
$siteinfo['modulenumberaverage'] = $modulenumberaverage;
|
||||
$siteinfo['language'] = get_config('hub', 'site_language_' . $cleanhuburl);
|
||||
$siteinfo['moodleversion'] = $CFG->version;
|
||||
$siteinfo['moodlerelease'] = $CFG->release;
|
||||
$siteinfo['url'] = $CFG->wwwroot;
|
||||
|
||||
return $siteinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the site privacy string matching the define value
|
||||
* @param string $privacy must match the define into moodlelib.php
|
||||
* @return string
|
||||
*/
|
||||
public function get_site_privacy_string($privacy) {
|
||||
switch ($privacy) {
|
||||
case HUB_SITENOTPUBLISHED:
|
||||
$privacystring = get_string('siteprivacynotpublished', 'hub');
|
||||
break;
|
||||
case HUB_SITENAMEPUBLISHED:
|
||||
$privacystring = get_string('siteprivacypublished', 'hub');
|
||||
break;
|
||||
case HUB_SITELINKPUBLISHED:
|
||||
$privacystring = get_string('siteprivacylinked', 'hub');
|
||||
break;
|
||||
}
|
||||
if (empty($privacystring)) {
|
||||
throw new moodle_exception('unknownprivacy');
|
||||
}
|
||||
return $privacystring;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,163 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* This page displays the site registration form.
|
||||
* It handles redirection to the hub to continue the registration workflow process.
|
||||
* It also handles update operation by web service.
|
||||
*/
|
||||
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
$huburl = required_param('huburl', PARAM_URL);
|
||||
$huburl = rtrim($huburl, "/");
|
||||
$password = optional_param('password', '', PARAM_TEXT);
|
||||
$hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
if (!confirm_sesskey()) {
|
||||
throw new moodle_exception('missingparameter');
|
||||
}
|
||||
|
||||
/* TO DO
|
||||
if DB config plugin table is not good for dealing with token reference and token confirmation
|
||||
=> create other DB table
|
||||
-----------------------------------------------------------------------------
|
||||
Local Type | Token | Local WS | Remote Type | Remote URL | Confirmed
|
||||
-----------------------------------------------------------------------------
|
||||
HUB 4er4e server HUB-DIRECTORY http...moodle.org Yes
|
||||
HUB 73j53 client HUB-DIRECTORY http...moodle.org Yes
|
||||
SITE dfsd7 server HUB http...hub Yes
|
||||
SITE fd8fd client HUB http...hub Yes
|
||||
HUB ds78s server SITE http...site.com Yes
|
||||
HUB-DIR. d7d8s server HUB http...hub Yes
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$registrationmanager = new registration_manager();
|
||||
|
||||
$registeredhub = $registrationmanager->get_registeredhub($huburl);
|
||||
|
||||
$siteregistrationform = new site_registration_form('',
|
||||
array('alreadyregistered' => !empty($registeredhub->token),
|
||||
'huburl' => $huburl, 'hubname' => $hubname,
|
||||
'password' => $password));
|
||||
$fromform = $siteregistrationform->get_data();
|
||||
|
||||
if (!empty($fromform) and confirm_sesskey()) {
|
||||
//save the settings
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
|
||||
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
|
||||
set_config('site_contactname_' . $cleanhuburl, $fromform->contactname, 'hub');
|
||||
set_config('site_contactemail_' . $cleanhuburl, $fromform->contactemail, 'hub');
|
||||
set_config('site_contactphone_' . $cleanhuburl, $fromform->contactphone, 'hub');
|
||||
set_config('site_imageurl_' . $cleanhuburl, $fromform->imageurl, 'hub');
|
||||
set_config('site_privacy_' . $cleanhuburl, $fromform->privacy, 'hub');
|
||||
set_config('site_address_' . $cleanhuburl, $fromform->address, 'hub');
|
||||
set_config('site_region_' . $cleanhuburl, $fromform->regioncode, 'hub');
|
||||
set_config('site_country_' . $cleanhuburl, $fromform->countrycode, 'hub');
|
||||
set_config('site_language_' . $cleanhuburl, $fromform->language, 'hub');
|
||||
set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub');
|
||||
set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, 'hub');
|
||||
set_config('site_emailalert_' . $cleanhuburl, $fromform->emailalert, 'hub');
|
||||
set_config('site_coursesnumber_' . $cleanhuburl, $fromform->courses, 'hub');
|
||||
set_config('site_usersnumber_' . $cleanhuburl, $fromform->users, 'hub');
|
||||
set_config('site_roleassignmentsnumber_' . $cleanhuburl, $fromform->roleassignments, 'hub');
|
||||
set_config('site_postsnumber_' . $cleanhuburl, $fromform->posts, 'hub');
|
||||
set_config('site_questionsnumber_' . $cleanhuburl, $fromform->questions, 'hub');
|
||||
set_config('site_resourcesnumber_' . $cleanhuburl, $fromform->resources, 'hub');
|
||||
set_config('site_modulenumberaverage_' . $cleanhuburl, $fromform->modulenumberaverage, 'hub');
|
||||
set_config('site_participantnumberaverage_' . $cleanhuburl, $fromform->participantnumberaverage, 'hub');
|
||||
}
|
||||
|
||||
/////// UPDATE ACTION ////////
|
||||
|
||||
// update the hub registration
|
||||
$update = optional_param('update', 0, PARAM_INT);
|
||||
if ($update and confirm_sesskey()) {
|
||||
|
||||
//update the registration
|
||||
$function = 'hub_update_site_info';
|
||||
$siteinfo = $registrationmanager->get_site_info($huburl);
|
||||
$params = array('siteinfo' => $siteinfo);
|
||||
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
} catch (Exception $e) {
|
||||
$error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/////// FORM REGISTRATION ACTION //////
|
||||
|
||||
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
|
||||
|
||||
if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
|
||||
$params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
|
||||
|
||||
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
|
||||
if (empty($unconfirmedhub)) {
|
||||
//we save the token into the communication table in order to have a reference
|
||||
$unconfirmedhub = new stdClass();
|
||||
$unconfirmedhub->token = get_site_identifier();
|
||||
$unconfirmedhub->huburl = $huburl;
|
||||
$unconfirmedhub->hubname = $hubname;
|
||||
$unconfirmedhub->confirmed = 0;
|
||||
$unconfirmedhub->id = $registrationmanager->add_registeredhub($unconfirmedhub);
|
||||
}
|
||||
|
||||
$params['token'] = $unconfirmedhub->token;
|
||||
$params['url'] = $CFG->wwwroot;
|
||||
redirect(new moodle_url($huburl . '/local/hub/siteregistration.php', $params));
|
||||
}
|
||||
}
|
||||
|
||||
/////// OUTPUT SECTION /////////////
|
||||
|
||||
echo $OUTPUT->header();
|
||||
//Display update notification result
|
||||
if (!empty($registeredhub->confirmed)) {
|
||||
if (!empty($result)) {
|
||||
echo $OUTPUT->notification(get_string('siteregistrationupdated', 'hub'), 'notifysuccess');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($error)) {
|
||||
echo $error;
|
||||
}
|
||||
|
||||
$siteregistrationform->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Registration renderer.
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @copyright 2010 Moodle Pty Ltd (http://moodle.com)
|
||||
* @author Jerome Mouneyrac
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_register_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display a box message confirming a site registration (add or update)
|
||||
* @param string $confirmationmessage
|
||||
* @return string
|
||||
*/
|
||||
public function registration_confirmation($confirmationmessage) {
|
||||
$linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'),
|
||||
array('href' => new moodle_url('/local/hub/index.php')));
|
||||
$message = $confirmationmessage . html_writer::empty_tag('br') . $linktositelist;
|
||||
return $this->output->box($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page to register on Moodle.org or on a specific hub
|
||||
*/
|
||||
public function registrationselector($updatemoodleorg = false) {
|
||||
global $CFG;
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
|
||||
$table->size = array('50%', '50%');
|
||||
//$table->attributes['class'] = 'registerindextable';
|
||||
//Moodle.org information cell
|
||||
$moodleorgcell = get_string('moodleorgregistrationdetail', 'hub');
|
||||
$moodleorgcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
|
||||
$moodleorgcell = html_writer::tag('div', $moodleorgcell, array('class' => 'justifytext'));
|
||||
|
||||
//Specific hub information cell
|
||||
$specifichubcell = get_string('specifichubregistrationdetail', 'hub');
|
||||
$specifichubcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
|
||||
$specifichubcell = html_writer::tag('div', $specifichubcell, array('class' => 'justifytext'));
|
||||
|
||||
//add information cells
|
||||
$cells = array($moodleorgcell, $specifichubcell);
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
|
||||
//Moodle.org button cell
|
||||
$registeronmoodleorgurl = new moodle_url("/" . $CFG->admin . "/registration/register.php",
|
||||
array('sesskey' => sesskey(), 'huburl' => HUB_MOODLEORGHUBURL
|
||||
, 'hubname' => 'Moodle.org'));
|
||||
$registeronmoodleorgbutton = new single_button($registeronmoodleorgurl,
|
||||
$updatemoodleorg ? get_string('updatesite', 'hub', 'Moodle.org') : get_string('registeronmoodleorg', 'hub'));
|
||||
$registeronmoodleorgbutton->class = 'centeredbutton';
|
||||
$registeronmoodleorgbuttonhtml = $this->output->render($registeronmoodleorgbutton);
|
||||
$moodleorgcell = $registeronmoodleorgbuttonhtml;
|
||||
|
||||
//Specific hub button cell
|
||||
$registeronspecifichuburl = new moodle_url("/" . $CFG->admin . "/registration/hubselector.php",
|
||||
array('sesskey' => sesskey()));
|
||||
$registeronspecifichubbutton = new single_button($registeronspecifichuburl,
|
||||
get_string('registeronspecifichub', 'hub'));
|
||||
$registeronspecifichubbutton->class = 'centeredbutton';
|
||||
$registeronspecifichubbuttonhtml = $this->output->render($registeronspecifichubbutton);
|
||||
$specifichubcell = $registeronspecifichubbuttonhtml;
|
||||
|
||||
//add button cells
|
||||
$cells = array($moodleorgcell, $specifichubcell);
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the listing of registered on hub
|
||||
*/
|
||||
public function registeredonhublisting($hubs) {
|
||||
global $CFG;
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
|
||||
$table->size = array('80%', '20%');
|
||||
|
||||
foreach ($hubs as $hub) {
|
||||
if ($hub->huburl == HUB_MOODLEORGHUBURL) {
|
||||
$hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname);
|
||||
}
|
||||
$hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl));
|
||||
$hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));
|
||||
|
||||
$unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php",
|
||||
array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
|
||||
'unregistration' => 1));
|
||||
$unregisterbutton = new single_button($unregisterhuburl,
|
||||
get_string('unregister', 'hub'));
|
||||
$unregisterbutton->class = 'centeredbutton';
|
||||
$unregisterbuttonhtml = $this->output->render($unregisterbutton);
|
||||
|
||||
//add button cells
|
||||
$cells = array($hublinkcell, $unregisterbuttonhtml);
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
}
|
||||
+16
-28
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
<?php /// $Id$
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -13,52 +11,42 @@ $search = optional_param('search', '', PARAM_RAW);
|
||||
$replace = optional_param('replace', '', PARAM_RAW);
|
||||
|
||||
###################################################################
|
||||
echo $OUTPUT->header();
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo $OUTPUT->heading('Search and replace text throughout the whole database');
|
||||
print_heading('Search and replace text throughout the whole database');
|
||||
|
||||
|
||||
if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
echo '<div class="mdl-align">';
|
||||
print_simple_box_start('center');
|
||||
echo '<div align="center">';
|
||||
echo '<form action="replace.php" method="post">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo 'Search whole database for: <input type="text" name="search" /><br />';
|
||||
echo 'Replace with this string: <input type="text" name="replace" /><br />';
|
||||
echo '<input type="submit" value="Yes, do it now" /><br />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
print_simple_box_start('center');
|
||||
|
||||
if (!db_replace($search, $replace)) {
|
||||
print_error('erroroccur', debug);
|
||||
error('An error has occured during this process');
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Try to replace some well-known serialised contents (html blocks)
|
||||
echo $OUTPUT->notification('Replacing in html blocks...');
|
||||
$instances = $DB->get_recordset('block_instances', array('blockname' => 'html'));
|
||||
foreach ($instances as $instance) {
|
||||
$blockobject = block_instance('html', $instance);
|
||||
$blockobject->config->text = str_replace($search, $replace, $blockobject->config->text);
|
||||
$blockobject->instance_config_commit();
|
||||
}
|
||||
$instances->close();
|
||||
print_simple_box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
notify('Rebuilding course cache...');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
notify('...finished');
|
||||
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
print_continue('index.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
// index.php - scheduled backup logs
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/backup/lib.php');
|
||||
|
||||
admin_externalpage_setup('reportbackups');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
|
||||
admin_externalpage_setup('reportbackups');
|
||||
echo $OUTPUT->header();
|
||||
require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
|
||||
/// Automated backups aren't active by the site admin
|
||||
/// Scheduled backups are disabled by the server admin
|
||||
if (!empty($CFG->disablescheduledbackups)) {
|
||||
print_error('scheduledbackupsdisabled', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Scheduled backups aren't active by the site admin
|
||||
$backup_config = backup_get_config();
|
||||
if (empty($backup_config->backup_auto_active)) {
|
||||
echo $OUTPUT->notification(get_string('automatedbackupsinactive', 'backup'));
|
||||
if (empty($backup_config->backup_sche_active)) {
|
||||
notify(get_string('scheduledbackupsinactive'));
|
||||
}
|
||||
|
||||
/// Get needed strings
|
||||
@@ -33,18 +41,18 @@
|
||||
$strcourse = get_string("course");
|
||||
$strtimetaken = get_string("timetaken","quiz");
|
||||
$strstatus = get_string("status");
|
||||
$strnext = get_string("backupnext");
|
||||
$strnext = get_string("next");
|
||||
|
||||
/// Decide when to show last execution logs or detailed logs
|
||||
/// Lastlog view
|
||||
if (!$courseid) {
|
||||
echo $OUTPUT->heading($backuploglaststatus);
|
||||
echo $OUTPUT->box_start();
|
||||
print_heading($backuploglaststatus);
|
||||
print_simple_box_start('center');
|
||||
/// Now, get every record from backup_courses
|
||||
$courses = $DB->get_records("backup_courses");
|
||||
$courses = get_records("backup_courses");
|
||||
|
||||
if (!$courses) {
|
||||
echo $OUTPUT->notification(get_string('nologsfound'));
|
||||
notify(get_string('nologsfound'));
|
||||
} else {
|
||||
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
||||
//Print table header
|
||||
@@ -55,7 +63,7 @@
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strnext</font></td></tr>";
|
||||
foreach ($courses as $course) {
|
||||
/// Get the course shortname
|
||||
$coursename = $DB->get_field ("course", "fullname", array("id"=>$course->courseid));
|
||||
$coursename = get_field ("course","fullname","id",$course->courseid);
|
||||
if ($coursename) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\"><a href=\"index.php?courseid=$course->courseid\">".$coursename."</a></font></td>";
|
||||
@@ -77,37 +85,38 @@
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
print_simple_box_end();
|
||||
/// Detailed View !!
|
||||
} else {
|
||||
echo $OUTPUT->heading($backuplogdetailed);
|
||||
print_heading($backuplogdetailed);
|
||||
|
||||
$coursename = $DB->get_field("course", "fullname", array("id"=>"$courseid"));
|
||||
echo $OUTPUT->heading("$strcourse: $coursename");
|
||||
$coursename = get_field("course","fullname","id","$courseid");
|
||||
print_heading("$strcourse: $coursename");
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
print_simple_box_start('center');
|
||||
|
||||
/// First, me get all the distinct backups for that course in backup_log
|
||||
$executions = $DB->get_records_sql("SELECT DISTINCT laststarttime
|
||||
FROM {backup_log}
|
||||
WHERE courseid = ? AND backuptype = ?
|
||||
ORDER BY laststarttime DESC", array($courseid,'scheduledbackup'));
|
||||
$executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid'
|
||||
ORDER BY laststarttime DESC");
|
||||
|
||||
/// Iterate over backup executions
|
||||
if (!$executions) {
|
||||
echo $OUTPUT->notification(get_string('nologsfound'));
|
||||
notify(get_string('nologsfound'));
|
||||
} else {
|
||||
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
||||
foreach($executions as $execution) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\">";
|
||||
echo $OUTPUT->box(userdate($execution->laststarttime));
|
||||
print_simple_box("<center>".userdate($execution->laststarttime)."</center>", "center");
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
$logs = $DB->get_records_sql("SELECT *
|
||||
FROM {backup_log}
|
||||
WHERE courseid = ? AND laststarttime = ? AND backuptype = ?
|
||||
ORDER BY id", array($courseid, $execution->laststarttime,'scheduledbackup'));
|
||||
$logs = get_records_sql("SELECT *
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid' AND
|
||||
laststarttime = '$execution->laststarttime'
|
||||
ORDER BY id");
|
||||
if ($logs) {
|
||||
foreach ($logs as $log) {
|
||||
echo "<tr>";
|
||||
@@ -121,8 +130,9 @@
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('reports', new admin_externalpage('reportbackups', get_string('backups', 'admin'), "$CFG->wwwroot/$CFG->admin/report/backups/index.php",'moodle/backup:backupcourse'));
|
||||
@@ -1,214 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* For a given capability, show what permission it has for every role, and
|
||||
* everywhere that it is overridden.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*/
|
||||
|
||||
/** */
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
|
||||
// Get URL parameters.
|
||||
$capability = optional_param('capability', '', PARAM_CAPABILITY);
|
||||
$roleids = optional_param('roles', array('0'), PARAM_INTEGER);
|
||||
|
||||
// Clean the passed in list of role ids. If 'All' selected as an option, or
|
||||
// if none were selected, do all roles.
|
||||
$allroles = get_all_roles();
|
||||
$cleanedroleids = array();
|
||||
foreach ($roleids as $roleid) {
|
||||
if ($roleid == 0) {
|
||||
$cleanedroleids = array_keys($allroles);
|
||||
break;
|
||||
}
|
||||
if (array_key_exists($roleid, $allroles)) {
|
||||
$cleanedroleids[] = $roleid;
|
||||
}
|
||||
}
|
||||
if (empty($cleanedroleids)) {
|
||||
$cleanedroleids = array_keys($allroles);
|
||||
}
|
||||
|
||||
// Include the required JavaScript.
|
||||
$PAGE->requires->js_init_call('M.report_capability.init', array(get_string('search')));
|
||||
|
||||
// Log.
|
||||
add_to_log(SITEID, "admin", "report capability", "report/capability/index.php?capability=$capability", $capability);
|
||||
|
||||
// Print the header.
|
||||
admin_externalpage_setup('reportcapability');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Prepare the list of capabilities to choose from
|
||||
$allcapabilities = fetch_context_capabilities($systemcontext);
|
||||
$capabilitychoices = array();
|
||||
foreach ($allcapabilities as $cap) {
|
||||
$capabilitychoices[$cap->name] = $cap->name . ': ' . get_capability_string($cap->name);
|
||||
}
|
||||
|
||||
// Prepare the list of roles to choose from
|
||||
$rolechoices = array('0' => get_string('all'));
|
||||
foreach ($allroles as $role) {
|
||||
$rolechoices[$role->id] = $role->name;
|
||||
}
|
||||
if (count($cleanedroleids) == count($allroles)) {
|
||||
// Select 'All', rather than each role individually.
|
||||
$selectedroleids = array('0');
|
||||
} else {
|
||||
$selectedroleids = $cleanedroleids;
|
||||
}
|
||||
|
||||
// Print the settings form.
|
||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
||||
echo '<form method="get" action="." id="settingsform"><div>';
|
||||
echo $OUTPUT->heading(get_string('reportsettings', 'report_capability'));
|
||||
echo '<p id="intro">', get_string('intro', 'report_capability') , '</p>';
|
||||
echo '<p><label for="menucapability"> ' . get_string('capabilitylabel', 'report_capability') . '</label></p>';
|
||||
echo html_writer::select($capabilitychoices, 'capability', $capability, array(''=>'choose'), array('size'=>10));
|
||||
echo '<p><label for="menuroles"> ' . get_string('roleslabel', 'report_capability') . '</label></p>';
|
||||
echo html_writer::select($rolechoices, 'roles[]', $selectedroleids, false, array('size'=>10, 'multiple'=>'multiple'));
|
||||
echo '<p><input type="submit" id="settingssubmit" value="' . get_string('getreport', 'report_capability') . '" /></p>';
|
||||
echo '</div></form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// If we have a capability, generate the report.
|
||||
if ($capability) {
|
||||
|
||||
// Work out the bits needed for the SQL WHERE clauses.
|
||||
$params = array($capability);
|
||||
$sqlroletest = '';
|
||||
if (count($cleanedroleids) != count($allroles)) {
|
||||
list($sqlroletest, $roleparams) = $DB->get_in_or_equal($cleanedroleids);
|
||||
$params = array_merge($params, $roleparams);
|
||||
$sqlroletest = 'AND roleid ' . $sqlroletest;
|
||||
}
|
||||
|
||||
// Get all the role_capabilities rows for this capability - that is, all
|
||||
// role definitions, and all role overrides.
|
||||
$rolecaps = $DB->get_records_sql("
|
||||
SELECT id, roleid, contextid, permission
|
||||
FROM {role_capabilities}
|
||||
WHERE capability = ? $sqlroletest", $params);
|
||||
|
||||
// In order to display a nice tree of contexts, we need to get all the
|
||||
// ancestors of all the contexts in the query we just did.
|
||||
$relevantpaths = $DB->get_records_sql_menu("
|
||||
SELECT DISTINCT con.path, 1
|
||||
FROM {context} con JOIN {role_capabilities} rc ON rc.contextid = con.id
|
||||
WHERE capability = ? $sqlroletest", $params);
|
||||
$requiredcontexts = array($systemcontext->id);
|
||||
foreach ($relevantpaths as $path => $notused) {
|
||||
$requiredcontexts = array_merge($requiredcontexts, explode('/', trim($path, '/')));
|
||||
}
|
||||
$requiredcontexts = array_unique($requiredcontexts);
|
||||
|
||||
// Now load those contexts.
|
||||
list($sqlcontexttest, $contextparams) = $DB->get_in_or_equal($requiredcontexts);
|
||||
$contexts = get_sorted_contexts('ctx.id ' . $sqlcontexttest, $contextparams);
|
||||
|
||||
// Prepare some empty arrays to hold the data we are about to compute.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$contexts[$conid]->children = array();
|
||||
$contexts[$conid]->rolecapabilities = array();
|
||||
}
|
||||
|
||||
// Put the contexts into a tree structure.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$parentcontextid = get_parent_contextid($con);
|
||||
if ($parentcontextid) {
|
||||
$contexts[$parentcontextid]->children[] = $conid;
|
||||
}
|
||||
}
|
||||
|
||||
// Put the role capabilities into the context tree.
|
||||
foreach ($rolecaps as $rolecap) {
|
||||
$contexts[$rolecap->contextid]->rolecapabilities[$rolecap->roleid] = $rolecap->permission;
|
||||
}
|
||||
|
||||
// Fill in any missing rolecaps for the system context.
|
||||
foreach ($cleanedroleids as $roleid) {
|
||||
if (!isset($contexts[$systemcontext->id]->rolecapabilities[$roleid])) {
|
||||
$contexts[$systemcontext->id]->rolecapabilities[$roleid] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
|
||||
// Print the report heading.
|
||||
echo $OUTPUT->heading(get_string('reportforcapability', 'report_capability', get_capability_string($capability)), 2, 'main', 'report');
|
||||
if (count($cleanedroleids) != count($allroles)) {
|
||||
$rolenames = array();
|
||||
foreach ($cleanedroleids as $roleid) {
|
||||
$rolenames[] = $allroles[$roleid]->name;
|
||||
}
|
||||
echo '<p>', get_string('forroles', 'report_capability', implode(', ', $rolenames)), '</p>';
|
||||
}
|
||||
|
||||
// Now, recursively print the contexts, and the role information.
|
||||
print_report_tree($systemcontext->id, $contexts, $allroles);
|
||||
}
|
||||
|
||||
// Footer.
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function print_report_tree($contextid, $contexts, $allroles) {
|
||||
global $CFG;
|
||||
|
||||
// Array for holding lang strings.
|
||||
static $strpermissions = null;
|
||||
if (is_null($strpermissions)) {
|
||||
$strpermissions = array(
|
||||
CAP_INHERIT => get_string('notset','role'),
|
||||
CAP_ALLOW => get_string('allow','role'),
|
||||
CAP_PREVENT => get_string('prevent','role'),
|
||||
CAP_PROHIBIT => get_string('prohibit','role')
|
||||
);
|
||||
}
|
||||
|
||||
// Start the list item, and print the context name as a link to the place to
|
||||
// make changes.
|
||||
if ($contextid == get_system_context()->id) {
|
||||
$url = "$CFG->wwwroot/$CFG->admin/roles/manage.php";
|
||||
$title = get_string('changeroles', 'report_capability');
|
||||
} else {
|
||||
$url = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid";
|
||||
$title = get_string('changeoverrides', 'report_capability');
|
||||
}
|
||||
echo '<h3><a href="' . $url . '" title="' . $title . '">', print_context_name($contexts[$contextid]), '</a></h3>';
|
||||
|
||||
// If there are any role overrides here, print them.
|
||||
if (!empty($contexts[$contextid]->rolecapabilities)) {
|
||||
$rowcounter = 0;
|
||||
echo '<table class="generaltable rolecaps"><tbody>';
|
||||
foreach ($allroles as $role) {
|
||||
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
|
||||
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
|
||||
echo '<tr class="r' . ($rowcounter % 2) . '"><th class="cell">', $role->name,
|
||||
'</th><td class="cell">' . $strpermissions[$permission] . '</td></tr>';
|
||||
$rowcounter++;
|
||||
}
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
|
||||
// After we have done the site context, change the string for CAP_INHERIT
|
||||
// from 'notset' to 'inherit'.
|
||||
$strpermissions[CAP_INHERIT] = get_string('inherit','role');
|
||||
|
||||
// If there are any child contexts, print them recursively.
|
||||
if (!empty($contexts[$contextid]->children)) {
|
||||
echo '<ul>';
|
||||
foreach ($contexts[$contextid]->children as $childcontextid) {
|
||||
echo '<li>';
|
||||
print_report_tree($childcontextid, $contexts, $allroles);
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'report_capability', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package report_capability
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['capabilitylabel'] = 'Capability:';
|
||||
$string['capabilityreport'] = 'Capability report';
|
||||
$string['forroles'] = 'For roles {$a}';
|
||||
$string['getreport'] = 'Get the report';
|
||||
$string['changeoverrides'] = 'Change overrides in this context';
|
||||
$string['changeroles'] = 'Change role definitions';
|
||||
$string['intro'] = 'This report shows, for a particular capability, what permission that capability has in the definition of every role (or a selection of roles), and everywhere in the site where that capability is overridden.';
|
||||
$string['pluginname'] = 'Capability report';
|
||||
$string['reportforcapability'] = 'Report for capability \'{$a}\'';
|
||||
$string['reportsettings'] = 'Report settings';
|
||||
$string['roleslabel'] = 'Roles:';
|
||||
@@ -1,75 +0,0 @@
|
||||
|
||||
M.report_capability = {
|
||||
select: null,
|
||||
input: null,
|
||||
button: null,
|
||||
|
||||
init: function(Y, strsearch) {
|
||||
var context = M.report_capability;
|
||||
|
||||
// Find the form controls.
|
||||
context.select = document.getElementById('menucapability');
|
||||
context.button = document.getElementById('settingssubmit');
|
||||
|
||||
// Create a div to hold the search UI.
|
||||
var div = document.createElement('div');
|
||||
div.id = 'capabilitysearchui';
|
||||
|
||||
// Find the capability search input.
|
||||
var input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.id = 'capabilitysearch';
|
||||
context.input = input;
|
||||
|
||||
// Create a label for the search input.
|
||||
var label = document.createElement('label');
|
||||
label.htmlFor = input.id;
|
||||
label.appendChild(document.createTextNode(strsearch + ' '));
|
||||
|
||||
// Tie it all together
|
||||
div.appendChild(label);
|
||||
div.appendChild(input);
|
||||
context.select.parentNode.insertBefore(div, context.select);
|
||||
Y.on('keyup', context.typed, input);
|
||||
Y.on('change', context.validate, context.select);
|
||||
context.select.options[0].style.display = 'none';
|
||||
context.validate();
|
||||
},
|
||||
|
||||
typed: function() {
|
||||
var context = M.report_capability;
|
||||
|
||||
var filtertext = context.input.value;
|
||||
var options = context.select.options;
|
||||
var onlycapability = -1;
|
||||
for (var i = 1; i < options.length; i++) {
|
||||
if (options[i].text.indexOf(filtertext) >= 0) {
|
||||
options[i].disabled = false;
|
||||
options[i].style.display = 'block';
|
||||
if (onlycapability == -1) {
|
||||
onlycapability = i;
|
||||
} else {
|
||||
onlycapability = -2;
|
||||
}
|
||||
} else {
|
||||
options[i].disabled = true;
|
||||
options[i].selected = false;
|
||||
options[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
if (onlycapability >= 0) {
|
||||
options[onlycapability].selected = true;
|
||||
}
|
||||
if (onlycapability == -1) {
|
||||
context.input.className = "error";
|
||||
} else {
|
||||
context.input.className = "";
|
||||
}
|
||||
context.validate();
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
var context = M.report_capability;
|
||||
context.button.disabled = (context.select.value == '');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('roles', new admin_externalpage('reportcapability', get_string('pluginname', 'report_capability'), "$CFG->wwwroot/$CFG->admin/report/capability/index.php",'moodle/role:manage'));
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// page parameters
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$perpage = optional_param('perpage', 30, PARAM_INT); // how many per page
|
||||
$sort = optional_param('sort', 'timemodified', PARAM_ALPHA);
|
||||
$dir = optional_param('dir', 'DESC', PARAM_ALPHA);
|
||||
|
||||
admin_externalpage_setup('reportconfiglog');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
|
||||
|
||||
$changescount = $DB->count_records('config_log');
|
||||
|
||||
$columns = array('firstname' => get_string('firstname'),
|
||||
'lastname' => get_string('lastname'),
|
||||
'timemodified' => get_string('timemodified', 'report_configlog'),
|
||||
'plugin' => get_string('plugin', 'report_configlog'),
|
||||
'name' => get_string('setting', 'report_configlog'),
|
||||
'value' => get_string('value', 'report_configlog'),
|
||||
'oldvalue' => get_string('oldvalue', 'report_configlog'),
|
||||
);
|
||||
$hcolumns = array();
|
||||
|
||||
|
||||
if (!isset($columns[$sort])) {
|
||||
$sort = 'lastname';
|
||||
}
|
||||
|
||||
foreach ($columns as $column=>$strcolumn) {
|
||||
if ($sort != $column) {
|
||||
$columnicon = '';
|
||||
if ($column == 'lastaccess') {
|
||||
$columndir = 'DESC';
|
||||
} else {
|
||||
$columndir = 'ASC';
|
||||
}
|
||||
} else {
|
||||
$columndir = $dir == 'ASC' ? 'DESC':'ASC';
|
||||
if ($column == 'lastaccess') {
|
||||
$columnicon = $dir == 'ASC' ? 'up':'down';
|
||||
} else {
|
||||
$columnicon = $dir == 'ASC' ? 'down':'up';
|
||||
}
|
||||
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
|
||||
|
||||
}
|
||||
$hcolumns[$column] = "<a href=\"index.php?sort=$column&dir=$columndir&page=$page&perpage=$perpage\">".$strcolumn."</a>$columnicon";
|
||||
}
|
||||
|
||||
$baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
|
||||
echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
|
||||
|
||||
$override = new stdClass();
|
||||
$override->firstname = 'firstname';
|
||||
$override->lastname = 'lastname';
|
||||
$fullnamelanguage = get_string('fullnamedisplay', '', $override);
|
||||
if (($CFG->fullnamedisplay == 'firstname lastname') or
|
||||
($CFG->fullnamedisplay == 'firstname') or
|
||||
($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname' )) {
|
||||
$fullnamedisplay = $hcolumns['firstname'].' / '.$hcolumns['lastname'];
|
||||
} else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname')
|
||||
$fullnamedisplay = $hcolumns['lastname'].' / '.$hcolumns['firstname'];
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']);
|
||||
$table->align = array('left', 'left', 'left', 'left', 'left', 'left');
|
||||
$table->size = array('30%', '10%', '10%', '10%', '20%', '20%');
|
||||
$table->width = '95%';
|
||||
$table->data = array();
|
||||
|
||||
if ($sort == 'firstname' or $sort == 'lastname') {
|
||||
$orderby = "u.$sort $dir";
|
||||
} else {
|
||||
$orderby = "cl.$sort $dir";
|
||||
}
|
||||
|
||||
$ufields = user_picture::fields('u');
|
||||
$sql = "SELECT $ufields,
|
||||
cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue
|
||||
FROM {config_log} cl
|
||||
JOIN {user} u ON u.id = cl.userid
|
||||
ORDER BY $orderby";
|
||||
|
||||
$rs = $DB->get_recordset_sql($sql, array(), $page*$perpage, $perpage);
|
||||
foreach ($rs as $log) {
|
||||
$row = array();
|
||||
$row[] = userdate($log->timemodified);
|
||||
$row[] = fullname($log);
|
||||
if (is_null($log->plugin)) {
|
||||
$row[] = 'core';
|
||||
} else {
|
||||
$row[] = $log->plugin;
|
||||
}
|
||||
$row[] = $log->name;
|
||||
$row[] = s($log->value);
|
||||
$row[] = s($log->oldvalue);
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'report_configlog', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package report_configlog
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['configlog'] = 'Config changes';
|
||||
$string['oldvalue'] = 'Original value';
|
||||
$string['plugin'] = 'Plugin';
|
||||
$string['setting'] = 'Setting';
|
||||
$string['timemodified'] = 'Date';
|
||||
$string['value'] = 'New value';
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('reports', new admin_externalpage('reportconfiglog', get_string('configlog', 'report_configlog'), "$CFG->wwwroot/$CFG->admin/report/configlog/index.php"));
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'report/courseoverview:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user