Compare commits
610 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8e1ad9100 | |||
| f84058a263 | |||
| 03e29fff56 | |||
| 3765c3f098 | |||
| 15125314eb | |||
| 44e6b8ff57 | |||
| c46c673568 | |||
| aa79f99d53 | |||
| ef65eefff8 | |||
| df390ba9f0 | |||
| 2a41529f68 | |||
| e9adc8f6eb | |||
| 22edb9944a | |||
| ceedbe876d | |||
| 213eaa94f6 | |||
| 2acfb396ec | |||
| 936f6706c2 | |||
| 2e3a96e192 | |||
| 417fdfab6b | |||
| 77c9ae457d | |||
| a8fd6146e7 | |||
| 538e680d39 | |||
| ec5f521a59 | |||
| 100308ce24 | |||
| f6fc3616de | |||
| 9a8343cdde | |||
| a4e3607a21 | |||
| 27a2c6bffd | |||
| b6481ac993 | |||
| 2abbe6e2a3 | |||
| 3687ab70bc | |||
| 201159335f | |||
| c3ceb8d218 | |||
| 9df28ce5a3 | |||
| 784c24fde1 | |||
| cf264063c1 | |||
| 3f51ad2a70 | |||
| 6b0b96c581 | |||
| 8190a2911f | |||
| ac30618786 | |||
| e9889abe38 | |||
| c0e1e425be | |||
| 517d606401 | |||
| f3cbcc623d | |||
| be36e2ad1d | |||
| aff1c65c3d | |||
| d96d964425 | |||
| 4f76e7ddf7 | |||
| 393d636e25 | |||
| 2b98c3d5e0 | |||
| 2bd3fc4d03 | |||
| 6b43f50c41 | |||
| 533a766447 | |||
| 59f3144e0a | |||
| ef5a198d1c | |||
| 60e7f2b113 | |||
| 68bc5b7b68 | |||
| 45222fc50f | |||
| 78092d6742 | |||
| a3fe5348ab | |||
| e3f6f30896 | |||
| 50296e134b | |||
| a6c44179e5 | |||
| ab93b02919 | |||
| 07ea543a1c | |||
| 768dd79e1f | |||
| c7f51d2dfe | |||
| ebbc9e717f | |||
| 617027cf84 | |||
| 21dc44b4df | |||
| 922817560c | |||
| 4b9cb37191 | |||
| a4673317a7 | |||
| deba736fbc | |||
| badddcab36 | |||
| be1f4ab759 | |||
| 01bb865997 | |||
| 79f544a45f | |||
| eadbd73918 | |||
| bf9f318ead | |||
| c015236f00 | |||
| 7a3156d001 | |||
| b22eb6a987 | |||
| c7c83663e1 | |||
| 49d85b7cfa | |||
| bc5d53c15c | |||
| 95f780c200 | |||
| 3656becc4a | |||
| 89ba1d6c2b | |||
| cca30c4795 | |||
| c78b71efb6 | |||
| 35a5d3b2fc | |||
| 40638405ea | |||
| a53760ef5a | |||
| 1193e6b023 | |||
| 8c5b86e044 | |||
| 6bc177e912 | |||
| 1f7907dac3 | |||
| 25c53e2b9f | |||
| 83fcca9346 | |||
| ab837e6113 | |||
| 96651cf9ed | |||
| 583c465a3a | |||
| 24f90eedb9 | |||
| 0d81404f9a | |||
| 7ba9375e84 | |||
| 15ffa46a1a | |||
| 38bc3c281a | |||
| 9bb6e09468 | |||
| 77de688b82 | |||
| dd8e618917 | |||
| ea819f2205 | |||
| 05deeaacdb | |||
| 19dd687377 | |||
| f2c12522c3 | |||
| 79a80529f8 | |||
| 70a649e40c | |||
| 38a94e0d39 | |||
| 327c88b76b | |||
| b229f563e5 | |||
| 7769615e76 | |||
| 056d2682a1 | |||
| a103d27e06 | |||
| d9c90952bb | |||
| 89b2800f75 | |||
| e12559481f | |||
| 6761018805 | |||
| 9948122905 | |||
| 308e53f572 | |||
| 3367e3ee1e | |||
| c1979ef02d | |||
| 25a5bd96f9 | |||
| 536c7aa882 | |||
| 534eebdd35 | |||
| e317113746 | |||
| ac473cb811 | |||
| fea115dab3 | |||
| 46306d8a25 | |||
| 2c9b8852f0 | |||
| 413b73ffe3 | |||
| 5bda351ef7 | |||
| e5180a491c | |||
| 5d7b69cd80 | |||
| 4bd293ee63 | |||
| 8252cd2848 | |||
| a35be2f5ef | |||
| 668a9eb90b | |||
| 606e175133 | |||
| 2e214b26f3 | |||
| c24ad72ba0 | |||
| ed26ad33ca | |||
| 9a380fbb53 | |||
| 6893e10840 | |||
| c18a7f9d94 | |||
| 07ca3c6816 | |||
| 9315fd7200 | |||
| 10bc60a163 | |||
| 0f9a1467e2 | |||
| 8b3405e8f2 | |||
| c5b7c1f627 | |||
| cc56539e51 | |||
| ae8da34929 | |||
| 0a6604e525 | |||
| 385e9d72ec | |||
| ae912070ea | |||
| 988f1a05e7 | |||
| b8369f5e9f | |||
| 020f0ffc5b | |||
| 087a329eef | |||
| 39025fe177 | |||
| 473afcbfec | |||
| 1dcb107bd4 | |||
| 7cf9937724 | |||
| f6c6bb4d39 | |||
| 814bce6575 | |||
| f12c714e6f | |||
| 74e78f3ad8 | |||
| 4a7e2298a3 | |||
| 910c941fa8 | |||
| bfb0183f6d | |||
| add39c57dd | |||
| 1b024a0b51 | |||
| 9d12edfcae | |||
| 746f1ac85c | |||
| 8277c39c76 | |||
| fb654f651f | |||
| 494f645bf4 | |||
| a26a8c6a6f | |||
| 27beb68c4b | |||
| 8254083dc9 | |||
| 9b7ac1ea57 | |||
| b214520d8b | |||
| abfe9dbe6e | |||
| 8c75bb5976 | |||
| e78632643c | |||
| f114cff65f | |||
| 3c18677ad1 | |||
| 1a199937f0 | |||
| b39029f718 | |||
| 7cb1a84978 | |||
| 8f7c097a09 | |||
| 5dc47fbbc6 | |||
| bac9a5e95e | |||
| 4a8d589d41 | |||
| ffd06a7394 | |||
| ba55e33828 | |||
| 3fcd1d05b9 | |||
| 29f02f10f0 | |||
| ff555b58be | |||
| 42d1a03acc | |||
| 80a90f8d71 | |||
| 4a225b69bb | |||
| 727242750d | |||
| 454efc509f | |||
| 1bef145b49 | |||
| 1a20976561 | |||
| 2558ce3593 | |||
| ab14ec06d2 | |||
| d072124ba4 | |||
| d9c19266c8 | |||
| cf93662ffe | |||
| 177f14d6f6 | |||
| bdcea1a221 | |||
| 25ebb1df63 | |||
| 39af096daf | |||
| 0ff186d7d7 | |||
| 26a92149cc | |||
| 38961259de | |||
| 528cde2db2 | |||
| 0ca33a3835 | |||
| 2a02a3f0de | |||
| 8445c4724c | |||
| 3e6c1d4d55 | |||
| 2c85a824fc | |||
| 6ce26b03e7 | |||
| ae18165edd | |||
| 5def8d573d | |||
| 41c5f54940 | |||
| 39b5360e69 | |||
| 6409d38377 | |||
| 945df69ff3 | |||
| 16aae71dcd | |||
| 371e83db2d | |||
| f4bc50d2bb | |||
| b32484d582 | |||
| 6750bec6c9 | |||
| 6a8787828e | |||
| 466b23caf7 | |||
| a4d6717aec | |||
| cc50a2fbc4 | |||
| 3345c20e29 | |||
| c06e87a410 | |||
| db005da178 | |||
| cfc9f55ca6 | |||
| 15f0d2ed37 | |||
| a370e4e4fa | |||
| a9e0bc82fb | |||
| ec05915767 | |||
| b5e8919b7c | |||
| 397262e292 | |||
| ea1e93b265 | |||
| 29e42725a4 | |||
| 91c59dbd8e | |||
| 87c8b752ca | |||
| 4fcc689dfc | |||
| 27f31cc626 | |||
| 9660303cc2 | |||
| 9abec7278b | |||
| ba7c14c1a7 | |||
| 97161e5008 | |||
| 25041083d5 | |||
| a1c5868475 | |||
| d4e94648cf | |||
| b651e7bb74 | |||
| d527599fcd | |||
| c1d93d47e9 | |||
| 6160c1721c | |||
| 71472b0a82 | |||
| ba3721d463 | |||
| 1a1f7b0eec | |||
| 0c60b1113e | |||
| 79121602c4 | |||
| ba16180449 | |||
| 01765239b0 | |||
| d65a2b2262 | |||
| 4754c0edd1 | |||
| ec441b6dd0 | |||
| df01a82082 | |||
| 00338d8b94 | |||
| 57e034c094 | |||
| c5b9fe0dda | |||
| 07511dbe6d | |||
| df70dfe4ee | |||
| f872b32778 | |||
| beb807e033 | |||
| 98d17b5bad | |||
| bca840b4bc | |||
| 80406e9dd8 | |||
| f4c5e50440 | |||
| 1382f8a549 | |||
| c372808e97 | |||
| f279137a86 | |||
| 0ad12999d7 | |||
| a390156411 | |||
| b84a272faf | |||
| f2ba68efc1 | |||
| 629ea4957b | |||
| 4c1db5b4ea | |||
| 7ea0f8e519 | |||
| ece057943d | |||
| edb8d49d35 | |||
| 8c23e3f5ff | |||
| 30a39ee2b7 | |||
| c3a68f4496 | |||
| d230fb7bcd | |||
| 0f37e97dc6 | |||
| c33e534dce | |||
| 65814f90c1 | |||
| 3a1380d81a | |||
| 743010f779 | |||
| 5a1a6fc1f0 | |||
| b0022f8d91 | |||
| 838f1bcdf4 | |||
| 014fba4928 | |||
| 32eadaf080 | |||
| dba24103ea | |||
| 0a770d5c6c | |||
| 29775a8e89 | |||
| f2855813c7 | |||
| b5e1c2e748 | |||
| 98c1207c46 | |||
| 3466a42f31 | |||
| 3fc24f1238 | |||
| 2e8ab7269c | |||
| 72ca02b0b2 | |||
| 22a7afd577 | |||
| c281550ce5 | |||
| 4a94bae470 | |||
| 92480bc82b | |||
| 2ff8943027 | |||
| da63c93657 | |||
| 4e184a9ce6 | |||
| 36420f78c1 | |||
| 93e980d52b | |||
| 9e5855cb1a | |||
| f9ba5c5222 | |||
| f79dd3b57d | |||
| f5eec88fb6 | |||
| f5a4f25375 | |||
| d714350a11 | |||
| a021f72a34 | |||
| 32af9814f1 | |||
| bcb785fa9e | |||
| 733bd07b8b | |||
| 19ab387d06 | |||
| 02a03f4fe2 | |||
| 75c92b6306 | |||
| e56ac08a5c | |||
| 0cf31e061b | |||
| 65150b26cd | |||
| e1ad9ae4f5 | |||
| ffa12b8397 | |||
| 890c7fae4e | |||
| 9f2e9b535d | |||
| c7d4a92ccf | |||
| 5bd0e7af9f | |||
| 794fb0e565 | |||
| 998b74a160 | |||
| 9ae0b69f59 | |||
| f4dc83e6e6 | |||
| ca2b2eb8af | |||
| 5399e053d1 | |||
| 6ef4ef1ee5 | |||
| f5a1b068cc | |||
| b9d64ab18f | |||
| 39d106ee76 | |||
| 07373d91a8 | |||
| 633fcef536 | |||
| dde17843e0 | |||
| 2430319b52 | |||
| adabef8bf6 | |||
| 22ea14df25 | |||
| 6867fc94b7 | |||
| 8385249f5b | |||
| 30dc7311ad | |||
| 9784520acb | |||
| d015c2352f | |||
| 35fa620a2e | |||
| 15516e6445 | |||
| 280a641232 | |||
| 14dac82376 | |||
| 06ede85e1f | |||
| 31a43cca97 | |||
| 8ad8b7dba8 | |||
| a09897b4b1 | |||
| 5e00f29019 | |||
| 36f0835e72 | |||
| 259b9d05f3 | |||
| da20cd7b43 | |||
| acb4688d29 | |||
| 471952fe82 | |||
| 0d738689bd | |||
| 7390fdde63 | |||
| 1374c61bb4 | |||
| 98d9209a34 | |||
| 8351ce1bd0 | |||
| b911ab236c | |||
| b4730465e6 | |||
| 78cc7bee62 | |||
| 5d6eafcf10 | |||
| 090e19328e | |||
| 34b5e856b0 | |||
| c44a5d5946 | |||
| b7d7679112 | |||
| 90061a6d95 | |||
| c9c031fc90 | |||
| 64a17788aa | |||
| 0baa1eee59 | |||
| 9f6eeb4abf | |||
| 6a48b42ae8 | |||
| 2dd90f136c | |||
| e6647397b9 | |||
| 07fa10d725 | |||
| 98032d512d | |||
| 389235fb00 | |||
| 656237dd55 | |||
| e3cc5b1a7f | |||
| 0742ea86b2 | |||
| 41f79b5c07 | |||
| ed85c0acd2 | |||
| 9c39028179 | |||
| 9fb4a6300b | |||
| 44c9dc6e7b | |||
| 4af7c9d188 | |||
| 847dee60ce | |||
| b7551bdf23 | |||
| e0be8fd6a3 | |||
| 55e03d1233 | |||
| e391f907af | |||
| bef867a96c | |||
| 4207d47742 | |||
| bd7193c7ac | |||
| 77e4a16c4f | |||
| 7daba2713e | |||
| 03b1be3005 | |||
| 5c8511ecf7 | |||
| 52435228c5 | |||
| c9dc3e5564 | |||
| ffaf18a8c1 | |||
| f5fddc6081 | |||
| 9d5a4e2b7c | |||
| ba9103b2c6 | |||
| 79196c9ed5 | |||
| a572cfe5bd | |||
| 92d7776478 | |||
| 2715f96932 | |||
| 6919d9f790 | |||
| 8be0517692 | |||
| a4b65c11b9 | |||
| 64e711f04b | |||
| e6cf40de78 | |||
| 174f5a0189 | |||
| dd56fd7c64 | |||
| 436f83f8ff | |||
| d03f904759 | |||
| 15a6af91f5 | |||
| 0a23dec07a | |||
| 6f8081bef4 | |||
| c643d3ae06 | |||
| 507ccf1c4b | |||
| 60bc533ee8 | |||
| 42f2b8d0dd | |||
| 84047d1fc9 | |||
| b79ac7e0d6 | |||
| 241ceba38c | |||
| 8e49e0833c | |||
| f6bf9c932d | |||
| 1fb2369b09 | |||
| 4de0925820 | |||
| 81f2a1686a | |||
| 5f509554a5 | |||
| edd5d0693d | |||
| d59a75a841 | |||
| 9b482d1cbe | |||
| ca090f3262 | |||
| 12db898084 | |||
| c79345c0f0 | |||
| d691571218 | |||
| 4e1bb6e10c | |||
| a7e920fbfb | |||
| 7a725d6b59 | |||
| 489c6ef357 | |||
| dbb6157aa1 | |||
| 50467e50c9 | |||
| 85a91fb98e | |||
| 75454e2567 | |||
| 06c09f30e3 | |||
| 26daa23d9d | |||
| 74a2ee73ed | |||
| fca41d2589 | |||
| 6de6a45a10 | |||
| 0f1fac1f1f | |||
| 692134ecd4 | |||
| d7706bac2c | |||
| 391e054c03 | |||
| 71f2316fe6 | |||
| 16d610019a | |||
| 4f5791da64 | |||
| c5e3a242b1 | |||
| 13ad1eaf37 | |||
| 7ca448fa83 | |||
| 37efb4f1ee | |||
| 81bd2292bc | |||
| 8fa13d155d | |||
| 465846f082 | |||
| f68815ffcf | |||
| 67b5d74b2c | |||
| 3d0e3ade75 | |||
| 7d1fb2f6ec | |||
| 227e54d65a | |||
| ee6181b1e7 | |||
| 3962c89bbf | |||
| 59137c2c5b | |||
| b83e494d6f | |||
| 3b2164bdca | |||
| aa54d70440 | |||
| d2d4bccec1 | |||
| f3a3c59f48 | |||
| 3d62a46b26 | |||
| 9aacfedb22 | |||
| 12b734434b | |||
| f9068e531c | |||
| 96506c474a | |||
| 0d66e33da5 | |||
| 934fa3ed6c | |||
| 6743d6c520 | |||
| cf76e10e4a | |||
| c800e31213 | |||
| 23580ddacb | |||
| 827fcdb347 | |||
| 60aaf1dc77 | |||
| fd8fa6f9d0 | |||
| 8adf19eda8 | |||
| a6e29ac6a3 | |||
| 52e184904f | |||
| b8d80c062e | |||
| eb9d692f8b | |||
| a805d653d1 | |||
| fe4a0cfe63 | |||
| d0e3447e43 | |||
| f046221272 | |||
| 42a50a0a45 | |||
| 77335e76e9 | |||
| ddf3e875f3 | |||
| 91fa7abf3d | |||
| b060e5b0b8 | |||
| f9c8746704 | |||
| c629aeabe3 | |||
| 27614a5e5d | |||
| ba32fc0042 | |||
| 87b05ba3e0 | |||
| 728f3c9d08 | |||
| d7dd177eb4 | |||
| 507de745e3 | |||
| bf8ff4889b | |||
| f9112bda35 | |||
| ba63612bfa | |||
| 408612d111 | |||
| 60e837038a | |||
| 4cb05cea9d | |||
| 0960f2f417 | |||
| 09c1e72a56 | |||
| d2455301b7 | |||
| 1be2b904ab | |||
| 337817e669 | |||
| b17a3a5591 | |||
| c44c552efa | |||
| faa297ce6f | |||
| b6225c0f2f | |||
| 50496af78b | |||
| 8fc52ccf46 | |||
| 9f9324f408 | |||
| d4dc367a5b | |||
| 3ede344b5c | |||
| 5c686792c6 | |||
| 91a4b3bd3e | |||
| 1a6a1487f4 | |||
| a5286ae4cc | |||
| 5b97bff526 | |||
| 1c4873ba1b | |||
| 9a8f8cea49 | |||
| c37f03543b | |||
| cd4ca97611 | |||
| 77bfc4ce0f | |||
| 13c53a4a2e | |||
| d3796a2c61 | |||
| 43070e6193 | |||
| d099348e32 | |||
| c4dd3bb86f | |||
| ce8b66c67f | |||
| d38f419d5c | |||
| c102060deb | |||
| 0ae36f6638 | |||
| 3c3d544700 | |||
| c4b491a417 | |||
| 112d3b4962 | |||
| 7bb8ae5911 | |||
| dbe6d9f821 | |||
| 4927443761 | |||
| ac3e0b3c8c |
@@ -94,7 +94,7 @@ $oldversion = "$CFG->release ($CFG->version)";
|
||||
$newversion = "$release ($version)";
|
||||
|
||||
// test environment first
|
||||
if (!check_moodle_environment($version, $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
|
||||
@@ -328,4 +328,118 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.1" requires="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<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" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.2" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<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>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+2
-2
@@ -387,10 +387,10 @@ class generator {
|
||||
.$this->get('number_of_modules')." modules in each section, for each course...");
|
||||
|
||||
list($modules_list_sql, $modules_params) =
|
||||
$DB->get_in_or_equal($this->get('modules_list'), SQL_PARAMS_NAMED, 'param0000', true);
|
||||
$DB->get_in_or_equal($this->get('modules_list'), SQL_PARAMS_NAMED, 'mod', true);
|
||||
|
||||
list($modules_ignored_sql, $ignore_params) =
|
||||
$DB->get_in_or_equal($this->modules_to_ignore, SQL_PARAMS_NAMED, 'param2000', false);
|
||||
$DB->get_in_or_equal($this->modules_to_ignore, SQL_PARAMS_NAMED, 'ignore', false);
|
||||
|
||||
$wheresql = "name $modules_list_sql AND name $modules_ignored_sql";
|
||||
$modules = $DB->get_records_select('modules', $wheresql, array_merge($modules_params, $ignore_params));
|
||||
|
||||
+4
-4
@@ -147,12 +147,12 @@ if (!core_tables_exist()) {
|
||||
}
|
||||
}
|
||||
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($releasenoteslink, 'generalbox releasenoteslink');
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
print_upgrade_reload("index.php?agreelicense=1&lang=$CFG->lang");
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
@@ -229,7 +229,7 @@ if ($version > $CFG->version) { // upgrade
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading("Moodle $release");
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($releasenoteslink);
|
||||
|
||||
@@ -440,7 +440,7 @@ if (!empty($CFG->maintenance_enabled)) {
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/en/Release" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />'.
|
||||
'<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
|
||||
|
||||
@@ -53,11 +53,6 @@ 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();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* 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
|
||||
* @see http://docs.moodle.org/dev/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
|
||||
|
||||
@@ -47,7 +47,7 @@ $error = optional_param('error', '', PARAM_ALPHANUM);
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
if (!empty($error) and $error == 'urlalreadyexist') {
|
||||
throw new moodle_exception('urlalreadyregistered', 'hub',
|
||||
throw new moodle_exception('urlalreadyregistered', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
} else {
|
||||
throw new moodle_exception('wrongtoken', 'hub',
|
||||
throw new moodle_exception('wrongtoken', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
|
||||
@@ -148,12 +148,12 @@ if (empty($cancel) and $unregistration and !$confirm) {
|
||||
$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')) {
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
$hubs = $registrationmanager->get_registered_on_hubs();
|
||||
if (!empty($hubs)) {
|
||||
echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
|
||||
|
||||
@@ -79,13 +79,12 @@
|
||||
$param->extras
|
||||
ORDER BY $param->orderby";
|
||||
}
|
||||
//error_log($sql);
|
||||
|
||||
$courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
echo $OUTPUT->notification(get_string('statsnodata'));
|
||||
echo '</td></tr></table>';echo '<p>after notify</p>';
|
||||
echo '</td></tr></table>';
|
||||
|
||||
} else {
|
||||
if (empty($CFG->gdversion)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/report/customlang/db" VERSION="20101115" COMMENT="XMLDB file for Moodle admin/report/customlang"
|
||||
<XMLDB PATH="admin/report/customlang/db" VERSION="20110419" COMMENT="XMLDB file for Moodle admin/report/customlang"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -30,11 +30,11 @@
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
|
||||
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The checked out version of the plugin, null of the version is unknown" PREVIOUS="name"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The checked out version of the plugin, null if the version is unknown" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
@@ -57,5 +57,18 @@ function xmldb_report_customlang_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2010111500, 'report', 'customlang');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the version field from integer to varchar
|
||||
*/
|
||||
if ($oldversion < 2011041900) {
|
||||
$table = new xmldb_table('report_customlang_components');
|
||||
$field = new xmldb_field('version', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'name');
|
||||
|
||||
$dbman->change_field_type($table, $field);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2011041900, 'report', 'customlang');
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true); // progress bar is used here
|
||||
|
||||
require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/report/customlang/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -45,8 +47,22 @@ if ($action === 'checkout') {
|
||||
if (empty($lng)) {
|
||||
print_error('missingparameter');
|
||||
}
|
||||
report_customlang_utils::checkout($lng);
|
||||
redirect(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)));
|
||||
|
||||
$PAGE->set_cacheable(false); // progress bar is used here
|
||||
$output = $PAGE->get_renderer('report_customlang');
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginname', 'report_customlang'));
|
||||
$progressbar = new progress_bar();
|
||||
$progressbar->create(); // prints the HTML code of the progress bar
|
||||
|
||||
// we may need a bit of extra execution time and memory here
|
||||
@set_time_limit(HOURSECS);
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
report_customlang_utils::checkout($lng, $progressbar);
|
||||
|
||||
echo $output->continue_button(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)), 'get');
|
||||
echo $output->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === 'checkin') {
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['checkin'] = 'Check in strings into disk';
|
||||
$string['checkout'] = 'Check out strings into translator';
|
||||
$string['checkout'] = 'Check out strings into the translator';
|
||||
$string['checkoutdone'] = 'Strings checked out successfully into the translator';
|
||||
$string['checkoutinprogress'] = 'Checking out strings into the translator';
|
||||
$string['confirmcheckin'] = 'You are about to check in modified strings into your local language pack. This will export the customized strings from the translator into the data directory and Moodle will start using the modified strings. Press \'Continue\' button to proceed check in.';
|
||||
$string['customlang:edit'] = 'Edit local translation';
|
||||
$string['customlang:view'] = 'View local translation';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Definition of classes used by Langugae customization admin report
|
||||
* Definition of classes used by language customization admin report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
@@ -33,6 +33,12 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class report_customlang_utils {
|
||||
|
||||
/**
|
||||
* Rough number of strings that are being processed during a full checkout.
|
||||
* This is used to estimate the progress of the checkout.
|
||||
*/
|
||||
const ROUGH_NUMBER_OF_STRINGS = 16500;
|
||||
|
||||
/** @var array cache of {@link self::list_components()} results */
|
||||
protected static $components = null;
|
||||
|
||||
@@ -83,8 +89,9 @@ class report_customlang_utils {
|
||||
* This should be executed each time before going to the translation page
|
||||
*
|
||||
* @param string $lang language code to checkout
|
||||
* @param progress_bar $progressbar optionally, the given progress bar can be updated
|
||||
*/
|
||||
public static function checkout($lang) {
|
||||
public static function checkout($lang, progress_bar $progressbar = null) {
|
||||
global $DB;
|
||||
|
||||
// make sure that all components are registered
|
||||
@@ -107,6 +114,10 @@ class report_customlang_utils {
|
||||
}
|
||||
unset($current);
|
||||
|
||||
// initialize the progress counter - stores the number of processed strings
|
||||
$done = 0;
|
||||
$strinprogress = get_string('checkoutinprogress', 'report_customlang');
|
||||
|
||||
// reload components and fetch their strings
|
||||
$stringman = get_string_manager();
|
||||
$components = $DB->get_records('report_customlang_components');
|
||||
@@ -129,6 +140,12 @@ class report_customlang_utils {
|
||||
$stringlocal = isset($local[$stringid]) ? $local[$stringid] : null;
|
||||
$now = time();
|
||||
|
||||
if (!is_null($progressbar)) {
|
||||
$done++;
|
||||
$donepercent = floor(min($done, self::ROUGH_NUMBER_OF_STRINGS) / self::ROUGH_NUMBER_OF_STRINGS * 100);
|
||||
$progressbar->update_full($donepercent, $strinprogress);
|
||||
}
|
||||
|
||||
if (isset($current[$stringid])) {
|
||||
$needsupdate = false;
|
||||
$currentoriginal = $current[$stringid]->original;
|
||||
@@ -175,6 +192,10 @@ class report_customlang_utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($progressbar)) {
|
||||
$progressbar->update_full(100, get_string('checkoutdone', 'report_customlang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,3 +63,7 @@
|
||||
background-color: #f6f6f6;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
#page-admin-report-customlang-index .continuebutton {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2010120900;
|
||||
$plugin->version = 2011041900;
|
||||
$plugin->requires = 2010120700;
|
||||
|
||||
@@ -151,19 +151,21 @@ function search_spammers($keywords) {
|
||||
$params = array('userid'=>$USER->id);
|
||||
|
||||
$keywordfull = array();
|
||||
$i = 0;
|
||||
foreach ($keywords as $keyword) {
|
||||
$keywordfull[] = $DB->sql_like('description', ':descpat', false);
|
||||
$params['descpat'] = "%$keyword%";
|
||||
$keywordfull2[] = $DB->sql_like('p.summary', ':sumpat', false);
|
||||
$params['sumpat'] = "%$keyword%";
|
||||
$keywordfull[] = $DB->sql_like('description', ':descpat'.$i, false);
|
||||
$params['descpat'.$i] = "%$keyword%";
|
||||
$keywordfull2[] = $DB->sql_like('p.summary', ':sumpat'.$i, false);
|
||||
$params['sumpat'.$i] = "%$keyword%";
|
||||
$i++;
|
||||
}
|
||||
$conditions = '( '.implode(' OR ', $keywordfull).' )';
|
||||
$conditions2 = '( '.implode(' OR ', $keywordfull2).' )';
|
||||
|
||||
$sql = "SELECT * FROM {user} WHERE deleted = 0 AND id <> :userid AND $conditions"; // Exclude oneself
|
||||
$sql2 = "SELECT u.*, p.summary FROM {user} AS u, {post} AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> :userid";
|
||||
$spamusers_desc = $DB->get_recordset_sql($sql);
|
||||
$spamusers_blog = $DB->get_recordset_sql($sql2);
|
||||
$spamusers_desc = $DB->get_recordset_sql($sql, $params);
|
||||
$spamusers_blog = $DB->get_recordset_sql($sql2, $params);
|
||||
|
||||
$keywordlist = implode(', ', $keywords);
|
||||
echo $OUTPUT->box(get_string('spamresult', 'report_spamcleaner').s($keywordlist)).' ...';
|
||||
|
||||
@@ -108,7 +108,7 @@ M.report_spamcleaner = {
|
||||
context.Y = Y;
|
||||
context.me = me;
|
||||
if (Y.one("#removeall_btn")) {
|
||||
Y.on("click", context.del_all, "#removeall_btn");
|
||||
Y.on("click", context.del_all, "#removeall_btn");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,7 +68,11 @@ if (!empty($edit) || !empty($new)) {
|
||||
$settings['name'] = $fromform->name;
|
||||
if (!$instance->readonly) {
|
||||
foreach($configs as $config) {
|
||||
$settings[$config] = $fromform->$config;
|
||||
if (isset($fromform->$config)) {
|
||||
$settings[$config] = $fromform->$config;
|
||||
} else {
|
||||
$settings[$config] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
$success = $instance->set_option($settings);
|
||||
|
||||
+3
-3
@@ -628,7 +628,7 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
|
||||
// Legacy type.
|
||||
$archetype = optional_param('archetype', null, PARAM_RAW);
|
||||
if ($archetype) {
|
||||
if (isset($archetype)) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (isset($archetypes[$archetype])){
|
||||
$this->role->archetype = $archetype;
|
||||
@@ -716,7 +716,6 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
global $OUTPUT;
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
foreach(get_role_archetypes() as $type) {
|
||||
@@ -1143,7 +1142,7 @@ class existing_role_holders extends role_assign_user_selector_base {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params = array_merge($params, $ctxparams);
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
@@ -1317,6 +1316,7 @@ abstract class role_allow_role_page {
|
||||
foreach ($rs as $allow) {
|
||||
$this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true;
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -138,7 +138,7 @@ M.core_role.init_cap_table_filter = function(Y, tableid, contextid) {
|
||||
lastheading = null;
|
||||
|
||||
this.setFilterCookieValue(filtertext);
|
||||
|
||||
|
||||
this.button.set('disabled', (filtertext == ''));
|
||||
|
||||
this.table.all('tr').each(function(row){
|
||||
|
||||
@@ -139,7 +139,7 @@ if ($hassiteconfig
|
||||
400 => '400',
|
||||
500 => '500');
|
||||
$temp->add(new admin_setting_configselect('backup/backup_auto_keep', get_string('keep'), get_string('backupkeephelp'), 1, $keepoptoins));
|
||||
|
||||
|
||||
|
||||
$temp->add(new admin_setting_heading('automatedsettings', get_string('automatedsettings','backup'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', get_string('users'), get_string('backupusershelp'), 1));
|
||||
@@ -152,8 +152,8 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', get_string('generaluserscompletion','backup'), get_string('configgeneraluserscompletion','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', get_string('logs'), get_string('backuplogshelp'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', get_string('generalhistories','backup'), get_string('configgeneralhistories','backup'), 0));
|
||||
|
||||
|
||||
|
||||
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0));
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0));
|
||||
|
||||
|
||||
@@ -52,13 +52,22 @@ if (!during_initial_install()) { //do not use during installation
|
||||
$temp->add(new admin_setting_configtext('coursesperpage', get_string('coursesperpage', 'admin'), get_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
|
||||
|
||||
// front page default role
|
||||
$roleoptions = array(0=>get_string('none')); // roles to choose from
|
||||
if ($roles = get_all_roles()) {
|
||||
foreach ($roles as $role) {
|
||||
$roleoptions[$role->id] = strip_tags(format_string($role->name, true));
|
||||
$options = array(0=>get_string('none')); // roles to choose from
|
||||
$defaultfrontpageroleid = 0;
|
||||
foreach (get_all_roles() as $role) {
|
||||
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
|
||||
$options[$role->id] = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
if ($role->archetype === 'frontpage') {
|
||||
$defaultfrontpageroleid = $role->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', 0, $roleoptions));
|
||||
if ($defaultfrontpageroleid and (!isset($CFG->defaultfrontpageroleid) or $CFG->defaultfrontpageroleid)) {
|
||||
//frotpage role may not exist in old upgraded sites
|
||||
unset($options[0]);
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', $defaultfrontpageroleid, $options));
|
||||
|
||||
|
||||
$ADMIN->add('frontpage', $temp);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ if ($hassiteconfig) {
|
||||
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_string_manager()->get_list_of_translations())); // $CFG->lang might be set in installer already, default en is in setup.php
|
||||
$temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1));
|
||||
$temp->add(new admin_setting_langlist());
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('langcache_desc', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('langstringcache', get_string('langstringcache', 'admin'), get_string('configlangstringcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE));
|
||||
$temp->add(new admin_setting_configselect('latinexcelexport', get_string('latinexcelexport', 'admin'), get_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin')));
|
||||
|
||||
@@ -241,6 +241,8 @@ $temp->add(new admin_setting_configselect('extramemorylimit', get_string('extram
|
||||
$temp->add(new admin_setting_configtext('curlcache', get_string('curlcache', 'admin'),
|
||||
get_string('configcurlcache', 'admin'), 120, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_configtext('curltimeoutkbitrate', get_string('curltimeoutkbitrate', 'admin'),
|
||||
get_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
|
||||
/* //TODO: we need to fix code instead of relying on slow rcache, enable this once we have some code that is actually using it
|
||||
$temp->add(new admin_setting_special_selectsetup('cachetype', get_string('cachetype', 'admin'),
|
||||
get_string('configcachetype', 'admin'), '',
|
||||
|
||||
+25
-27
@@ -38,17 +38,18 @@ if ($hassiteconfig
|
||||
if ($ADMIN->fulltree) {
|
||||
if (!during_initial_install()) {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$allroles = array();
|
||||
$generalroles = array();
|
||||
|
||||
$otherroles = array();
|
||||
$guestroles = array();
|
||||
$userroles = array();
|
||||
$studentroles = array();
|
||||
$teacherroles = array();
|
||||
$creatornewroles = array();
|
||||
|
||||
$defaultteacherid = null;
|
||||
$defaultuserid = null;
|
||||
$defaultguestid = null;
|
||||
|
||||
foreach (get_all_roles() as $role) {
|
||||
$rolename = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
$allroles[$role->id] = $rolename;
|
||||
switch ($role->archetype) {
|
||||
case 'manager':
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
@@ -56,58 +57,55 @@ if ($hassiteconfig
|
||||
case 'coursecreator':
|
||||
break;
|
||||
case 'editingteacher':
|
||||
$teacherroles[$role->id] = $rolename;
|
||||
$defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'teacher':
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'student':
|
||||
$studentroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'guest':
|
||||
$defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
|
||||
$guestroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'user':
|
||||
$defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
|
||||
$userroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'frontpage':
|
||||
break;
|
||||
default:
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
$generalroles[$role->id] = $rolename;
|
||||
$otherroles[$role->id] = $rolename;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reset($guestroles);
|
||||
$defaultguestid = key($guestroles);
|
||||
reset($studentroles);
|
||||
$defaultstudentid = key($studentroles);
|
||||
reset($teacherroles);
|
||||
$defaultteacherid = key($teacherroles);
|
||||
if (empty($guestroles)) {
|
||||
$guestroles[0] = get_string('none');
|
||||
$defaultguestid = 0;
|
||||
}
|
||||
|
||||
if ($userroles) {
|
||||
reset($userroles);
|
||||
$defaultuserid = key($userroles);
|
||||
} else {
|
||||
$userroles = array('0'=>get_string('none'));
|
||||
if (empty($userroles)) {
|
||||
$userroles[0] = get_string('none');
|
||||
$defaultuserid = 0;
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
|
||||
get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
|
||||
get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
|
||||
$temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
|
||||
get_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
|
||||
get_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
|
||||
$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
|
||||
get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $generalroles)));
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
|
||||
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
|
||||
get_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
|
||||
|
||||
// release memory
|
||||
unset($otherroles);
|
||||
unset($guestroles);
|
||||
unset($userroles);
|
||||
unset($creatornewroles);
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
|
||||
|
||||
+26
-6
@@ -307,6 +307,9 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
// process templates
|
||||
$user->$field = uu_process_template($formdata->$field, $user);
|
||||
$formdefaults[$field] = true;
|
||||
if (in_array($field, $upt->columns)) {
|
||||
$upt->track($field, s($user->$field), 'normal');
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($PRF_FIELDS as $field) {
|
||||
@@ -465,6 +468,7 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
if (!isset($supportedauths[$user->auth])) {
|
||||
$upt->track('auth', $struserauthunsupported, 'warning');
|
||||
}
|
||||
$doupdate = true;
|
||||
}
|
||||
$allcolumns = array_merge($STD_FIELDS, $PRF_FIELDS);
|
||||
foreach ($allcolumns as $column) {
|
||||
@@ -614,7 +618,13 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
|
||||
$isinternalauth = $auth->is_internal();
|
||||
|
||||
if ($DB->record_exists('user', array('email'=>$user->email))) {
|
||||
if (empty($user->email)) {
|
||||
$upt->track('email', get_string('invalidemail'), 'error');
|
||||
$upt->track('status', $strusernotaddederror, 'error');
|
||||
$userserrors++;
|
||||
continue;
|
||||
|
||||
} else if ($DB->record_exists('user', array('email'=>$user->email))) {
|
||||
if ($noemailduplicates) {
|
||||
$upt->track('email', $stremailduplicate, 'error');
|
||||
$upt->track('status', $strusernotaddederror, 'error');
|
||||
@@ -765,7 +775,7 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
}
|
||||
}
|
||||
|
||||
$manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend, true);
|
||||
$manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->course = $shortname;
|
||||
@@ -898,12 +908,22 @@ while ($linenum <= $previewrows and $fields = $cir->next()) {
|
||||
$rowcols['status'][] = get_string('missingusername');
|
||||
}
|
||||
|
||||
if (!validate_email($rowcols['email'])) {
|
||||
$rowcols['status'][] = get_string('invalidemail');
|
||||
if (isset($rowcols['email'])) {
|
||||
if (!validate_email($rowcols['email'])) {
|
||||
$rowcols['status'][] = get_string('invalidemail');
|
||||
}
|
||||
if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
|
||||
$rowcols['status'][] = $stremailduplicate;
|
||||
}
|
||||
}
|
||||
if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
|
||||
$rowcols['status'][] = $stremailduplicate;
|
||||
|
||||
if (isset($rowcols['city'])) {
|
||||
$rowcols['city'] = trim($rowcols['city']);
|
||||
if (empty($rowcols['city'])) {
|
||||
$rowcols['status'][] = get_string('fieldrequired', 'error', 'city');
|
||||
}
|
||||
}
|
||||
|
||||
$rowcols['status'] = implode('<br />', $rowcols['status']);
|
||||
$data[] = $rowcols;
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
} else {
|
||||
$mform->setDefault('city', $CFG->defaultcity);
|
||||
}
|
||||
$mform->addRule('city', get_string('required'), 'required');
|
||||
|
||||
$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
|
||||
if (empty($CFG->country)) {
|
||||
@@ -408,10 +409,6 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
if (!in_array('email', $columns) and empty($data['email'])) {
|
||||
$errors['email'] = get_string('requiredtemplate', 'admin');
|
||||
}
|
||||
|
||||
if (!in_array('city', $columns) and empty($data['city'])) {
|
||||
$errors['city'] = get_string('required');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
|
||||
+61
-28
@@ -157,14 +157,14 @@ class uu_progress_tracker {
|
||||
|
||||
/**
|
||||
* Validation callback function - verified the column line of csv file.
|
||||
* Converts column names to lowercase too.
|
||||
* Converts standard column names to lowercase.
|
||||
* @param csv_import_reader $cir
|
||||
* @param array standard user fields
|
||||
* @param array custom profile fields
|
||||
* @param array $stdfields standard user fields
|
||||
* @param array $profilefields custom profile fields
|
||||
* @param moodle_url $returnurl return url in case of any error
|
||||
* @return array list of fields
|
||||
*/
|
||||
function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $frofilefields, moodle_url $returnurl) {
|
||||
function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $profilefields, moodle_url $returnurl) {
|
||||
$columns = $cir->get_columns();
|
||||
|
||||
if (empty($columns)) {
|
||||
@@ -178,22 +178,40 @@ function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $fr
|
||||
print_error('csvfewcolumns', 'error', $returnurl);
|
||||
}
|
||||
|
||||
$textlib = textlib_get_instance(); // profile fields may contain unicode chars
|
||||
|
||||
// test columns
|
||||
$processed = array();
|
||||
foreach ($columns as $key=>$unused) {
|
||||
$field = strtolower($columns[$key]); // no unicode expected here, ignore case
|
||||
if (!in_array($field, $stdfields) && !in_array($field, $frofilefields) &&// if not a standard field and not an enrolment field, then we have an error
|
||||
!preg_match('/^course\d+$/', $field) && !preg_match('/^group\d+$/', $field) &&
|
||||
!preg_match('/^type\d+$/', $field) && !preg_match('/^role\d+$/', $field) &&
|
||||
!preg_match('/^enrolperiod\d+$/', $field)) {
|
||||
print_error('invalidfieldname', 'error', $returnurl, $field);
|
||||
}
|
||||
if (in_array($field, $processed)) {
|
||||
$field = $columns[$key];
|
||||
$lcfield = $textlib->strtolower($field);
|
||||
if (in_array($field, $stdfields) or in_array($lcfield, $stdfields)) {
|
||||
// standard fields are only lowercase
|
||||
$newfield = $lcfield;
|
||||
|
||||
} else if (in_array($field, $profilefields)) {
|
||||
// exact profile field name match - these are case sensitive
|
||||
$newfield = $field;
|
||||
|
||||
} else if (in_array($lcfield, $profilefields)) {
|
||||
// hack: somebody wrote uppercase in csv file, but the system knows only lowercase profile field
|
||||
$newfield = $lcfield;
|
||||
|
||||
} else if (preg_match('/^(course|group|type|role|enrolperiod)\d+$/', $lcfield)) {
|
||||
// special fields for enrolments
|
||||
$newfield = $lcfield;
|
||||
|
||||
} else {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('duplicatefieldname', 'error', $returnurl, $field);
|
||||
print_error('invalidfieldname', 'error', $returnurl, $field);
|
||||
}
|
||||
$processed[$key] = $field;
|
||||
if (in_array($newfield, $processed)) {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('duplicatefieldname', 'error', $returnurl, $newfield);
|
||||
}
|
||||
$processed[$key] = $newfield;
|
||||
}
|
||||
|
||||
return $processed;
|
||||
@@ -248,33 +266,48 @@ function uu_process_template($template, $user) {
|
||||
|
||||
if (is_null($result)) {
|
||||
return $template; //error during regex processing??
|
||||
}
|
||||
|
||||
if (is_array($template)) {
|
||||
$template['text'] = $result;
|
||||
return $t;
|
||||
} else {
|
||||
if (array($template)) {
|
||||
$template['text'] = $t;
|
||||
return $t;
|
||||
} else {
|
||||
return $t;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal callback function.
|
||||
*/
|
||||
function uu_process_template_callback($block, $username, $firstname, $lastname) {
|
||||
function uu_process_template_callback($username, $firstname, $lastname, $block) {
|
||||
$textlib = textlib_get_instance();
|
||||
$repl = $block[0];
|
||||
|
||||
switch ($block[3]) {
|
||||
case 'u': $repl = $username; break;
|
||||
case 'f': $repl = $firstname; break;
|
||||
case 'l': $repl = $lastname; break;
|
||||
case 'u':
|
||||
$repl = $username;
|
||||
break;
|
||||
case 'f':
|
||||
$repl = $firstname;
|
||||
break;
|
||||
case 'l':
|
||||
$repl = $lastname;
|
||||
break;
|
||||
default:
|
||||
return $block[0];
|
||||
}
|
||||
|
||||
switch ($block[1]) {
|
||||
case '+': $repl = $textlib->strtoupper($repl); break;
|
||||
case '-': $repl = $textlib->strtolower($repl); break;
|
||||
case '~': $repl = $textlib->strtotitle($repl); break;
|
||||
case '+':
|
||||
$repl = $textlib->strtoupper($repl);
|
||||
break;
|
||||
case '-':
|
||||
$repl = $textlib->strtolower($repl);
|
||||
break;
|
||||
case '~':
|
||||
$repl = $textlib->strtotitle($repl);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($block[2])) {
|
||||
$repl = $textlib->substr($repl, 0 , $block[2]);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ $userid = required_param('userid', PARAM_INT);
|
||||
admin_externalpage_setup('externalserviceusersettings');
|
||||
|
||||
//define nav bar
|
||||
$PAGE->set_url('/' . $CFG->admin . '/webservice/service_user_settings.php',
|
||||
$PAGE->set_url('/' . $CFG->admin . '/webservice/service_user_settings.php',
|
||||
array('id' => $serviceid, 'userid' => $userid));
|
||||
$node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
|
||||
if ($node) {
|
||||
@@ -62,7 +62,7 @@ if ($usersettingsform->is_cancelled()) {
|
||||
$serviceuserinfo->id = $serviceuser->serviceuserid;
|
||||
$serviceuserinfo->iprestriction = $settingsformdata->iprestriction;
|
||||
$serviceuserinfo->validuntil = $settingsformdata->validuntil;
|
||||
|
||||
|
||||
$webservicemanager->update_ws_authorised_user($serviceuserinfo);
|
||||
|
||||
//TODO: assign capability
|
||||
|
||||
@@ -37,7 +37,7 @@ $PAGE->set_url('/' . $CFG->admin . '/webservice/testclient.php');
|
||||
$PAGE->navbar->ignore_active(true);
|
||||
$PAGE->navbar->add(get_string('administrationsite'));
|
||||
$PAGE->navbar->add(get_string('development', 'admin'));
|
||||
$PAGE->navbar->add(get_string('testclient', 'webservice'),
|
||||
$PAGE->navbar->add(get_string('testclient', 'webservice'),
|
||||
new moodle_url('/' . $CFG->admin . '/webservice/testclient.php'));
|
||||
if (!empty($function)) {
|
||||
$PAGE->navbar->add($function);
|
||||
@@ -169,4 +169,4 @@ if ($mform->is_cancelled()) {
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ switch ($action) {
|
||||
die;
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
case 'delete':
|
||||
$token = $webservicemanager->get_created_by_user_ws_token($USER->id, $tokenid);
|
||||
|
||||
//Delete the token
|
||||
|
||||
@@ -290,7 +290,7 @@ class main_view extends XMLDBAction {
|
||||
$o .= ' that seems to be active (true). ENUMs support has been dropped in Moodle 2.0, ' .
|
||||
' the XMLDB Editor will delete any ENUM reference next time you save this file' .
|
||||
' and you MUST provide one upgrade block in your code to drop them from DB. See' .
|
||||
' <a href="http://docs.moodle.org/en/Development:DB_layer_2.0_migration_docs#The_changes">' .
|
||||
' <a href="http://docs.moodle.org/dev/DB_layer_2.0_migration_docs#The_changes">' .
|
||||
' Moodle Docs</a> for more info and examples.';
|
||||
} else {
|
||||
$o .= ' that seem to be inactive (false). ENUMs support has been dropped in Moodle 2.0,' .
|
||||
|
||||
+36
-1
@@ -360,7 +360,7 @@ class auth_plugin_cas extends auth_plugin_ldap {
|
||||
* @return boolean result
|
||||
*/
|
||||
function iscreator($username) {
|
||||
if ((empty($this->config->attrcreators) && empty($this->config->groupecreators)) or empty($this->config->memberattribute)) {
|
||||
if (empty($this->config->host_url) or (empty($this->config->attrcreators) && empty($this->config->groupecreators)) or empty($this->config->memberattribute)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -405,4 +405,39 @@ class auth_plugin_cas extends auth_plugin_ldap {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads user information from LDAP and returns it as array()
|
||||
*
|
||||
* If no LDAP servers are configured, user information has to be
|
||||
* provided via other methods (CSV file, manually, etc.). Return
|
||||
* an empty array so existing user info is not lost. Otherwise,
|
||||
* calls parent class method to get user info.
|
||||
*
|
||||
* @param string $username username
|
||||
* @return mixed array with no magic quotes or false on error
|
||||
*/
|
||||
function get_userinfo($username) {
|
||||
if (empty($this->config->host_url)) {
|
||||
return array();
|
||||
}
|
||||
return parent::get_userinfo($username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncronizes users from LDAP server to moodle user table.
|
||||
*
|
||||
* If no LDAP servers are configured, simply return. Otherwise,
|
||||
* call parent class method to do the work.
|
||||
*
|
||||
* @param bool $do_updates will do pull in data updates from LDAP if relevant
|
||||
* @return nothing
|
||||
*/
|
||||
function sync_users($do_updates=true) {
|
||||
if (empty($this->config->host_url)) {
|
||||
error_log('[AUTH CAS] '.get_string('noldapserver', 'auth_cas'));
|
||||
return;
|
||||
}
|
||||
parent::sync_users($do_updates);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,5 @@ $string['auth_cas_text'] = 'Secure connection';
|
||||
$string['auth_cas_use_cas'] = 'Use CAS';
|
||||
$string['auth_cas_version'] = 'Version of CAS';
|
||||
$string['CASform'] = 'Authentication choice';
|
||||
$string['noldapserver'] = 'No LDAP server configured for CAS! Syncing disabled.';
|
||||
$string['pluginname'] = 'CAS server (SSO)';
|
||||
|
||||
+6
-6
@@ -228,17 +228,17 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
|
||||
// find obsolete users
|
||||
if (count($userlist)) {
|
||||
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u0000', false);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username, u.email, u.auth
|
||||
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', false);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.*
|
||||
FROM {user} u
|
||||
WHERE u.auth=:authtype AND u.deleted=0 AND u.username $notin_sql";
|
||||
} else {
|
||||
$sql = "SELECT u.id, u.username, u.email, u.auth
|
||||
$sql = "SELECT u.*
|
||||
FROM {user} u
|
||||
WHERE u.auth=:authtype AND u.deleted=0";
|
||||
$params = array();
|
||||
$params['authtype'] = $this->authtype;
|
||||
$params['authtype'] = $this->authtype;
|
||||
}
|
||||
$remove_users = $DB->get_records_sql($sql, $params);
|
||||
|
||||
@@ -290,7 +290,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
// only go ahead if we actually
|
||||
// have fields to update locally
|
||||
if (!empty($updatekeys)) {
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u0000', true);
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', true);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username
|
||||
FROM {user} u
|
||||
|
||||
@@ -29,7 +29,7 @@ $string['auth_emailchangepending'] = 'Change pending. Open the link sent to you
|
||||
$string['auth_emailnoemail'] = 'Tried to send you an email but failed!';
|
||||
$string['auth_emailnoinsert'] = 'Could not add your record to the database!';
|
||||
$string['auth_emailnowexists'] = 'The email address you tried to assign to your profile has been assigned to someone else since your original request. Your request for change of email address is hereby cancelled, but you may try again with a different address.';
|
||||
$string['auth_emailrecaptcha'] = 'Adds a visual/audio confirmation form element to the signup page for email self-registering users. This protects your site against spammers and contributes to a worthwhile cause. See http://recaptcha.net/learnmore.html for more details. <br /><em>PHP cURL extension is required.</em>';
|
||||
$string['auth_emailrecaptcha'] = 'Adds a visual/audio confirmation form element to the signup page for email self-registering users. This protects your site against spammers and contributes to a worthwhile cause. See http://www.google.com/recaptcha/learnmore for more details. <br /><em>PHP cURL extension is required.</em>';
|
||||
$string['auth_emailrecaptcha_key'] = 'Enable reCAPTCHA element';
|
||||
$string['auth_emailsettings'] = 'Settings';
|
||||
$string['auth_emailupdate'] = 'Email address update';
|
||||
|
||||
+2
-2
@@ -689,7 +689,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
// Find users in DB that aren't in ldap -- to be removed!
|
||||
// this is still not as scalable (but how often do we mass delete?)
|
||||
if ($this->config->removeuser !== AUTH_REMOVEUSER_KEEP) {
|
||||
$sql = 'SELECT u.id, u.username, u.email, u.auth
|
||||
$sql = 'SELECT u.*
|
||||
FROM {user} u
|
||||
LEFT JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid)
|
||||
WHERE u.auth = ?
|
||||
@@ -1385,7 +1385,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
}
|
||||
}
|
||||
}
|
||||
$moodleattributes['username'] = $this->config->user_attribute;
|
||||
$moodleattributes['username'] = moodle_strtolower(trim($this->config->user_attribute));
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +290,9 @@ class backup_controller extends backup implements loggable {
|
||||
* @return void Throws and exception of completes
|
||||
*/
|
||||
public function execute_plan() {
|
||||
// Basic/initial prevention against time/memory limits
|
||||
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
return $this->plan->execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -296,6 +296,9 @@ class restore_controller extends backup implements loggable {
|
||||
}
|
||||
|
||||
public function execute_plan() {
|
||||
// Basic/initial prevention against time/memory limits
|
||||
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
return $this->plan->execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,15 @@ class backup_course_task extends backup_task {
|
||||
// Generate the enrolment file
|
||||
$this->add_step(new backup_enrolments_structure_step('course_enrolments', 'enrolments.xml'));
|
||||
|
||||
// Annotate the groups used in already annotated groupings
|
||||
$this->add_step(new backup_annotate_groups_from_groupings('annotate_groups'));
|
||||
// Annotate all the groups and groupings belonging to the course
|
||||
$this->add_step(new backup_annotate_course_groups_and_groupings('annotate_course_groups'));
|
||||
|
||||
// Annotate the groups used in already annotated groupings (note this may be
|
||||
// unnecessary now that we are annotating all the course groups and groupings in the
|
||||
// step above. But we keep it working in case we decide, someday, to introduce one
|
||||
// setting to transform the step above into an optional one. This is here to support
|
||||
// course->defaultgroupingid
|
||||
$this->add_step(new backup_annotate_groups_from_groupings('annotate_groups_from_groupings'));
|
||||
|
||||
// Annotate the question_categories belonging to the course context
|
||||
$this->add_step(new backup_calculate_question_categories('course_question_categories'));
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Base class for course report backup plugins.
|
||||
*
|
||||
* NOTE: When you back up a course, it potentially may run backup for all
|
||||
* course reports. In order to control whether a particular report gets
|
||||
* backed up, a course report should make use of the second and third
|
||||
* parameters in get_plugin_element().
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage backup-moodle2
|
||||
* @copyright 2011 onwards The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class backup_coursereport_plugin extends backup_plugin {
|
||||
// Use default parent behaviour
|
||||
}
|
||||
@@ -36,6 +36,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_subplugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_settingslib.php');
|
||||
|
||||
@@ -53,7 +53,12 @@ abstract class backup_qtype_plugin extends backup_plugin {
|
||||
$answers->add_child($answer);
|
||||
|
||||
// Set the sources
|
||||
$answer->set_source_table('question_answers', array('question' => backup::VAR_PARENTID));
|
||||
$answer->set_source_sql('
|
||||
SELECT *
|
||||
FROM {question_answers}
|
||||
WHERE question = :question
|
||||
ORDER BY id',
|
||||
array('question' => backup::VAR_PARENTID));
|
||||
|
||||
// Aliases
|
||||
$answer->set_source_alias('answer', 'answertext');
|
||||
@@ -82,7 +87,12 @@ abstract class backup_qtype_plugin extends backup_plugin {
|
||||
$units->add_child($unit);
|
||||
|
||||
// Set the sources
|
||||
$unit->set_source_table('question_numerical_units', array('question' => backup::VAR_PARENTID));
|
||||
$unit->set_source_sql('
|
||||
SELECT *
|
||||
FROM {question_numerical_units}
|
||||
WHERE question = :question
|
||||
ORDER BY id',
|
||||
array('question' => backup::VAR_PARENTID));
|
||||
|
||||
// don't need to annotate ids nor files
|
||||
}
|
||||
|
||||
@@ -419,6 +419,10 @@ class backup_course_structure_step extends backup_structure_step {
|
||||
// save course data (in case of user theme, legacy theme, etc)
|
||||
$this->add_plugin_structure('theme', $course, true);
|
||||
|
||||
// attach course report plugin structure to $course element; multiple
|
||||
// course reports can save course data if required
|
||||
$this->add_plugin_structure('coursereport', $course, true);
|
||||
|
||||
// attach plagiarism plugin structure to $course element, only one allowed
|
||||
$this->add_plugin_structure('plagiarism', $course, false);
|
||||
|
||||
@@ -1560,6 +1564,32 @@ class backup_activity_grade_items_to_ids extends backup_execution_step {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This step will annotate all the groups and groupings belonging to the course
|
||||
*/
|
||||
class backup_annotate_course_groups_and_groupings extends backup_execution_step {
|
||||
|
||||
protected function define_execution() {
|
||||
global $DB;
|
||||
|
||||
// Get all the course groups
|
||||
if ($groups = $DB->get_records('groups', array(
|
||||
'courseid' => $this->task->get_courseid()))) {
|
||||
foreach ($groups as $group) {
|
||||
backup_structure_dbops::insert_backup_ids_record($this->get_backupid(), 'group', $group->id);
|
||||
}
|
||||
}
|
||||
|
||||
// Get all the course groupings
|
||||
if ($groupings = $DB->get_records('groupings', array(
|
||||
'courseid' => $this->task->get_courseid()))) {
|
||||
foreach ($groupings as $grouping) {
|
||||
backup_structure_dbops::insert_backup_ids_record($this->get_backupid(), 'grouping', $grouping->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This step will annotate all the groups belonging to already annotated groupings
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,7 @@ abstract class restore_activity_task extends restore_task {
|
||||
protected $modulename; // name of the module
|
||||
protected $moduleid; // new (target) id of the course module
|
||||
protected $oldmoduleid; // old (original) id of the course module
|
||||
protected $oldmoduleversion; // old (original) version of the module
|
||||
protected $contextid; // new (target) context of the activity
|
||||
protected $oldcontextid;// old (original) context of the activity
|
||||
protected $activityid; // new (target) id of the activity
|
||||
@@ -43,11 +44,11 @@ abstract class restore_activity_task extends restore_task {
|
||||
* Constructor - instantiates one object of this class
|
||||
*/
|
||||
public function __construct($name, $info, $plan = null) {
|
||||
|
||||
$this->info = $info;
|
||||
$this->modulename = $this->info->modulename;
|
||||
$this->moduleid = 0;
|
||||
$this->oldmoduleid = $this->info->moduleid;
|
||||
$this->oldmoduleversion = 0;
|
||||
$this->contextid = 0;
|
||||
$this->oldcontextid = 0;
|
||||
$this->activityid = 0;
|
||||
@@ -66,6 +67,10 @@ abstract class restore_activity_task extends restore_task {
|
||||
$this->moduleid = $moduleid;
|
||||
}
|
||||
|
||||
public function set_old_moduleversion($oldmoduleversion) {
|
||||
$this->oldmoduleversion = $oldmoduleversion;
|
||||
}
|
||||
|
||||
public function set_activityid($activityid) {
|
||||
$this->activityid = $activityid;
|
||||
}
|
||||
@@ -90,6 +95,10 @@ abstract class restore_activity_task extends restore_task {
|
||||
return $this->moduleid;
|
||||
}
|
||||
|
||||
public function get_old_moduleversion() {
|
||||
return $this->oldmoduleversion;
|
||||
}
|
||||
|
||||
public function get_activityid() {
|
||||
return $this->activityid;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Restore for course plugin: course report.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage backup-moodle2
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class restore_coursereport_plugin extends restore_plugin {
|
||||
// Use default parent behaviour
|
||||
}
|
||||
@@ -41,6 +41,6 @@ abstract class restore_plagiarism_plugin extends restore_plugin {
|
||||
if (!array_key_exists($this->pluginname, $enabledplugins)) {
|
||||
return;
|
||||
}
|
||||
parent::define_plugin_structure($connectionpoint);
|
||||
return parent::define_plugin_structure($connectionpoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,13 @@ require_once($CFG->dirroot . '/backup/moodle2/restore_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_theme_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_coursereport_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_plagiarism_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_subplugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_settingslib.php');
|
||||
|
||||
@@ -80,6 +80,23 @@ abstract class restore_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* after_restore dispatcher for any restore_plugin class
|
||||
*
|
||||
* This method will dispatch execution to the corresponding
|
||||
* after_restore_xxx() method when available, with xxx
|
||||
* being the connection point of the instance, so plugin
|
||||
* classes with multiple connection points will support
|
||||
* multiple after_restore methods, one for each connection point
|
||||
*/
|
||||
public function launch_after_restore_methods() {
|
||||
// Check if the after_restore method exists and launch it
|
||||
$afterrestore = 'after_restore_' . basename($this->connectionpoint->get_path());
|
||||
if (method_exists($this, $afterrestore)) {
|
||||
$this->$afterrestore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns one array with all the decode contents
|
||||
* to be processed by the links decoder
|
||||
|
||||
@@ -273,7 +273,9 @@ class restore_gradebook_structure_step extends restore_structure_step {
|
||||
//$this->set_mapping('grade_setting', $oldid, $newitemid);
|
||||
}
|
||||
|
||||
//put all activity grade items in the correct grade category and mark all for recalculation
|
||||
/**
|
||||
* put all activity grade items in the correct grade category and mark all for recalculation
|
||||
*/
|
||||
protected function after_execute() {
|
||||
global $DB;
|
||||
|
||||
@@ -284,8 +286,15 @@ class restore_gradebook_structure_step extends restore_structure_step {
|
||||
);
|
||||
$rs = $DB->get_recordset('backup_ids_temp', $conditions);
|
||||
|
||||
// We need this for calculation magic later on.
|
||||
$mappings = array();
|
||||
|
||||
if (!empty($rs)) {
|
||||
foreach($rs as $grade_item_backup) {
|
||||
|
||||
// Store the oldid with the new id.
|
||||
$mappings[$grade_item_backup->itemid] = $grade_item_backup->newitemid;
|
||||
|
||||
$updateobj = new stdclass();
|
||||
$updateobj->id = $grade_item_backup->newitemid;
|
||||
|
||||
@@ -301,6 +310,57 @@ class restore_gradebook_structure_step extends restore_structure_step {
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
// We need to update the calculations for calculated grade items that may reference old
|
||||
// grade item ids using ##gi\d+##.
|
||||
// $mappings can be empty, use 0 if so (won't match ever)
|
||||
$mappings = !empty($mappings) ? $mappings : array(0);
|
||||
list($sql, $params) = $DB->get_in_or_equal(array_values($mappings), SQL_PARAMS_NAMED);
|
||||
$sql = "SELECT gi.id, gi.calculation
|
||||
FROM {grade_items} gi
|
||||
WHERE gi.id {$sql} AND
|
||||
calculation IS NOT NULL";
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($rs as $gradeitem) {
|
||||
// Collect all of the used grade item id references
|
||||
if (preg_match_all('/##gi(\d+)##/', $gradeitem->calculation, $matches) < 1) {
|
||||
// This calculation doesn't reference any other grade items... EASY!
|
||||
continue;
|
||||
}
|
||||
// For this next bit we are going to do the replacement of id's in two steps:
|
||||
// 1. We will replace all old id references with a special mapping reference.
|
||||
// 2. We will replace all mapping references with id's
|
||||
// Why do we do this?
|
||||
// Because there potentially there will be an overlap of ids within the query and we
|
||||
// we substitute the wrong id.. safest way around this is the two step system
|
||||
$calculationmap = array();
|
||||
$mapcount = 0;
|
||||
foreach ($matches[1] as $match) {
|
||||
// Check that the old id is known to us, if not it was broken to begin with and will
|
||||
// continue to be broken.
|
||||
if (!array_key_exists($match, $mappings)) {
|
||||
continue;
|
||||
}
|
||||
// Our special mapping key
|
||||
$mapping = '##MAPPING'.$mapcount.'##';
|
||||
// The old id that exists within the calculation now
|
||||
$oldid = '##gi'.$match.'##';
|
||||
// The new id that we want to replace the old one with.
|
||||
$newid = '##gi'.$mappings[$match].'##';
|
||||
// Replace in the special mapping key
|
||||
$gradeitem->calculation = str_replace($oldid, $mapping, $gradeitem->calculation);
|
||||
// And record the mapping
|
||||
$calculationmap[$mapping] = $newid;
|
||||
$mapcount++;
|
||||
}
|
||||
// Iterate all special mappings for this calculation and replace in the new id's
|
||||
foreach ($calculationmap as $mapping => $newid) {
|
||||
$gradeitem->calculation = str_replace($mapping, $newid, $gradeitem->calculation);
|
||||
}
|
||||
// Update the calculation now that its being remapped
|
||||
$DB->update_record('grade_items', $gradeitem);
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
//need to correct the grade category path and parent
|
||||
$conditions = array(
|
||||
'courseid' => $this->get_courseid()
|
||||
@@ -1010,6 +1070,9 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
// Apply for 'theme' plugins optional paths at course level
|
||||
$this->add_plugin_structure('theme', $course);
|
||||
|
||||
// Apply for 'course report' plugins optional paths at course level
|
||||
$this->add_plugin_structure('coursereport', $course);
|
||||
|
||||
// Apply for plagiarism plugins optional paths at course level
|
||||
$this->add_plugin_structure('plagiarism', $course);
|
||||
|
||||
@@ -1797,28 +1860,47 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
}
|
||||
|
||||
protected function process_grade_item($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object)($data);
|
||||
$oldid = $data->id; // We'll need these later
|
||||
$oldparentid = $data->categoryid;
|
||||
$courseid = $this->get_courseid();
|
||||
|
||||
// make sure top course category exists, all grade items will be associated
|
||||
// to it. Later, if restoring the whole gradebook, categories will be introduced
|
||||
$coursecat = grade_category::fetch_course_category($this->get_courseid());
|
||||
$coursecat = grade_category::fetch_course_category($courseid);
|
||||
$coursecatid = $coursecat->id; // Get the categoryid to be used
|
||||
|
||||
$idnumber = null;
|
||||
if (!empty($data->idnumber)) {
|
||||
// Don't get any idnumber from course module. Keep them as they are in grade_item->idnumber
|
||||
// Reason: it's not clear what happens with outcomes->idnumber or activities with multiple items (workshop)
|
||||
// so the best is to keep the ones already in the gradebook
|
||||
// Potential problem: duplicates if same items are restored more than once. :-(
|
||||
// This needs to be fixed in some way (outcomes & activities with multiple items)
|
||||
// $data->idnumber = get_coursemodule_from_instance($data->itemmodule, $data->iteminstance)->idnumber;
|
||||
// In any case, verify always for uniqueness
|
||||
$sql = "SELECT cm.id
|
||||
FROM {course_modules} cm
|
||||
WHERE cm.course = :courseid AND
|
||||
cm.idnumber = :idnumber AND
|
||||
cm.id <> :cmid";
|
||||
$params = array(
|
||||
'courseid' => $courseid,
|
||||
'idnumber' => $data->idnumber,
|
||||
'cmid' => $this->task->get_moduleid()
|
||||
);
|
||||
if (!$DB->record_exists_sql($sql, $params) && !$DB->record_exists('grade_items', array('courseid' => $courseid, 'idnumber' => $data->idnumber))) {
|
||||
$idnumber = $data->idnumber;
|
||||
}
|
||||
}
|
||||
|
||||
unset($data->id);
|
||||
$data->categoryid = $coursecatid;
|
||||
$data->courseid = $this->get_courseid();
|
||||
$data->iteminstance = $this->task->get_activityid();
|
||||
// Don't get any idnumber from course module. Keep them as they are in grade_item->idnumber
|
||||
// Reason: it's not clear what happens with outcomes->idnumber or activities with multiple items (workshop)
|
||||
// so the best is to keep the ones already in the gradebook
|
||||
// Potential problem: duplicates if same items are restored more than once. :-(
|
||||
// This needs to be fixed in some way (outcomes & activities with multiple items)
|
||||
// $data->idnumber = get_coursemodule_from_instance($data->itemmodule, $data->iteminstance)->idnumber;
|
||||
// In any case, verify always for uniqueness
|
||||
$data->idnumber = grade_verify_idnumber($data->idnumber, $this->get_courseid()) ? $data->idnumber : null;
|
||||
$data->idnumber = $idnumber;
|
||||
$data->scaleid = $this->get_mappingid('scale', $data->scaleid);
|
||||
$data->outcomeid = $this->get_mappingid('outcome', $data->outcomeid);
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
@@ -2022,6 +2104,8 @@ class restore_module_structure_step extends restore_structure_step {
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
|
||||
$this->task->set_old_moduleversion($data->version);
|
||||
|
||||
$data->course = $this->task->get_courseid();
|
||||
$data->module = $DB->get_field('modules', 'id', array('name' => $data->modulename));
|
||||
// Map section (first try by course_section mapping match. Useful in course and section restores)
|
||||
@@ -2194,6 +2278,7 @@ abstract class restore_activity_structure_step extends restore_structure_step {
|
||||
/**
|
||||
* As far as activity restore steps are implementing restore_subplugin stuff, they need to
|
||||
* have the parent task available for wrapping purposes (get course/context....)
|
||||
* @return restore_task
|
||||
*/
|
||||
public function get_task() {
|
||||
return $this->task;
|
||||
|
||||
@@ -1340,7 +1340,8 @@ abstract class restore_dbops {
|
||||
$course->sortorder = 0;
|
||||
$course->timecreated = time();
|
||||
$course->timemodified = $course->timecreated;
|
||||
$course->visible = $category->visible;
|
||||
// forcing skeleton courses to be hidden instead of going by $category->visible , until MDL-27790 is resolved.
|
||||
$course->visible = 0;
|
||||
|
||||
$courseid = $DB->insert_record('course', $course);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ abstract class backup_cron_automated_helper {
|
||||
} else if ($state === backup_cron_automated_helper::STATE_RUNNING) {
|
||||
mtrace('RUNNING');
|
||||
if ($rundirective == self::RUN_IMMEDIATELY) {
|
||||
mtrace('automated backups are already. If this script is being run by cron this constitues an error. You will need to increase the time between executions within cron.');
|
||||
mtrace('Automated backups are already running. If this script is being run by cron this constitues an error. You will need to increase the time between executions within cron.');
|
||||
} else {
|
||||
mtrace("automated backup are already running. Execution delayed");
|
||||
}
|
||||
@@ -401,10 +401,19 @@ abstract class backup_cron_automated_helper {
|
||||
if ($active === self::AUTO_BACKUP_DISABLED || ($rundirective == self::RUN_ON_SCHEDULE && $active === self::AUTO_BACKUP_MANUAL)) {
|
||||
return self::STATE_DISABLED;
|
||||
} else if (!empty($config->backup_auto_running)) {
|
||||
// TODO: We should find some way of checking whether the automated
|
||||
// backup has infact finished. In 1.9 this was being done by checking
|
||||
// the log entries.
|
||||
return self::STATE_RUNNING;
|
||||
// Detect if the backup_auto_running semaphore is a valid one
|
||||
// by looking for recent activity in the backup_controllers table
|
||||
// for backups of type backup::MODE_AUTOMATED
|
||||
$timetosee = 60 * 90; // Time to consider in order to clean the semaphore
|
||||
$params = array( 'purpose' => backup::MODE_AUTOMATED, 'timetolook' => (time() - $timetosee));
|
||||
if ($DB->record_exists_select('backup_controllers',
|
||||
"operation = 'backup' AND type = 'course' AND purpose = :purpose AND timemodified > :timetolook", $params)) {
|
||||
return self::STATE_RUNNING; // Recent activity found, still running
|
||||
} else {
|
||||
// No recent activity found, let's clean the semaphore
|
||||
mtrace('Automated backups activity not found in last ' . (int)$timetosee/60 . ' minutes. Cleaning running status');
|
||||
backup_cron_automated_helper::set_state_running(false);
|
||||
}
|
||||
}
|
||||
return self::STATE_OK;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,9 @@ abstract class backup_general_helper extends backup_helper {
|
||||
$rolemappings->modified = false;
|
||||
$rolemappings->mappings = array();
|
||||
$info->role_mappings = $rolemappings;
|
||||
|
||||
// Some initially empty containers
|
||||
$info->sections = array();
|
||||
$info->activities = array();
|
||||
|
||||
// Now the contents
|
||||
$contentsarr = $infoarr['contents'];
|
||||
@@ -164,7 +166,6 @@ abstract class backup_general_helper extends backup_helper {
|
||||
}
|
||||
if (isset($contentsarr['sections']) && isset($contentsarr['sections']['section'])) {
|
||||
$sectionarr = $contentsarr['sections']['section'];
|
||||
$sections = array();
|
||||
foreach ($sectionarr as $section) {
|
||||
$section = (object)$section;
|
||||
$section->settings = array();
|
||||
@@ -174,7 +175,6 @@ abstract class backup_general_helper extends backup_helper {
|
||||
}
|
||||
if (isset($contentsarr['activities']) && isset($contentsarr['activities']['activity'])) {
|
||||
$activityarr = $contentsarr['activities']['activity'];
|
||||
$activities = array();
|
||||
foreach ($activityarr as $activity) {
|
||||
$activity = (object)$activity;
|
||||
$activity->settings = array();
|
||||
|
||||
@@ -360,6 +360,43 @@ abstract class restore_structure_step extends restore_step {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch all the after_restore methods present in all the processing objects
|
||||
*
|
||||
* This method will launch all the after_restore methods that can be defined
|
||||
* both in restore_plugin class
|
||||
*
|
||||
* For restore_plugin classes the name of the method to be executed will be
|
||||
* "after_restore_" + connection point (as far as can be multiple connection
|
||||
* points in the same class)
|
||||
*/
|
||||
public function launch_after_restore_methods() {
|
||||
$alreadylaunched = array(); // To avoid multiple executions
|
||||
foreach ($this->pathelements as $pathelement) {
|
||||
// Get the processing object
|
||||
$pobject = $pathelement->get_processing_object();
|
||||
// Skip null processors (child of grouped ones for sure)
|
||||
if (is_null($pobject)) {
|
||||
continue;
|
||||
}
|
||||
// Skip restore structure step processors (this)
|
||||
if ($pobject instanceof restore_structure_step) {
|
||||
continue;
|
||||
}
|
||||
// Skip already launched processing objects
|
||||
if (in_array($pobject, $alreadylaunched, true)) {
|
||||
continue;
|
||||
}
|
||||
// Add processing object to array of launched ones
|
||||
$alreadylaunched[] = $pobject;
|
||||
// If the processing object has support for
|
||||
// launching after_restore methods, use it
|
||||
if (method_exists($pobject, 'launch_after_restore_methods')) {
|
||||
$pobject->launch_after_restore_methods();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be executed after the whole structure step have been processed
|
||||
*
|
||||
|
||||
@@ -100,6 +100,13 @@ abstract class restore_task extends base_task {
|
||||
* method if available
|
||||
*/
|
||||
public function execute_after_restore() {
|
||||
if ($this->executed) {
|
||||
foreach ($this->steps as $step) {
|
||||
if (method_exists($step, 'launch_after_restore_methods')) {
|
||||
$step->launch_after_restore_methods();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->executed && method_exists($this, 'after_restore')) {
|
||||
$this->after_restore();
|
||||
}
|
||||
|
||||
@@ -130,19 +130,7 @@ class backup_ui extends base_ui {
|
||||
}
|
||||
return $backupid;
|
||||
}
|
||||
/**
|
||||
* Cancels the current backup and redirects the user back to the relevant place
|
||||
*/
|
||||
public function cancel_backup() {
|
||||
global $PAGE;
|
||||
// Determine the approriate URL to redirect the user to
|
||||
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
|
||||
$relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
|
||||
} else {
|
||||
$relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
|
||||
}
|
||||
redirect($relevanturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of progress bar items that can be displayed through the backup renderer.
|
||||
* @return array Array of items for the progress bar
|
||||
|
||||
@@ -81,7 +81,7 @@ class backup_ui_stage_initial extends backup_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
$data = $form->get_data();
|
||||
@@ -180,7 +180,7 @@ class backup_ui_stage_schema extends backup_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it wasn't cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
// Check it has been submit
|
||||
@@ -288,7 +288,7 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it hasn't been cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
$data = $form->get_data();
|
||||
|
||||
@@ -226,6 +226,21 @@ abstract class base_ui {
|
||||
public static function load_controller($uniqueid=false) {
|
||||
throw new coding_exception('load_controller() method needs to be overridden in each subclass of base_ui');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current backup/restore and redirects the user back to the relevant place
|
||||
*/
|
||||
public function cancel_process() {
|
||||
global $PAGE;
|
||||
// Determine the appropriate URL to redirect the user to
|
||||
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
|
||||
$relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
|
||||
} else {
|
||||
$relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
|
||||
}
|
||||
redirect($relevanturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of progress bar items that can be displayed through the backup renderer.
|
||||
* @return array Array of items for the progress bar
|
||||
|
||||
@@ -72,7 +72,7 @@ abstract class restore_search_base implements renderable {
|
||||
*/
|
||||
public function __construct(array $config=array()) {
|
||||
|
||||
$this->search = optional_param($this->get_varsearch(), self::DEFAULT_SEARCH, PARAM_ALPHANUMEXT);
|
||||
$this->search = optional_param($this->get_varsearch(), self::DEFAULT_SEARCH, PARAM_NOTAGS);
|
||||
|
||||
foreach ($config as $name=>$value) {
|
||||
$method = 'set_'.$name;
|
||||
|
||||
@@ -392,7 +392,7 @@ class restore_ui_stage_schema extends restore_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it wasn't cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
// Check it has been submit
|
||||
@@ -500,7 +500,7 @@ class restore_ui_stage_review extends restore_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it hasn't been cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
$data = $form->get_data();
|
||||
|
||||
@@ -1,15 +1,65 @@
|
||||
<?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/>.
|
||||
|
||||
// seems to work...
|
||||
// maybe I should add some pretty icons?
|
||||
// or possibly add the ability to custom-name things?
|
||||
/**
|
||||
* Admin Bookmarks Block page.
|
||||
*
|
||||
* @package block
|
||||
* @subpackage admin_bookmarks
|
||||
* @copyright 2011 Moodle
|
||||
* @author 2006 vinkmar
|
||||
* 2011 Rossiani Wijaya (updated)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The admin bookmarks block class
|
||||
*/
|
||||
class block_admin_bookmarks extends block_base {
|
||||
|
||||
/** @var string */
|
||||
public $blockname = null;
|
||||
|
||||
/** @var bool */
|
||||
protected $contentgenerated = false;
|
||||
|
||||
/** @var bool|null */
|
||||
protected $docked = null;
|
||||
|
||||
/**
|
||||
* Set the initial properties for the block
|
||||
*/
|
||||
function init() {
|
||||
$this->title = get_string('pluginname', 'block_admin_bookmarks');
|
||||
$this->blockname = get_class($this);
|
||||
$this->title = get_string('pluginname', $this->blockname);
|
||||
}
|
||||
|
||||
/**
|
||||
* All multiple instances of this block
|
||||
* @return bool Returns false
|
||||
*/
|
||||
function instance_allow_multiple() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the applicable formats for this block to all
|
||||
* @return array
|
||||
*/
|
||||
function applicable_formats() {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
return array('all' => true);
|
||||
@@ -18,58 +68,59 @@ class block_admin_bookmarks extends block_base {
|
||||
}
|
||||
}
|
||||
|
||||
function preferred_width() {
|
||||
return 210;
|
||||
}
|
||||
|
||||
function create_item($visiblename,$link,$icon) {
|
||||
$this->tempcontent .= '<a href="' . $link . '"><img src="' . $icon . '" alt="" /> ' . $visiblename . '</a><br />' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content for this block
|
||||
*/
|
||||
function get_content() {
|
||||
|
||||
global $CFG, $USER;
|
||||
global $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
// First check if we have already generated, don't waste cycles
|
||||
if ($this->contentgenerated === true) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
if (get_user_preferences('admin_bookmarks')) {
|
||||
// this is expensive! Only require when bookmakrs exist..
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
$adminroot = admin_get_root(false, false); // settings not required - only pages
|
||||
|
||||
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
|
||||
// hmm... just a liiitle (potentially) processor-intensive
|
||||
// (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
|
||||
|
||||
/// Accessibility: markup as a list.
|
||||
$this->content->text .= '<ol class="list">'."\n";
|
||||
|
||||
$contents = array();
|
||||
foreach($bookmarks as $bookmark) {
|
||||
$temp = $adminroot->locate($bookmark);
|
||||
if ($temp instanceof admin_settingpage) {
|
||||
$this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
|
||||
$contenturl = new moodle_url('/admin/settings.php', array('section'=>$bookmark));
|
||||
$contentlink = html_writer::link($contenturl, $temp->visiblename);
|
||||
$contents[] = html_writer::tag('li', $contentlink);
|
||||
} else if ($temp instanceof admin_externalpage) {
|
||||
$this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
|
||||
$contenturl = new moodle_url($temp->url);
|
||||
$contentlink = html_writer::link($contenturl, $temp->visiblename);
|
||||
$contents[] = html_writer::tag('li', $contentlink);
|
||||
}
|
||||
}
|
||||
$this->content->text .= "</ol>\n";
|
||||
$this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list'));
|
||||
} else {
|
||||
$bookmarks = array();
|
||||
}
|
||||
|
||||
if (isset($this->page->section) and $this->page->section == 'search'){
|
||||
$this->content->footer = '';
|
||||
$this->page->settingsnav->initialise();
|
||||
$node = $this->page->settingsnav->get('root', navigation_node::TYPE_SETTING);
|
||||
if (!$node || !$node->contains_active_node()) {
|
||||
return $this->content;
|
||||
}
|
||||
$section = $node->find_active_node()->key;
|
||||
|
||||
if ($section == 'search' || empty($section)){
|
||||
// the search page can't be properly bookmarked at present
|
||||
$this->content->footer = '';
|
||||
} else if (($section = (isset($this->page->section) ? $this->page->section : '')) && (in_array($section, $bookmarks))) {
|
||||
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&sesskey='.sesskey().'">' . get_string('unbookmarkthispage','admin') . '</a>';
|
||||
} else if ($section = (isset($this->page->section) ? $this->page->section : '')) {
|
||||
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&sesskey='.sesskey().'">' . get_string('bookmarkthispage','admin') . '</a>';
|
||||
} else if (in_array($section, $bookmarks)) {
|
||||
$deleteurl = new moodle_url('/blocks/admin_bookmarks/delete.php', array('section'=>$section, 'sesskey'=>sesskey()));
|
||||
$this->content->footer = html_writer::link($deleteurl, get_string('unbookmarkthispage','admin'));
|
||||
} else {
|
||||
$this->content->footer = '';
|
||||
$createurl = new moodle_url('/blocks/admin_bookmarks/create.php', array('section'=>$section, 'sesskey'=>sesskey()));
|
||||
$this->content->footer = html_writer::link($createurl, get_string('bookmarkthispage','admin'));
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -4,6 +4,8 @@ require('../../config.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$PAGE->set_context($context);
|
||||
$adminroot = admin_get_root(false, false); // settings not required - only pages
|
||||
|
||||
if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
|
||||
|
||||
@@ -5,6 +5,8 @@ require('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$PAGE->set_context($context);
|
||||
$adminroot = admin_get_root(false, false); // settings not required - only pages
|
||||
|
||||
if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
<?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 comments block
|
||||
*
|
||||
* @package block
|
||||
* @subpackage comments
|
||||
* @copyright 2009 Dongsheng Cai <dongsheng@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
// Obviously required
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
class block_comments extends block_base {
|
||||
@@ -38,15 +64,17 @@ class block_comments extends block_base {
|
||||
$this->content->footer = '';
|
||||
$this->content->text = '';
|
||||
list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
|
||||
$args = new stdClass();
|
||||
|
||||
$args = new stdClass;
|
||||
$args->context = $PAGE->context;
|
||||
$args->course = $course;
|
||||
$args->area = 'page_comments';
|
||||
$args->itemid = 0;
|
||||
// set 'env' to tell moodle tweak ui for this block
|
||||
$args->env = 'block_comments';
|
||||
$args->component = 'block_comments';
|
||||
$args->linktext = get_string('showcomments');
|
||||
$args->notoggle = true;
|
||||
$args->autostart = true;
|
||||
$args->displaycancel = true;
|
||||
$comment = new comment($args);
|
||||
$comment->set_view_permission(true);
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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 comments block helper functions and callbacks
|
||||
*
|
||||
* @package block
|
||||
* @subpackage comments
|
||||
* @copyright 2011 Dongsheng Cai <dongsheng@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Validate comment parameter before perform other comments actions
|
||||
*
|
||||
* @param stdClass $comment_param {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
* commentarea => string comment area
|
||||
* itemid => int itemid
|
||||
* }
|
||||
* @return boolean
|
||||
*/
|
||||
function comments_comment_validate($comment_param) {
|
||||
if ($comment_param->commentarea != 'page_comments') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($comment_param->itemid != 0) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Running addtional permission check on plugins
|
||||
*
|
||||
* @param stdClass $args
|
||||
* @return array
|
||||
*/
|
||||
function comments_comment_permissions($args) {
|
||||
return array('post'=>true, 'view'=>true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate comment data before displaying comments
|
||||
*
|
||||
* @param stdClass $comment
|
||||
* @param stdClass $args
|
||||
* @return boolean
|
||||
*/
|
||||
function comments_comment_display($comments, $args) {
|
||||
if ($args->commentarea != 'page_comments') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($args->itemid != 0) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
return $comments;
|
||||
}
|
||||
@@ -47,19 +47,34 @@ class block_completionstatus extends block_base {
|
||||
// Create empty content
|
||||
$this->content = new stdClass;
|
||||
|
||||
// Can edit settings?
|
||||
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
|
||||
|
||||
// Get course completion data
|
||||
$info = new completion_info($this->page->course);
|
||||
|
||||
// Don't display if completion isn't enabled!
|
||||
if (!$this->page->course->enablecompletion) {
|
||||
$this->content->text = get_string('completionnotenabled', 'block_completionstatus');
|
||||
if (!completion_info::is_enabled_for_site()) {
|
||||
if ($can_edit) {
|
||||
$this->content->text = get_string('completionnotenabledforsite', 'completion');
|
||||
}
|
||||
return $this->content;
|
||||
|
||||
} else if (!$info->is_enabled()) {
|
||||
if ($can_edit) {
|
||||
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// Load criteria to display
|
||||
$info = new completion_info($this->page->course);
|
||||
$completions = $info->get_completions($USER->id);
|
||||
|
||||
// Check if this course has any criteria
|
||||
if (empty($completions)) {
|
||||
$this->content->text = get_string('nocriteria', 'block_completionstatus');
|
||||
if ($can_edit) {
|
||||
$this->content->text = get_string('nocriteriaset', 'completion');
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -137,7 +152,10 @@ class block_completionstatus extends block_base {
|
||||
$shtml .= '<tr><td>';
|
||||
$shtml .= get_string('activitiescompleted', 'completion');
|
||||
$shtml .= '</td><td style="text-align: right">';
|
||||
$shtml .= $activities_complete.' of '.count($activities);
|
||||
$a = new stdClass();
|
||||
$a->first = $activities_complete;
|
||||
$a->second = count($activities);
|
||||
$shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
|
||||
$shtml .= '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -147,7 +165,10 @@ class block_completionstatus extends block_base {
|
||||
$phtml = '<tr><td>';
|
||||
$phtml .= get_string('prerequisitescompleted', 'completion');
|
||||
$phtml .= '</td><td style="text-align: right">';
|
||||
$phtml .= $prerequisites_complete.' of '.count($prerequisites);
|
||||
$a = new stdClass();
|
||||
$a->first = $prerequisites_complete;
|
||||
$a->second = count($prerequisites);
|
||||
$shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
|
||||
$phtml .= '</td></tr>';
|
||||
|
||||
$shtml = $phtml . $shtml;
|
||||
|
||||
@@ -60,14 +60,11 @@ $can_view = false;
|
||||
// Can view own report
|
||||
if ($USER->id == $user->id) {
|
||||
$can_view = true;
|
||||
}
|
||||
elseif (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
|
||||
} else if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
|
||||
$can_view = true;
|
||||
}
|
||||
elseif (has_capability('coursereport/completion:view', $coursecontext)) {
|
||||
} else if (has_capability('coursereport/completion:view', $coursecontext)) {
|
||||
$can_view = true;
|
||||
}
|
||||
elseif (has_capability('coursereport/completion:view', $personalcontext)) {
|
||||
} else if (has_capability('coursereport/completion:view', $personalcontext)) {
|
||||
$can_view = true;
|
||||
}
|
||||
|
||||
@@ -76,23 +73,31 @@ if (!$can_view) {
|
||||
}
|
||||
|
||||
|
||||
// Load completion data
|
||||
$info = new completion_info($course);
|
||||
|
||||
$returnurl = "{$CFG->wwwroot}/course/view.php?id={$id}";
|
||||
|
||||
// Don't display if completion isn't enabled!
|
||||
if (!$course->enablecompletion) {
|
||||
print_error('completionnotenabled', 'block_completionstatus');
|
||||
if (!$info->is_enabled()) {
|
||||
print_error('completionnotenabled', 'completion', $returnurl);
|
||||
}
|
||||
|
||||
// Load criteria to display
|
||||
$info = new completion_info($course);
|
||||
$completions = $info->get_completions($user->id);
|
||||
|
||||
// Check if this course has any criteria
|
||||
if (empty($completions)) {
|
||||
print_error('nocriteria', 'block_completionstatus');
|
||||
print_error('nocriteriaset', 'completion', $returnurl);
|
||||
}
|
||||
|
||||
// Check this user is enroled
|
||||
if (!$info->is_tracked_user($user->id)) {
|
||||
print_error('notenroled', 'completion');
|
||||
if ($USER->id == $user->id) {
|
||||
print_error('notenroled', 'completion', $returnurl);
|
||||
} else {
|
||||
print_error('usernotenroled', 'completion', $returnurl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +237,7 @@ foreach ($rows as $row) {
|
||||
|
||||
// Is complete
|
||||
echo '<td class="c4">';
|
||||
echo ($row['status'] === 'Yes') ? 'Yes' : 'No';
|
||||
echo ($row['status'] === get_string('yes')) ? get_string('yes') : get_string('no');
|
||||
echo '</td>';
|
||||
|
||||
// Completion data
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
$string['completionnotenabled'] = 'Course completion is not enabled';
|
||||
$string['completionprogressdetails'] = 'Completion progress details';
|
||||
$string['completionstatus'] = 'Course completion status';
|
||||
$string['criteriagroup'] = 'Criteria group';
|
||||
$string['nocriteria'] = 'No criteria have been set for this course';
|
||||
$string['firstofsecond'] = '{$a->first} of {$a->second}';
|
||||
$string['pluginname'] = 'Course completion status';
|
||||
$string['requirement'] = 'Requirement';
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
.block_messages .content {text-align:left;padding-top:5px;}
|
||||
.block_messages .content .list li.listentry {clear:both;}
|
||||
.block_messages .content .list li.listentry div.user {float:left;position:relative;}
|
||||
.block_messages .content .list li.listentry div.message {float:right;}
|
||||
.block_messages .content .footer {clear:both;}
|
||||
.block_messages .content .list li.listentry .user {float:left;position:relative;}
|
||||
.block_messages .content .list li.listentry .message {float:right;}
|
||||
.block_messages .content .info {text-align:center;}
|
||||
.block_messages .content .footer {clear:both;}
|
||||
|
||||
.dir-rtl .block_messages .content .list li.listentry .user {float:right;}
|
||||
.dir-rtl .block_messages .content .list li.listentry .message {float:left;}
|
||||
@@ -35,16 +35,18 @@
|
||||
.ie6 .block_navigation .block_tree .tree_item {width:100%;}
|
||||
|
||||
/** Overide for RTL layout **/
|
||||
.dir-rtl .block_navigation .block_tree {padding-right:0px;}
|
||||
.dir-rtl .block_navigation .block_tree li.item_with_icon > p img {right:0;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree li ul {padding-right:0;}
|
||||
.dir-rtl .block_navigation .block_tree li.depth_2 ul {padding-right:16px;}
|
||||
.dir-rtl .block_navigation .block_tree li.depth_2 ul {padding-left:0;padding-right: 7px;}
|
||||
.dir-rtl .block_navigation .block_tree .tree_item {padding-right: 18px;text-align:right;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree .tree_item.branch {background-position: center right;}
|
||||
.dir-rtl .block_navigation .block_tree .navigation_node.tree_item.branch {padding-right:0;}
|
||||
.dir-rtl .block_navigation .block_tree .root_node.leaf {padding-right:0px;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree,
|
||||
.dir-rtl .block_navigation .block_tree li ul,
|
||||
.dir-rtl .block_navigation .block_tree .navigation_node.tree_item.branch,
|
||||
.dir-rtl .block_navigation .block_tree .root_node.leaf {padding-right:0;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree li.item_with_icon > p img,
|
||||
.dir-rtl .block_navigation .block_tree .type_activity > .tree_item.branch img {right:0;left:auto;}
|
||||
|
||||
.jsenabled.dir-rtl .block_navigation .block_tree .tree_item.emptybranch {background-image: url([[pix:t/collapsed_empty_rtl]]);background-position: center right;}
|
||||
.jsenabled.dir-rtl .block_navigation .block_tree .collapsed .tree_item.branch {background-image: url([[pix:t/collapsed_rtl]]);}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
.block_online_users .content .list li.listentry {clear:both;}
|
||||
.block_online_users .content .list li.listentry div.user {float:left;position:relative;}
|
||||
.block_online_users .content .list li.listentry div.message {float:right;}
|
||||
.block_online_users .content .list li.listentry .user {float:left;position:relative;}
|
||||
.block_online_users .content .list li.listentry .message {float:right;}
|
||||
.block_online_users .content .info {text-align:center;}
|
||||
|
||||
.dir-rtl .block_online_users .content .list li.listentry .user {float:right;}
|
||||
.dir-rtl .block_online_users .content .list li.listentry .message {float:left;}
|
||||
@@ -1,4 +1,6 @@
|
||||
.block_recent_activity .activitydate,
|
||||
.block_recent_activity .activityhead {text-align:center;}
|
||||
.block_recent_activity .unlist li {margin-bottom:1em;}
|
||||
.block_recent_activity li .head .date {float:right;}
|
||||
.block_recent_activity li .head .date {float:right;}
|
||||
|
||||
.dir-rtl .block_recent_activity .content h3 {text-align: right;}
|
||||
@@ -55,14 +55,6 @@
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (!$CFG->enablerssfeeds) {
|
||||
$this->content->text = '';
|
||||
if ($this->page->user_is_editing()) {
|
||||
$this->content->text = get_string('disabledrssfeeds', 'block_rss_client');
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// initalise block content object
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
|
||||
@@ -59,7 +59,8 @@ if ($returnurl) {
|
||||
$urlparams['returnurl'] = $returnurl;
|
||||
$extraparams = '&returnurl=' . $returnurl;
|
||||
}
|
||||
$PAGE->set_url('/blocks/rss_client/managefeeds.php', $urlparams);
|
||||
$baseurl = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
|
||||
$PAGE->set_url($baseurl);
|
||||
|
||||
// Process any actions
|
||||
if ($deleterssid && confirm_sesskey()) {
|
||||
@@ -78,7 +79,7 @@ $feeds = $DB->get_records_select('block_rss_client', $select, null, $DB->sql_ord
|
||||
|
||||
$strmanage = get_string('managefeeds', 'block_rss_client');
|
||||
|
||||
$PAGE->set_pagelayout('base');
|
||||
$PAGE->set_pagelayout('standard');
|
||||
$PAGE->set_title($strmanage);
|
||||
$PAGE->set_heading($strmanage);
|
||||
|
||||
@@ -93,6 +94,7 @@ $table = new flexible_table('rss-display-feeds');
|
||||
|
||||
$table->define_columns(array('feed', 'actions'));
|
||||
$table->define_headers(array(get_string('feed', 'block_rss_client'), get_string('actions', 'moodle')));
|
||||
$table->define_baseurl($baseurl);
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'rssfeeds');
|
||||
|
||||
@@ -40,36 +40,44 @@ class block_selfcompletion extends block_base {
|
||||
}
|
||||
|
||||
public function get_content() {
|
||||
global $USER;
|
||||
global $CFG, $USER;
|
||||
|
||||
// If content is cached
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
global $CFG;
|
||||
|
||||
// Create empty content
|
||||
$this->content = new stdClass;
|
||||
|
||||
// Don't display if completion isn't enabled!
|
||||
if (!$this->page->course->enablecompletion) {
|
||||
$this->content->text = get_string('completionnotenabled', 'block_selfcompletion');
|
||||
return $this->content;
|
||||
}
|
||||
// Can edit settings?
|
||||
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
|
||||
|
||||
// Get course completion data
|
||||
$info = new completion_info($this->page->course);
|
||||
$completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
|
||||
|
||||
// Is course complete?
|
||||
if ($info->is_course_complete($USER->id)) {
|
||||
// Don't display if completion isn't enabled!
|
||||
if (!completion_info::is_enabled_for_site()) {
|
||||
if ($can_edit) {
|
||||
$this->content->text = get_string('completionnotenabledforsite', 'completion');
|
||||
}
|
||||
return $this->content;
|
||||
|
||||
} else if (!$info->is_enabled()) {
|
||||
if ($can_edit) {
|
||||
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// Get this user's data
|
||||
$completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
|
||||
|
||||
// Check if self completion is one of this course's criteria
|
||||
if (empty($completion)) {
|
||||
$this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
|
||||
if ($can_edit) {
|
||||
$this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -79,13 +87,21 @@ class block_selfcompletion extends block_base {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// Check if the user has already marked themselves as complete
|
||||
if ($completion->is_complete()) {
|
||||
// Is course complete?
|
||||
if ($info->is_course_complete($USER->id)) {
|
||||
$this->content->text = get_string('coursealreadycompleted', 'completion');
|
||||
return $this->content;
|
||||
|
||||
// Check if the user has already marked themselves as complete
|
||||
} else if ($completion->is_complete()) {
|
||||
$this->content->text = get_string('alreadyselfcompleted', 'block_selfcompletion');
|
||||
return $this->content;
|
||||
|
||||
// If user is not complete, or has not yet self completed
|
||||
} else {
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/course/togglecompletion.php?course='.$this->page->course->id.'">'.
|
||||
get_string('completecourse', 'block_selfcompletion').'</a>...';
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/course/togglecompletion.php?course='.$this->page->course->id.'">';
|
||||
$this->content->footer .= get_string('completecourse', 'block_selfcompletion').'</a>...';
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['selfcompletion'] = 'Self completion';
|
||||
$string['pluginname'] = 'Self completion';
|
||||
$string['alreadyselfcompleted'] = 'You have already marked yourself as complete in this course';
|
||||
$string['completecourse'] = 'Complete course';
|
||||
$string['completionnotenabled'] = 'Course completion is not enabled';
|
||||
$string['pluginname'] = 'Self completion';
|
||||
$string['selfcompletion'] = 'Self completion';
|
||||
$string['selfcompletionnotenabled'] = 'The self completion criteria has not been enabled for this course';
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
|
||||
/** Overide for RTL layout **/
|
||||
.dir-rtl .block_settings .block_tree {padding-right:0px;}
|
||||
.dir-rtl .block_settings .block_tree li ul {padding-right:16px;}
|
||||
.dir-rtl .block_settings .block_tree li.item_with_icon > p img {right:0;}
|
||||
.dir-rtl .block_settings .block_tree li ul {padding-left:0;padding-right: 7px;}
|
||||
.dir-rtl .block_settings .block_tree li.item_with_icon > p img,
|
||||
.dir-rtl .block_navigation .block_tree .type_activity > .tree_item.branch img {left:auto;right:0;}
|
||||
.dir-rtl .block_settings .block_tree .tree_item {padding-right: 18px;text-align:right;}
|
||||
.dir-rtl .block_settings .block_tree .tree_item.branch {background-position: center right;}
|
||||
.dir-rtl .block_settings .block_tree .root_node.leaf {padding-right:0px;}
|
||||
|
||||
@@ -966,3 +966,65 @@ function blog_get_associated_count($courseid, $cmid=null) {
|
||||
}
|
||||
return $DB->count_records('blog_association', array('contextid' => $context->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Running addtional permission check on plugin, for example, plugins
|
||||
* may have switch to turn on/off comments option, this callback will
|
||||
* affect UI display, not like pluginname_comment_validate only throw
|
||||
* exceptions.
|
||||
* Capability check has been done in comment->check_permissions(), we
|
||||
* don't need to do it again here.
|
||||
*
|
||||
* @param stdClass $comment_param {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
* commentarea => string comment area
|
||||
* itemid => int itemid
|
||||
* }
|
||||
* @return array
|
||||
*/
|
||||
function blog_comment_permissions($comment_param) {
|
||||
return array('post'=>true, 'view'=>true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate comment parameter before perform other comments actions
|
||||
*
|
||||
* @param stdClass $comment {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
* commentarea => string comment area
|
||||
* itemid => int itemid
|
||||
* }
|
||||
* @return boolean
|
||||
*/
|
||||
function blog_comment_validate($comment_param) {
|
||||
global $DB;
|
||||
// validate comment itemid
|
||||
if (!$entry = $DB->get_record('post', array('id'=>$comment_param->itemid))) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
// validate comment area
|
||||
if ($comment_param->commentarea != 'format_blog') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
// validation for comment deletion
|
||||
if (!empty($comment_param->commentid)) {
|
||||
if ($record = $DB->get_record('comments', array('id'=>$comment_param->commentid))) {
|
||||
if ($record->commentarea != 'format_blog') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($record->contextid != $comment_param->context->id) {
|
||||
throw new comment_exception('invalidcontext');
|
||||
}
|
||||
if ($record->itemid != $comment_param->itemid) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
} else {
|
||||
throw new comment_exception('invalidcommentid');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+6
-3
@@ -117,7 +117,7 @@ class blog_entry {
|
||||
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
|
||||
|
||||
$options = array('overflowdiv'=>true);
|
||||
$template['body'] = format_text($this->summary, $this->summaryformat, $options).$cmttext;
|
||||
$template['body'] = format_text($this->summary, $this->summaryformat, $options);
|
||||
$template['title'] = format_string($this->subject);
|
||||
$template['userid'] = $user->id;
|
||||
$template['author'] = fullname($user);
|
||||
@@ -307,6 +307,9 @@ class blog_entry {
|
||||
$contentcell->text .= '</div>';
|
||||
}
|
||||
|
||||
//add comments under everything
|
||||
$contentcell->text .= $cmttext;
|
||||
|
||||
$mainrow->cells[] = $contentcell;
|
||||
$table->data = array($mainrow);
|
||||
|
||||
@@ -517,7 +520,7 @@ class blog_entry {
|
||||
|
||||
} else {
|
||||
if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links
|
||||
$imagereturn .= "<br />" . $OUTPUT->pix_icon($ffurl, $filename);
|
||||
$imagereturn .= '<br /><img src="'.$ffurl.'" alt="" />';
|
||||
} else {
|
||||
$imagereturn .= html_writer::link($ffurl, $image);
|
||||
$imagereturn .= format_text(html_writer::link($ffurl, $filename), FORMAT_HTML, array('context'=>$syscontext));
|
||||
@@ -718,7 +721,7 @@ class blog_listing {
|
||||
global $DB;
|
||||
|
||||
if (empty($this->entries)) {
|
||||
if ($sqlarray = $this->get_entry_fetch_sql()) {
|
||||
if ($sqlarray = $this->get_entry_fetch_sql(false, 'created DESC')) {
|
||||
$this->entries = $DB->get_records_sql($sqlarray['sql'], $sqlarray['params'], $start, $limit);
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -149,7 +149,7 @@ if ($eventid !== 0) {
|
||||
} else {
|
||||
$title = get_string('newevent', 'calendar');
|
||||
calendar_get_allowed_types($formoptions->eventtypes, $USER->id);
|
||||
$event = new calendar_event();
|
||||
$event = new stdClass();
|
||||
$event->action = $action;
|
||||
$event->course = $courseid;
|
||||
$event->timeduration = 0;
|
||||
@@ -171,6 +171,7 @@ if ($eventid !== 0) {
|
||||
$event->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
$event = new calendar_event($event);
|
||||
if (!calendar_add_event_allowed($event)) {
|
||||
print_error('nopermissions');
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ if (empty($CFG->enablecalendarexport)) {
|
||||
}
|
||||
|
||||
//Fetch user information
|
||||
if (!$user = get_complete_user_data('username', $username)) {
|
||||
if (!$user = $DB->get_record('user', array('username' => $username), 'id,password')) {
|
||||
//No such user
|
||||
die('Invalid authentication');
|
||||
}
|
||||
|
||||
+67
-63
@@ -460,8 +460,11 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
|
||||
}
|
||||
}
|
||||
if ($event->modulename == 'assignment'){
|
||||
// create calendar_event to test edit_event capability
|
||||
// this new event will also prevent double creation of calendar_event object
|
||||
$checkevent = new calendar_event($event);
|
||||
// TODO: rewrite this hack somehow
|
||||
if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student
|
||||
if (!calendar_edit_event_allowed($checkevent)){ // cannot manage entries, eg. student
|
||||
if (!$assignment = $DB->get_record('assignment', array('id'=>$event->instance))) {
|
||||
// print_error("invalidid", 'assignment');
|
||||
continue;
|
||||
@@ -1435,16 +1438,18 @@ function calendar_edit_event_allowed($event) {
|
||||
// 2) They have managegroupentries AND are in the group
|
||||
$group = $DB->get_record('groups', array('id'=>$event->groupid));
|
||||
return $group && (
|
||||
has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
|
||||
has_capability('moodle/calendar:manageentries', $event->context) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', $event->context)
|
||||
&& groups_is_member($event->groupid)));
|
||||
} else if (!empty($event->courseid)) {
|
||||
// if groupid is not set, but course is set,
|
||||
// it's definiely a course event
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid));
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
} else if (!empty($event->userid) && $event->userid == $USER->id) {
|
||||
// if course is not set, but userid id set, it's a user event
|
||||
return (has_capability('moodle/calendar:manageownentries', $sitecontext));
|
||||
return (has_capability('moodle/calendar:manageownentries', $event->context));
|
||||
} else if (!empty($event->userid)) {
|
||||
return (has_capability('moodle/calendar:manageentries', $event->context));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1675,7 +1680,7 @@ function calendar_add_event_allowed($event) {
|
||||
|
||||
switch ($event->eventtype) {
|
||||
case 'course':
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid));
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
|
||||
case 'group':
|
||||
// Allow users to add/edit group events if:
|
||||
@@ -1683,24 +1688,21 @@ function calendar_add_event_allowed($event) {
|
||||
// 2) They have managegroupentries AND are in the group
|
||||
$group = $DB->get_record('groups', array('id'=>$event->groupid));
|
||||
return $group && (
|
||||
has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
|
||||
has_capability('moodle/calendar:manageentries', $event->context) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', $event->context)
|
||||
&& groups_is_member($event->groupid)));
|
||||
|
||||
case 'user':
|
||||
if ($event->userid == $USER->id) {
|
||||
return (has_capability('moodle/calendar:manageownentries', $sitecontext));
|
||||
return (has_capability('moodle/calendar:manageownentries', $event->context));
|
||||
}
|
||||
//there is no 'break;' intentionally
|
||||
|
||||
case 'site':
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, SITEID));
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
|
||||
default:
|
||||
if (isset($event->courseid) && $event->courseid > 0) {
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid));
|
||||
}
|
||||
return false;
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1809,6 +1811,9 @@ class calendar_event {
|
||||
$data->format = editors_get_preferred_format();
|
||||
}
|
||||
|
||||
if (empty($data->context)) {
|
||||
$data->context = $this->calculate_context($data);
|
||||
}
|
||||
$this->properties = $data;
|
||||
}
|
||||
|
||||
@@ -1858,6 +1863,39 @@ class calendar_event {
|
||||
return !empty($this->properties->{$key});
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the context value needed for calendar_event.
|
||||
* Event's type can be determine by the available value store in $data
|
||||
* It is important to check for the existence of course/courseid to determine
|
||||
* the course event.
|
||||
* Default value is set to CONTEXT_USER
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function calculate_context(stdClass $data) {
|
||||
global $USER;
|
||||
|
||||
$context = null;
|
||||
if (isset($data->courseid) && $data->courseid > 0) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $data->courseid);
|
||||
} else if (isset($data->course) && $data->course > 0) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $data->course);
|
||||
} else if (isset($data->groupid) && $data->groupid > 0) {
|
||||
$group = $DB->get_record('groups', array('id'=>$data->groupid));
|
||||
$context = get_context_instance(CONTEXT_COURSE, $group->courseid);
|
||||
} else if (isset($data->userid) && $data->userid > 0 && $data->userid == $USER->id) {
|
||||
$context = get_context_instance(CONTEXT_USER);
|
||||
} else if (isset($data->userid) && $data->userid > 0 && $data->userid != $USER->id &&
|
||||
isset($data->instance) && $data->instance > 0) {
|
||||
$cm = get_coursemodule_from_instance($data->modulename, $data->instance, 0, false, MUST_EXIST);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_USER);
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of editoroptions for this event: Called by __get
|
||||
* Please use $blah = $event->editoroptions;
|
||||
@@ -1874,7 +1912,7 @@ class calendar_event {
|
||||
* @return string
|
||||
*/
|
||||
protected function get_description() {
|
||||
global $USER, $CFG;
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
@@ -1883,28 +1921,10 @@ class calendar_event {
|
||||
if ($this->editorcontext === null) {
|
||||
// Switch on the event type to decide upon the appropriate context
|
||||
// to use for this event
|
||||
switch ($this->properties->eventtype) {
|
||||
case 'course':
|
||||
case 'group':
|
||||
// Course and group event files are served from the course context
|
||||
// and there are checks in plugin.php to ensure permissions are
|
||||
// followed
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
break;
|
||||
case 'user':
|
||||
// User context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
break;
|
||||
case 'site':
|
||||
// Site context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
break;
|
||||
default:
|
||||
// Hmmmm some modules use custom eventtype strings, if that is the
|
||||
// case we are going to abandon using files. Anything that uses a
|
||||
// custom type is being added manually through code
|
||||
return clean_text($this->properties->description, $this->properties->format);
|
||||
break;
|
||||
$this->editorcontext = $this->properties->context;
|
||||
if ($this->properties->eventtype != 'user' && $this->properties->eventtype != 'course'
|
||||
&& $this->properties->eventtype != 'site' && $this->properties->eventtype != 'group') {
|
||||
return clean_text($this->properties->description, $this->properties->format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1973,24 +1993,24 @@ class calendar_event {
|
||||
if ($usingeditor) {
|
||||
switch ($this->properties->eventtype) {
|
||||
case 'user':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->courseid = 0;
|
||||
$this->properties->groupid = 0;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
case 'site':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->courseid = SITEID;
|
||||
$this->properties->groupid = 0;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
case 'course':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->groupid = 0;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
case 'group':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
default:
|
||||
@@ -2133,7 +2153,7 @@ class calendar_event {
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($deleterepeated=false) {
|
||||
global $DB, $USER, $CFG;
|
||||
global $DB;
|
||||
|
||||
// If $this->properties->id is not set then something is wrong
|
||||
if (empty($this->properties->id)) {
|
||||
@@ -2146,23 +2166,7 @@ class calendar_event {
|
||||
|
||||
// If the editor context hasn't already been set then set it now
|
||||
if ($this->editorcontext === null) {
|
||||
switch ($this->properties->eventtype) {
|
||||
case 'course':
|
||||
case 'group':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
break;
|
||||
case 'user':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
break;
|
||||
case 'site':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
break;
|
||||
default:
|
||||
// There is a chance we can get here as some modules use there own
|
||||
// eventtype strings. In this case the event has been added by code
|
||||
// and we don't need to worry about it anyway
|
||||
break;
|
||||
}
|
||||
$this->editorcontext = $this->properties->context;
|
||||
}
|
||||
|
||||
// If the context has been set delete all associated files
|
||||
@@ -2224,10 +2228,10 @@ class calendar_event {
|
||||
|
||||
if ($properties->eventtype === 'site') {
|
||||
// Site context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
} else if ($properties->eventtype === 'user') {
|
||||
// User context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
} else if ($properties->eventtype === 'group' || $properties->eventtype === 'course') {
|
||||
// First check the course is valid
|
||||
$course = $DB->get_record('course', array('id'=>$properties->courseid));
|
||||
@@ -2235,7 +2239,7 @@ class calendar_event {
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
// Course context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
// We have a course and are within the course context so we had
|
||||
// better use the courses max bytes value
|
||||
$this->editoroptions['maxbytes'] = $course->maxbytes;
|
||||
@@ -2375,7 +2379,7 @@ class calendar_event {
|
||||
if (!is_object($properties)) {
|
||||
throw new coding_exception('When creating an event properties should be either an object or an assoc array');
|
||||
}
|
||||
$event = new calendar_event();
|
||||
$event = new calendar_event($properties);
|
||||
if ($event->update($properties)) {
|
||||
return $event;
|
||||
} else {
|
||||
|
||||
+3
-4
@@ -40,9 +40,9 @@ M.core_comment = {
|
||||
this.component = args.component;
|
||||
this.courseid = args.courseid;
|
||||
this.contextid = args.contextid;
|
||||
this.env = args.env;
|
||||
this.autostart = (args.autostart);
|
||||
// expand comments?
|
||||
if (args.autostart) {
|
||||
if (this.autostart) {
|
||||
this.view(args.page);
|
||||
}
|
||||
// load comments
|
||||
@@ -115,7 +115,6 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
|
||||
scope = args['scope'];
|
||||
}
|
||||
//params['page'] = args.page?args.page:'';
|
||||
params['env'] = '';
|
||||
// the form element only accept certain file types
|
||||
params['sesskey'] = M.cfg.sesskey;
|
||||
params['action'] = args.action?args.action:'';
|
||||
@@ -347,7 +346,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
|
||||
var d = container.getStyle('display');
|
||||
if (d=='none'||d=='') {
|
||||
// show
|
||||
if (this.env != 'block_comments') {
|
||||
if (!this.autostart) {
|
||||
this.load(page);
|
||||
} else {
|
||||
this.register_delete_buttons();
|
||||
|
||||
+64
-56
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -24,87 +23,96 @@ require_once('../config.php');
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
if (empty($CFG->usecomments)) {
|
||||
throw new comment_exception('commentsnotenabled', 'moodle');
|
||||
}
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_url('/comment/comment_ajax.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
// Allow anonymous user to view comments providing forcelogin now enabled
|
||||
require_course_login($course, true, $cm);
|
||||
$PAGE->set_context($context);
|
||||
if (!empty($cm)) {
|
||||
$PAGE->set_cm($cm, $course);
|
||||
} else if (!empty($course)) {
|
||||
$PAGE->set_course($course);
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
$error = array('error'=>get_string('invalidsesskey'));
|
||||
$error = array('error'=>get_string('invalidsesskey', 'error'));
|
||||
die(json_encode($error));
|
||||
}
|
||||
|
||||
if (!isloggedin()) {
|
||||
// display comments on front page without permission check
|
||||
if ($action == 'get') {
|
||||
if ($context->id == get_context_instance(CONTEXT_COURSE, SITEID)->id) {
|
||||
$ignore_permission = true;
|
||||
} else {
|
||||
// tell user to log in to view comments
|
||||
$ignore_permission = false;
|
||||
echo json_encode(array('error'=>'require_login'));
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
// ignore request
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
$ignore_permission = false;
|
||||
}
|
||||
|
||||
$client_id = required_param('client_id', PARAM_ALPHANUM);
|
||||
$area = optional_param('area', '', PARAM_ALPHAEXT);
|
||||
$client_id = optional_param('client_id', '', PARAM_RAW);
|
||||
$commentid = optional_param('commentid', -1, PARAM_INT);
|
||||
$content = optional_param('content', '', PARAM_RAW);
|
||||
$itemid = optional_param('itemid', '', PARAM_INT);
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
echo $OUTPUT->header(); // send headers
|
||||
|
||||
// initilising comment object
|
||||
if (!empty($client_id)) {
|
||||
$args = new stdClass();
|
||||
$args->context = $context;
|
||||
$args->course = $course;
|
||||
$args->cm = $cm;
|
||||
$args->area = $area;
|
||||
$args->itemid = $itemid;
|
||||
$args->client_id = $client_id;
|
||||
$args->component = $component;
|
||||
// only for comments in frontpage
|
||||
$args->ignore_permission = $ignore_permission;
|
||||
$manager = new comment($args);
|
||||
} else {
|
||||
die;
|
||||
}
|
||||
$args = new stdClass;
|
||||
$args->context = $context;
|
||||
$args->course = $course;
|
||||
$args->cm = $cm;
|
||||
$args->area = $area;
|
||||
$args->itemid = $itemid;
|
||||
$args->client_id = $client_id;
|
||||
$args->component = $component;
|
||||
$manager = new comment($args);
|
||||
|
||||
echo $OUTPUT->header(); // send headers
|
||||
|
||||
// process ajax request
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$result = $manager->add($content);
|
||||
if (!empty($result) && is_object($result)) {
|
||||
$result->count = $manager->count();
|
||||
$result->client_id = $client_id;
|
||||
echo json_encode($result);
|
||||
if ($manager->can_post()) {
|
||||
$result = $manager->add($content);
|
||||
if (!empty($result) && is_object($result)) {
|
||||
$result->count = $manager->count();
|
||||
$result->client_id = $client_id;
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
$result = $manager->delete($commentid);
|
||||
if ($result === true) {
|
||||
echo json_encode(array('client_id'=>$client_id, 'commentid'=>$commentid));
|
||||
$comment_record = $DB->get_record('comments', array('id'=>$commentid));
|
||||
if ($manager->can_delete($commentid) || $comment_record->userid == $USER->id) {
|
||||
if ($manager->delete($commentid)) {
|
||||
$result = array(
|
||||
'client_id' => $client_id,
|
||||
'commentid' => $commentid
|
||||
);
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'get':
|
||||
default:
|
||||
$result = array();
|
||||
$comments = $manager->get_comments($page);
|
||||
$result['list'] = $comments;
|
||||
$result['count'] = $manager->count();
|
||||
$result['pagination'] = $manager->get_pagination($page);
|
||||
$result['client_id'] = $client_id;
|
||||
echo json_encode($result);
|
||||
if ($manager->can_view()) {
|
||||
$comments = $manager->get_comments($page);
|
||||
$result = array(
|
||||
'list' => $comments,
|
||||
'count' => $manager->count(),
|
||||
'pagination' => $manager->get_pagination($page),
|
||||
'client_id' => $client_id
|
||||
);
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isloggedin()) {
|
||||
// tell user to log in to view comments
|
||||
echo json_encode(array('error'=>'require_login'));
|
||||
}
|
||||
// ignore request
|
||||
die;
|
||||
|
||||
+18
-14
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -21,35 +20,40 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
if (empty($CFG->usecomments)) {
|
||||
throw new comment_exception('commentsnotenabled', 'moodle');
|
||||
}
|
||||
|
||||
$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
require_sesskey();
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$area = optional_param('area', '', PARAM_ALPHAEXT);
|
||||
$commentid = optional_param('commentid', -1, PARAM_INT);
|
||||
$content = optional_param('content', '', PARAM_RAW);
|
||||
$itemid = optional_param('itemid', '', PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', '', PARAM_URL);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$area = optional_param('area', '', PARAM_ALPHAEXT);
|
||||
$content = optional_param('content', '', PARAM_RAW);
|
||||
$itemid = optional_param('itemid', '', PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', '/', PARAM_URL);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
$cmt = new stdClass();
|
||||
// Currently this script can only add comments
|
||||
if ($action !== 'add') {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
$cmt = new stdClass;
|
||||
$cmt->contextid = $contextid;
|
||||
$cmt->courseid = $course->id;
|
||||
$cmt->cm = $cm;
|
||||
$cmt->area = $area;
|
||||
$cmt->itemid = $itemid;
|
||||
$cmt->component = $component;
|
||||
$comment = new comment($cmt);
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
if ($comment->can_post()) {
|
||||
$cmt = $comment->add($content);
|
||||
if (!empty($cmt) && is_object($cmt)) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
exit;
|
||||
}
|
||||
|
||||
+6
-3
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once('locallib.php');
|
||||
require_once($CFG->dirroot.'/comment/locallib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('comments', '', null, '', array('pagelayout'=>'report'));
|
||||
@@ -81,8 +81,11 @@ if (!empty($err)) {
|
||||
}
|
||||
if (empty($action)) {
|
||||
echo '<form method="post">';
|
||||
$manager->print_comments($page);
|
||||
echo '<input type="submit" id="comments_delete" name="batchdelete" value="'.get_string('delete').'" />';
|
||||
$return = $manager->print_comments($page);
|
||||
// if no comments available, $return will be false
|
||||
if ($return) {
|
||||
echo '<input type="submit" id="comments_delete" name="batchdelete" value="'.get_string('delete').'" />';
|
||||
}
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
|
||||
+492
-219
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -23,18 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class comment {
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $page;
|
||||
/**
|
||||
* there may be several comment box in one page
|
||||
* so we need a client_id to recognize them
|
||||
* @var integer
|
||||
*/
|
||||
private $cid;
|
||||
private $contextid;
|
||||
/**
|
||||
* commentarea is used to specify different
|
||||
* parts shared the same itemid
|
||||
@@ -46,59 +42,122 @@ class comment {
|
||||
* @var integer
|
||||
*/
|
||||
private $itemid;
|
||||
|
||||
/**
|
||||
* this html snippet will be used as a template
|
||||
* to build comment content
|
||||
* @var string
|
||||
*/
|
||||
private $template;
|
||||
/**
|
||||
* The context id for comments
|
||||
* @var int
|
||||
*/
|
||||
private $contextid;
|
||||
/**
|
||||
* The context itself
|
||||
* @var stdClass
|
||||
*/
|
||||
private $context;
|
||||
/**
|
||||
* The course id for comments
|
||||
* @var int
|
||||
*/
|
||||
private $courseid;
|
||||
/**
|
||||
* course module object, only be used to help find pluginname automatically
|
||||
* if pluginname is specified, it won't be used at all
|
||||
* @var string
|
||||
* @var stdClass
|
||||
*/
|
||||
private $cm;
|
||||
private $plugintype;
|
||||
/**
|
||||
* When used in module, it is recommended to use it
|
||||
* The component that this comment is for. It is STRONGLY recommended to set this.
|
||||
* @var string
|
||||
*/
|
||||
private $component;
|
||||
/**
|
||||
* This is calculated by normalising the component
|
||||
* @var string
|
||||
*/
|
||||
private $pluginname;
|
||||
private $viewcap;
|
||||
private $postcap;
|
||||
/**
|
||||
* to tell comments api where it is used
|
||||
* This is calculated by normalising the component
|
||||
* @var string
|
||||
*/
|
||||
private $env;
|
||||
private $plugintype;
|
||||
/**
|
||||
* Whether the user has the required capabilities/permissions to view comments.
|
||||
* @var bool
|
||||
*/
|
||||
private $viewcap = false;
|
||||
/**
|
||||
* Whether the user has the required capabilities/permissions to post comments.
|
||||
* @var bool
|
||||
*/
|
||||
private $postcap = false;
|
||||
/**
|
||||
* to costomize link text
|
||||
* @var string
|
||||
*/
|
||||
private $linktext;
|
||||
/**
|
||||
* If set to true then comment sections won't be able to be opened and closed
|
||||
* instead they will always be visible.
|
||||
* @var bool
|
||||
*/
|
||||
protected $notoggle = false;
|
||||
/**
|
||||
* If set to true comments are automatically loaded as soon as the page loads.
|
||||
* Normally this happens when the user expands the comment section.
|
||||
* @var bool
|
||||
*/
|
||||
protected $autostart = false;
|
||||
/**
|
||||
* If set to true the total count of comments is displayed when displaying comments.
|
||||
* @var bool
|
||||
*/
|
||||
protected $displaytotalcount = false;
|
||||
/**
|
||||
* If set to true a cancel button will be shown on the form used to submit comments.
|
||||
* @var bool
|
||||
*/
|
||||
protected $displaycancel = false;
|
||||
/**
|
||||
* The number of comments associated with this comments params
|
||||
* @var int
|
||||
*/
|
||||
protected $totalcommentcount = null;
|
||||
|
||||
// static variable will be used by non-js comments UI
|
||||
/**#@+
|
||||
* static variable will be used by non-js comments UI
|
||||
*/
|
||||
private static $nonjs = false;
|
||||
private static $comment_itemid = null;
|
||||
private static $comment_context = null;
|
||||
private static $comment_area = null;
|
||||
private static $comment_page = null;
|
||||
private static $comment_component = null;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Construct function of comment class, initialise
|
||||
* class members
|
||||
* @param object $options
|
||||
* @param stdClass $options
|
||||
* @param object $options {
|
||||
* context => context context to use for the comment [required]
|
||||
* component => string which plugin will comment being added to [required]
|
||||
* itemid => int the id of the associated item (forum post, glossary item etc) [required]
|
||||
* area => string comment area
|
||||
* cm => stdClass course module
|
||||
* course => course course object
|
||||
* client_id => string an unique id to identify comment area
|
||||
* autostart => boolean automatically expend comments
|
||||
* showcount => boolean display the number of comments
|
||||
* displaycancel => boolean display cancel button
|
||||
* notoggle => boolean don't show/hide button
|
||||
* linktext => string title of show/hide button
|
||||
* }
|
||||
*/
|
||||
public function __construct($options) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if (empty($CFG->commentsperpage)) {
|
||||
$CFG->commentsperpage = 15;
|
||||
}
|
||||
|
||||
public function __construct(stdClass $options) {
|
||||
$this->viewcap = false;
|
||||
$this->postcap = false;
|
||||
|
||||
@@ -121,7 +180,11 @@ class comment {
|
||||
}
|
||||
|
||||
if (!empty($options->component)) {
|
||||
// set and validate component
|
||||
$this->set_component($options->component);
|
||||
} else {
|
||||
// component cannot be empty
|
||||
throw new comment_exception('invalidcomponent');
|
||||
}
|
||||
|
||||
// setup course
|
||||
@@ -153,13 +216,6 @@ class comment {
|
||||
$this->itemid = 0;
|
||||
}
|
||||
|
||||
// setup env
|
||||
if (!empty($options->env)) {
|
||||
$this->env = $options->env;
|
||||
} else {
|
||||
$this->env = '';
|
||||
}
|
||||
|
||||
// setup customized linktext
|
||||
if (!empty($options->linktext)) {
|
||||
$this->linktext = $options->linktext;
|
||||
@@ -167,44 +223,46 @@ class comment {
|
||||
$this->linktext = get_string('comments');
|
||||
}
|
||||
|
||||
if (!empty($options->ignore_permission)) {
|
||||
$this->ignore_permission = true;
|
||||
} else {
|
||||
$this->ignore_permission = false;
|
||||
}
|
||||
|
||||
if (!empty($options->showcount)) {
|
||||
$count = $this->count();
|
||||
if (empty($count)) {
|
||||
$this->count = '';
|
||||
} else {
|
||||
$this->count = '('.$count.')';
|
||||
}
|
||||
} else {
|
||||
$this->count = '';
|
||||
}
|
||||
|
||||
// setup options for callback functions
|
||||
$this->args = new stdClass();
|
||||
$this->args->context = $this->context;
|
||||
$this->args->courseid = $this->courseid;
|
||||
$this->args->cm = $this->cm;
|
||||
$this->args->commentarea = $this->commentarea;
|
||||
$this->args->itemid = $this->itemid;
|
||||
$this->comment_param = new stdClass();
|
||||
$this->comment_param->context = $this->context;
|
||||
$this->comment_param->courseid = $this->courseid;
|
||||
$this->comment_param->cm = $this->cm;
|
||||
$this->comment_param->commentarea = $this->commentarea;
|
||||
$this->comment_param->itemid = $this->itemid;
|
||||
|
||||
// setup notoggle
|
||||
if (!empty($options->notoggle)) {
|
||||
$this->set_notoggle($options->notoggle);
|
||||
}
|
||||
|
||||
// setup notoggle
|
||||
if (!empty($options->autostart)) {
|
||||
$this->set_autostart($options->autostart);
|
||||
}
|
||||
|
||||
// setup displaycancel
|
||||
if (!empty($options->displaycancel)) {
|
||||
$this->set_displaycancel($options->displaycancel);
|
||||
}
|
||||
|
||||
// setup displaytotalcount
|
||||
if (!empty($options->showcount)) {
|
||||
$this->set_displaytotalcount($options->showcount);
|
||||
}
|
||||
|
||||
// setting post and view permissions
|
||||
$this->check_permissions();
|
||||
|
||||
// load template
|
||||
$this->template = <<<EOD
|
||||
<div class="comment-userpicture">___picture___</div>
|
||||
<div class="comment-content">
|
||||
___name___ - <span>___time___</span>
|
||||
<div>___content___</div>
|
||||
</div>
|
||||
EOD;
|
||||
$this->template = html_writer::tag('div', '___picture___', array('class' => 'comment-userpicture'));
|
||||
$this->template .= html_writer::start_tag('div', array('class' => 'comment-content'));
|
||||
$this->template .= '___name___ - ';
|
||||
$this->template .= html_writer::tag('span', '___time___');
|
||||
$this->template .= html_writer::tag('div', '___content___');
|
||||
$this->template .= html_writer::end_tag('div'); // .comment-content
|
||||
if (!empty($this->plugintype)) {
|
||||
$this->template = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'template', $this->args, $this->template);
|
||||
$this->template = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'template', array($this->comment_param), $this->template);
|
||||
}
|
||||
|
||||
unset($options);
|
||||
@@ -212,34 +270,63 @@ EOD;
|
||||
|
||||
/**
|
||||
* Receive nonjs comment parameters
|
||||
*
|
||||
* @param moodle_page $page The page object to initialise comments within
|
||||
* If not provided the global $PAGE is used
|
||||
*/
|
||||
public static function init() {
|
||||
global $PAGE, $CFG;
|
||||
public static function init(moodle_page $page = null) {
|
||||
global $PAGE;
|
||||
|
||||
if (empty($page)) {
|
||||
$page = $PAGE;
|
||||
}
|
||||
// setup variables for non-js interface
|
||||
self::$nonjs = optional_param('nonjscomment', '', PARAM_ALPHA);
|
||||
self::$nonjs = optional_param('nonjscomment', '', PARAM_ALPHANUM);
|
||||
self::$comment_itemid = optional_param('comment_itemid', '', PARAM_INT);
|
||||
self::$comment_context = optional_param('comment_context', '', PARAM_INT);
|
||||
self::$comment_page = optional_param('comment_page', '', PARAM_INT);
|
||||
self::$comment_area = optional_param('comment_area', '', PARAM_ALPHAEXT);
|
||||
|
||||
$PAGE->requires->string_for_js('addcomment', 'moodle');
|
||||
$PAGE->requires->string_for_js('deletecomment', 'moodle');
|
||||
$PAGE->requires->string_for_js('comments', 'moodle');
|
||||
$PAGE->requires->string_for_js('commentsrequirelogin', 'moodle');
|
||||
$page->requires->string_for_js('addcomment', 'moodle');
|
||||
$page->requires->string_for_js('deletecomment', 'moodle');
|
||||
$page->requires->string_for_js('comments', 'moodle');
|
||||
$page->requires->string_for_js('commentsrequirelogin', 'moodle');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the component.
|
||||
*
|
||||
* This method shouldn't be public, changing the component once it has been set potentially
|
||||
* invalidates permission checks.
|
||||
* A coding_error is now thrown if code attempts to change the component.
|
||||
*
|
||||
* @param string $component
|
||||
* @return void
|
||||
*/
|
||||
public function set_component($component) {
|
||||
if (!empty($this->component) && $this->component !== $component) {
|
||||
throw new coding_exception('You cannot change the component of a comment once it has been set');
|
||||
}
|
||||
$this->component = $component;
|
||||
list($this->plugintype, $this->pluginname) = normalize_component($component);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the user can view the comment.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function set_view_permission($value) {
|
||||
$this->viewcap = $value;
|
||||
$this->viewcap = (bool)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the user can post a comment
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function set_post_permission($value) {
|
||||
$this->postcap = $value;
|
||||
$this->postcap = (bool)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,21 +336,110 @@ EOD;
|
||||
* function named $pluginname_check_comment_post must be implemented
|
||||
*/
|
||||
private function check_permissions() {
|
||||
global $CFG;
|
||||
$this->postcap = has_capability('moodle/comment:post', $this->context);
|
||||
$this->viewcap = has_capability('moodle/comment:view', $this->context);
|
||||
if (!empty($this->plugintype)) {
|
||||
$permissions = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'permissions', array($this->args), array('post'=>true, 'view'=>true));
|
||||
if ($this->ignore_permission) {
|
||||
$this->postcap = $permissions['post'];
|
||||
$this->viewcap = $permissions['view'];
|
||||
} else {
|
||||
$this->postcap = $this->postcap && $permissions['post'];
|
||||
$this->viewcap = $this->viewcap && $permissions['view'];
|
||||
}
|
||||
$permissions = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'permissions', array($this->comment_param), array('post'=>false, 'view'=>false));
|
||||
$this->postcap = $this->postcap && $permissions['post'];
|
||||
$this->viewcap = $this->viewcap && $permissions['view'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a link for this page that will work with JS disabled.
|
||||
*
|
||||
* @global moodle_page $PAGE
|
||||
* @param moodle_page $page
|
||||
* @return moodle_url
|
||||
*/
|
||||
public function get_nojslink(moodle_page $page = null) {
|
||||
if ($page === null) {
|
||||
global $PAGE;
|
||||
$page = $PAGE;
|
||||
}
|
||||
|
||||
$link = new moodle_url($page->url, array(
|
||||
'nonjscomment' => true,
|
||||
'comment_itemid' => $this->itemid,
|
||||
'comment_context' => $this->context->id,
|
||||
'comment_area' => $this->commentarea,
|
||||
));
|
||||
$link->remove_params(array('comment_page'));
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the notoggle option.
|
||||
*
|
||||
* If set to true then the user will not be able to expand and collase
|
||||
* the comment section.
|
||||
*
|
||||
* @param bool $newvalue
|
||||
*/
|
||||
public function set_notoggle($newvalue = true) {
|
||||
$this->notoggle = (bool)$newvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the autostart option.
|
||||
*
|
||||
* If set to true then the comments will be loaded during page load.
|
||||
* Normally this happens only once the user expands the comment section.
|
||||
*
|
||||
* @param bool $newvalue
|
||||
*/
|
||||
public function set_autostart($newvalue = true) {
|
||||
$this->autostart = (bool)$newvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the displaycancel option
|
||||
*
|
||||
* If set to true then a cancel button will be shown when using the form
|
||||
* to post comments.
|
||||
*
|
||||
* @param bool $newvalue
|
||||
*/
|
||||
public function set_displaycancel($newvalue = true) {
|
||||
$this->displaycancel = (bool)$newvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the displaytotalcount option
|
||||
*
|
||||
* If set to true then the total number of comments will be displayed
|
||||
* when printing comments.
|
||||
*
|
||||
* @param bool $newvalue
|
||||
*/
|
||||
public function set_displaytotalcount($newvalue = true) {
|
||||
$this->displaytotalcount = (bool)$newvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the JavaScript that enchances the comment API.
|
||||
*
|
||||
* @param moodle_page $page The moodle page object that the JavaScript should be
|
||||
* initialised for.
|
||||
*/
|
||||
public function initialise_javascript(moodle_page $page) {
|
||||
|
||||
$options = new stdClass;
|
||||
$options->client_id = $this->cid;
|
||||
$options->commentarea = $this->commentarea;
|
||||
$options->itemid = $this->itemid;
|
||||
$options->page = 0;
|
||||
$options->courseid = $this->courseid;
|
||||
$options->contextid = $this->contextid;
|
||||
$options->component = $this->component;
|
||||
$options->notoggle = $this->notoggle;
|
||||
$options->autostart = $this->autostart;
|
||||
|
||||
$page->requires->js_init_call('M.core_comment.init', array($options), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare comment code in html
|
||||
* @param boolean $return
|
||||
@@ -271,108 +447,80 @@ EOD;
|
||||
*/
|
||||
public function output($return = true) {
|
||||
global $PAGE, $OUTPUT;
|
||||
static $template_printed;
|
||||
static $template_printed;
|
||||
|
||||
$this->link = $PAGE->url;
|
||||
$murl = new moodle_url($this->link);
|
||||
$murl->remove_params('nonjscomment');
|
||||
$murl->param('nonjscomment', 'true');
|
||||
$murl->param('comment_itemid', $this->itemid);
|
||||
$murl->param('comment_context', $this->context->id);
|
||||
$murl->param('comment_area', $this->commentarea);
|
||||
$murl->remove_params('comment_page');
|
||||
$this->link = $murl->out();
|
||||
|
||||
$options = new stdClass();
|
||||
$options->client_id = $this->cid;
|
||||
$options->commentarea = $this->commentarea;
|
||||
$options->itemid = $this->itemid;
|
||||
$options->page = 0;
|
||||
$options->courseid = $this->courseid;
|
||||
$options->contextid = $this->contextid;
|
||||
$options->env = $this->env;
|
||||
$options->component = $this->component;
|
||||
if ($this->env == 'block_comments') {
|
||||
$options->notoggle = true;
|
||||
$options->autostart = true;
|
||||
}
|
||||
|
||||
$PAGE->requires->js_init_call('M.core_comment.init', array($options), true);
|
||||
$this->initialise_javascript($PAGE);
|
||||
|
||||
if (!empty(self::$nonjs)) {
|
||||
// return non js comments interface
|
||||
return $this->print_comments(self::$comment_page, $return, true);
|
||||
}
|
||||
|
||||
$strsubmit = get_string('savecomment');
|
||||
$strcancel = get_string('cancel');
|
||||
$strshowcomments = get_string('showcommentsnonjs');
|
||||
$sesskey = sesskey();
|
||||
$html = '';
|
||||
|
||||
// print html template
|
||||
// Javascript will use the template to render new comments
|
||||
if (empty($template_printed) && !empty($this->viewcap)) {
|
||||
$html .= '<div style="display:none" id="cmt-tmpl">' . $this->template . '</div>';
|
||||
if (empty($template_printed) && $this->can_view()) {
|
||||
$html .= html_writer::tag('div', $this->template, array('style' => 'display:none', 'id' => 'cmt-tmpl'));
|
||||
$template_printed = true;
|
||||
}
|
||||
|
||||
if (!empty($this->viewcap)) {
|
||||
if ($this->can_view()) {
|
||||
// print commenting icon and tooltip
|
||||
$icon = $OUTPUT->pix_url('t/collapsed');
|
||||
$html .= <<<EOD
|
||||
<div class="mdl-left">
|
||||
<a class="showcommentsnonjs" href="{$this->link}">{$strshowcomments}</a>
|
||||
EOD;
|
||||
if ($this->env != 'block_comments') {
|
||||
$html .= <<<EOD
|
||||
<a id="comment-link-{$this->cid}" class="comment-link" href="#">
|
||||
<img id="comment-img-{$this->cid}" src="$icon" alt="{$this->linktext}" title="{$this->linktext}" />
|
||||
<span id="comment-link-text-{$this->cid}">{$this->linktext} {$this->count}</span>
|
||||
</a>
|
||||
EOD;
|
||||
$html .= html_writer::start_tag('div', array('class' => 'mdl-left'));
|
||||
$html .= html_writer::link($this->get_nojslink($PAGE), get_string('showcommentsnonjs'), array('class' => 'showcommentsnonjs'));
|
||||
|
||||
if (!$this->notoggle) {
|
||||
// If toggling is enabled (notoggle=false) then print the controls to toggle
|
||||
// comments open and closed
|
||||
$countstring = '';
|
||||
if ($this->displaytotalcount) {
|
||||
$countstring = '('.$this->count().')';
|
||||
}
|
||||
$html .= html_writer::start_tag('a', array('class' => 'comment-link', 'id' => 'comment-link-'.$this->cid, 'href' => '#'));
|
||||
$html .= html_writer::empty_tag('img', array('id' => 'comment-img-'.$this->cid, 'src' => $OUTPUT->pix_url('t/collapsed'), 'alt' => $this->linktext, 'title' => $this->linktext));
|
||||
$html .= html_writer::tag('span', $this->linktext.' '.$countstring, array('id' => 'comment-link-text-'.$this->cid));
|
||||
$html .= html_writer::end_tag('a');
|
||||
}
|
||||
|
||||
$html .= <<<EOD
|
||||
<div id="comment-ctrl-{$this->cid}" class="comment-ctrl">
|
||||
<ul id="comment-list-{$this->cid}" class="comment-list">
|
||||
<li class="first"></li>
|
||||
EOD;
|
||||
// in comments block, we print comments list right away
|
||||
if ($this->env == 'block_comments') {
|
||||
$html .= html_writer::start_tag('div', array('id' => 'comment-ctrl-'.$this->cid, 'class' => 'comment-ctrl'));
|
||||
|
||||
if ($this->autostart) {
|
||||
// If autostart has been enabled print the comments list immediatly
|
||||
$html .= html_writer::start_tag('ul', array('id' => 'comment-list-'.$this->cid, 'class' => 'comment-list comments-loaded'));
|
||||
$html .= html_writer::tag('li', '', array('class' => 'first'));
|
||||
$html .= $this->print_comments(0, true, false);
|
||||
$html .= '</ul>';
|
||||
$html .= html_writer::end_tag('ul'); // .comment-list
|
||||
$html .= $this->get_pagination(0);
|
||||
} else {
|
||||
$html .= <<<EOD
|
||||
</ul>
|
||||
<div id="comment-pagination-{$this->cid}" class="comment-pagination"></div>
|
||||
EOD;
|
||||
$html .= html_writer::start_tag('ul', array('id' => 'comment-list-'.$this->cid, 'class' => 'comment-list'));
|
||||
$html .= html_writer::tag('li', '', array('class' => 'first'));
|
||||
$html .= html_writer::end_tag('ul'); // .comment-list
|
||||
$html .= html_writer::tag('div', '', array('id' => 'comment-pagination-'.$this->cid, 'class' => 'comment-pagination'));
|
||||
}
|
||||
|
||||
// print posting textarea
|
||||
if (!empty($this->postcap)) {
|
||||
$html .= <<<EOD
|
||||
<div class='comment-area'>
|
||||
<div class="bd">
|
||||
<textarea name="content" rows="2" cols="20" id="dlg-content-{$this->cid}"></textarea>
|
||||
</div>
|
||||
<div class="fd" id="comment-action-{$this->cid}">
|
||||
<a href="#" id="comment-action-post-{$this->cid}"> {$strsubmit} </a>
|
||||
EOD;
|
||||
if ($this->env != 'block_comments') {
|
||||
$html .= "<span> | </span><a href=\"#\" id=\"comment-action-cancel-{$this->cid}\"> {$strcancel} </a>";
|
||||
if ($this->can_post()) {
|
||||
// print posting textarea
|
||||
$html .= html_writer::start_tag('div', array('class' => 'comment-area'));
|
||||
$html .= html_writer::start_tag('div', array('class' => 'db'));
|
||||
$html .= html_writer::tag('textarea', '', array('name' => 'content', 'rows' => 2, 'cols' => 20, 'id' => 'dlg-content-'.$this->cid));
|
||||
$html .= html_writer::end_tag('div'); // .db
|
||||
|
||||
$html .= html_writer::start_tag('div', array('class' => 'fd', 'id' => 'comment-action-'.$this->cid));
|
||||
$html .= html_writer::link('#', get_string('savecomment'), array('id' => 'comment-action-post-'.$this->cid));
|
||||
|
||||
if ($this->displaycancel) {
|
||||
$html .= html_writer::tag('span', ' | ');
|
||||
$html .= html_writer::link('#', get_string('cancel'), array('id' => 'comment-action-cancel-'.$this->cid));
|
||||
}
|
||||
$html .= <<<EOD
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
EOD;
|
||||
|
||||
$html .= html_writer::end_tag('div'); // .fd
|
||||
$html .= html_writer::end_tag('div'); // .comment-area
|
||||
$html .= html_writer::tag('div', '', array('class' => 'clearer'));
|
||||
}
|
||||
|
||||
$html .= <<<EOD
|
||||
</div><!-- end of comment-ctrl -->
|
||||
</div>
|
||||
EOD;
|
||||
$html .= html_writer::end_tag('div'); // .comment-ctrl
|
||||
$html .= html_writer::end_tag('div'); // .mdl-left
|
||||
} else {
|
||||
$html = '';
|
||||
}
|
||||
@@ -392,15 +540,15 @@ EOD;
|
||||
*/
|
||||
public function get_comments($page = '') {
|
||||
global $DB, $CFG, $USER, $OUTPUT;
|
||||
if (empty($this->viewcap)) {
|
||||
if (!$this->can_view()) {
|
||||
return false;
|
||||
}
|
||||
if (!is_numeric($page)) {
|
||||
$page = 0;
|
||||
}
|
||||
$this->page = $page;
|
||||
$params = array();
|
||||
$start = $page * $CFG->commentsperpage;
|
||||
$perpage = (!empty($CFG->commentsperpage))?$CFG->commentsperpage:15;
|
||||
$start = $page * $perpage;
|
||||
$ufields = user_picture::fields('u');
|
||||
$sql = "SELECT $ufields, c.id AS cid, c.content AS ccontent, c.format AS cformat, c.timecreated AS ctimecreated
|
||||
FROM {comments} c
|
||||
@@ -412,9 +560,8 @@ EOD;
|
||||
$params['itemid'] = $this->itemid;
|
||||
|
||||
$comments = array();
|
||||
$candelete = has_capability('moodle/comment:delete', $this->context);
|
||||
$formatoptions = array('overflowdiv' => true);
|
||||
$rs = $DB->get_recordset_sql($sql, $params, $start, $CFG->commentsperpage);
|
||||
$rs = $DB->get_recordset_sql($sql, $params, $start, $perpage);
|
||||
foreach ($rs as $u) {
|
||||
$c = new stdClass();
|
||||
$c->id = $u->cid;
|
||||
@@ -426,8 +573,9 @@ EOD;
|
||||
$c->fullname = fullname($u);
|
||||
$c->time = userdate($c->timecreated, get_string('strftimerecent', 'langconfig'));
|
||||
$c->content = format_text($c->content, $c->format, $formatoptions);
|
||||
|
||||
$c->avatar = $OUTPUT->user_picture($u, array('size'=>18));
|
||||
|
||||
$candelete = $this->can_delete($c->id);
|
||||
if (($USER->id == $u->id) || !empty($candelete)) {
|
||||
$c->delete = true;
|
||||
}
|
||||
@@ -437,31 +585,45 @@ EOD;
|
||||
|
||||
if (!empty($this->plugintype)) {
|
||||
// moodle module will filter comments
|
||||
$comments = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'display', array($comments, $this->args), $comments);
|
||||
$comments = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'display', array($comments, $this->comment_param), $comments);
|
||||
}
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of comments associated with the details of this object
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
global $DB;
|
||||
if ($count = $DB->count_records('comments', array('itemid'=>$this->itemid, 'commentarea'=>$this->commentarea, 'contextid'=>$this->context->id))) {
|
||||
return $count;
|
||||
} else {
|
||||
return 0;
|
||||
if ($this->totalcommentcount === null) {
|
||||
$this->totalcommentcount = $DB->count_records('comments', array('itemid' => $this->itemid, 'commentarea' => $this->commentarea, 'contextid' => $this->context->id));
|
||||
}
|
||||
return $this->totalcommentcount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML to display a pagination bar
|
||||
*
|
||||
* @global stdClass $CFG
|
||||
* @global core_renderer $OUTPUT
|
||||
* @param int $page
|
||||
* @return string
|
||||
*/
|
||||
public function get_pagination($page = 0) {
|
||||
global $DB, $CFG, $OUTPUT;
|
||||
global $CFG, $OUTPUT;
|
||||
$count = $this->count();
|
||||
$pages = (int)ceil($count/$CFG->commentsperpage);
|
||||
$perpage = (!empty($CFG->commentsperpage))?$CFG->commentsperpage:15;
|
||||
$pages = (int)ceil($count/$perpage);
|
||||
if ($pages == 1 || $pages == 0) {
|
||||
return '';
|
||||
return html_writer::tag('div', '', array('id' => 'comment-pagination-'.$this->cid, 'class' => 'comment-pagination'));
|
||||
}
|
||||
if (!empty(self::$nonjs)) {
|
||||
// used in non-js interface
|
||||
return $OUTPUT->paging_bar($count, $page, $CFG->commentsperpage, $this->link, 'comment_page');
|
||||
return $OUTPUT->paging_bar($count, $page, $perpage, $this->get_nojslink(), 'comment_page');
|
||||
} else {
|
||||
// return ajax paging bar
|
||||
$str = '';
|
||||
@@ -481,16 +643,18 @@ EOD;
|
||||
|
||||
/**
|
||||
* Add a new comment
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param string $content
|
||||
* @return mixed
|
||||
*/
|
||||
public function add($content, $format = FORMAT_MOODLE) {
|
||||
global $CFG, $DB, $USER, $OUTPUT;
|
||||
if (empty($this->postcap)) {
|
||||
if (!$this->can_post()) {
|
||||
throw new comment_exception('nopermissiontocomment');
|
||||
}
|
||||
$now = time();
|
||||
$newcmt = new stdClass();
|
||||
$newcmt = new stdClass;
|
||||
$newcmt->contextid = $this->contextid;
|
||||
$newcmt->commentarea = $this->commentarea;
|
||||
$newcmt->itemid = $this->itemid;
|
||||
@@ -499,20 +663,15 @@ EOD;
|
||||
$newcmt->userid = $USER->id;
|
||||
$newcmt->timecreated = $now;
|
||||
|
||||
if (!empty($this->plugintype)) {
|
||||
// moodle module will check content
|
||||
$ret = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'add', array(&$newcmt, $this->args), true);
|
||||
if (!$ret) {
|
||||
throw new comment_exception('modulererejectcomment');
|
||||
}
|
||||
}
|
||||
// This callback allow module to modify the content of comment, such as filter or replacement
|
||||
plugin_callback($this->plugintype, $this->pluginname, 'comment', 'add', array(&$newcmt, $this->comment_param));
|
||||
|
||||
$cmt_id = $DB->insert_record('comments', $newcmt);
|
||||
if (!empty($cmt_id)) {
|
||||
$newcmt->id = $cmt_id;
|
||||
$newcmt->time = userdate($now, get_string('strftimerecent', 'langconfig'));
|
||||
$newcmt->fullname = fullname($USER);
|
||||
$url = new moodle_url('/user/view.php', array('id'=>$USER->id, 'course'=>$this->courseid));
|
||||
$url = new moodle_url('/user/view.php', array('id' => $USER->id, 'course' => $this->courseid));
|
||||
$newcmt->profileurl = $url->out();
|
||||
$newcmt->content = format_text($newcmt->content, $format, array('overflowdiv'=>true));
|
||||
$newcmt->avatar = $OUTPUT->user_picture($USER, array('size'=>16));
|
||||
@@ -524,7 +683,7 @@ EOD;
|
||||
|
||||
/**
|
||||
* delete by context, commentarea and itemid
|
||||
* @param object $param {
|
||||
* @param stdClass|array $param {
|
||||
* contextid => int the context in which the comments exist [required]
|
||||
* commentarea => string the comment area [optional]
|
||||
* itemid => int comment itemid [optional]
|
||||
@@ -543,7 +702,8 @@ EOD;
|
||||
|
||||
/**
|
||||
* Delete page_comments in whole course, used by course reset
|
||||
* @param object $context course context
|
||||
*
|
||||
* @param stdClass $context course context
|
||||
*/
|
||||
public function reset_course_page_comments($context) {
|
||||
global $DB;
|
||||
@@ -559,6 +719,7 @@ EOD;
|
||||
|
||||
/**
|
||||
* Delete a comment
|
||||
*
|
||||
* @param int $commentid
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -577,6 +738,7 @@ EOD;
|
||||
|
||||
/**
|
||||
* Print comments
|
||||
*
|
||||
* @param int $page
|
||||
* @param boolean $return return comments list string or print it out
|
||||
* @param boolean $nonjs print nonjs comments list or not?
|
||||
@@ -584,6 +746,11 @@ EOD;
|
||||
*/
|
||||
public function print_comments($page = 0, $return = true, $nonjs = true) {
|
||||
global $DB, $CFG, $PAGE;
|
||||
|
||||
if (!$this->can_view()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '';
|
||||
if (!(self::$comment_itemid == $this->itemid &&
|
||||
self::$comment_context == $this->context->id &&
|
||||
@@ -594,38 +761,34 @@ EOD;
|
||||
|
||||
$html = '';
|
||||
if ($nonjs) {
|
||||
$html .= '<h3>'.get_string('comments').'</h3>';
|
||||
$html .= "<ul id='comment-list-$this->cid' class='comment-list'>";
|
||||
$html .= html_writer::tag('h3', get_string('comments'));
|
||||
$html .= html_writer::start_tag('ul', array('id' => 'comment-list-'.$this->cid, 'class' => 'comment-list'));
|
||||
}
|
||||
$results = array();
|
||||
$list = '';
|
||||
|
||||
foreach ($comments as $cmt) {
|
||||
$list = '<li id="comment-'.$cmt->id.'-'.$this->cid.'">'.$this->print_comment($cmt, $nonjs).'</li>' . $list;
|
||||
// Reverse the comments array to display them in the correct direction
|
||||
foreach (array_reverse($comments) as $cmt) {
|
||||
$html .= html_writer::tag('li', $this->print_comment($cmt, $nonjs), array('id' => 'comment-'.$cmt->id.'-'.$this->cid));
|
||||
}
|
||||
$html .= $list;
|
||||
if ($nonjs) {
|
||||
$html .= '</ul>';
|
||||
$html .= html_writer::end_tag('ul');
|
||||
$html .= $this->get_pagination($page);
|
||||
}
|
||||
$sesskey = sesskey();
|
||||
$returnurl = $PAGE->url;
|
||||
$strsubmit = get_string('submit');
|
||||
if ($nonjs) {
|
||||
$html .= <<<EOD
|
||||
<form method="POST" action="{$CFG->wwwroot}/comment/comment_post.php">
|
||||
<textarea name="content" rows="2"></textarea>
|
||||
<input type="hidden" name="contextid" value="$this->contextid" />
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<input type="hidden" name="area" value="$this->commentarea" />
|
||||
<input type="hidden" name="component" value="$this->component" />
|
||||
<input type="hidden" name="itemid" value="$this->itemid" />
|
||||
<input type="hidden" name="courseid" value="{$this->courseid}" />
|
||||
<input type="hidden" name="sesskey" value="{$sesskey}" />
|
||||
<input type="hidden" name="returnurl" value="{$returnurl}" />
|
||||
<input type="submit" value="{$strsubmit}" />
|
||||
</form>
|
||||
EOD;
|
||||
if ($nonjs && $this->can_post()) {
|
||||
// Form to add comments
|
||||
$html .= html_writer::start_tag('form', array('method' => 'post', 'action' => new moodle_url('/comment/comment_post.php')));
|
||||
// Comment parameters
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'contextid', 'value' => $this->contextid));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'add'));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'area', 'value' => $this->commentarea));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'component', 'value' => $this->component));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'itemid', 'value' => $this->itemid));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'courseid', 'value' => $this->courseid));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'returnurl', 'value' => $PAGE->url));
|
||||
// Textarea for the actual comment
|
||||
$html .= html_writer::tag('textarea', '', array('name' => 'content', 'rows' => 2));
|
||||
// Submit button to add the comment
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('submit')));
|
||||
$html .= html_writer::end_tag('form');
|
||||
}
|
||||
if ($return) {
|
||||
return $html;
|
||||
@@ -634,14 +797,35 @@ EOD;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing comments in HTML format.
|
||||
*
|
||||
* @global core_renderer $OUTPUT
|
||||
* @param stdClass $cmt {
|
||||
* id => int comment id
|
||||
* content => string comment content
|
||||
* format => int comment text format
|
||||
* timecreated => int comment's timecreated
|
||||
* profileurl => string link to user profile
|
||||
* fullname => comment author's full name
|
||||
* avatar => string user's avatar
|
||||
* delete => boolean does user have permission to delete comment?
|
||||
* }
|
||||
* @param bool $nonjs
|
||||
* @return array
|
||||
*/
|
||||
public function print_comment($cmt, $nonjs = true) {
|
||||
global $OUTPUT;
|
||||
$patterns = array();
|
||||
$replacements = array();
|
||||
|
||||
if (!empty($cmt->delete) && empty($nonjs)) {
|
||||
$cmt->content = '<div class="comment-delete"><a href="#" id ="comment-delete-'.$this->cid.'-'.$cmt->id.'"><img src="'.$OUTPUT->pix_url('t/delete').'" alt="'.get_string('delete').'" /></a></div>' . $cmt->content;
|
||||
// add the button
|
||||
$deletelink = html_writer::start_tag('div', array('class'=>'comment-delete'));
|
||||
$deletelink .= html_writer::start_tag('a', array('href' => '#', 'id' => 'comment-delete-'.$this->cid.'-'.$cmt->id));
|
||||
$deletelink .= $OUTPUT->pix_icon('t/delete', get_string('delete'));
|
||||
$deletelink .= html_writer::end_tag('a');
|
||||
$deletelink .= html_writer::end_tag('div');
|
||||
$cmt->content = $deletelink . $cmt->content;
|
||||
}
|
||||
$patterns[] = '___picture___';
|
||||
$patterns[] = '___name___';
|
||||
@@ -655,12 +839,101 @@ EOD;
|
||||
// use html template to format a single comment.
|
||||
return str_replace($patterns, $replacements, $this->template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke validate callbacks
|
||||
*
|
||||
* @param stdClass $params addtionall parameters need to add to callbacks
|
||||
*/
|
||||
protected function validate($params=array()) {
|
||||
foreach ($params as $key=>$value) {
|
||||
$this->comment_param->$key = $value;
|
||||
}
|
||||
$validation = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'validate', array($this->comment_param), false);
|
||||
if (!$validation) {
|
||||
throw new comment_exception('invalidcommentparam');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the user is able to view comments
|
||||
* @return bool
|
||||
*/
|
||||
public function can_view() {
|
||||
$this->validate();
|
||||
return !empty($this->viewcap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the user can add comments against this comment description
|
||||
* @return bool
|
||||
*/
|
||||
public function can_post() {
|
||||
$this->validate();
|
||||
return isloggedin() && !empty($this->postcap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the user can delete this comment
|
||||
* @param int $commentid
|
||||
* @return bool
|
||||
*/
|
||||
public function can_delete($commentid) {
|
||||
$this->validate(array('commentid'=>$commentid));
|
||||
return has_capability('moodle/comment:delete', $this->context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component associated with the comment
|
||||
* @return string
|
||||
*/
|
||||
public function get_compontent() {
|
||||
return $this->component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context associated with the comment
|
||||
* @return stdClass
|
||||
*/
|
||||
public function get_context() {
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the course id associated with the comment
|
||||
* @return int
|
||||
*/
|
||||
public function get_courseid() {
|
||||
return $this->courseid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the course module associated with the comment
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function get_cm() {
|
||||
return $this->cm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item id associated with the comment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_itemid() {
|
||||
return $this->itemid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the comment area associated with the commentarea
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function get_commentarea() {
|
||||
return $this->commentarea;
|
||||
}
|
||||
}
|
||||
|
||||
class comment_exception extends moodle_exception {
|
||||
public $message;
|
||||
function __construct($errorcode) {
|
||||
$this->errorcode = $errorcode;
|
||||
$this->message = get_string($errorcode, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
+104
-52
@@ -23,46 +23,70 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class comment_manager {
|
||||
|
||||
/**
|
||||
* The number of comments to display per page
|
||||
* @var int
|
||||
*/
|
||||
private $perpage;
|
||||
function __construct() {
|
||||
|
||||
/**
|
||||
* Constructs the comment_manage object
|
||||
*/
|
||||
public function __construct() {
|
||||
global $CFG;
|
||||
$this->perpage = $CFG->commentsperpage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return comments by pages
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
* @return array An array of comments
|
||||
*/
|
||||
function get_comments($page) {
|
||||
global $DB, $CFG, $USER;
|
||||
$params = array();
|
||||
global $DB;
|
||||
|
||||
if ($page == 0) {
|
||||
$start = 0;
|
||||
} else {
|
||||
$start = $page*$this->perpage;
|
||||
$start = $page * $this->perpage;
|
||||
}
|
||||
$sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated
|
||||
FROM {comments} c, {user} u
|
||||
WHERE u.id=c.userid ORDER BY c.timecreated ASC";
|
||||
|
||||
$comments = array();
|
||||
|
||||
$sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated
|
||||
FROM {comments} c
|
||||
JOIN {user} u
|
||||
ON u.id=c.userid
|
||||
ORDER BY c.timecreated ASC";
|
||||
$rs = $DB->get_recordset_sql($sql, null, $start, $this->perpage);
|
||||
$formatoptions = array('overflowdiv' => true);
|
||||
if ($records = $DB->get_records_sql($sql, array(), $start, $this->perpage)) {
|
||||
foreach ($records as $item) {
|
||||
$item->fullname = fullname($item);
|
||||
$item->time = userdate($item->timecreated);
|
||||
$item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
|
||||
$comments[] = $item;
|
||||
unset($item->firstname);
|
||||
unset($item->lastname);
|
||||
unset($item->timecreated);
|
||||
}
|
||||
foreach ($rs as $item) {
|
||||
// Set calculated fields
|
||||
$item->fullname = fullname($item);
|
||||
$item->time = userdate($item->timecreated);
|
||||
$item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
|
||||
// Unset fields not related to the comment
|
||||
unset($item->firstname);
|
||||
unset($item->lastname);
|
||||
unset($item->timecreated);
|
||||
// Record the comment
|
||||
$comments[] = $item;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the course object
|
||||
*
|
||||
* @global moodle_page $PAGE
|
||||
* @global moodle_database $DB
|
||||
* @param int $courseid
|
||||
* @return void
|
||||
*/
|
||||
private function setup_course($courseid) {
|
||||
global $PAGE, $DB;
|
||||
if (!empty($this->course)) {
|
||||
@@ -71,88 +95,116 @@ class comment_manager {
|
||||
}
|
||||
if ($courseid == $PAGE->course->id) {
|
||||
$this->course = $PAGE->course;
|
||||
} else if (!$this->course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
} else if (!$this->course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
$this->course = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the module or block information for a comment
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param stdClass $comment
|
||||
* @return bool
|
||||
*/
|
||||
private function setup_plugin($comment) {
|
||||
global $DB;
|
||||
$this->context = get_context_instance_by_id($comment->contextid);
|
||||
if (!is_object($this->context)) {
|
||||
return;
|
||||
if (!$this->context) {
|
||||
return false;
|
||||
}
|
||||
if ($this->context->contextlevel == CONTEXT_BLOCK) {
|
||||
if ($block = $DB->get_record('block_instances', array('id'=>$this->context->instanceid))) {
|
||||
$this->plugintype = 'block';
|
||||
$this->pluginname = $block->blockname;
|
||||
}
|
||||
}
|
||||
if ($this->context->contextlevel == CONTEXT_MODULE) {
|
||||
$this->plugintype = 'mod';
|
||||
$this->cm = get_coursemodule_from_id('', $this->context->instanceid);
|
||||
$this->setup_course($this->cm->course);
|
||||
$this->modinfo = get_fast_modinfo($this->course);
|
||||
$this->pluginname = $this->modinfo->cms[$this->cm->id]->modname;
|
||||
switch ($this->context->contextlevel) {
|
||||
case CONTEXT_BLOCK:
|
||||
if ($block = $DB->get_record('block_instances', array('id' => $this->context->instanceid))) {
|
||||
$this->plugintype = 'block';
|
||||
$this->pluginname = $block->blockname;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$this->plugintype = 'mod';
|
||||
$this->cm = get_coursemodule_from_id('', $this->context->instanceid);
|
||||
$this->setup_course($this->cm->course);
|
||||
$this->modinfo = get_fast_modinfo($this->course);
|
||||
$this->pluginname = $this->modinfo->cms[$this->cm->id]->modname;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print comments
|
||||
* @param int $page
|
||||
* @return boolean return false if no comments available
|
||||
*/
|
||||
function print_comments($page=0) {
|
||||
global $CFG, $OUTPUT, $DB;
|
||||
$count = $DB->count_records_sql('SELECT COUNT(*) FROM {comments} c');
|
||||
public function print_comments($page = 0) {
|
||||
global $OUTPUT, $CFG, $OUTPUT, $DB;
|
||||
|
||||
$count = $DB->count_records('comments');
|
||||
$comments = $this->get_comments($page);
|
||||
if (count($comments) == 0) {
|
||||
echo $OUTPUT->notification(get_string('nocomments', 'moodle'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array (html_writer::checkbox('selectall', '', false, get_string('selectall'), array('id'=>'comment_select_all', 'class'=>'comment-report-selectall')), get_string('author', 'search'), get_string('content'), get_string('action'));
|
||||
$table->head = array (
|
||||
html_writer::checkbox('selectall', '', false, get_string('selectall'), array('id'=>'comment_select_all', 'class'=>'comment-report-selectall')),
|
||||
get_string('author', 'search'),
|
||||
get_string('content'),
|
||||
get_string('action')
|
||||
);
|
||||
$table->align = array ('left', 'left', 'left', 'left');
|
||||
$table->attributes = array('class'=>'generaltable commentstable');
|
||||
$table->data = array();
|
||||
$linkbase = $CFG->wwwroot.'/comment/index.php?action=delete&sesskey='.sesskey();
|
||||
|
||||
$link = new moodle_url('/comment/index.php', array('action' => 'delete', 'sesskey' => sesskey()));
|
||||
foreach ($comments as $c) {
|
||||
$link = $linkbase . '&commentid='. $c->id;
|
||||
$this->setup_plugin($c);
|
||||
if (!empty($this->plugintype)) {
|
||||
$context_url = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'url', array($c));
|
||||
$context_url = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'url', array($c));
|
||||
}
|
||||
$checkbox = html_writer::checkbox('comments', $c->id, false);
|
||||
$action = html_writer::link($link, get_string('delete'));
|
||||
$action = html_writer::link(new moodle_url($link, array('commentid' => $c->id)), get_string('delete'));
|
||||
if (!empty($context_url)) {
|
||||
$action .= html_writer::tag('br', null);
|
||||
$action .= html_writer::empty_tag('br');
|
||||
$action .= html_writer::link($context_url, get_string('commentincontext'), array('target'=>'_blank'));
|
||||
}
|
||||
$table->data[] = array($checkbox, $c->fullname, $c->content, $action);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
echo $OUTPUT->paging_bar($count, $page, $this->perpage, $CFG->wwwroot.'/comment/index.php');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a comment
|
||||
* Delete a comment
|
||||
*
|
||||
* @param int $commentid
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_comment($commentid) {
|
||||
global $DB;
|
||||
if ($comment = $DB->get_record('comments', array('id'=>$commentid))) {
|
||||
$DB->delete_records('comments', array('id'=>$commentid));
|
||||
if ($DB->record_exists('comments', array('id' => $commentid))) {
|
||||
$DB->delete_records('comments', array('id' => $commentid));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* delete comments
|
||||
* @param int $commentid
|
||||
* Delete comments
|
||||
*
|
||||
* @param string $list A list of comment ids separated by hyphens
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_comments($list) {
|
||||
global $DB;
|
||||
$ids = explode('-', $list);
|
||||
foreach ($ids as $id) {
|
||||
if (is_int((int)$id)) {
|
||||
if ($comment = $DB->get_record('comments', array('id'=>$id))) {
|
||||
$DB->delete_records('comments', array('id'=>$comment->id));
|
||||
}
|
||||
$id = (int)$id;
|
||||
if ($DB->record_exists('comments', array('id' => $id))) {
|
||||
$DB->delete_records('comments', array('id' => $id));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -357,6 +357,13 @@ $CFG->admin = 'admin';
|
||||
//
|
||||
// $CFG->langcacheroot = '/var/www/moodle/htdocs/altcache/lang';
|
||||
//
|
||||
// If $CFG->langcache is enabled (which should always be in production
|
||||
// environment), Moodle stores the list of available languages in a cache file.
|
||||
// By default, the file $CFG->dataroot/languages is used. You may wish to
|
||||
// specify an alternative location of this cache file.
|
||||
//
|
||||
// $CFG->langmenucachefile = '/var/www/moodle/htdocs/altcache/languages';
|
||||
//
|
||||
// Site default language can be set via standard administration interface. If you
|
||||
// want to have initial error messages for eventual database connection problems
|
||||
// localized too, you have to set your language code here.
|
||||
|
||||
@@ -89,7 +89,7 @@ function callback_weeks_get_section_name($course, $section) {
|
||||
foreach ($sections as $sec) {
|
||||
if ($sec->id == $section->id) {
|
||||
break;
|
||||
} else if ($sec->visible && $sec->section != 0) {
|
||||
} else if ($sec->section != 0) {
|
||||
$weekdate += 604800;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-61
@@ -347,7 +347,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
|
||||
$table->head = array(
|
||||
get_string('time'),
|
||||
get_string('ip_address'),
|
||||
get_string('fullnamecourse'),
|
||||
get_string('fullnameuser'),
|
||||
get_string('action'),
|
||||
get_string('info')
|
||||
);
|
||||
@@ -462,7 +462,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
|
||||
}
|
||||
echo "<th class=\"c1 header\">".get_string('time')."</th>\n";
|
||||
echo "<th class=\"c2 header\">".get_string('ip_address')."</th>\n";
|
||||
echo "<th class=\"c3 header\">".get_string('fullnamecourse')."</th>\n";
|
||||
echo "<th class=\"c3 header\">".get_string('fullnameuser')."</th>\n";
|
||||
echo "<th class=\"c4 header\">".get_string('action')."</th>\n";
|
||||
echo "<th class=\"c5 header\">".get_string('info')."</th>\n";
|
||||
echo "</tr>\n";
|
||||
@@ -529,7 +529,7 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
|
||||
global $DB;
|
||||
|
||||
$text = get_string('course')."\t".get_string('time')."\t".get_string('ip_address')."\t".
|
||||
get_string('fullnamecourse')."\t".get_string('action')."\t".get_string('info');
|
||||
get_string('fullnameuser')."\t".get_string('action')."\t".get_string('info');
|
||||
|
||||
if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
|
||||
$modname, $modid, $modaction, $groupid)) {
|
||||
@@ -565,7 +565,7 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
|
||||
header("Pragma: public");
|
||||
|
||||
echo get_string('savedat').userdate(time(), $strftimedatetime)."\n";
|
||||
echo $text;
|
||||
echo $text."\n";
|
||||
|
||||
if (empty($logs['logs'])) {
|
||||
return true;
|
||||
@@ -642,7 +642,7 @@ function print_log_xls($course, $user, $date, $order='l.time DESC', $modname,
|
||||
|
||||
$worksheet = array();
|
||||
$headers = array(get_string('course'), get_string('time'), get_string('ip_address'),
|
||||
get_string('fullnamecourse'), get_string('action'), get_string('info'));
|
||||
get_string('fullnameuser'), get_string('action'), get_string('info'));
|
||||
|
||||
// Creating worksheets
|
||||
for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
|
||||
@@ -753,7 +753,7 @@ function print_log_ods($course, $user, $date, $order='l.time DESC', $modname,
|
||||
|
||||
$worksheet = array();
|
||||
$headers = array(get_string('course'), get_string('time'), get_string('ip_address'),
|
||||
get_string('fullnamecourse'), get_string('action'), get_string('info'));
|
||||
get_string('fullnameuser'), get_string('action'), get_string('info'));
|
||||
|
||||
// Creating worksheets
|
||||
for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
|
||||
@@ -1637,6 +1637,16 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
// Module can put text after the link (e.g. forum unread)
|
||||
echo $mod->get_after_link();
|
||||
|
||||
// If there is content but NO link (eg label), then display the
|
||||
// content here (BEFORE any icons). In this case cons must be
|
||||
// displayed after the content so that it makes more sense visually
|
||||
// and for accessibility reasons, e.g. if you have a one-line label
|
||||
// it should work similarly (at least in terms of ordering) to an
|
||||
// activity.
|
||||
if (empty($url)) {
|
||||
echo $contentpart;
|
||||
}
|
||||
|
||||
if ($isediting) {
|
||||
if ($groupbuttons and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
|
||||
if (! $mod->groupmodelink = $groupbuttonslink) {
|
||||
@@ -1707,7 +1717,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
$extraclass = '';
|
||||
}
|
||||
echo "
|
||||
<form class='togglecompletion$extraclass' method='post' action='togglecompletion.php'><div>
|
||||
<form class='togglecompletion$extraclass' method='post' action='".$CFG->wwwroot."/course/togglecompletion.php'><div>
|
||||
<input type='hidden' name='id' value='{$mod->id}' />
|
||||
<input type='hidden' name='sesskey' value='".sesskey()."' />
|
||||
<input type='hidden' name='completionstate' value='$newstate' />
|
||||
@@ -1721,8 +1731,11 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
}
|
||||
}
|
||||
|
||||
// Display the content (if any) at this part of the html
|
||||
echo $contentpart;
|
||||
// If there is content AND a link, then display the content here
|
||||
// (AFTER any icons). Otherwise it was displayed before
|
||||
if (!empty($url)) {
|
||||
echo $contentpart;
|
||||
}
|
||||
|
||||
// Show availability information (for someone who isn't allowed to
|
||||
// see the activity itself, or for staff)
|
||||
@@ -1880,56 +1893,6 @@ function get_category_or_system_context($categoryid) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the cached list of course activities stored in the database
|
||||
* @param int $courseid - id of course to rebuild, empty means all
|
||||
* @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
|
||||
*/
|
||||
function rebuild_course_cache($courseid=0, $clearonly=false) {
|
||||
global $COURSE, $DB, $OUTPUT;
|
||||
|
||||
// Destroy navigation caches
|
||||
navigation_cache::destroy_volatile_caches();
|
||||
|
||||
if ($clearonly) {
|
||||
if (empty($courseid)) {
|
||||
$courseselect = array();
|
||||
} else {
|
||||
$courseselect = array('id'=>$courseid);
|
||||
}
|
||||
$DB->set_field('course', 'modinfo', null, $courseselect);
|
||||
// update cached global COURSE too ;-)
|
||||
if ($courseid == $COURSE->id or empty($courseid)) {
|
||||
$COURSE->modinfo = null;
|
||||
}
|
||||
// reset the fast modinfo cache
|
||||
$reset = 'reset';
|
||||
get_fast_modinfo($reset);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($courseid) {
|
||||
$select = array('id'=>$courseid);
|
||||
} else {
|
||||
$select = array();
|
||||
@set_time_limit(0); // this could take a while! MDL-10954
|
||||
}
|
||||
|
||||
$rs = $DB->get_recordset("course", $select,'','id,fullname');
|
||||
foreach ($rs as $course) {
|
||||
$modinfo = serialize(get_array_of_activities($course->id));
|
||||
$DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
|
||||
// update cached global COURSE too ;-)
|
||||
if ($course->id == $COURSE->id) {
|
||||
$COURSE->modinfo = $modinfo;
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
// reset the fast modinfo cache
|
||||
$reset = 'reset';
|
||||
get_fast_modinfo($reset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the child categories of a given courses category. Uses a static cache
|
||||
* to make repeat calls efficient.
|
||||
@@ -2509,7 +2472,7 @@ function print_course($course, $highlightterms = '') {
|
||||
$course->summaryformat = FORMAT_MOODLE;
|
||||
}
|
||||
echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options, $course->id));
|
||||
if ((!isloggedin() || is_siteadmin()) && $icons = enrol_get_course_info_icons($course)) {
|
||||
if ($icons = enrol_get_course_info_icons($course)) {
|
||||
echo html_writer::start_tag('div', array('class'=>'enrolmenticons'));
|
||||
foreach ($icons as $icon) {
|
||||
echo $OUTPUT->render($icon);
|
||||
@@ -3403,10 +3366,13 @@ function move_courses($courseids, $categoryid) {
|
||||
}
|
||||
|
||||
$courseids = array_reverse($courseids);
|
||||
$newparent = get_context_instance(CONTEXT_COURSECAT, $category->id);
|
||||
$i = 1;
|
||||
|
||||
foreach ($courseids as $courseid) {
|
||||
if ($course = $DB->get_record('course', array('id'=>$courseid), 'id, category')) {
|
||||
$course = new stdClass();
|
||||
$course->id = $courseid;
|
||||
$course->category = $category->id;
|
||||
$course->sortorder = $category->sortorder + MAX_COURSES_IN_CATEGORY - $i++;
|
||||
if ($category->visible == 0) {
|
||||
@@ -3418,7 +3384,6 @@ function move_courses($courseids, $categoryid) {
|
||||
$DB->update_record('course', $course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$newparent = get_context_instance(CONTEXT_COURSECAT, $course->category);
|
||||
context_moved($context, $newparent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ if(!$csv) {
|
||||
// Try load a aggregation method
|
||||
$method = $completion->get_aggregation_method($current_group->criteriatype);
|
||||
|
||||
$method = $method == 1 ? 'All' : 'Any';
|
||||
$method = $method == 1 ? get_string('all') : get_string('any');
|
||||
|
||||
} else {
|
||||
$method = '-';
|
||||
@@ -406,7 +406,7 @@ if(!$csv) {
|
||||
// Get course aggregation
|
||||
$method = $completion->get_aggregation_method();
|
||||
|
||||
print $method == 1 ? 'All' : 'Any';
|
||||
print $method == 1 ? get_string('all') : get_string('any');
|
||||
print '</th>';
|
||||
|
||||
print '</tr>';
|
||||
@@ -515,7 +515,7 @@ if(!$csv) {
|
||||
|
||||
// Overall course completion status
|
||||
print '<th class="criteriaicon">';
|
||||
print '<img src="'.$OUTPUT->pix_url('i/course').'" class="icon" alt="Course" title="Course Complete" />'; //TODO: localize
|
||||
print '<img src="'.$OUTPUT->pix_url('i/course').'" class="icon" alt="'.get_string('course').'" title="'.get_string('coursecomplete', 'completion').'" />';
|
||||
print '</th>';
|
||||
|
||||
print '</tr>';
|
||||
@@ -634,7 +634,7 @@ foreach ($progress as $user) {
|
||||
print '<td class="completion-progresscell">'.
|
||||
'<a href="'.$CFG->wwwroot.'/course/togglecompletion.php?user='.$user->id.'&course='.$course->id.'&rolec='.$allow_marking_criteria.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/completion-manual-'.($is_complete ? 'y' : 'n')).
|
||||
'" alt="'.$describe.'" class="icon" title="Mark as complete" /></a></td>'; //TODO: localize
|
||||
'" alt="'.$describe.'" class="icon" title="'.get_string('markcomplete', 'completion').'" /></a></td>';
|
||||
} else {
|
||||
print '<td class="completion-progresscell">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/'.$completionicon).
|
||||
|
||||
@@ -94,6 +94,7 @@ switch ($type) {
|
||||
$reducedays = 0;
|
||||
}
|
||||
|
||||
$days = array();
|
||||
$i = 0;
|
||||
while ($timestart < $timenow) {
|
||||
$timefinish = $timestart + 86400;
|
||||
@@ -167,6 +168,7 @@ switch ($type) {
|
||||
}
|
||||
$dayfinish = $daystart + 86400;
|
||||
|
||||
$hours = array();
|
||||
for ($i=0; $i<=23; $i++) {
|
||||
$logs[$i] = 0;
|
||||
$hour = $daystart + $i * 3600;
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
$actions = array_merge($viewnames, $postnames);
|
||||
}
|
||||
|
||||
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action0');
|
||||
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action');
|
||||
$actionsql = "action $actionsql";
|
||||
|
||||
$relatedcontexts = get_related_contexts_string($context);
|
||||
|
||||
+16
-12
@@ -33,9 +33,9 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$switchrole = optional_param('switchrole',-1, PARAM_INT);
|
||||
$returnurlkey = optional_param('returnurl', false, PARAM_INT);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$switchrole = optional_param('switchrole',-1, PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', false, PARAM_URL);
|
||||
|
||||
$PAGE->set_url('/course/switchrole.php', array('id'=>$id));
|
||||
|
||||
@@ -69,17 +69,21 @@ if ($switchrole > 0 && has_capability('moodle/role:switchroles', $context)) {
|
||||
}
|
||||
}
|
||||
|
||||
$returnurl = false;
|
||||
if ($returnurlkey && !empty($SESSION->returnurl) && strpos($SESSION->returnurl, 'moodle_url')!==false) {
|
||||
$returnurl = @unserialize($SESSION->returnurl);
|
||||
if (!($returnurl instanceof moodle_url)) {
|
||||
$returnurl = false;
|
||||
// TODO: Using SESSION->returnurl is deprecated and should be removed in the future.
|
||||
// Till then this code remains to support any external applications calling this script.
|
||||
if (!empty($returnurl) && is_numeric($returnurl)) {
|
||||
$returnurl = false;
|
||||
if (!empty($SESSION->returnurl) && strpos($SESSION->returnurl, 'moodle_url')!==false) {
|
||||
debugging('Code calling switchrole should be passing a URL as a param.', DEBUG_DEVELOPER);
|
||||
$returnurl = @unserialize($SESSION->returnurl);
|
||||
if (!($returnurl instanceof moodle_url)) {
|
||||
$returnurl = false;
|
||||
}
|
||||
}
|
||||
unset($SESSION->returnurl);
|
||||
}
|
||||
|
||||
if ($returnurl===false) {
|
||||
$returnurl = new moodle_url('/course/view.php', array('id'=>$course->id));
|
||||
if ($returnurl === false) {
|
||||
$returnurl = new moodle_url('/course/view.php', array('id' => $course->id));
|
||||
}
|
||||
redirect($returnurl);
|
||||
|
||||
redirect($returnurl);
|
||||
@@ -152,6 +152,7 @@ if ($course->id != SITEID && has_capability('moodle/course:viewparticipants', $c
|
||||
}
|
||||
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
|
||||
$PAGE->set_title("$course->shortname: $stractivityreport ($mode)");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
+20
-1
@@ -102,16 +102,29 @@ switch ($action) {
|
||||
break;
|
||||
case 'enrolcohort':
|
||||
require_capability('moodle/course:enrolconfig', $context);
|
||||
require_capability('enrol/cohort:config', $context);
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
if (!array_key_exists($roleid, $manager->get_assignable_roles())) {
|
||||
throw new enrol_ajax_exception('invalidrole');
|
||||
}
|
||||
$cohortid = required_param('cohortid', PARAM_INT);
|
||||
if (!array_key_exists($cohortid, $manager->get_cohorts())) {
|
||||
throw new enrol_ajax_exception('errorenrolcohort');
|
||||
}
|
||||
if (!$manager->enrol_cohort($cohortid, $roleid)) {
|
||||
throw new enrol_ajax_exception('errorenrolcohort');
|
||||
}
|
||||
break;
|
||||
case 'enrolcohortusers':
|
||||
require_capability('moodle/course:enrolconfig', $context);
|
||||
require_capability('enrol/manual:enrol', $context);
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
if (!array_key_exists($roleid, $manager->get_assignable_roles())) {
|
||||
throw new enrol_ajax_exception('invalidrole');
|
||||
}
|
||||
$cohortid = required_param('cohortid', PARAM_INT);
|
||||
if (!array_key_exists($cohortid, $manager->get_cohorts())) {
|
||||
throw new enrol_ajax_exception('errorenrolcohortusers');
|
||||
}
|
||||
$result = $manager->enrol_cohort_users($cohortid, $roleid);
|
||||
if ($result === false) {
|
||||
throw new enrol_ajax_exception('errorenrolcohortusers');
|
||||
@@ -154,6 +167,8 @@ switch ($action) {
|
||||
$roleid = optional_param('role', null, PARAM_INT);
|
||||
$duration = optional_param('duration', 0, PARAM_INT);
|
||||
$startdate = optional_param('startdate', 0, PARAM_INT);
|
||||
$recovergrades = optional_param('recovergrades', 0, PARAM_INT);
|
||||
|
||||
if (empty($roleid)) {
|
||||
$roleid = null;
|
||||
}
|
||||
@@ -185,6 +200,10 @@ switch ($action) {
|
||||
$plugin = $plugins[$instance->enrol];
|
||||
if ($plugin->allow_enrol($instance) && has_capability('enrol/'.$plugin->get_name().':enrol', $context)) {
|
||||
$plugin->enrol_user($instance, $user->id, $roleid, $timestart, $timeend);
|
||||
if ($recovergrades) {
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_recover_history_grades($user->id, $instance->courseid);
|
||||
}
|
||||
} else {
|
||||
throw new enrol_ajax_exception('enrolnotpermitted');
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ $string['youcantdo'] = 'You can\'t do this action: {$a->action}';
|
||||
$string['zipcode'] = 'Zip code';
|
||||
$string['cost'] = 'Cost';
|
||||
$string['currency'] = 'Currency';
|
||||
$string['enrolperiod'] = 'Enrolment period';
|
||||
$string['enrolperiod'] = 'Enrolment duration';
|
||||
$string['enrolstartdate'] = 'Start date';
|
||||
$string['enrolenddate'] = 'End date';
|
||||
$string['enrolenddaterror'] = 'Enrolment end date cannot be earlier than start date';
|
||||
|
||||
@@ -111,7 +111,7 @@ class enrol_category_handler {
|
||||
$params = array('courselevel'=>CONTEXT_COURSE, 'match'=>$parentcontext->path.'/%', 'userid'=>$ra->userid);
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
$params['userid'] = $ra->userid;
|
||||
|
||||
foreach ($rs as $instance) {
|
||||
@@ -119,7 +119,7 @@ class enrol_category_handler {
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
array_pop($contextids); // remove system context, we are interested in categories only
|
||||
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c000');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
|
||||
$params = array_merge($params, $contextparams);
|
||||
|
||||
$sql = "SELECT ra.id
|
||||
@@ -168,8 +168,8 @@ function enrol_category_sync_course($course) {
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
array_pop($contextids); // remove system context, we are interested in categories only
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
|
||||
$params = array_merge($params, $contextparams);
|
||||
$params['courseid'] = $course->id;
|
||||
|
||||
@@ -257,7 +257,7 @@ function enrol_category_sync_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
$params['courselevel'] = CONTEXT_COURSE;
|
||||
$params['catlevel'] = CONTEXT_COURSECAT;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user