Compare commits
770 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 305fbe760a | |||
| 79ef66af49 | |||
| ce70f9d0f7 | |||
| 3021f92c8c | |||
| 0cdc8c2261 | |||
| db948187be | |||
| 16ce52bb7d | |||
| 90048d3cba | |||
| 8e12fdea29 | |||
| e0c7cb6ffa | |||
| 7351ed0134 | |||
| 683f0e73d4 | |||
| dc6451ce04 | |||
| c0c6e7966e | |||
| dcce217160 | |||
| 547695f20d | |||
| afb6a8aa24 | |||
| ca6141c264 | |||
| 56861454c1 | |||
| 54bf19763e | |||
| 383fc1fbae | |||
| c0cea70f0b | |||
| 4598cc934a | |||
| c47951f806 | |||
| eb8509c5c3 | |||
| 9db56e51d9 | |||
| b33cc65f3e | |||
| 06a3ab6c0b | |||
| 705b30e99e | |||
| 81bf2a1a1d | |||
| 92697b53ee | |||
| b16832db0d | |||
| 842a71a6ac | |||
| f2fdb7f73a | |||
| 662ddae6c2 | |||
| 1bcd3da0de | |||
| f90d6ddb6d | |||
| dbaad889e8 | |||
| 9d8d2ee619 | |||
| 4a9727aa23 | |||
| d8b0e1bc26 | |||
| 50dfe52884 | |||
| e2710cb374 | |||
| 78040342e0 | |||
| 041a4a7d94 | |||
| 8c4489c53b | |||
| 66f9505a53 | |||
| 1d5490dfed | |||
| 8579d40d59 | |||
| c185e558a6 | |||
| ca6495bb72 | |||
| cd7265af3a | |||
| 4769b04283 | |||
| 1693774015 | |||
| de856ec6a8 | |||
| c25e1814ce | |||
| 95718caae7 | |||
| 42ed5416a5 | |||
| bf9417002d | |||
| b8251ddc44 | |||
| 92e6515548 | |||
| 52f95b5431 | |||
| c6483eb217 | |||
| 19219f8c10 | |||
| b9fdddbabd | |||
| de9de3cc1b | |||
| 461499b836 | |||
| 803122e110 | |||
| 116714e8dc | |||
| 880b243c8d | |||
| 1d2b991046 | |||
| 260bbdbc09 | |||
| 713e6922e0 | |||
| 3721bbf279 | |||
| f2b9ab28e6 | |||
| 5464847212 | |||
| c45e903821 | |||
| 06314d7faf | |||
| 66424a611f | |||
| 65c02d62ae | |||
| a00d309b33 | |||
| 5f980afc0e | |||
| 0601dd6961 | |||
| 404cc924aa | |||
| c657426438 | |||
| f54292267b | |||
| dd613b60ec | |||
| f4bd9d38a6 | |||
| 62cfefdbee | |||
| 91190892f1 | |||
| f0ad78b829 | |||
| adb1616724 | |||
| 90e0da6f75 | |||
| c6fbd0c8bf | |||
| 68b0cae5bc | |||
| 72988ea0f4 | |||
| e9a8da9d76 | |||
| b030363b02 | |||
| 9f0e9e6296 | |||
| 1257e3b729 | |||
| 59f80a1b88 | |||
| 84acd5d794 | |||
| fc79f4ca61 | |||
| 61c520c03c | |||
| e0c06eddc3 | |||
| b917d504a3 | |||
| 217926aaa1 | |||
| 83d3858b16 | |||
| f4eaf5c7f0 | |||
| 6991ad41a3 | |||
| c9af9c7570 | |||
| df4870fb31 | |||
| c80ffce497 | |||
| 0646f76fb6 | |||
| 63472c089e | |||
| 2249f52fe2 | |||
| 984109868d | |||
| ecbe7b1154 | |||
| 13d01b3338 | |||
| 5e1fc324de | |||
| d9a92e8f41 | |||
| 2b4dff5697 | |||
| d9a3cd37fe | |||
| 1d823156f7 | |||
| 124bda4f28 | |||
| b7f81b199c | |||
| 6d94ae6827 | |||
| 034f40257e | |||
| f68fd67f0c | |||
| ebf57c7e94 | |||
| b6c9003756 | |||
| 0d1bd690cb | |||
| aa0bf8596a | |||
| 65345f200c | |||
| be87ace1b6 | |||
| f17cc9cfe8 | |||
| c2a3bd52d2 | |||
| cd9f44d8df | |||
| 0f63503db0 | |||
| 897329c247 | |||
| de50c77537 | |||
| 8ad93cebfa | |||
| 89c3d84eda | |||
| 63e5ddeb20 | |||
| acb0b565b1 | |||
| c93ff53c82 | |||
| 75bb216d66 | |||
| cdfa338430 | |||
| a911b4cb3e | |||
| 1850ab013c | |||
| 887e2c8535 | |||
| b98956fdd2 | |||
| 29515af1d8 | |||
| 52b6c9bc01 | |||
| 746a8b2838 | |||
| 1e93a653a4 | |||
| a41848a445 | |||
| 31ffef36ac | |||
| bac1415a0b | |||
| e78e39cdbb | |||
| 4e6fbf663c | |||
| d1e6d47f1a | |||
| 50eb136630 | |||
| 99778c82c7 | |||
| af7278a4ff | |||
| 57dd3c6909 | |||
| 8d7887cdb5 | |||
| 65d7459b6d | |||
| 6a27fc8b34 | |||
| 9331c1ec8c | |||
| 46d433f701 | |||
| 928a51ad3d | |||
| 882ef2f226 | |||
| 042ae10e1d | |||
| 20253ec57b | |||
| 092e389f4f | |||
| bc861f559d | |||
| c4b48436f9 | |||
| db181b6a14 | |||
| 5fd1ca61b8 | |||
| 33db7d7276 | |||
| dd428d8c06 | |||
| e2cc9b272e | |||
| 3824133b8e | |||
| c8471b85e1 | |||
| 55a83bd034 | |||
| 5d0c60f882 | |||
| 8b01dd9d0f | |||
| 2b75dbe9b1 | |||
| b71e34d890 | |||
| e313d1695b | |||
| 085adaf545 | |||
| 129abbb41b | |||
| 4819f2eadd | |||
| 3c96772120 | |||
| fbbb4cc708 | |||
| f674c132b3 | |||
| d09e2a36f2 | |||
| 5411ca9e40 | |||
| ed2b8be31a | |||
| c7fc98256a | |||
| d1ced7c144 | |||
| 4625a1b540 | |||
| 21bb3f9466 | |||
| 514da614c3 | |||
| 78e010e9df | |||
| 91d9449144 | |||
| 787132eabc | |||
| 8e6ec68cdf | |||
| 562129c91d | |||
| db5e62d250 | |||
| c5fc1191e0 | |||
| ef6ad52352 | |||
| 03ba959758 | |||
| 1605e8d8d2 | |||
| 865f537fea | |||
| cd2b730489 | |||
| bcaed19cc9 | |||
| 92f03977db | |||
| 7e3707635c | |||
| d855d780a3 | |||
| 0e55d4af36 | |||
| c9ab8472a6 | |||
| f4cfa2cbd6 | |||
| 35124c3c4f | |||
| 857e992ff7 | |||
| a66bb4213e | |||
| 5a3f6eb468 | |||
| 5bd7b691b6 | |||
| ce46ec1eaf | |||
| e5d6cd5461 | |||
| dcd5d0840b | |||
| d48f4d2f75 | |||
| 64258fa070 | |||
| 35f858e855 | |||
| 5bb8e807eb | |||
| 5606d3aa5c | |||
| adb9f1aa1a | |||
| 2c1dda9302 | |||
| 4902915edb | |||
| 8d83e44bc4 | |||
| 62c4db2a24 | |||
| 792d1ea2dd | |||
| a8cf5e9574 | |||
| c61f5f8730 | |||
| 4fb3cc5894 | |||
| 04c5f73665 | |||
| 0d1e39b466 | |||
| f67ac6697c | |||
| bfb54eeea3 | |||
| bb5bda8aa1 | |||
| 3d1e457e3e | |||
| 05ceae9bb2 | |||
| e57802961b | |||
| 605b539184 | |||
| c58c05ad4f | |||
| fcb203c11b | |||
| 11ba685a7b | |||
| 0f6113cba0 | |||
| b51ac4e290 | |||
| fee000ff4e | |||
| 0c9fb0c1cb | |||
| 3e11be405b | |||
| 319887f86e | |||
| b27eef0f7e | |||
| 6dbe8ddbd8 | |||
| cd358c666f | |||
| bb61c874bb | |||
| d78b67b2fc | |||
| c31149fa67 | |||
| 2f76ac6362 | |||
| 14fdcb4f13 | |||
| 2871fedb58 | |||
| 42446a0b6d | |||
| 7fcdb8275c | |||
| 1ac90bc28e | |||
| 8e1f3b11c7 | |||
| a71e869f34 | |||
| 3dc794a8f5 | |||
| 1765044c64 | |||
| 573e559c96 | |||
| 5724bb16eb | |||
| 843599ae86 | |||
| 5a6042c9be | |||
| e8cc54227e | |||
| b3e26da9d9 | |||
| de05ce07c2 | |||
| c163f86350 | |||
| d9df0e34fc | |||
| f97184b9c9 | |||
| f8e01f918b | |||
| 479f14a07b | |||
| 1eab78b30e | |||
| 2ce6285fb0 | |||
| 4e3a4dd55c | |||
| 278fc5d6dc | |||
| 4acfacdbf8 | |||
| f4d4fcaa41 | |||
| 418f8dd9a7 | |||
| 7e647445dd | |||
| 97bb109b55 | |||
| a6bc302e64 | |||
| 043a0d4c27 | |||
| 8dd8427aa2 | |||
| d5e59d8950 | |||
| f3248ac9f2 | |||
| 39a3a53069 | |||
| bf03cf12b7 | |||
| 7d127b53e3 | |||
| 734d880e35 | |||
| 2146aae7bf | |||
| 6e765a4ce5 | |||
| 7c4f93cd5f | |||
| 94492249ec | |||
| 1f90d92464 | |||
| 7d3704f293 | |||
| ce4126c7a9 | |||
| fd32dbfa1d | |||
| 48861429c7 | |||
| 6cf9033d8d | |||
| a6f5a72ef5 | |||
| 94b0258dc3 | |||
| f818719f11 | |||
| 194c653a11 | |||
| 3782723995 | |||
| 6ba42caef7 | |||
| 673ee48eb8 | |||
| 2d129fbea0 | |||
| b37bb96b0f | |||
| a6b4124840 | |||
| ad9fee8416 | |||
| 1357fde409 | |||
| c0ba02d066 | |||
| 93af314f78 | |||
| a1f173f774 | |||
| 3a48019ea3 | |||
| ed88a0b815 | |||
| 8d716acba5 | |||
| f4e4ac8c59 | |||
| 329920fa22 | |||
| d6a84028e5 | |||
| 22f754bae6 | |||
| ffeebe6088 | |||
| 0bfc4d763a | |||
| 4b641eaf82 | |||
| 47b43d0b4c | |||
| d28da62e34 | |||
| 9d3f3b5093 | |||
| e71b8ccbd1 | |||
| 9d669d60bd | |||
| 73db83bfaa | |||
| 900e37bec7 | |||
| 35f7fa3d36 | |||
| 5c85ac9572 | |||
| fee082d56c | |||
| 9622a33982 | |||
| 57f2278c69 | |||
| fca1061612 | |||
| 8075bd8d8a | |||
| 4553925614 | |||
| 373d42cf3a | |||
| 08546a8973 | |||
| 3bb5950c7e | |||
| fd1e4d5039 | |||
| 1cecb26b18 | |||
| 8b727da971 | |||
| 46d732c252 | |||
| 3416857d84 | |||
| 58d053313f | |||
| e0a57f8ccc | |||
| 3dde1fcafb | |||
| cc2a87e3fe | |||
| d0eeb25a64 | |||
| 0ee1c3db00 | |||
| 9a260ddd2c | |||
| fc3a00dc64 | |||
| 6e3ef95711 | |||
| 44835cdc8b | |||
| 81308ee649 | |||
| 1434fdf7a6 | |||
| daa44ab05e | |||
| 3464845868 | |||
| 390c3bc54a | |||
| ead5f3793b | |||
| b5907a8674 | |||
| 839e233f17 | |||
| d76ac3bab6 | |||
| 8a8f68ff97 | |||
| b969338742 | |||
| ba69b6952a | |||
| e1765762c2 | |||
| ceb66eb1fd | |||
| d68cf3877c | |||
| 9257815ff1 | |||
| 446dbeed7a | |||
| 5f5990903f | |||
| 0baa0a305d | |||
| 23caf506ba | |||
| 50223a8ae1 | |||
| 1fc08528c7 | |||
| 79c0996c64 | |||
| 923ea459d8 | |||
| ab01926c99 | |||
| 47a6c7ee31 | |||
| c821346cfe | |||
| b8fffc6128 | |||
| 08258a6dfb | |||
| cf1f0dfb43 | |||
| 8c19c9cfd0 | |||
| 76c51e3b9b | |||
| 48dd268c8d | |||
| d71590772f | |||
| 89d13f61ca | |||
| 5f250cff88 | |||
| 46c485a63c | |||
| 36e673a766 | |||
| 352476d131 | |||
| b5dd45511d | |||
| 5c487f23ae | |||
| 8a28dbd4e1 | |||
| 8589241024 | |||
| 525a4642cd | |||
| d25f6a8ecb | |||
| 1d6070951a | |||
| 958f4ff45f | |||
| 8d66adc9b8 | |||
| 186fe7abe9 | |||
| 80f9011c00 | |||
| 0742a01d54 | |||
| cbc6589769 | |||
| f46c9dd0f2 | |||
| 5a2d320ca6 | |||
| 3b1055ee4c | |||
| f7de3d4360 | |||
| 1e13c7b154 | |||
| ac05e65ef2 | |||
| c609c3968e | |||
| 7b969f0bb0 | |||
| 3691c0de24 | |||
| 4be12986aa | |||
| 2d3659da69 | |||
| 7c4e7f8fdf | |||
| ced892ebb2 | |||
| 6d8e40a429 | |||
| 2bda67fa52 | |||
| ead9fe0cdf | |||
| d97f2caf13 | |||
| f084d74ed1 | |||
| b795d69cc3 | |||
| f778133a99 | |||
| 6a726a9901 | |||
| 412ae7b629 | |||
| c3cc54fcce | |||
| 9fed35fb09 | |||
| 6e41a68058 | |||
| 65634948fa | |||
| 85427358fc | |||
| 8df946ba30 | |||
| edb257109e | |||
| e89535552b | |||
| c08ea5202f | |||
| bd680d8a01 | |||
| 1ac84ccdfc | |||
| 661fc73a96 | |||
| 62c325eefe | |||
| e5a5ca2bcb | |||
| 595b68e2fd | |||
| 804feede10 | |||
| dc2c1b8974 | |||
| 93fb7b528b | |||
| d6f387e262 | |||
| a25ac01e95 | |||
| adca1840c4 | |||
| 54ba4bf583 | |||
| 403c191be1 | |||
| 69065330c4 | |||
| c8ad77f876 | |||
| 35eb31fa38 | |||
| dc52f193eb | |||
| e449096842 | |||
| 49eb5cf372 | |||
| 36ddd604b5 | |||
| 1399a5bc41 | |||
| 2547042fe6 | |||
| 5335b7deb8 | |||
| afa1de62b2 | |||
| d2db892076 | |||
| ddbc74866d | |||
| 80bc3d9880 | |||
| d4608845b2 | |||
| 4a979297aa | |||
| ce4ca89ef1 | |||
| 41d2e418a7 | |||
| 11990142b0 | |||
| 253b5f4d7e | |||
| 8858129c17 | |||
| 0656d45fbc | |||
| 98a4be5176 | |||
| b2fd3caea6 | |||
| 77b300ca51 | |||
| cb36e6ba4a | |||
| b182c1238e | |||
| fead3b432a | |||
| 877a07f709 | |||
| e0538fa845 | |||
| 41f8ca66e0 | |||
| a68b0363bf | |||
| 47860563bc | |||
| ade4de356e | |||
| 4494053b02 | |||
| 6c6042404a | |||
| 085cc4ef9a | |||
| b1d3043354 | |||
| dc201dce9e | |||
| 92a7892d42 | |||
| c2e8445bf1 | |||
| e6524dcbf9 | |||
| 2ed2d8c111 | |||
| e8a2384eb6 | |||
| 61231c48fa | |||
| b0a994f460 | |||
| bd8d0b81d6 | |||
| 999f7e3e17 | |||
| ec01a02d8b | |||
| e71b08c529 | |||
| d4341ff79c | |||
| 697f104ac1 | |||
| 167c8c6714 | |||
| d8c5082b76 | |||
| b054ead121 | |||
| 3f046db150 | |||
| d9cc6b7a31 | |||
| eb11030b38 | |||
| 43400d60de | |||
| 2719e7c8f9 | |||
| 767ed44ca4 | |||
| f24ff8f8d4 | |||
| 42bcf023b4 | |||
| c461a6a0a7 | |||
| bdd773ba40 | |||
| fcc24148d6 | |||
| 729ef69705 | |||
| 8c6bc1e000 | |||
| d6b01141a1 | |||
| 4f4bf67a31 | |||
| d0f6d6172a | |||
| 3ba909de87 | |||
| 97c0418e64 | |||
| a028969cc7 | |||
| cb2c45b31f | |||
| 65e5640a94 | |||
| f65eadd42d | |||
| ed9cc071d5 | |||
| 41b4bb03b2 | |||
| 18ca35b3fa | |||
| 17ee774fdf | |||
| 2de2d0d2cd | |||
| 94bea73f29 | |||
| a99a9a163e | |||
| d54abc73a1 | |||
| 46303d1deb | |||
| 0292c465fe | |||
| 12376c971f | |||
| 84c10aaa7c | |||
| fc0acdfacd | |||
| 59c0293d9e | |||
| 04b1865d44 | |||
| 31238c016e | |||
| d2fbfb5f73 | |||
| f01c7ddc7c | |||
| 48e43c12e6 | |||
| f90a927b52 | |||
| 120aa6fd38 | |||
| 11c5042847 | |||
| 76fae9b6ab | |||
| 431c68a867 | |||
| 7b88b81a49 | |||
| 4b023f2a10 | |||
| 2be11d5faf | |||
| d6105bc1e1 | |||
| 7068811aa9 | |||
| 2c92dc7bab | |||
| 0971dd7939 | |||
| 5e9050d1fb | |||
| d55cca19cf | |||
| 0175c5efaa | |||
| 29e247e44e | |||
| 112bbb8ff4 | |||
| e4a8f90479 | |||
| 58db57ad53 | |||
| cf6b626f39 | |||
| bddec3c1d6 | |||
| 340691baab | |||
| 67ace38c82 | |||
| 4bc0b067b6 | |||
| 9d0610f0f3 | |||
| 3bf0bb64fd | |||
| 59fccfb0cf | |||
| 0161e20b65 | |||
| da496c52f8 | |||
| ec202ddbba | |||
| 015c334a73 | |||
| e0f6644dc0 | |||
| 26420be610 | |||
| 4270267ee9 | |||
| 55878aa09b | |||
| e30281eed5 | |||
| d06b2e0c89 | |||
| 071746fb4a | |||
| 07435fc117 | |||
| 2733a8c4d5 | |||
| ea496d1a00 | |||
| f6fd27e70a | |||
| e06bc8c074 | |||
| 46424df47a | |||
| abdbeec6bb | |||
| 772c720527 | |||
| 4cfd77fc0e | |||
| 7ec66c7da8 | |||
| 44f2c95717 | |||
| a69d0091fa | |||
| c0254bafa8 | |||
| e8e1b85e72 | |||
| a81e8c47f1 | |||
| 292f509cff | |||
| 7ebb628d8d | |||
| ef1889484b | |||
| 4941396825 | |||
| 366d7c0aba | |||
| 11c86239b7 | |||
| 89399cb129 | |||
| 0d2001b756 | |||
| 9c6d59285e | |||
| 91e79a37cc | |||
| 9530780571 | |||
| a57b5479db | |||
| 6a680dd4aa | |||
| a8e1b6b3ef | |||
| e9ed7e0ed0 | |||
| 9f84da6969 | |||
| fbc708dc4d | |||
| 507e6a2eda | |||
| dff9c69fa8 | |||
| 26777ab2c3 | |||
| e9d7fb3a88 | |||
| e6c9fdb384 | |||
| cff8f5db55 | |||
| 5691235ace | |||
| 33ce9928d8 | |||
| 2cd9cfcc97 | |||
| a440a25c64 | |||
| 59307a664c | |||
| 42ec1aa258 | |||
| 246e844e5f | |||
| ad6c9ad223 | |||
| 56f55380a9 | |||
| aa7574545f | |||
| 739d5c91b9 | |||
| 2e83093eba | |||
| 2e32076884 | |||
| e10faa46a6 | |||
| 8b66d25681 | |||
| 51ffccda4d | |||
| fc109fac2d | |||
| 3905c1f75b | |||
| 2c4e52a7df | |||
| fb2e8f82c9 | |||
| ce539ad701 | |||
| 4bf46b6e96 | |||
| 5c1a9d64ac | |||
| 466b9bad29 | |||
| b1ddd85ca1 | |||
| 1f373dfef0 | |||
| 69439955e6 | |||
| 96f953cbe2 | |||
| 0ce936b081 | |||
| c232e12bf2 | |||
| fa0f103c89 | |||
| fc08a60dc1 | |||
| 51f205a7e3 | |||
| 7d0f9cef34 | |||
| 832626da76 | |||
| f51ba2033b | |||
| 3db8d8499e | |||
| be626b193e | |||
| 658762de67 | |||
| 494884fe7c | |||
| 104ed36274 | |||
| 27c202c1c0 | |||
| 3ef24c6f3b | |||
| 9616f3f71d | |||
| e6be794910 | |||
| b87ca9b713 | |||
| 7f40235c18 | |||
| 378ef32da0 | |||
| da9cfb9630 | |||
| 999e6901c8 | |||
| b2ace0016f | |||
| d22a68bd18 | |||
| a784430288 | |||
| 08b6184488 | |||
| 3da552e27c | |||
| 489981eaba | |||
| 6014124ea3 | |||
| c04109fcb1 | |||
| 7f7aac7ad1 | |||
| 298dd4ca5d | |||
| 08ba77f32e | |||
| 33e69c39ef | |||
| d047098e46 | |||
| 52b26f8a5b | |||
| 66e23d6a6c | |||
| e9f2ede177 | |||
| 861de3cda1 | |||
| 2b6a38f5c2 | |||
| 3ad6f443b4 | |||
| 22dde645f4 | |||
| d254ae8cfe | |||
| ec2b87aede | |||
| 0b1579b2d8 | |||
| 07f641f250 | |||
| 33d1075328 | |||
| 1b75985a39 | |||
| 3e6e265d1a | |||
| 7fabd5af5c | |||
| c81e5bc9cc | |||
| 13cd1994af | |||
| 6ac047c7de | |||
| f29d40dc03 | |||
| b3fe3fb6c8 | |||
| 12d0b6c5ae | |||
| 25ff180756 | |||
| cbb8087b30 | |||
| 030f323fbb | |||
| 10fd3cd054 | |||
| 840dc3cb94 | |||
| 495baea515 | |||
| 7f2d783fad | |||
| 1b99f0565a | |||
| f5ee52a7fe | |||
| 06d09486b5 | |||
| 337e7897de | |||
| aacacde221 | |||
| 0c1e3a753b | |||
| 15958e8677 | |||
| eb1f147000 | |||
| cfaa50a61d | |||
| 7ac10ac609 | |||
| 113b864ffc | |||
| 7303944957 | |||
| dd21fb11f0 | |||
| 10a6003a3a | |||
| ed4a909035 | |||
| 2bf4996444 | |||
| 4e68456832 | |||
| caec0405f4 | |||
| 181918691c | |||
| 45962a179c | |||
| 61df8b24d2 | |||
| 5b585b8ddf | |||
| 0aa433a054 | |||
| 53e40ebe2d | |||
| f822433322 | |||
| 44b4c10a47 | |||
| b1f60fe2f7 | |||
| 9d75f3a0b9 | |||
| cbf6a4989e | |||
| 35d565ad8f | |||
| a7bc85ea03 | |||
| 3bb16960af |
@@ -76,7 +76,13 @@ if (!empty($options['engine'])) {
|
||||
}
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
$DB->change_database_structure("ALTER TABLE {$table->name} ENGINE = $engine");
|
||||
try {
|
||||
$DB->change_database_structure("ALTER TABLE {$table->name} ENGINE = $engine");
|
||||
} catch (moodle_exception $e) {
|
||||
echo $e->getMessage()."\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
echo "DONE\n";
|
||||
$converted++;
|
||||
}
|
||||
|
||||
+4
-20
@@ -214,11 +214,7 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="mysql" version="5.0.25" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
@@ -335,11 +331,7 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="mysql" version="5.0.25" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
@@ -449,11 +441,7 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="mysql" version="5.0.25" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
@@ -563,11 +551,7 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
|
||||
@@ -50,7 +50,7 @@ class mnet_simple_host_form extends moodleform {
|
||||
$this->add_action_buttons(false, get_string('addhost', 'mnet'));
|
||||
}
|
||||
|
||||
function validation($data) {
|
||||
function validation($data, $files) {
|
||||
global $DB;
|
||||
|
||||
$wwwroot = $data['wwwroot'];
|
||||
@@ -154,7 +154,7 @@ class mnet_review_host_form extends moodleform {
|
||||
$this->add_action_buttons(false);
|
||||
}
|
||||
|
||||
function validation($data) {
|
||||
function validation($data, $files) {
|
||||
$errors = array();
|
||||
if ($data['oldpublickey'] == $data['public_key']) {
|
||||
return;
|
||||
|
||||
@@ -39,6 +39,15 @@ class mnet_profile_form extends moodleform {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mnetprofileimportfields = '';
|
||||
if (isset($CFG->mnetprofileimportfields)) {
|
||||
$mnetprofileimportfields = str_replace(',', ', ', $CFG->mnetprofileimportfields);
|
||||
}
|
||||
|
||||
$mnetprofileexportfields = '';
|
||||
if (isset($CFG->mnetprofileexportfields)) {
|
||||
$mnetprofileexportfields = str_replace(',', ', ', $CFG->mnetprofileexportfields);
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$fields = mnet_profile_field_options();
|
||||
@@ -49,7 +58,7 @@ class mnet_profile_form extends moodleform {
|
||||
$select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileimportfields));
|
||||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), $mnetprofileimportfields);
|
||||
|
||||
// Fields to export ----------------------------------------------------
|
||||
$mform->addElement('header', 'export', get_string('exportfields', 'mnet'));
|
||||
@@ -57,7 +66,7 @@ class mnet_profile_form extends moodleform {
|
||||
$select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileexportfields));
|
||||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), $mnetprofileexportfields);
|
||||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class mnet_services_form extends moodleform {
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$mnet_peer =& $this->_customdata['peer'];
|
||||
$myservices =& mnet_get_service_info($mnet_peer);
|
||||
$myservices = mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
|
||||
|
||||
@@ -50,8 +50,10 @@ if ($course) {
|
||||
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
$safeoverridesonly = false;
|
||||
if (!has_capability('moodle/role:override', $context)) {
|
||||
require_capability('moodle/role:safeoverride', $context);
|
||||
$safeoverridesonly = true;
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context($context);
|
||||
@@ -119,7 +121,7 @@ if (empty($overridableroles[$roleid])) {
|
||||
}
|
||||
|
||||
// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, false);
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable->read_submitted_permissions();
|
||||
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
|
||||
@@ -54,6 +54,17 @@ if (!$canview) {
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
|
||||
}
|
||||
|
||||
if ($userid != $USER->id) {
|
||||
// If its not the current user we need to extend the navigation for that user to ensure
|
||||
// their navigation is loaded and this page found upon it.
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
}
|
||||
if ($course->id != $SITE->id || $userid != $USER->id) {
|
||||
// If we're within a course OR if we're viewing another user then we need to include the
|
||||
// settings base on the navigation to ensure that the navbar will contain the users name.
|
||||
$PAGE->navbar->includesettingsbase = true;
|
||||
}
|
||||
|
||||
/// Now get the role assignments for this user.
|
||||
$sql = "SELECT
|
||||
ra.id, ra.userid, ra.contextid, ra.roleid, ra.component, ra.itemid,
|
||||
@@ -120,14 +131,9 @@ $title = get_string('xroleassignments', 'role', $fullname);
|
||||
$PAGE->set_title($title);
|
||||
if ($courseid != SITEID) {
|
||||
$PAGE->set_heading($fullname);
|
||||
if (has_capability('moodle/course:viewparticipants', $coursecontext)) {
|
||||
$PAGE->navbar->add(get_string('participants'),new moodle_url('/user/index.php', array('id'=>$courseid)));
|
||||
}
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
$PAGE->navbar->add($fullname, new moodle_url("$CFG->wwwroot/user/view.php", array('id'=>$userid,'course'=>$courseid)));
|
||||
$PAGE->navbar->add($straction);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title, 3);
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
|
||||
@@ -92,8 +92,29 @@ if ($hassiteconfig
|
||||
// Add a category for backups
|
||||
$ADMIN->add('courses', new admin_category('backups', get_string('backups','admin')));
|
||||
|
||||
// Create a page for general backup defaults
|
||||
// Create a page for general backups configuration and defaults.
|
||||
$temp = new admin_settingpage('backupgeneralsettings', get_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse');
|
||||
|
||||
// General configuration section.
|
||||
$temp->add(new admin_setting_configselect('backup/loglifetime', get_string('loglifetime', 'backup'), get_string('configloglifetime', 'backup'), 30, array(
|
||||
1 => get_string('numdays', '', 1),
|
||||
2 => get_string('numdays', '', 2),
|
||||
3 => get_string('numdays', '', 3),
|
||||
5 => get_string('numdays', '', 5),
|
||||
7 => get_string('numdays', '', 7),
|
||||
10 => get_string('numdays', '', 10),
|
||||
14 => get_string('numdays', '', 14),
|
||||
20 => get_string('numdays', '', 20),
|
||||
30 => get_string('numdays', '', 30),
|
||||
60 => get_string('numdays', '', 60),
|
||||
90 => get_string('numdays', '', 90),
|
||||
120 => get_string('numdays', '', 120),
|
||||
180 => get_string('numdays', '', 180),
|
||||
365 => get_string('numdays', '', 365)
|
||||
)));
|
||||
|
||||
// General defaults section.
|
||||
$temp->add(new admin_setting_heading('generalsettings', get_string('generalsettings', 'backup'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_users', get_string('generalusers','backup'), get_string('configgeneralusers','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_anonymize', get_string('generalanonymize','backup'), get_string('configgeneralanonymize','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_role_assignments', get_string('generalroleassignments','backup'), get_string('configgeneralroleassignments','backup'), array('value'=>1, 'locked'=>0)));
|
||||
@@ -106,8 +127,10 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', get_string('generalhistories','backup'), get_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
/// "backups" settingpage
|
||||
// Create a page for automated backups configuration and defaults.
|
||||
$temp = new admin_settingpage('automated', get_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
|
||||
|
||||
// Automated configuration section.
|
||||
$temp->add(new admin_setting_configselect('backup/backup_auto_active', get_string('active'), get_string('autoactivedescription', 'backup'), 0, array(
|
||||
0 => get_string('autoactivedisabled', 'backup'),
|
||||
1 => get_string('autoactiveenabled', 'backup'),
|
||||
@@ -138,8 +161,9 @@ 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_configcheckbox('backup/backup_shortname', get_string('backup_shortname', 'admin'), get_string('backup_shortnamehelp', 'admin'), 0));
|
||||
|
||||
|
||||
// Automated defaults section.
|
||||
$temp->add(new admin_setting_heading('automatedsettings', get_string('automatedsettings','backup'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', get_string('generalusers', 'backup'), get_string('configgeneralusers', 'backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', get_string('generalroleassignments','backup'), get_string('configgeneralroleassignments','backup'), 1));
|
||||
|
||||
@@ -477,6 +477,13 @@ foreach ($pages as $page) {
|
||||
$ADMIN->add('reportplugins', $page);
|
||||
}
|
||||
|
||||
/// Add all admin tools
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('tools', get_string('tools', 'admin')));
|
||||
$ADMIN->add('tools', new admin_externalpage('managetools', get_string('toolsmanage', 'admin'),
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
|
||||
}
|
||||
|
||||
// Now add various admin tools
|
||||
foreach (get_plugin_list('tool') as $plugin => $plugindir) {
|
||||
$settings_path = "$plugindir/settings.php";
|
||||
@@ -485,13 +492,6 @@ foreach (get_plugin_list('tool') as $plugin => $plugindir) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Add all admin tools
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('tools', get_string('tools', 'admin')));
|
||||
$ADMIN->add('tools', new admin_externalpage('managetools', get_string('toolsmanage', 'admin'),
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
|
||||
}
|
||||
|
||||
/// Add all local plugins - must be always last!
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('localplugins', get_string('localplugins')));
|
||||
|
||||
+3
-1
@@ -9,6 +9,9 @@
|
||||
$zone = clean_param($zone, PARAM_PATH);
|
||||
}
|
||||
|
||||
$PAGE->set_url('/admin/timezone.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
@@ -18,7 +21,6 @@
|
||||
$strusers = get_string("users");
|
||||
$strall = get_string("all");
|
||||
|
||||
$PAGE->set_url('/admin/timezone.php');
|
||||
$PAGE->set_title($strtimezone);
|
||||
$PAGE->set_heading($strtimezone);
|
||||
$PAGE->navbar->add($strtimezone);
|
||||
|
||||
@@ -121,7 +121,7 @@ function bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid=-1) {
|
||||
$discussion->groupid = $groupid;
|
||||
$message = '';
|
||||
|
||||
$discussionid = forum_add_discussion($discussion, null, $message);
|
||||
$discussionid = forum_add_discussion($discussion, null, $message, $blogentry->userid);
|
||||
|
||||
// Copy file attachment records
|
||||
$fs = get_file_storage();
|
||||
|
||||
@@ -46,11 +46,17 @@ if (data_submitted() and $confirm and confirm_sesskey()) {
|
||||
|
||||
echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
if ($tables = $DB->get_tables()) {
|
||||
$DB->set_debug(true);
|
||||
foreach ($tables as $table) {
|
||||
$fulltable = $DB->get_prefix().$table;
|
||||
$DB->change_database_structure("ALTER TABLE $fulltable ENGINE=INNODB");
|
||||
try {
|
||||
$DB->change_database_structure("ALTER TABLE $fulltable ENGINE=INNODB");
|
||||
} catch (moodle_exception $e) {
|
||||
echo $OUTPUT->notification(s($e->getMessage()).'<br />'.s($e->debuginfo));
|
||||
}
|
||||
}
|
||||
$DB->set_debug(false);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ With a lot of question attempts, doing the whole conversion on upgrade is very
|
||||
slow. The plugin can help with that in various ways.
|
||||
|
||||
|
||||
1. It provies a report of how much data there is to upgrade.
|
||||
1. It provides a report of how much data there is to upgrade.
|
||||
|
||||
2. It can extract test-cases from the database. This can help you report bugs
|
||||
in the upgrade process to the developers.
|
||||
@@ -35,3 +35,9 @@ subsequently been modified) so you can re-upgrade them. This may allow you to
|
||||
recover from a buggy upgrade.
|
||||
|
||||
9. Finally, you can still use the extract test-cases script to help report bugs.
|
||||
|
||||
|
||||
Manual upgrades can be processed via the web interface or the command line tool
|
||||
cliupgrade.php. To run cliupgrade.php, use a command similar to:
|
||||
sudo -u www-data /usr/bin/php admin/tool/qeupgradehelper/cli/convert.php -h
|
||||
The -h flag will show the options for running the tool.
|
||||
@@ -0,0 +1,129 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Script to allow upgrading of quizzes with attempts that were previously
|
||||
* skipped.
|
||||
*
|
||||
* @package tool_qeupgradehelper
|
||||
* @copyright 2012 Eric Merrill, Oakland Unversity
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.php');
|
||||
require_once(dirname(dirname(__FILE__)) . '/locallib.php');
|
||||
require_once(dirname(dirname(__FILE__)) . '/lib.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // CLI only functions.
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('quiz'=>false, 'timelimit'=>false, 'countlimit'=>false, 'help'=>false),
|
||||
array('c'=>'countlimit', 't'=>'timelimit', 'h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Question engine upgrade helper CLI tool.
|
||||
Will upgrade all remaining question attempts if no options are specified.
|
||||
|
||||
Options:
|
||||
-c, --countlimit=<n> Process n number of quizzes then exit
|
||||
-t, --timelimit=<n> Process quizzes for n number of seconds, then exit. A quiz
|
||||
currently in progress will not be interrupted.
|
||||
--quiz=<quizid> Process quiz quizid only
|
||||
-h, --help Print out this help
|
||||
|
||||
countlimit and timelimit can be used together. First one to trigger will stop execution.
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/tool/qeupgradehelper/cliupgrade.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!tool_qeupgradehelper_is_upgraded()) {
|
||||
mtrace('qeupgradehelper: site not yet upgraded. Doing nothing.');
|
||||
return;
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/afterupgradelib.php');
|
||||
|
||||
|
||||
$starttime = time();
|
||||
|
||||
// Setup the stop time.
|
||||
if ($options['timelimit']) {
|
||||
$stoptime = time() + $options['timelimit'];
|
||||
} else {
|
||||
$stoptime = false;
|
||||
}
|
||||
|
||||
// If we are doing a quiz id, limit to one.
|
||||
if ($options['quiz']) {
|
||||
$options['countlimit'] = 1;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
|
||||
mtrace('qeupgradehelper: processing ...');
|
||||
|
||||
/* This while statement does a few things
|
||||
* Basically if an option is set to false, then that subsection will return
|
||||
* true, and will short circuit the test condition for that option, and always
|
||||
* being true. Both options are anded together, so either one can trigger to stop.
|
||||
*/
|
||||
while ((!$stoptime || (time() < $stoptime)) && (!$options['countlimit'] || ($count < $options['countlimit']))) {
|
||||
if ($options['quiz']) {
|
||||
$quizid = $options['quiz'];
|
||||
} else {
|
||||
$quiz = tool_qeupgradehelper_get_quiz_for_upgrade();
|
||||
if (!$quiz) {
|
||||
mtrace('qeupgradehelper: No more quizzes to process.');
|
||||
break; // No more to do.
|
||||
}
|
||||
|
||||
$quizid = $quiz->id;
|
||||
}
|
||||
$quizsummary = tool_qeupgradehelper_get_quiz($quizid);
|
||||
if ($quizsummary) {
|
||||
mtrace(' starting upgrade of attempts at quiz ' . $quizid);
|
||||
$upgrader = new tool_qeupgradehelper_attempt_upgrader(
|
||||
$quizsummary->id, $quizsummary->numtoconvert);
|
||||
$upgrader->convert_all_quiz_attempts();
|
||||
mtrace(' upgrade of quiz ' . $quizid . ' complete.');
|
||||
} else {
|
||||
mtrace('quiz ' . $quizid . ' not found or already upgraded.');
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
mtrace('qeupgradehelper: Done. Processed '.$count.' quizes in '.(time()-$starttime).' seconds');
|
||||
return;
|
||||
@@ -48,16 +48,16 @@ $string['gotoindex'] = 'Back to the list of quizzes that can be upgraded';
|
||||
$string['gotoquizreport'] = 'Go to the reports for this quiz, to check the upgrade';
|
||||
$string['gotoresetlink'] = 'Go to the list of quizzes that can be reset';
|
||||
$string['includedintheupgrade'] = 'Included in the upgrade?';
|
||||
$string['invalidquizid'] = 'Invaid quiz id. Either the quiz does not exist, or it has no attempts to convert.';
|
||||
$string['invalidquizid'] = 'Invalid quiz id. Either the quiz does not exist, or it has no attempts to convert.';
|
||||
$string['listpreupgrade'] = 'List quizzes and attempts';
|
||||
$string['listpreupgrade_desc'] = 'This will show a report of all the quizzes on the system and how many attempts they have. This will give you an idea of the scope of the upgrade you have to do.';
|
||||
$string['listpreupgradeintro'] = 'These are the number of quiz attempts that will need to be processed when you upgrade your site. A few tens of thousands is no worry. Much beyond that and you need to think about how long the upgrade will take.';
|
||||
$string['listtodo'] = 'List quizzes still to upgrade';
|
||||
$string['listtodo_desc'] = 'This will show a report of all the quizzes on the system (if any) that have attempts that still need to be upgraded to the new question engine.';
|
||||
$string['listtodointro'] = 'These are all the quizzes with attempt data that still needs to be converted. You can convert the attempts by clicking the link.';
|
||||
$string['listupgraded'] = 'List already upgrade quizzes that can be reset';
|
||||
$string['listupgraded'] = 'List already upgraded quizzes that can be reset';
|
||||
$string['listupgraded_desc'] = 'This will show a report of all the quizzes on the system whose attempts have been upgraded, and where the old data is still present so the upgrade could be reset and redone.';
|
||||
$string['listupgradedintro'] = 'These are all the quizzes that have attempts that were upgraded, and where the old attempt data is so there, so they could be reset, and the upgrade re-done.';
|
||||
$string['listupgradedintro'] = 'These are all the quizzes that have attempts that were upgraded, and where the old attempt data is still there, so they could be reset, and the upgrade re-done.';
|
||||
$string['noquizattempts'] = 'Your site does not have any quiz attempts at all!';
|
||||
$string['nothingupgradedyet'] = 'No upgraded attempts that can be reset';
|
||||
$string['notupgradedsiterequired'] = 'This script can only work before the site has been upgraded.';
|
||||
@@ -80,4 +80,4 @@ $string['resettingquizattemptsprogress'] = 'Resetting attempt {$a->done} / {$a->
|
||||
$string['upgradingquizattempts'] = 'Upgrading the attempts for quiz \'{$a->name}\' in course {$a->shortname}';
|
||||
$string['upgradedsitedetected'] = 'This appears to be a site that has been upgraded to include the new question engine.';
|
||||
$string['upgradedsiterequired'] = 'This script can only work after the site has been upgraded.';
|
||||
$string['veryoldattemtps'] = 'Your site has {$a} quiz attempts that were never completely updated during the upgrade from Moodle 1.4 to Moodle 1.5. These attempts will be dealt wiht before the main upgrade. You need to to consider the extra time required for this.';
|
||||
$string['veryoldattemtps'] = 'Your site has {$a} quiz attempts that were never completely updated during the upgrade from Moodle 1.4 to Moodle 1.5. These attempts will be dealt with before the main upgrade. You need to to consider the extra time required for this.';
|
||||
|
||||
@@ -669,5 +669,5 @@ function tool_qeupgradehelper_get_quiz_for_upgrade() {
|
||||
JOIN {course} c ON c.id = quiz.course
|
||||
WHERE quiza.preview = 0 AND quiza.needsupgradetonewqe = 1
|
||||
GROUP BY quiz.id, quiz.name, c.shortname, c.id
|
||||
ORDER BY quiza.timemodified DESC", array(), IGNORE_MULTIPLE);
|
||||
ORDER BY MAX(quiza.timemodified) DESC", array(), IGNORE_MULTIPLE);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['configintrotimezones'] = 'This page will search for new information about world timezones (including daylight savings time rules) and update your local database with this information. These locations will be checked, in order: {$a} This procedure is generally very safe and can not break normal installations. Do you wish to update your timezones now?';
|
||||
$string['configintrotimezones'] = 'This page will search for new information about world timezones (including daylight savings time rules) and update your local database with this information. These locations will be checked, in order: {$a} Do you wish to update your timezones now?';
|
||||
$string['importtimezones'] = 'Update complete list of timezones';
|
||||
$string['importtimezonescount'] = '{$a->count} entries imported from {$a->source}';
|
||||
$string['importtimezonesfailed'] = 'No sources found! (Bad news)';
|
||||
|
||||
@@ -70,6 +70,7 @@ $string['documentationintro'] = 'This documentation is generated automatically f
|
||||
$string['down'] = 'Down';
|
||||
$string['duplicate'] = 'Duplicate';
|
||||
$string['duplicatefieldname'] = 'Another field with that name exists';
|
||||
$string['duplicatefieldsused'] = 'Duplicate fields used';
|
||||
$string['duplicatekeyname'] = 'Another key with that name exists';
|
||||
$string['duplicatetablename'] = 'Another table with that name exists';
|
||||
$string['edit'] = 'Edit';
|
||||
@@ -89,6 +90,7 @@ $string['field'] = 'Field';
|
||||
$string['fieldnameempty'] = 'Name field empty';
|
||||
$string['fields'] = 'Fields';
|
||||
$string['fieldsnotintable'] = 'Field doesn\'t exist in table';
|
||||
$string['fieldsusedinindex'] = 'This field is used as index';
|
||||
$string['fieldsusedinkey'] = 'This field is used as key.';
|
||||
$string['filenotwriteable'] = 'File not writeable';
|
||||
$string['fkviolationdetails'] = 'Foreign key {$a->keyname} on table {$a->tablename} is violated by {$a->numviolations} out of {$a->numrows} rows.';
|
||||
@@ -114,8 +116,10 @@ $string['incorrectfieldname'] = 'Incorrect name';
|
||||
$string['index'] = 'Index';
|
||||
$string['indexes'] = 'Indexes';
|
||||
$string['integerincorrectlength'] = 'Incorrect length for integer field';
|
||||
$string['incorrectkeyname'] = 'Incorrect key name';
|
||||
$string['incorrecttablename'] = 'Incorrect table name';
|
||||
$string['key'] = 'Key';
|
||||
$string['keynameempty'] = 'The key name cannot be empty';
|
||||
$string['keys'] = 'Keys';
|
||||
$string['listreservedwords'] = 'List of Reserved Words<br />(used to keep <a href="http://docs.moodle.org/en/XMLDB_reserved_words" target="_blank">XMLDB_reserved_words</a> updated)';
|
||||
$string['load'] = 'Load';
|
||||
@@ -133,8 +137,11 @@ $string['newkey'] = 'New key';
|
||||
$string['newtable'] = 'New table';
|
||||
$string['newtablefrommysql'] = 'New table from MySQL';
|
||||
$string['new_table_from_mysql'] = 'New table from MySQL';
|
||||
$string['nofieldsspecified'] = 'No fields specified';
|
||||
$string['nomasterprimaryuniquefound'] = 'The column(s) that you foreign key references must be included in a primary or unique KEY in the referenced table. Note, the column being in a UNIQUE INDEX is not good enough.';
|
||||
$string['nomissingindexesfound'] = 'No missing indexes have been found, your DB doesn\'t need further actions.';
|
||||
$string['noreffieldsspecified'] = 'No reference fields specified';
|
||||
$string['noreftablespecified'] = 'Specified reference table not found';
|
||||
$string['noviolatedforeignkeysfound'] = 'No violated foreign keys found';
|
||||
$string['nowrongdefaultsfound'] = 'No inconsistent default values have been found, your DB does not need further actions.';
|
||||
$string['nowrongintsfound'] = 'No wrong integers have been found, your DB doesn\'t need further actions.';
|
||||
@@ -145,6 +152,7 @@ $string['pendingchanges'] = 'Note: You have performed changes to this file. They
|
||||
$string['pendingchangescannotbesaved'] = 'There are changes in this file but they cannot be saved! Please verify that both the directory and the "install.xml" within it have write permissions for the web server.';
|
||||
$string['pendingchangescannotbesavedreload'] = 'There are changes in this file but they cannot be saved! Please verify that both the directory and the "install.xml" within it have write permissions for the web server. Then reload this page and you should be able to save those changes.';
|
||||
$string['pluginname'] = 'XMLDB editor';
|
||||
$string['primarykeyonlyallownotnullfields'] = 'Primary keys cannot be null';
|
||||
$string['reserved'] = 'Reserved';
|
||||
$string['reservedwords'] = 'Reserved words';
|
||||
$string['revert'] = 'Revert';
|
||||
@@ -181,6 +189,7 @@ $string['wrong'] = 'Wrong';
|
||||
$string['wrongdefaults'] = 'Wrong defaults found';
|
||||
$string['wrongints'] = 'Wrong integers found';
|
||||
$string['wronglengthforenum'] = 'Incorrect length for enum field';
|
||||
$string['wrongnumberofreffields'] = 'Wrong number of reference fields';
|
||||
$string['wrongreservedwords'] = 'Currently used reserved words<br />(note that table names aren\'t important if using $CFG->prefix)';
|
||||
$string['wrongoraclesemantics'] = 'Wrong Oracle BYTE semantics found';
|
||||
$string['yesmissingindexesfound'] = 'Some missing indexes have been found in your DB. Here are their details and the needed SQL statements to be executed with your favourite SQL interface to create all them (don\'t forget to backup your data before doing that).<br /><br />After doing that, it\'s highly recommended to execute this utility again to check that no more missing indexes are found.';
|
||||
|
||||
@@ -63,6 +63,7 @@ class external_service_form extends moodleform {
|
||||
|
||||
$mform->addElement('text', 'name', get_string('name'));
|
||||
$mform->addRule('name', get_string('required'), 'required', null, 'client');
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'webservice'));
|
||||
$mform->addElement('advcheckbox', 'restrictedusers',
|
||||
get_string('restrictedusers', 'webservice'));
|
||||
@@ -112,7 +113,7 @@ class external_service_form extends moodleform {
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
if (!empty($service->id)) {
|
||||
$buttonlabel = get_string('editaservice', 'webservice');
|
||||
$buttonlabel = get_string('savechanges');
|
||||
} else {
|
||||
$buttonlabel = get_string('addaservice', 'webservice');
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
admin_externalpage_setup('externalservicefunctions');
|
||||
|
||||
//define nav bar
|
||||
$PAGE->set_url('/' . $CFG->admin . '/websevice/service_functions.php', array('id' => $serviceid));
|
||||
$PAGE->set_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid));
|
||||
$node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
|
||||
if ($node) {
|
||||
$node->make_active();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<div class="loginbox clearfix">
|
||||
<div class="loginpanel">
|
||||
<div>
|
||||
<a href="<?php echo $CFG->wwwroot.'/login/index.php?authCAS=CAS';?>"><?php print_string('accesCAS', 'auth_cas');?></a>
|
||||
<a href="<?php echo get_login_url() . '?authCAS=CAS';?>"><?php print_string('accesCAS', 'auth_cas');?></a>
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
<a href="<?php echo $CFG->wwwroot.'/login/index.php?authCAS=NOCAS';?>"><?php print_string('accesNOCAS', 'auth_cas');?></a>
|
||||
<a href="<?php echo get_login_url() . '?authCAS=NOCAS';?>"><?php print_string('accesNOCAS', 'auth_cas');?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,8 +30,8 @@ $string['auth_cas_baseuri'] = 'URI of the server (nothing if no baseUri)<br />Fo
|
||||
$string['auth_cas_baseuri_key'] = 'Base URI';
|
||||
$string['auth_cas_broken_password'] = 'You cannot proceed without changing your password, however there is no available page for changing it. Please contact your Moodle Administrator.';
|
||||
$string['auth_cas_cantconnect'] = 'LDAP part of CAS-module cannot connect to server: {$a}';
|
||||
$string['auth_cas_casversion'] = 'Version';
|
||||
$string['auth_cas_certificate_check'] = 'Turn this to \'yes\' if you want to validate the server certificate';
|
||||
$string['auth_cas_casversion'] = 'CAS protocol version';
|
||||
$string['auth_cas_certificate_check'] = 'Select \'yes\' if you want to validate the server certificate';
|
||||
$string['auth_cas_certificate_path_empty'] = 'If you turn on Server validation, you need to specify a certificate path';
|
||||
$string['auth_cas_certificate_check_key'] = 'Server validation';
|
||||
$string['auth_cas_certificate_path'] = 'Path of the CA chain file (PEM Format) to validate the server certificate';
|
||||
@@ -44,22 +44,22 @@ $string['auth_cas_hostname'] = 'Hostname of the CAS server <br />eg: host.domain
|
||||
$string['auth_cas_hostname_key'] = 'Hostname';
|
||||
$string['auth_cas_changepasswordurl'] = 'Password-change URL';
|
||||
$string['auth_cas_invalidcaslogin'] = 'Sorry, your login has failed - you could not be authorised';
|
||||
$string['auth_cas_language'] = 'Selected language';
|
||||
$string['auth_cas_language'] = 'Select language for authentication pages';
|
||||
$string['auth_cas_language_key'] = 'Language';
|
||||
$string['auth_cas_logincas'] = 'Secure connection access';
|
||||
$string['auth_cas_logoutcas'] = 'Turn this to \'yes\' if you want to logout from CAS when you disconnect from Moodle';
|
||||
$string['auth_cas_logoutcas_key'] = 'Logout CAS';
|
||||
$string['auth_cas_multiauth'] = 'Turn this to \'yes\' if you want to have multi-authentication (CAS + other authentication)';
|
||||
$string['auth_cas_logoutcas'] = 'Select \'yes\' if you want to logout from CAS when you disconnect from Moodle';
|
||||
$string['auth_cas_logoutcas_key'] = 'CAS logout option';
|
||||
$string['auth_cas_multiauth'] = 'Select \'yes\' if you want to have multi-authentication (CAS + other authentication)';
|
||||
$string['auth_cas_multiauth_key'] = 'Multi-authentication';
|
||||
$string['auth_casnotinstalled'] = 'Cannot use CAS authentication. The PHP LDAP module is not installed.';
|
||||
$string['auth_cas_port'] = 'Port of the CAS server';
|
||||
$string['auth_cas_port_key'] = 'Port';
|
||||
$string['auth_cas_proxycas'] = 'Turn this to \'yes\' if you use CASin proxy-mode';
|
||||
$string['auth_cas_proxycas'] = 'Select \'yes\' if you use CAS in proxy-mode';
|
||||
$string['auth_cas_proxycas_key'] = 'Proxy mode';
|
||||
$string['auth_cas_server_settings'] = 'CAS server configuration';
|
||||
$string['auth_cas_text'] = 'Secure connection';
|
||||
$string['auth_cas_use_cas'] = 'Use CAS';
|
||||
$string['auth_cas_version'] = 'Version of CAS';
|
||||
$string['auth_cas_version'] = 'CAS protocol version to use';
|
||||
$string['CASform'] = 'Authentication choice';
|
||||
$string['noldapserver'] = 'No LDAP server configured for CAS! Syncing disabled.';
|
||||
$string['pluginname'] = 'CAS server (SSO)';
|
||||
|
||||
@@ -57,7 +57,7 @@ $string['auth_dbsybasequoting'] = 'Use sybase quotes';
|
||||
$string['auth_dbsybasequotinghelp'] = 'Sybase style single quote escaping - needed for Oracle, MS SQL and some other databases. Do not use for MySQL!';
|
||||
$string['auth_dbtable'] = 'Name of the table in the database';
|
||||
$string['auth_dbtable_key'] = 'Table';
|
||||
$string['auth_dbtype'] = 'The database type (See the <a href="../lib/adodb/readme.htm#drivers">ADOdb documentation</a> for details)';
|
||||
$string['auth_dbtype'] = 'The database type (See the <a href="http://phplens.com/adodb/supported.databases.html" target="_blank">ADOdb documentation</a> for details)';
|
||||
$string['auth_dbtype_key'] = 'Database';
|
||||
$string['auth_dbupdatinguser'] = 'Updating user {$a->name} id {$a->id}';
|
||||
$string['auth_dbuser'] = 'Username with read access to the database';
|
||||
|
||||
@@ -33,8 +33,9 @@ $PAGE->set_title("$site->fullname: $loginsite");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// $PAGE->https_required() up above takes care of what $CFG->httpswwwroot should be.
|
||||
$msg = '<p>'.get_string('ntlmsso_attempting', 'auth_ldap').'</p>'
|
||||
. '<img width="1", height="1" '
|
||||
. ' src="' . $CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
|
||||
. ' src="' . $CFG->httpswwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
|
||||
. $sesskey . '" />';
|
||||
redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);
|
||||
redirect($CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);
|
||||
|
||||
@@ -29,7 +29,8 @@ $file = $CFG->dirroot.'/pix/spacer.gif';
|
||||
if ($authplugin->ntlmsso_magic($sesskey) && file_exists($file)) {
|
||||
if (!empty($authplugin->config->ntlmsso_ie_fastpath)) {
|
||||
if (check_browser_version('MSIE')) {
|
||||
redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php');
|
||||
// $PAGE->https_required() up above takes care of what $CFG->httpswwwroot should be.
|
||||
redirect($CFG->httpswwwroot.'/auth/ldap/ntlmsso_finish.php');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,17 +44,17 @@ $PAGE->https_required();
|
||||
// Redirect to SessionInitiator with entityID as argument
|
||||
if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])) {
|
||||
// For Shibbolet 1.x Service Providers
|
||||
header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
|
||||
header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
|
||||
|
||||
// For Shibbolet 2.x Service Providers
|
||||
// header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
|
||||
// header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
|
||||
|
||||
} else {
|
||||
// For Shibbolet 1.x Service Providers
|
||||
header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
|
||||
header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
|
||||
|
||||
// For Shibboleth 2.x Service Providers
|
||||
// header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
|
||||
// header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
|
||||
}
|
||||
} elseif (isset($_POST['idp']) && !isset($IdPs[$_POST['idp']])) {
|
||||
$errormsg = get_string('auth_shibboleth_errormsg', 'auth_shibboleth');
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ switch ($type) {
|
||||
case backup::TYPE_1SECTION :
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/backup:backupsection', $coursecontext);
|
||||
if (!empty($section->name)) {
|
||||
if ((string)$section->name !== '') {
|
||||
$sectionname = format_string($section->name, true, array('context' => $coursecontext));
|
||||
$heading = get_string('backupsection', 'backup', $sectionname);
|
||||
$PAGE->navbar->add($sectionname);
|
||||
|
||||
+18
-5
@@ -71,6 +71,11 @@ class cc2moodle {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Before iterate over directories, try to find one manifest at top level
|
||||
if (file_exists($folder . '/imsmanifest.xml')) {
|
||||
return $folder . '/imsmanifest.xml';
|
||||
}
|
||||
|
||||
$result = false;
|
||||
try {
|
||||
$dirIter = new RecursiveDirectoryIterator($folder, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
|
||||
@@ -615,15 +620,23 @@ class cc2moodle {
|
||||
$array_index++;
|
||||
|
||||
if ($item->nodeName == "item") {
|
||||
$identifierref = '';
|
||||
if ($item->hasAttribute('identifierref')) {
|
||||
$identifierref = $item->getAttribute('identifierref');
|
||||
}
|
||||
|
||||
$identifierref = $xpath->query('@identifierref', $item);
|
||||
$identifierref = !empty($identifierref->item(0)->nodeValue) ? $identifierref->item(0)->nodeValue : '';
|
||||
|
||||
$title = $xpath->query('imscc:title', $item);
|
||||
$title = !empty($title->item(0)->nodeValue) ? $title->item(0)->nodeValue : '';
|
||||
$title = '';
|
||||
$titles = $xpath->query('imscc:title', $item);
|
||||
if ($titles->length > 0) {
|
||||
$title = $titles->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$cc_type = $this->get_item_cc_type($identifierref);
|
||||
$moodle_type = $this->convert_to_moodle_type($cc_type);
|
||||
//Fix the label issue - MDL-33523
|
||||
if (empty($identifierref) && empty($title)) {
|
||||
$moodle_type = TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
elseif ($item->nodeName == "resource") {
|
||||
|
||||
|
||||
@@ -262,14 +262,14 @@ class entities {
|
||||
if (!empty($labels) && ($labels->length > 0)) {
|
||||
$tname = 'course_files';
|
||||
$dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
|
||||
$rfpath = 'folder.gif';
|
||||
$rfpath = 'files.gif';
|
||||
$fpath = $dpath . DIRECTORY_SEPARATOR . $rfpath;
|
||||
|
||||
if (!file_exists($dpath)) {
|
||||
mkdir($dpath);
|
||||
}
|
||||
//copy the folder.gif file
|
||||
$folder_gif = "{$CFG->dirroot}/pix/f/folder.gif";
|
||||
$folder_gif = "{$CFG->dirroot}/pix/i/files.gif";
|
||||
copy($folder_gif, $fpath);
|
||||
$all_files[] = $rfpath;
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ class entities11 extends entities {
|
||||
if (!empty($labels) && ($labels->length > 0)) {
|
||||
$tname = 'course_files';
|
||||
$dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
|
||||
$rfpath = 'folder.gif';
|
||||
$fpath = $dpath . DIRECTORY_SEPARATOR . 'folder.gif';
|
||||
$rfpath = 'files.gif';
|
||||
$fpath = $dpath . DIRECTORY_SEPARATOR . 'files.gif';
|
||||
if (!file_exists($dpath)) {
|
||||
mkdir($dpath);
|
||||
}
|
||||
//copy the folder.gif file
|
||||
$folder_gif = "{$CFG->dirroot}/pix/f/folder.gif";
|
||||
$folder_gif = "{$CFG->dirroot}/pix/i/files.gif";
|
||||
copy($folder_gif, $fpath);
|
||||
$all_files[] = $rfpath;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class cc_label extends entities {
|
||||
'[#date_now#]');
|
||||
|
||||
$title = isset($instance['title']) && !empty($instance['title']) ? $instance['title'] : 'Untitled';
|
||||
$content = "<img src=\"$@FILEPHP@$$@SLASH@$"."folder.gif\" alt=\"Folder\" title=\"{$title}\" /> {$title}";
|
||||
$content = "<img src=\"$@FILEPHP@$$@SLASH@$"."files.gif\" alt=\"Folder\" title=\"{$title}\" /> {$title}";
|
||||
$replace_values = array($instance['instance'],
|
||||
self::safexml($title),
|
||||
self::safexml($content),
|
||||
|
||||
@@ -170,17 +170,22 @@ class backup_controller extends backup implements loggable {
|
||||
}
|
||||
|
||||
public function set_status($status) {
|
||||
$this->log('setting controller status to', backup::LOG_DEBUG, $status);
|
||||
// TODO: Check it's a correct status
|
||||
$this->status = $status;
|
||||
// Ensure that, once set to backup::STATUS_AWAITING, controller is stored in DB
|
||||
// Note: never save_controller() after STATUS_EXECUTING or the whole controller,
|
||||
// Note: never save_controller() with the object info after STATUS_EXECUTING or the whole controller,
|
||||
// containing all the steps will be sent to DB. 100% (monster) useless.
|
||||
$this->log('setting controller status to', backup::LOG_DEBUG, $status);
|
||||
// TODO: Check it's a correct status.
|
||||
$this->status = $status;
|
||||
// Ensure that, once set to backup::STATUS_AWAITING, controller is stored in DB.
|
||||
if ($status == backup::STATUS_AWAITING) {
|
||||
$this->save_controller();
|
||||
$tbc = self::load_controller($this->backupid);
|
||||
$this->logger = $tbc->logger; // wakeup loggers
|
||||
$tbc->destroy(); // Clean temp controller structures
|
||||
|
||||
} else if ($status == backup::STATUS_FINISHED_OK) {
|
||||
// If the operation has ended without error (backup::STATUS_FINISHED_OK)
|
||||
// proceed by cleaning the object from database. MDL-29262.
|
||||
$this->save_controller(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,12 +317,20 @@ class backup_controller extends backup implements loggable {
|
||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||
}
|
||||
|
||||
public function save_controller() {
|
||||
/**
|
||||
* Save controller information
|
||||
*
|
||||
* @param bool $includeobj to decide if the object itself must be updated (true) or no (false)
|
||||
* @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)
|
||||
*/
|
||||
public function save_controller($includeobj = true, $cleanobj = false) {
|
||||
// Going to save controller to persistent storage, calculate checksum for later checks and save it
|
||||
// TODO: flag the controller as NA. Any operation on it should be forbidden util loaded back
|
||||
$this->log('saving controller to db', backup::LOG_DEBUG);
|
||||
$this->checksum = $this->calculate_checksum();
|
||||
backup_controller_dbops::save_controller($this, $this->checksum);
|
||||
if ($includeobj ) { // Only calculate checksum if we are going to include the object.
|
||||
$this->checksum = $this->calculate_checksum();
|
||||
}
|
||||
backup_controller_dbops::save_controller($this, $this->checksum, $includeobj, $cleanobj);
|
||||
}
|
||||
|
||||
public static function load_controller($backupid) {
|
||||
|
||||
@@ -166,17 +166,22 @@ class restore_controller extends backup implements loggable {
|
||||
}
|
||||
|
||||
public function set_status($status) {
|
||||
$this->log('setting controller status to', backup::LOG_DEBUG, $status);
|
||||
// TODO: Check it's a correct status
|
||||
$this->status = $status;
|
||||
// Ensure that, once set to backup::STATUS_AWAITING | STATUS_NEED_PRECHECK, controller is stored in DB
|
||||
// Note: never save_controller() after STATUS_EXECUTING or the whole controller,
|
||||
// Note: never save_controller() with the object info after STATUS_EXECUTING or the whole controller,
|
||||
// containing all the steps will be sent to DB. 100% (monster) useless.
|
||||
$this->log('setting controller status to', backup::LOG_DEBUG, $status);
|
||||
// TODO: Check it's a correct status.
|
||||
$this->status = $status;
|
||||
// Ensure that, once set to backup::STATUS_AWAITING | STATUS_NEED_PRECHECK, controller is stored in DB.
|
||||
if ($status == backup::STATUS_AWAITING || $status == backup::STATUS_NEED_PRECHECK) {
|
||||
$this->save_controller();
|
||||
$tbc = self::load_controller($this->restoreid);
|
||||
$this->logger = $tbc->logger; // wakeup loggers
|
||||
$tbc->destroy(); // Clean temp controller structures
|
||||
|
||||
} else if ($status == backup::STATUS_FINISHED_OK) {
|
||||
// If the operation has ended without error (backup::STATUS_FINISHED_OK)
|
||||
// proceed by cleaning the object from database. MDL-29262.
|
||||
$this->save_controller(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,12 +368,20 @@ class restore_controller extends backup implements loggable {
|
||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||
}
|
||||
|
||||
public function save_controller() {
|
||||
/**
|
||||
* Save controller information
|
||||
*
|
||||
* @param bool $includeobj to decide if the object itself must be updated (true) or no (false)
|
||||
* @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)
|
||||
*/
|
||||
public function save_controller($includeobj = true, $cleanobj = false) {
|
||||
// Going to save controller to persistent storage, calculate checksum for later checks and save it
|
||||
// TODO: flag the controller as NA. Any operation on it should be forbidden util loaded back
|
||||
$this->log('saving controller to db', backup::LOG_DEBUG);
|
||||
$this->checksum = $this->calculate_checksum();
|
||||
restore_controller_dbops::save_controller($this, $this->checksum);
|
||||
if ($includeobj ) { // Only calculate checksum if we are going to include the object.
|
||||
$this->checksum = $this->calculate_checksum();
|
||||
}
|
||||
restore_controller_dbops::save_controller($this, $this->checksum, $includeobj, $cleanobj);
|
||||
}
|
||||
|
||||
public static function load_controller($restoreid) {
|
||||
|
||||
@@ -161,7 +161,7 @@ class backup_controller_test extends UnitTestCase {
|
||||
*/
|
||||
class mock_backup_controller extends backup_controller {
|
||||
|
||||
public function save_controller() {
|
||||
parent::save_controller();
|
||||
public function save_controller($includeobj = true, $cleanobj = false) {
|
||||
parent::save_controller($includeobj, $cleanobj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,11 @@ abstract class backup_activity_task extends backup_task {
|
||||
$this->add_step(new backup_activity_logs_structure_step('activity_logs', 'logs.xml'));
|
||||
}
|
||||
|
||||
// Generate the calendar events file (conditionally)
|
||||
if ($this->get_setting_value('calendarevents')) {
|
||||
$this->add_step(new backup_calendarevents_structure_step('activity_calendar', 'calendar.xml'));
|
||||
}
|
||||
|
||||
// Fetch all the activity grade items and put them to backup_ids
|
||||
$this->add_step(new backup_activity_grade_items_to_ids('fetch_activity_grade_items'));
|
||||
|
||||
|
||||
@@ -103,6 +103,11 @@ class backup_course_task extends backup_task {
|
||||
$this->add_step(new backup_comments_structure_step('course_comments', 'comments.xml'));
|
||||
}
|
||||
|
||||
// Generate the calender events file (conditionally)
|
||||
if ($this->get_setting_value('calendarevents')) {
|
||||
$this->add_step(new backup_calendarevents_structure_step('course_calendar', 'calendar.xml'));
|
||||
}
|
||||
|
||||
// Generate the logs file (conditionally)
|
||||
if ($this->get_setting_value('logs')) {
|
||||
$this->add_step(new backup_course_logs_structure_step('course_logs', 'logs.xml'));
|
||||
|
||||
@@ -108,27 +108,27 @@ class backup_final_task extends backup_task {
|
||||
|
||||
require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
|
||||
|
||||
//Checking if we have some converter involved in the process
|
||||
$converters = convert_helper::available_converters(false);
|
||||
//Conversion status
|
||||
// Look for converter steps only in type course and mode general backup operations.
|
||||
$conversion = false;
|
||||
foreach ($converters as $value) {
|
||||
if ($this->get_setting_value($value)) {
|
||||
//zip class
|
||||
$zip_contents = "{$value}_zip_contents";
|
||||
$store_backup_file = "{$value}_store_backup_file";
|
||||
$convert = "{$value}_backup_convert";
|
||||
if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) {
|
||||
$converters = convert_helper::available_converters(false);
|
||||
foreach ($converters as $value) {
|
||||
if ($this->get_setting_value($value)) {
|
||||
// Zip class.
|
||||
$zip_contents = "{$value}_zip_contents";
|
||||
$store_backup_file = "{$value}_store_backup_file";
|
||||
$convert = "{$value}_backup_convert";
|
||||
|
||||
$this->add_step(new $convert("package_convert_{$value}"));
|
||||
$this->add_step(new $zip_contents("zip_contents_{$value}"));
|
||||
$this->add_step(new $store_backup_file("save_backupfile_{$value}"));
|
||||
if (!$conversion) {
|
||||
$conversion = true;
|
||||
$this->add_step(new $convert("package_convert_{$value}"));
|
||||
$this->add_step(new $zip_contents("zip_contents_{$value}"));
|
||||
$this->add_step(new $store_backup_file("save_backupfile_{$value}"));
|
||||
if (!$conversion) {
|
||||
$conversion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// On backup::MODE_IMPORT, we don't have to zip nor store the the file, skip these steps
|
||||
if (($this->plan->get_mode() != backup::MODE_IMPORT) && !$conversion) {
|
||||
// Generate the zip file (mbz extension)
|
||||
|
||||
@@ -65,12 +65,15 @@ class backup_root_task extends backup_task {
|
||||
$filename->set_ui(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50));
|
||||
$this->add_setting($filename);
|
||||
|
||||
//Sample custom settings
|
||||
$converters = convert_helper::available_converters(false);
|
||||
foreach ($converters as $cnv) {
|
||||
$formatcnv = new backup_users_setting($cnv, base_setting::IS_BOOLEAN, false);
|
||||
$formatcnv->set_ui(new backup_setting_ui_checkbox($formatcnv, get_string('backupformat'.$cnv, 'backup')));
|
||||
$this->add_setting($formatcnv);
|
||||
// Present converter settings only in type course and mode general backup operations.
|
||||
$converters = array();
|
||||
if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) {
|
||||
$converters = convert_helper::available_converters(false);
|
||||
foreach ($converters as $cnv) {
|
||||
$formatcnv = new backup_users_setting($cnv, base_setting::IS_BOOLEAN, false);
|
||||
$formatcnv->set_ui(new backup_setting_ui_checkbox($formatcnv, get_string('backupformat'.$cnv, 'backup')));
|
||||
$this->add_setting($formatcnv);
|
||||
}
|
||||
}
|
||||
|
||||
// Define users setting (keeping it on hand to define dependencies)
|
||||
@@ -114,6 +117,12 @@ class backup_root_task extends backup_task {
|
||||
$this->add_setting($comments);
|
||||
$users->add_dependency($comments);
|
||||
|
||||
// Define calendar events (dependent of users)
|
||||
$events = new backup_calendarevents_setting('calendarevents', base_setting::IS_BOOLEAN, true);
|
||||
$events->set_ui(new backup_setting_ui_checkbox($events, get_string('rootsettingcalendarevents', 'backup')));
|
||||
$this->add_setting($events);
|
||||
$users->add_dependency($events);
|
||||
|
||||
// Define completion (dependent of users)
|
||||
$completion = new backup_userscompletion_setting('userscompletion', base_setting::IS_BOOLEAN, true);
|
||||
$completion->set_ui(new backup_setting_ui_checkbox($completion, get_string('rootsettinguserscompletion', 'backup')));
|
||||
|
||||
@@ -89,6 +89,13 @@ class backup_logs_setting extends backup_anonymize_setting {}
|
||||
*/
|
||||
class backup_comments_setting extends backup_anonymize_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if backup will include
|
||||
* calender events or no (any level), depends of @backup_users_setting
|
||||
* exactly in the same way than @backup_anonymize_setting so we extend from it
|
||||
*/
|
||||
class backup_calendarevents_setting extends backup_anonymize_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if backup will include
|
||||
* users completion data or no (any level), depends of @backup_users_setting
|
||||
|
||||
@@ -767,6 +767,48 @@ class backup_comments_structure_step extends backup_structure_step {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* structure step in charge of constructing the calender.xml file for all the events found
|
||||
* in a given context
|
||||
*/
|
||||
class backup_calendarevents_structure_step extends backup_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
// Define each element separated
|
||||
|
||||
$events = new backup_nested_element('events');
|
||||
|
||||
$event = new backup_nested_element('event', array('id'), array(
|
||||
'name', 'description', 'format', 'courseid', 'groupid', 'userid',
|
||||
'repeatid', 'modulename', 'instance', 'eventtype', 'timestart',
|
||||
'timeduration', 'visible', 'uuid', 'sequence', 'timemodified'));
|
||||
|
||||
// Build the tree
|
||||
$events->add_child($event);
|
||||
|
||||
// Define sources
|
||||
if ($this->name == 'course_calendar') {
|
||||
$calendar_items_sql ="SELECT * FROM {event}
|
||||
WHERE courseid = :courseid
|
||||
AND (eventtype = 'course' OR eventtype = 'group')";
|
||||
$calendar_items_params = array('courseid'=>backup::VAR_COURSEID);
|
||||
$event->set_source_sql($calendar_items_sql, $calendar_items_params);
|
||||
} else {
|
||||
$event->set_source_table('event', array('courseid' => backup::VAR_COURSEID, 'instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME));
|
||||
}
|
||||
|
||||
// Define id annotations
|
||||
|
||||
$event->annotate_ids('user', 'userid');
|
||||
$event->annotate_ids('group', 'groupid');
|
||||
$event->annotate_files('calendar', 'event_description', 'id');
|
||||
|
||||
// Return the root element (events)
|
||||
return $events;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* structure step in charge of constructing the gradebook.xml file for all the gradebook config in the course
|
||||
* NOTE: the backup of the grade items themselves is handled by backup_activity_grades_structure_step
|
||||
|
||||
@@ -147,6 +147,11 @@ abstract class restore_activity_task extends restore_task {
|
||||
$this->add_step(new restore_comments_structure_step('activity_comments', 'comments.xml'));
|
||||
}
|
||||
|
||||
// Calendar events (conditionally)
|
||||
if ($this->get_setting_value('calendarevents')) {
|
||||
$this->add_step(new restore_calendarevents_structure_step('activity_calendar', 'calendar.xml'));
|
||||
}
|
||||
|
||||
// Grades (module-related, rest of gradebook is restored later if possible: cats, calculations...)
|
||||
$this->add_step(new restore_activity_grades_structure_step('activity_grades', 'grades.xml'));
|
||||
|
||||
|
||||
@@ -84,6 +84,11 @@ class restore_course_task extends restore_task {
|
||||
$this->add_step(new restore_comments_structure_step('course_comments', 'comments.xml'));
|
||||
}
|
||||
|
||||
// Calendar events (conditionally)
|
||||
if ($this->get_setting_value('calendarevents')) {
|
||||
$this->add_step(new restore_calendarevents_structure_step('course_calendar', 'calendar.xml'));
|
||||
}
|
||||
|
||||
// At the end, mark it as built
|
||||
$this->built = true;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,11 @@ class restore_final_task extends restore_task {
|
||||
$this->add_step(new restore_gradebook_structure_step('gradebook_step','gradebook.xml'));
|
||||
}
|
||||
|
||||
// Course completion
|
||||
$this->add_step(new restore_course_completion_structure_step('course_completion', 'completion.xml'));
|
||||
// Course completion, executed conditionally if restoring to new course
|
||||
if ($this->get_target() !== backup::TARGET_CURRENT_ADDING &&
|
||||
$this->get_target() !== backup::TARGET_EXISTING_ADDING) {
|
||||
$this->add_step(new restore_course_completion_structure_step('course_completion', 'completion.xml'));
|
||||
}
|
||||
|
||||
// Review all the module_availability records in backup_ids in order
|
||||
// to match them with existing modules / grade items.
|
||||
|
||||
@@ -170,6 +170,19 @@ class restore_root_task extends restore_task {
|
||||
$this->add_setting($comments);
|
||||
$users->add_dependency($comments);
|
||||
|
||||
// Define Calendar events (dependent of users)
|
||||
$defaultvalue = false; // Safer default
|
||||
$changeable = false;
|
||||
if (isset($rootsettings['calendarevents']) && $rootsettings['calendarevents']) { // Only enabled when available
|
||||
$defaultvalue = true;
|
||||
$changeable = true;
|
||||
}
|
||||
$events = new restore_calendarevents_setting('calendarevents', base_setting::IS_BOOLEAN, $defaultvalue);
|
||||
$events->set_ui(new backup_setting_ui_checkbox($events, get_string('rootsettingcalendarevents', 'backup')));
|
||||
$events->get_ui()->set_changeable($changeable);
|
||||
$this->add_setting($events);
|
||||
$users->add_dependency($events);
|
||||
|
||||
// Define completion (dependent of users)
|
||||
$defaultvalue = false; // Safer default
|
||||
$changeable = false;
|
||||
|
||||
@@ -58,6 +58,13 @@ class restore_activities_setting extends restore_generic_setting {}
|
||||
*/
|
||||
class restore_comments_setting extends restore_role_assignments_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if restore will create
|
||||
* events or no, depends of @restore_users_setting
|
||||
* exactly in the same way than @restore_role_assignments_setting so we extend from it
|
||||
*/
|
||||
class restore_calendarevents_setting extends restore_role_assignments_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if restore will create
|
||||
* completion info or no, depends of @restore_users_setting
|
||||
|
||||
@@ -206,21 +206,25 @@ class restore_gradebook_structure_step extends restore_structure_step {
|
||||
global $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
$olduserid = $data->userid;
|
||||
|
||||
$data->itemid = $this->get_new_parentid('grade_item');
|
||||
|
||||
$data->userid = $this->get_mappingid('user', $data->userid, NULL);
|
||||
$data->usermodified = $this->get_mappingid('user', $data->usermodified, NULL);
|
||||
$data->locktime = $this->apply_date_offset($data->locktime);
|
||||
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
|
||||
$data->overridden = $this->apply_date_offset($data->overridden);
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
$data->userid = $this->get_mappingid('user', $data->userid, null);
|
||||
if (!empty($data->userid)) {
|
||||
$data->usermodified = $this->get_mappingid('user', $data->usermodified, null);
|
||||
$data->locktime = $this->apply_date_offset($data->locktime);
|
||||
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
|
||||
$data->overridden = $this->apply_date_offset($data->overridden);
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
$newitemid = $DB->insert_record('grade_grades', $data);
|
||||
//$this->set_mapping('grade_grade', $oldid, $newitemid);
|
||||
$newitemid = $DB->insert_record('grade_grades', $data);
|
||||
} else {
|
||||
debugging("Mapped user id not found for user id '{$olduserid}', grade item id '{$data->itemid}'");
|
||||
}
|
||||
}
|
||||
|
||||
protected function process_grade_category($data) {
|
||||
global $DB;
|
||||
|
||||
@@ -1023,7 +1027,7 @@ class restore_section_structure_step extends restore_structure_step {
|
||||
// Section exists, update non-empty information
|
||||
} else {
|
||||
$section->id = $secrec->id;
|
||||
if (empty($secrec->name)) {
|
||||
if ((string)$secrec->name === '') {
|
||||
$section->name = $data->name;
|
||||
}
|
||||
if (empty($secrec->summary)) {
|
||||
@@ -1566,6 +1570,76 @@ class restore_comments_structure_step extends restore_structure_step {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This structure steps restores the calendar events
|
||||
*/
|
||||
class restore_calendarevents_structure_step extends restore_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
$paths = array();
|
||||
|
||||
$paths[] = new restore_path_element('calendarevents', '/events/event');
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
public function process_calendarevents($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
$restorefiles = true; // We'll restore the files
|
||||
// Find the userid and the groupid associated with the event. Return if not found.
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
if ($data->userid === false) {
|
||||
return;
|
||||
}
|
||||
if (!empty($data->groupid)) {
|
||||
$data->groupid = $this->get_mappingid('group', $data->groupid);
|
||||
if ($data->groupid === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'name' => $data->name,
|
||||
'description' => $data->description,
|
||||
'format' => $data->format,
|
||||
'courseid' => $this->get_courseid(),
|
||||
'groupid' => $data->groupid,
|
||||
'userid' => $data->userid,
|
||||
'repeatid' => $data->repeatid,
|
||||
'modulename' => $data->modulename,
|
||||
'eventtype' => $data->eventtype,
|
||||
'timestart' => $this->apply_date_offset($data->timestart),
|
||||
'timeduration' => $data->timeduration,
|
||||
'visible' => $data->visible,
|
||||
'uuid' => $data->uuid,
|
||||
'sequence' => $data->sequence,
|
||||
'timemodified' => $this->apply_date_offset($data->timemodified));
|
||||
if ($this->name == 'activity_calendar') {
|
||||
$params['instance'] = $this->task->get_activityid();
|
||||
} else {
|
||||
$params['instance'] = 0;
|
||||
}
|
||||
$sql = 'SELECT id FROM {event} WHERE name = ? AND courseid = ? AND
|
||||
repeatid = ? AND modulename = ? AND timestart = ? AND timeduration =?
|
||||
AND ' . $DB->sql_compare_text('description', 255) . ' = ' . $DB->sql_compare_text('?', 255);
|
||||
$arg = array ($params['name'], $params['courseid'], $params['repeatid'], $params['modulename'], $params['timestart'], $params['timeduration'], $params['description']);
|
||||
$result = $DB->record_exists_sql($sql, $arg);
|
||||
if (empty($result)) {
|
||||
$newitemid = $DB->insert_record('event', $params);
|
||||
$this->set_mapping('event_description', $oldid, $newitemid, $restorefiles);
|
||||
}
|
||||
|
||||
}
|
||||
protected function after_execute() {
|
||||
// Add related files
|
||||
$this->add_related_files('calendar', 'event_description', 'event_description');
|
||||
}
|
||||
}
|
||||
|
||||
class restore_course_completion_structure_step extends restore_structure_step {
|
||||
|
||||
/**
|
||||
@@ -2152,18 +2226,24 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
|
||||
protected function process_grade_grade($data) {
|
||||
$data = (object)($data);
|
||||
|
||||
$olduserid = $data->userid;
|
||||
unset($data->id);
|
||||
$data->itemid = $this->get_new_parentid('grade_item');
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
$data->usermodified = $this->get_mappingid('user', $data->usermodified);
|
||||
$data->rawscaleid = $this->get_mappingid('scale', $data->rawscaleid);
|
||||
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
|
||||
$data->overridden = $this->apply_date_offset($data->overridden);
|
||||
|
||||
$grade = new grade_grade($data, false);
|
||||
$grade->insert('restore');
|
||||
// no need to save any grade_grade mapping
|
||||
$data->itemid = $this->get_new_parentid('grade_item');
|
||||
|
||||
$data->userid = $this->get_mappingid('user', $data->userid, null);
|
||||
if (!empty($data->userid)) {
|
||||
$data->usermodified = $this->get_mappingid('user', $data->usermodified, null);
|
||||
$data->rawscaleid = $this->get_mappingid('scale', $data->rawscaleid);
|
||||
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
|
||||
$data->overridden = $this->apply_date_offset($data->overridden);
|
||||
|
||||
$grade = new grade_grade($data, false);
|
||||
$grade->insert('restore');
|
||||
// no need to save any grade_grade mapping
|
||||
} else {
|
||||
debugging("Mapped user id not found for user id '{$olduserid}', grade item id '{$data->itemid}'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,9 +168,9 @@ abstract class backup_check {
|
||||
$hasusercap = has_capability('moodle/backup:userinfo', $coursectx, $userid);
|
||||
|
||||
// If setting is enabled but user lacks permission
|
||||
if (!$hasusercap && $prevvalue) { // If user has not the capability and setting is enabled
|
||||
if (!$hasusercap) { // If user has not the capability
|
||||
// Now analyse if we are allowed to apply changes or must stop with exception
|
||||
if (!$apply) { // Cannot apply changes, throw exception
|
||||
if (!$apply && $prevvalue) { // Cannot apply changes and the value is set, throw exception
|
||||
$a = new stdclass();
|
||||
$a->setting = 'users';
|
||||
$a->value = $prevvalue;
|
||||
@@ -178,7 +178,12 @@ abstract class backup_check {
|
||||
throw new backup_controller_exception('backup_setting_value_wrong_for_capability', $a);
|
||||
|
||||
} else { // Can apply changes
|
||||
$userssetting->set_value(false); // Set the value to false
|
||||
// If it is already false, we don't want to try and set it again, because if it is
|
||||
// already locked, and exception will occur. The side benifit is if it is true and locked
|
||||
// we will get an exception...
|
||||
if ($prevvalue) {
|
||||
$userssetting->set_value(false); // Set the value to false
|
||||
}
|
||||
$userssetting->set_status(base_setting::LOCKED_BY_PERMISSION);// Set the status to locked by perm
|
||||
}
|
||||
}
|
||||
@@ -191,9 +196,9 @@ abstract class backup_check {
|
||||
$hasanoncap = has_capability('moodle/backup:anonymise', $coursectx, $userid);
|
||||
|
||||
// If setting is enabled but user lacks permission
|
||||
if (!$hasanoncap && $prevvalue) { // If user has not the capability and setting is enabled
|
||||
if (!$hasanoncap) { // If user has not the capability
|
||||
// Now analyse if we are allowed to apply changes or must stop with exception
|
||||
if (!$apply) { // Cannot apply changes, throw exception
|
||||
if (!$apply && $prevvalue) { // Cannot apply changes and the value is set, throw exception
|
||||
$a = new stdclass();
|
||||
$a->setting = 'anonymize';
|
||||
$a->value = $prevvalue;
|
||||
@@ -201,7 +206,9 @@ abstract class backup_check {
|
||||
throw new backup_controller_exception('backup_setting_value_wrong_for_capability', $a);
|
||||
|
||||
} else { // Can apply changes
|
||||
$anonsetting->set_value(false); // Set the value to false
|
||||
if ($prevvalue) { // If we try and set it back to false and it has already been locked, error will occur
|
||||
$anonsetting->set_value(false); // Set the value to false
|
||||
}
|
||||
$anonsetting->set_status(base_setting::LOCKED_BY_PERMISSION);// Set the status to locked by perm
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,16 +32,30 @@
|
||||
*/
|
||||
abstract class backup_controller_dbops extends backup_dbops {
|
||||
|
||||
public static function save_controller($controller, $checksum) {
|
||||
/**
|
||||
* Send one backup controller to DB
|
||||
*
|
||||
* @param backup_controller $controller controller to send to DB
|
||||
* @param string $checksum hash of the controller to be checked
|
||||
* @param bool $includeobj to decide if the object itself must be updated (true) or no (false)
|
||||
* @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)
|
||||
* @return int id of the controller record in the DB
|
||||
* @throws backup_controller_exception|backup_dbops_exception
|
||||
*/
|
||||
public static function save_controller($controller, $checksum, $includeobj = true, $cleanobj = false) {
|
||||
global $DB;
|
||||
// Check we are going to save one backup_controller
|
||||
if (! $controller instanceof backup_controller) {
|
||||
throw new backup_controller_exception('backup_controller_expected');
|
||||
}
|
||||
// Check checksum is ok. Sounds silly but it isn't ;-)
|
||||
if (!$controller->is_checksum_correct($checksum)) {
|
||||
// Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-).
|
||||
if ($includeobj and !$controller->is_checksum_correct($checksum)) {
|
||||
throw new backup_dbops_exception('backup_controller_dbops_saving_checksum_mismatch');
|
||||
}
|
||||
// Cannot request to $includeobj and $cleanobj at the same time.
|
||||
if ($includeobj and $cleanobj) {
|
||||
throw new backup_dbops_exception('backup_controller_dbops_saving_cannot_include_and_delete');
|
||||
}
|
||||
// Get all the columns
|
||||
$rec = new stdclass();
|
||||
$rec->backupid = $controller->get_backupid();
|
||||
@@ -57,7 +71,11 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
$rec->executiontime= $controller->get_executiontime();
|
||||
$rec->checksum = $checksum;
|
||||
// Serialize information
|
||||
$rec->controller = base64_encode(serialize($controller));
|
||||
if ($includeobj) {
|
||||
$rec->controller = base64_encode(serialize($controller));
|
||||
} else if ($cleanobj) {
|
||||
$rec->controller = '';
|
||||
}
|
||||
// Send it to DB
|
||||
if ($recexists = $DB->get_record('backup_controllers', array('backupid' => $rec->backupid))) {
|
||||
$rec->id = $recexists->id;
|
||||
|
||||
@@ -32,16 +32,30 @@
|
||||
*/
|
||||
abstract class restore_controller_dbops extends restore_dbops {
|
||||
|
||||
public static function save_controller($controller, $checksum) {
|
||||
/**
|
||||
* Send one restore controller to DB
|
||||
*
|
||||
* @param restore_controller $controller controller to send to DB
|
||||
* @param string $checksum hash of the controller to be checked
|
||||
* @param bool $includeobj to decide if the object itself must be updated (true) or no (false)
|
||||
* @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)
|
||||
* @return int id of the controller record in the DB
|
||||
* @throws backup_controller_exception|restore_dbops_exception
|
||||
*/
|
||||
public static function save_controller($controller, $checksum, $includeobj = true, $cleanobj = false) {
|
||||
global $DB;
|
||||
// Check we are going to save one backup_controller
|
||||
if (! $controller instanceof restore_controller) {
|
||||
throw new backup_controller_exception('restore_controller_expected');
|
||||
}
|
||||
// Check checksum is ok. Sounds silly but it isn't ;-)
|
||||
if (!$controller->is_checksum_correct($checksum)) {
|
||||
// Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-).
|
||||
if ($includeobj and !$controller->is_checksum_correct($checksum)) {
|
||||
throw new restore_dbops_exception('restore_controller_dbops_saving_checksum_mismatch');
|
||||
}
|
||||
// Cannot request to $includeobj and $cleanobj at the same time.
|
||||
if ($includeobj and $cleanobj) {
|
||||
throw new restore_dbops_exception('restore_controller_dbops_saving_cannot_include_and_delete');
|
||||
}
|
||||
// Get all the columns
|
||||
$rec = new stdclass();
|
||||
$rec->backupid = $controller->get_restoreid();
|
||||
@@ -57,7 +71,11 @@ abstract class restore_controller_dbops extends restore_dbops {
|
||||
$rec->executiontime= $controller->get_executiontime();
|
||||
$rec->checksum = $checksum;
|
||||
// Serialize information
|
||||
$rec->controller = base64_encode(serialize($controller));
|
||||
if ($includeobj) {
|
||||
$rec->controller = base64_encode(serialize($controller));
|
||||
} else if ($cleanobj) {
|
||||
$rec->controller = '';
|
||||
}
|
||||
// Send it to DB
|
||||
if ($recexists = $DB->get_record('backup_controllers', array('backupid' => $rec->backupid))) {
|
||||
$rec->id = $recexists->id;
|
||||
|
||||
@@ -139,7 +139,7 @@ abstract class backup_factory {
|
||||
throw new backup_task_exception('section_task_section_not_found', $sectionid);
|
||||
}
|
||||
|
||||
return new backup_section_task(empty($section->name) ? $section->section : $section->name, $sectionid);
|
||||
return new backup_section_task((string)$section->name === '' ? $section->section : $section->name, $sectionid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -315,6 +315,7 @@ abstract class backup_cron_automated_helper {
|
||||
*/
|
||||
public static function launch_automated_backup($course, $starttime, $userid) {
|
||||
|
||||
$outcome = true;
|
||||
$config = get_config('backup');
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_AUTOMATED, $userid);
|
||||
|
||||
@@ -347,32 +348,33 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$bc->set_status(backup::STATUS_AWAITING);
|
||||
|
||||
$outcome = $bc->execute_plan();
|
||||
$bc->execute_plan();
|
||||
$results = $bc->get_results();
|
||||
$file = $results['backup_destination'];
|
||||
$file = $results['backup_destination']; // may be empty if file already moved to target location
|
||||
$dir = $config->backup_auto_destination;
|
||||
$storage = (int)$config->backup_auto_storage;
|
||||
if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
|
||||
$dir = null;
|
||||
}
|
||||
if (!empty($dir) && $storage !== 0) {
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, true);
|
||||
if ($file && !empty($dir) && $storage !== 0) {
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, !$config->backup_shortname);
|
||||
$outcome = $file->copy_content_to($dir.'/'.$filename);
|
||||
if ($outcome && $storage === 1) {
|
||||
$file->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$outcome = true;
|
||||
} catch (backup_exception $e) {
|
||||
$bc->log('backup_auto_failed_on_course', backup::LOG_WARNING, $course->shortname);
|
||||
} catch (moodle_exception $e) {
|
||||
$bc->log('backup_auto_failed_on_course', backup::LOG_ERROR, $course->shortname); // Log error header.
|
||||
$bc->log('Exception: ' . $e->errorcode, backup::LOG_ERROR, $e->a, 1); // Log original exception problem.
|
||||
$bc->log('Debug: ' . $e->debuginfo, backup::LOG_DEBUG, null, 1); // Log original debug information.
|
||||
$outcome = false;
|
||||
}
|
||||
|
||||
$bc->destroy();
|
||||
unset($bc);
|
||||
|
||||
return true;
|
||||
return $outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,6 +461,11 @@ abstract class backup_cron_automated_helper {
|
||||
$storage = $config->backup_auto_storage;
|
||||
$dir = $config->backup_auto_destination;
|
||||
|
||||
if ($keep == 0) {
|
||||
// means keep all backup files
|
||||
return true;
|
||||
}
|
||||
|
||||
$backupword = str_replace(' ', '_', moodle_strtolower(get_string('backupfilename')));
|
||||
$backupword = trim(clean_filename($backupword), '_');
|
||||
|
||||
|
||||
@@ -176,8 +176,17 @@ abstract class backup_helper {
|
||||
/**
|
||||
* Given one backupid and the (FS) final generated file, perform its final storage
|
||||
* into Moodle file storage. For stored files it returns the complete file_info object
|
||||
*
|
||||
* Note: the $filepath is deleted if the backup file is created successfully
|
||||
*
|
||||
* @param int $backupid
|
||||
* @param string $filepath zip file containing the backup
|
||||
* @return stored_file if created, null otherwise
|
||||
*
|
||||
* @throws moodle_exception in case of any problems
|
||||
*/
|
||||
static public function store_backup_file($backupid, $filepath) {
|
||||
global $CFG;
|
||||
|
||||
// First of all, get some information from the backup_controller to help us decide
|
||||
list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($backupid);
|
||||
@@ -191,6 +200,7 @@ abstract class backup_helper {
|
||||
$userid = $dinfo[0]->userid; // User->id executing the backup
|
||||
$id = $dinfo[0]->id; // Id of activity/section/course (depends of type)
|
||||
$courseid = $dinfo[0]->courseid; // Id of the course
|
||||
$format = $dinfo[0]->format; // Type of backup file
|
||||
|
||||
// Quick hack. If for any reason, filename is blank, fix it here.
|
||||
// TODO: This hack will be out once MDL-22142 - P26 gets fixed
|
||||
@@ -200,7 +210,13 @@ abstract class backup_helper {
|
||||
|
||||
// Backups of type IMPORT aren't stored ever
|
||||
if ($backupmode == backup::MODE_IMPORT) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_readable($filepath)) {
|
||||
// we have a problem if zip file does not exist
|
||||
throw new coding_exception('backup_helper::store_backup_file() expects valid $filepath parameter');
|
||||
|
||||
}
|
||||
|
||||
// Calculate file storage options of id being backup
|
||||
@@ -232,6 +248,25 @@ abstract class backup_helper {
|
||||
if ($backupmode == backup::MODE_AUTOMATED) {
|
||||
// Automated backups have there own special area!
|
||||
$filearea = 'automated';
|
||||
|
||||
// If we're keeping the backup only in a chosen path, just move it there now
|
||||
// this saves copying from filepool to here later and filling trashdir.
|
||||
$config = get_config('backup');
|
||||
$dir = $config->backup_auto_destination;
|
||||
if ($config->backup_auto_storage == 1 and $dir and is_dir($dir) and is_writable($dir)) {
|
||||
$filedest = $dir.'/'.backup_plan_dbops::get_default_backup_filename($format, $backuptype, $courseid, $hasusers, $isannon, !$config->backup_shortname);
|
||||
// first try to move the file, if it is not possible copy and delete instead
|
||||
if (@rename($filepath, $filedest)) {
|
||||
return null;
|
||||
}
|
||||
umask(0000);
|
||||
if (copy($filepath, $filedest)) {
|
||||
@chmod($filedest, $CFG->filepermissions); // may fail because the permissions may not make sense outside of dataroot
|
||||
unlink($filepath);
|
||||
return null;
|
||||
}
|
||||
// bad luck, try to deal with the file the old way - keep backup in file area if we can not copy to ext system
|
||||
}
|
||||
}
|
||||
|
||||
// Backups of type HUB (by definition never have user info)
|
||||
@@ -275,7 +310,9 @@ abstract class backup_helper {
|
||||
$sf = $fs->get_file_by_hash($pathnamehash);
|
||||
$sf->delete();
|
||||
}
|
||||
return $fs->create_file_from_pathname($fr, $filepath);
|
||||
$file = $fs->create_file_from_pathname($fr, $filepath);
|
||||
unlink($filepath);
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,6 +67,10 @@ class backup_plan extends base_plan implements loggable {
|
||||
return $this->controller->get_backupid();
|
||||
}
|
||||
|
||||
public function get_type() {
|
||||
return $this->controller->get_type();
|
||||
}
|
||||
|
||||
public function get_mode() {
|
||||
return $this->controller->get_mode();
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ abstract class base_setting {
|
||||
if ($this->is_circular_reference($dependency->get_dependent_setting())) {
|
||||
$a = new stdclass();
|
||||
$a->alreadydependent = $this->name;
|
||||
$a->main = $dependentsetting->get_name();
|
||||
$a->main = $dependency->get_dependent_setting()->get_name();
|
||||
throw new base_setting_exception('setting_circular_reference', $a);
|
||||
}
|
||||
$this->dependencies[$dependency->get_dependent_setting()->get_name()] = $dependency;
|
||||
|
||||
@@ -32,10 +32,12 @@ require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php');
|
||||
require_once($CFG->dirroot . '/backup/backup.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/base_setting.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/backup_setting.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/setting_dependency.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/root/root_backup_setting.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/activity/activity_backup_setting.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/section/section_backup_setting.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/settings/course/course_backup_setting.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/ui/backup_ui_setting.class.php');
|
||||
|
||||
/*
|
||||
* setting tests (all)
|
||||
@@ -209,6 +211,21 @@ class setting_test extends UnitTestCase {
|
||||
$this->assertEqual($e->a->alreadydependent, 'test4');
|
||||
}
|
||||
|
||||
$bs1 = new mock_base_setting('test1', base_setting::IS_INTEGER, null);
|
||||
$bs2 = new mock_base_setting('test2', base_setting::IS_INTEGER, null);
|
||||
$bs1->register_dependency(new setting_dependency_disabledif_empty($bs1, $bs2));
|
||||
try {
|
||||
// $bs1 is already dependent on $bs2 so this should fail.
|
||||
$bs2->register_dependency(new setting_dependency_disabledif_empty($bs2, $bs1));
|
||||
$this->assertTrue(false, 'base_setting_exception expected');
|
||||
} catch (exception $e) {
|
||||
$this->assertTrue($e instanceof base_setting_exception);
|
||||
$this->assertEqual($e->errorcode, 'setting_circular_reference');
|
||||
$this->assertTrue($e->a instanceof stdclass);
|
||||
$this->assertEqual($e->a->main, 'test1');
|
||||
$this->assertEqual($e->a->alreadydependent, 'test2');
|
||||
}
|
||||
|
||||
// Create 3 settings and observe between them, last one must
|
||||
// automatically inherit all the settings defined in the main one
|
||||
$bs1 = new mock_base_setting('test1', base_setting::IS_INTEGER, null);
|
||||
|
||||
@@ -129,7 +129,7 @@ class base_setting_ui {
|
||||
* @param string $label
|
||||
*/
|
||||
public function set_label($label) {
|
||||
if (empty($label) || $label !== clean_param($label, PARAM_TEXT)) {
|
||||
if ((string)$label === '' || $label !== clean_param($label, PARAM_TEXT)) {
|
||||
throw new base_setting_ui_exception('setting_invalid_ui_label');
|
||||
}
|
||||
$this->label = $label;
|
||||
|
||||
@@ -171,7 +171,7 @@ class block_completionstatus extends block_base {
|
||||
$a = new stdClass();
|
||||
$a->first = $prerequisites_complete;
|
||||
$a->second = count($prerequisites);
|
||||
$shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
|
||||
$phtml .= get_string('firstofsecond', 'block_completionstatus', $a);
|
||||
$phtml .= '</td></tr>';
|
||||
|
||||
$shtml = $phtml . $shtml;
|
||||
|
||||
@@ -4,7 +4,7 @@ if (is_file($CFG->dirroot.'/mod/feedback/lib.php')) {
|
||||
define('FEEDBACK_BLOCK_LIB_IS_OK', true);
|
||||
}
|
||||
|
||||
class block_feedback extends block_base {
|
||||
class block_feedback extends block_list {
|
||||
|
||||
function init() {
|
||||
$this->title = get_string('feedback', 'block_feedback');
|
||||
@@ -21,10 +21,13 @@ class block_feedback extends block_base {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) {
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = get_string('missing_feedback_module', 'block_feedback');
|
||||
$this->content->footer = '';
|
||||
$this->content->items = array(get_string('missing_feedback_module', 'block_feedback'));
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -33,9 +36,7 @@ class block_feedback extends block_base {
|
||||
$courseid = SITEID;
|
||||
}
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
$icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />';
|
||||
|
||||
|
||||
if (empty($this->instance->pageid)) {
|
||||
@@ -47,8 +48,7 @@ class block_feedback extends block_base {
|
||||
foreach ($feedbacks as $feedback) {
|
||||
$url = new moodle_url($baseurl);
|
||||
$url->params(array('id'=>$feedback->cmid, 'courseid'=>$courseid));
|
||||
$icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" /> ';
|
||||
$this->content->text = ' <a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
|
||||
$this->content->items[] = '<a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -292,9 +292,16 @@ class blog_entry {
|
||||
|
||||
$contentcell->text .= $OUTPUT->container_start('commands');
|
||||
|
||||
if (blog_user_can_edit_entry($this) && empty($this->uniquehash)) {
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php', array('action' => 'edit', 'entryid' => $this->id)), $stredit) . ' | ';
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php', array('action' => 'delete', 'entryid' => $this->id)), $strdelete) . ' | ';
|
||||
if (blog_user_can_edit_entry($this)) {
|
||||
if (empty($this->uniquehash)) {
|
||||
//External blog entries should not be edited
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php',
|
||||
array('action' => 'edit', 'entryid' => $this->id)),
|
||||
$stredit) . ' | ';
|
||||
}
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php',
|
||||
array('action' => 'delete', 'entryid' => $this->id)),
|
||||
$strdelete) . ' | ';
|
||||
}
|
||||
|
||||
$contentcell->text .= html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $this->id)), get_string('permalink', 'blog'));
|
||||
|
||||
+3
-1
@@ -164,7 +164,9 @@ function blog_rss_get_feed($context, $args) {
|
||||
$item->title = $blog_entry->subject;
|
||||
$item->pubdate = $blog_entry->lastmodified;
|
||||
$item->link = $CFG->wwwroot.'/blog/index.php?entryid='.$blog_entry->id;
|
||||
$item->description = format_text($blog_entry->summary, $blog_entry->format);
|
||||
$summary = file_rewrite_pluginfile_urls($blog_entry->summary, 'pluginfile.php',
|
||||
$sitecontext->id, 'blog', 'post', $blog_entry->id);
|
||||
$item->description = format_text($summary, $blog_entry->format);
|
||||
if ( !empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blog_entry->id)) ) {
|
||||
if ($blogtags) {
|
||||
$item->tags = $blogtags;
|
||||
|
||||
+5
-2
@@ -107,7 +107,7 @@ $repeatspan = '';
|
||||
if (!empty($event->eventrepeats) && $event->eventrepeats > 0) {
|
||||
$url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->repeatid, 'confirm'=>true, 'repeats'=>true));
|
||||
$buttons .= $OUTPUT->single_button($url, get_string('deleteall'));
|
||||
$repeatspan = '<br /><br /><span>'.get_string('youcandeleteallrepeats', 'calendar').'</span>';
|
||||
$repeatspan = '<br /><br /><span>'.get_string('youcandeleteallrepeats', 'calendar', $event->eventrepeats).'</span>';
|
||||
}
|
||||
|
||||
// And add the cancel button
|
||||
@@ -121,7 +121,10 @@ echo $OUTPUT->box_end();
|
||||
|
||||
// Print the event so that people can visually confirm they have the correct event
|
||||
$event->time = calendar_format_event_time($event, time(), null, false);
|
||||
calendar_print_event($event, false);
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
echo $renderer->start_layout();
|
||||
echo $renderer->event($event);
|
||||
echo $renderer->complete_layout();
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -133,14 +133,16 @@ class event_form extends moodleform {
|
||||
$mform->setDefault('repeats', 1);
|
||||
$mform->disabledIf('repeats','repeat','notchecked');
|
||||
|
||||
} else if ($repeatedevents > 0) {
|
||||
} else if ($repeatedevents) {
|
||||
|
||||
$mform->addElement('hidden', 'repeatid');
|
||||
$mform->setType('repeatid', PARAM_INT);
|
||||
|
||||
$mform->addElement('header', 'repeatedevents', get_string('repeatedevents', 'calendar'));
|
||||
$mform->addElement('checkbox', 'repeateditall', null, get_string('repeateditall', 'calendar', $repeatedevents), 'repeat');
|
||||
$mform->setDefault('repeateditall', 'checked');
|
||||
$mform->addElement('radio', 'repeateditall', null, get_string('repeateditall', 'calendar', $this->_customdata->event->eventrepeats), 1);
|
||||
$mform->addElement('radio', 'repeateditall', null, get_string('repeateditthis', 'calendar'), 0);
|
||||
|
||||
$mform->setDefault('repeateditall', 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ foreach($events as $event) {
|
||||
$ev = new iCalendar_event;
|
||||
$ev->add_property('uid', $event->id.'@'.$hostaddress);
|
||||
$ev->add_property('summary', $event->name);
|
||||
$ev->add_property('description', $event->description);
|
||||
$ev->add_property('description', clean_param($event->description, PARAM_NOTAGS));
|
||||
$ev->add_property('class', 'PUBLIC'); // PUBLIC / PRIVATE / CONFIDENTIAL
|
||||
$ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified));
|
||||
$ev->add_property('dtstamp', Bennu::timestamp_to_datetime()); // now
|
||||
|
||||
+53
-25
@@ -209,7 +209,6 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
$days_title = calendar_get_days();
|
||||
|
||||
$summary = get_string('calendarheading', 'calendar', userdate(make_timestamp($y, $m), get_string('strftimemonthyear')));
|
||||
$summary = get_string('tabledata', 'access', $summary);
|
||||
$content .= '<table class="minicalendar calendartable" summary="'.$summary.'">'; // Begin table
|
||||
$content .= '<tr class="weekdays">'; // Header row: day names
|
||||
|
||||
@@ -1237,6 +1236,10 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
|
||||
$user = false;
|
||||
$group = false;
|
||||
|
||||
// capabilities that allow seeing group events from all groups
|
||||
// TODO: rewrite so that moodle/calendar:manageentries is not necessary here
|
||||
$allgroupscaps = array('moodle/site:accessallgroups', 'moodle/calendar:manageentries');
|
||||
|
||||
$isloggedin = isloggedin();
|
||||
|
||||
if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_COURSE)) {
|
||||
@@ -1262,26 +1265,35 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
|
||||
|
||||
if (!empty($courseeventsfrom) && (calendar_show_event_type(CALENDAR_EVENT_GROUP) || $ignorefilters)) {
|
||||
|
||||
if (!empty($CFG->calendar_adminseesall) && has_capability('moodle/calendar:manageentries', get_system_context())) {
|
||||
$group = true;
|
||||
} else if ($isloggedin) {
|
||||
$groupids = array();
|
||||
|
||||
// We already have the courses to examine in $courses
|
||||
// For each course...
|
||||
foreach ($courseeventsfrom as $courseid => $course) {
|
||||
// If the user is an editing teacher in there,
|
||||
if (!empty($USER->groupmember[$course->id])) {
|
||||
// We've already cached the users groups for this course so we can just use that
|
||||
$groupids = array_merge($groupids, $USER->groupmember[$course->id]);
|
||||
} else if (($course->groupmode != NOGROUPS || !$course->groupmodeforce) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
// If this course has groups, show events from all of them
|
||||
$coursegroups = groups_get_user_groups($course->id, $USER->id);
|
||||
$groupids = array_merge($groupids, $coursegroups['0']);
|
||||
}
|
||||
if (count($courseeventsfrom)==1) {
|
||||
$course = reset($courseeventsfrom);
|
||||
if (has_any_capability($allgroupscaps, get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$coursegroups = groups_get_all_groups($course->id, 0, 0, 'g.id');
|
||||
$group = array_keys($coursegroups);
|
||||
}
|
||||
if (!empty($groupids)) {
|
||||
$group = $groupids;
|
||||
}
|
||||
if ($group === false) {
|
||||
if (!empty($CFG->calendar_adminseesall) && has_any_capability($allgroupscaps, get_system_context())) {
|
||||
$group = true;
|
||||
} else if ($isloggedin) {
|
||||
$groupids = array();
|
||||
|
||||
// We already have the courses to examine in $courses
|
||||
// For each course...
|
||||
foreach ($courseeventsfrom as $courseid => $course) {
|
||||
// If the user is an editing teacher in there,
|
||||
if (!empty($USER->groupmember[$course->id])) {
|
||||
// We've already cached the users groups for this course so we can just use that
|
||||
$groupids = array_merge($groupids, $USER->groupmember[$course->id]);
|
||||
} else if ($course->groupmode != NOGROUPS || !$course->groupmodeforce) {
|
||||
// If this course has groups, show events from all of those related to the current user
|
||||
$coursegroups = groups_get_user_groups($course->id, $USER->id);
|
||||
$groupids = array_merge($groupids, $coursegroups['0']);
|
||||
}
|
||||
}
|
||||
if (!empty($groupids)) {
|
||||
$group = $groupids;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1349,15 +1361,16 @@ function calendar_get_default_courses() {
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
if (!empty($CFG->calendar_adminseesall) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (!empty($CFG->calendar_adminseesall) && has_capability('moodle/calendar:manageentries', context_system::instance())) {
|
||||
list ($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT DISTINCT c.* $select
|
||||
$sql = "SELECT c.* $select
|
||||
FROM {course} c
|
||||
JOIN {event} e ON e.courseid = c.id
|
||||
$join";
|
||||
$join
|
||||
WHERE EXISTS (SELECT 1 FROM {event} e WHERE e.courseid = c.id)
|
||||
";
|
||||
$courses = $DB->get_records_sql($sql, null, 0, 20);
|
||||
foreach ($courses as $course) {
|
||||
context_instance_preload($course);
|
||||
context_helper::preload_from_record($course);
|
||||
}
|
||||
return $courses;
|
||||
}
|
||||
@@ -1552,6 +1565,7 @@ function calendar_get_allowed_types(&$allowed, $course = null) {
|
||||
}
|
||||
if ($course->id != SITEID) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$allowed->user = has_capability('moodle/calendar:manageownentries', $coursecontext);
|
||||
|
||||
if (has_capability('moodle/calendar:manageentries', $coursecontext)) {
|
||||
$allowed->courses = array($course->id => 1);
|
||||
@@ -2087,6 +2101,20 @@ class calendar_event {
|
||||
// Delete the event
|
||||
$DB->delete_records('event', array('id'=>$this->properties->id));
|
||||
|
||||
// If we are deleting parent of a repeated event series, promote the next event in the series as parent
|
||||
if (($this->properties->id == $this->properties->repeatid) && !$deleterepeated) {
|
||||
$newparent = $DB->get_field_sql("SELECT id from {event} where repeatid = ? order by id ASC", array($this->properties->id), IGNORE_MULTIPLE);
|
||||
if (!empty($newparent)) {
|
||||
$DB->execute("UPDATE {event} SET repeatid = ? WHERE repeatid = ?", array($newparent, $this->properties->id));
|
||||
// Get all records where the repeatid is the same as the event being removed
|
||||
$events = $DB->get_records('event', array('repeatid' => $newparent));
|
||||
// For each of the returned events trigger the event_update hook.
|
||||
foreach ($events as $event) {
|
||||
self::calendar_event_hook('update_event', array($event, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the editor context hasn't already been set then set it now
|
||||
if ($this->editorcontext === null) {
|
||||
$this->editorcontext = $this->properties->context;
|
||||
|
||||
+17
-9
@@ -135,7 +135,9 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
* @return string
|
||||
*/
|
||||
public function fake_block_filters($courseid, $day, $month, $year, $view, $courses) {
|
||||
return html_writer::tag('div', calendar_filter_controls($this->page->url), array('class'=>'calendar_filters filters'));
|
||||
$returnurl = $this->page->url;
|
||||
$returnurl->param('course', $courseid);
|
||||
return html_writer::tag('div', calendar_filter_controls($returnurl), array('class'=>'calendar_filters filters'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,6 +415,8 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
|
||||
$table = new html_table();
|
||||
$table->attributes = array('class'=>'calendarmonth calendartable');
|
||||
$time = make_timestamp($calendar->year, $calendar->month);
|
||||
$table->summary = get_string('calendarheading', 'calendar', userdate($time, get_string('strftimemonthyear')));
|
||||
$table->data = array();
|
||||
|
||||
$header = new html_table_row();
|
||||
@@ -579,22 +583,24 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
|
||||
// Global events
|
||||
$link = new moodle_url(CALENDAR_URL.'set.php', array('var' => 'showglobal', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
|
||||
$strglobalevents = get_string('globalevents', 'calendar');
|
||||
if (calendar_show_event_type(CALENDAR_EVENT_GLOBAL)) {
|
||||
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_global', 'style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('globalevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $strglobalevents).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar').'<span class="accesshide">'.$strglobalevents.'</span>').')');
|
||||
} else {
|
||||
$output .= html_writer::tag('td', '', array('style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('globalevents', 'calendar')).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $strglobalevents).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar').'<span class="accesshide">'.$strglobalevents.'</span>').')');
|
||||
}
|
||||
|
||||
// Course events
|
||||
$link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showcourses', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
|
||||
$strcourseevents = get_string('courseevents', 'calendar');
|
||||
if (calendar_show_event_type(CALENDAR_EVENT_COURSE)) {
|
||||
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_course', 'style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('courseevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $strcourseevents).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar').'<span class="accesshide">'.$strcourseevents.'</span>').')');
|
||||
} else {
|
||||
$output .= html_writer::tag('td', '', array('style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('courseevents', 'calendar')).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $strcourseevents).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar').'<span class="accesshide">'.$strcourseevents.'</span>').')');
|
||||
}
|
||||
$output .= html_writer::end_tag('tr');
|
||||
|
||||
@@ -602,21 +608,23 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
$output .= html_writer::start_tag('tr');
|
||||
// Group events
|
||||
$link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showgroups', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
|
||||
$strgroupevents = get_string('groupevents', 'calendar');
|
||||
if (calendar_show_event_type(CALENDAR_EVENT_GROUP)) {
|
||||
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_group', 'style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('groupevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $strgroupevents).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar').'<span class="accesshide">'.$strgroupevents.'</span>').')');
|
||||
} else {
|
||||
$output .= html_writer::tag('td', '', array('style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('groupevents', 'calendar')).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $strgroupevents).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar').'<span class="accesshide">'.$strgroupevents.'</span>').')');
|
||||
}
|
||||
// User events
|
||||
$link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showuser', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
|
||||
$struserevents = get_string('userevents', 'calendar');
|
||||
if (calendar_show_event_type(CALENDAR_EVENT_USER)) {
|
||||
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_user', 'style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('userevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $struserevents).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar').'<span class="accesshide">'.$struserevents.'</span>').')');
|
||||
} else {
|
||||
$output .= html_writer::tag('td', '', array('style'=>'width:8px;'));
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('userevents', 'calendar')).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar')).')');
|
||||
$output .= html_writer::tag('td', html_writer::tag('strong', $struserevents).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar').'<span class="accesshide">'.$struserevents.'</span>').')');
|
||||
}
|
||||
$output .= html_writer::end_tag('tr');
|
||||
}
|
||||
|
||||
+7
-2
@@ -45,8 +45,13 @@ require_sesskey();
|
||||
|
||||
$var = required_param('var', PARAM_ALPHA);
|
||||
$return = clean_param(base64_decode(required_param('return', PARAM_RAW)), PARAM_URL);
|
||||
|
||||
$url = new moodle_url('/calendar/set.php', array('return'=>base64_encode($return),'var'=>$var, 'sesskey'=>sesskey()));
|
||||
$courseid = optional_param('id', -1, PARAM_INT);
|
||||
if ($courseid != -1) {
|
||||
$return = new moodle_url($return, array('course' => $courseid));
|
||||
} else {
|
||||
$return = new moodle_url($return);
|
||||
}
|
||||
$url = new moodle_url('/calendar/set.php', array('return'=>base64_encode($return->out(false)), 'course' => $courseid, 'var'=>$var, 'sesskey'=>sesskey()));
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ switch($view) {
|
||||
echo $renderer->show_day($calendar);
|
||||
break;
|
||||
case 'month':
|
||||
echo $renderer->show_month_detailed($calendar);
|
||||
echo $renderer->show_month_detailed($calendar, $url);
|
||||
break;
|
||||
case 'upcoming':
|
||||
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
|
||||
|
||||
@@ -49,7 +49,7 @@ class cohort_edit_form extends moodleform {
|
||||
$mform->addElement('select', 'contextid', get_string('context', 'role'), $options);
|
||||
|
||||
$mform->addElement('text', 'idnumber', get_string('idnumber', 'cohort'), 'maxlength="254" size="50"');
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('idnumber', PARAM_RAW); // idnumbers are plain text, must not be changed
|
||||
|
||||
$mform->addElement('editor', 'description_editor', get_string('description', 'cohort'), null, $editoroptions);
|
||||
$mform->setType('description_editor', PARAM_RAW);
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ $data = array();
|
||||
foreach($cohorts['cohorts'] as $cohort) {
|
||||
$line = array();
|
||||
$line[] = format_string($cohort->name);
|
||||
$line[] = $cohort->idnumber;
|
||||
$line[] = s($cohort->idnumber); // plain text
|
||||
$line[] = format_text($cohort->description, $cohort->descriptionformat);
|
||||
|
||||
$line[] = $DB->count_records('cohort_members', array('cohortid'=>$cohort->id));
|
||||
|
||||
@@ -385,6 +385,9 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
|
||||
},
|
||||
toggle_textarea: function(focus) {
|
||||
var t = Y.one('#dlg-content-'+this.client_id);
|
||||
if (!t) {
|
||||
return false;
|
||||
}
|
||||
if (focus) {
|
||||
if (t.get('value') == M.str.moodle.addcomment) {
|
||||
t.set('value', '');
|
||||
|
||||
+1
-1
@@ -569,7 +569,7 @@ class comment {
|
||||
$c->format = $u->cformat;
|
||||
$c->timecreated = $u->ctimecreated;
|
||||
$url = new moodle_url('/user/view.php', array('id'=>$u->id, 'course'=>$this->courseid));
|
||||
$c->profileurl = $url->out();
|
||||
$c->profileurl = $url->out(false);
|
||||
$c->fullname = fullname($u);
|
||||
$c->time = userdate($c->timecreated, get_string('strftimerecent', 'langconfig'));
|
||||
$c->content = format_text($c->content, $c->format, $formatoptions);
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@ $CFG->admin = 'admin';
|
||||
// memory limit to something higher.
|
||||
// The value for the settings should be a valid PHP memory value. e.g. 512M, 1G
|
||||
//
|
||||
// $CFG->extramemorylimit = 1G;
|
||||
// $CFG->extramemorylimit = '1G';
|
||||
//
|
||||
//=========================================================================
|
||||
// 8. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!
|
||||
|
||||
+407
-398
@@ -1,445 +1,454 @@
|
||||
<?php
|
||||
// Displays the top level category or all courses
|
||||
// In editing mode, allows the admin to edit a category,
|
||||
// and rearrange courses
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
/**
|
||||
* Displays the top level category or all courses
|
||||
* In editing mode, allows the admin to edit a category,
|
||||
* and rearrange courses
|
||||
*
|
||||
* @package core
|
||||
* @subpackage course
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Category id
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); // how many per page
|
||||
$categoryedit = optional_param('categoryedit', -1, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
$movedown = optional_param('movedown', 0, PARAM_INT);
|
||||
$moveto = optional_param('moveto', 0, PARAM_INT);
|
||||
$resort = optional_param('resort', 0, PARAM_BOOL);
|
||||
require_once("../config.php");
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$site = get_site();
|
||||
$id = required_param('id', PARAM_INT); // Category id
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); // how many per page
|
||||
$categoryedit = optional_param('categoryedit', -1, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
$movedown = optional_param('movedown', 0, PARAM_INT);
|
||||
$moveto = optional_param('moveto', 0, PARAM_INT);
|
||||
$resort = optional_param('resort', 0, PARAM_BOOL);
|
||||
$sesskey = optional_param('sesskey', '', PARAM_RAW);
|
||||
|
||||
if (empty($id)) {
|
||||
print_error("unknowcategory");
|
||||
if (empty($id)) {
|
||||
print_error("unknowcategory");
|
||||
}
|
||||
|
||||
$PAGE->set_category_by_id($id);
|
||||
$PAGE->set_url(new moodle_url('/course/category.php', array('id' => $id)));
|
||||
// This is sure to be the category context
|
||||
$context = $PAGE->context;
|
||||
// And the object has been loaded for us no need for another DB call
|
||||
$category = $PAGE->category;
|
||||
|
||||
$canedit = can_edit_in_category($category->id);
|
||||
if ($canedit) {
|
||||
if ($categoryedit !== -1) {
|
||||
$USER->editing = $categoryedit;
|
||||
}
|
||||
|
||||
$PAGE->set_category_by_id($id);
|
||||
$urlparams = array('id' => $id);
|
||||
if ($page) {
|
||||
$urlparams['page'] = $page;
|
||||
}
|
||||
if ($perpage) {
|
||||
$urlparams['perpage'] = $perpage;
|
||||
}
|
||||
$PAGE->set_url(new moodle_url('/course/category.php', array('id' => $id)));
|
||||
navigation_node::override_active_url($PAGE->url);
|
||||
$context = $PAGE->context;
|
||||
$category = $PAGE->category;
|
||||
|
||||
$canedit = can_edit_in_category($category->id);
|
||||
if ($canedit) {
|
||||
if ($categoryedit !== -1) {
|
||||
$USER->editing = $categoryedit;
|
||||
}
|
||||
require_login();
|
||||
$editingon = $PAGE->user_is_editing();
|
||||
} else {
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
$editingon = $PAGE->user_is_editing();
|
||||
} else {
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
$editingon = false;
|
||||
}
|
||||
|
||||
if (!$category->visible) {
|
||||
require_capability('moodle/category:viewhiddencategories', $context);
|
||||
}
|
||||
|
||||
$canmanage = has_capability('moodle/category:manage', $context);
|
||||
$sesskeyprovided = !empty($sesskey) && confirm_sesskey($sesskey);
|
||||
|
||||
// Process any category actions.
|
||||
if ($canmanage && $resort && $sesskeyprovided) {
|
||||
// Resort the category if requested
|
||||
if ($courses = get_courses($category->id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
|
||||
$i = 1;
|
||||
foreach ($courses as $course) {
|
||||
$DB->set_field('course', 'sortorder', $category->sortorder+$i, array('id'=>$course->id));
|
||||
$i++;
|
||||
}
|
||||
$editingon = false;
|
||||
fix_course_sortorder(); // should not be needed
|
||||
}
|
||||
}
|
||||
|
||||
if (!$category->visible) {
|
||||
require_capability('moodle/category:viewhiddencategories', $context);
|
||||
}
|
||||
// Process any course actions.
|
||||
if ($editingon && $sesskeyprovided) {
|
||||
|
||||
// Process any category actions.
|
||||
if (has_capability('moodle/category:manage', $context)) {
|
||||
/// Resort the category if requested
|
||||
if ($resort and confirm_sesskey()) {
|
||||
if ($courses = get_courses($category->id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
|
||||
$i = 1;
|
||||
foreach ($courses as $course) {
|
||||
$DB->set_field('course', 'sortorder', $category->sortorder+$i, array('id'=>$course->id));
|
||||
$i++;
|
||||
}
|
||||
fix_course_sortorder(); // should not be needed
|
||||
}
|
||||
// Move a specified course to a new category
|
||||
if (!empty($moveto) and $data = data_submitted()) {
|
||||
// Some courses are being moved
|
||||
// user must have category update in both cats to perform this
|
||||
require_capability('moodle/category:manage', $context);
|
||||
require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $moveto));
|
||||
|
||||
if (!$destcategory = $DB->get_record('course_categories', array('id' => $data->moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $data->moveto);
|
||||
}
|
||||
}
|
||||
|
||||
// Process any course actions.
|
||||
if ($editingon) {
|
||||
/// Move a specified course to a new category
|
||||
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
||||
// user must have category update in both cats to perform this
|
||||
require_capability('moodle/category:manage', $context);
|
||||
require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $moveto));
|
||||
$courses = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (preg_match('/^c\d+$/', $key)) {
|
||||
$courseid = substr($key, 1);
|
||||
array_push($courses, $courseid);
|
||||
|
||||
if (!$destcategory = $DB->get_record('course_categories', array('id' => $data->moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $data->moveto);
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (preg_match('/^c\d+$/', $key)) {
|
||||
$courseid = substr($key, 1);
|
||||
array_push($courses, $courseid);
|
||||
|
||||
// check this course's category
|
||||
if ($movingcourse = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
if ($movingcourse->category != $id ) {
|
||||
print_error('coursedoesnotbelongtocategory');
|
||||
}
|
||||
} else {
|
||||
print_error('cannotfindcourse');
|
||||
// check this course's category
|
||||
if ($movingcourse = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
if ($movingcourse->category != $id ) {
|
||||
print_error('coursedoesnotbelongtocategory');
|
||||
}
|
||||
} else {
|
||||
print_error('cannotfindcourse');
|
||||
}
|
||||
}
|
||||
move_courses($courses, $data->moveto);
|
||||
}
|
||||
|
||||
/// Hide or show a course
|
||||
if ((!empty($hide) or !empty($show)) and confirm_sesskey()) {
|
||||
if (!empty($hide)) {
|
||||
$course = $DB->get_record('course', array('id' => $hide));
|
||||
$visible = 0;
|
||||
} else {
|
||||
$course = $DB->get_record('course', array('id' => $show));
|
||||
$visible = 1;
|
||||
}
|
||||
|
||||
if ($course) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/course:visibility', $coursecontext);
|
||||
$DB->set_field('course', 'visible', $visible, array('id' => $course->id));
|
||||
$DB->set_field('course', 'visibleold', $visible, array('id' => $course->id)); // we set the old flag when user manually changes visibility of course
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Move a course up or down
|
||||
if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) {
|
||||
require_capability('moodle/category:manage', $context);
|
||||
|
||||
// Ensure the course order has continuous ordering
|
||||
fix_course_sortorder();
|
||||
$swapcourse = NULL;
|
||||
|
||||
if (!empty($moveup)) {
|
||||
if ($movecourse = $DB->get_record('course', array('id' => $moveup))) {
|
||||
$swapcourse = $DB->get_record('course', array('sortorder' => $movecourse->sortorder - 1));
|
||||
}
|
||||
} else {
|
||||
if ($movecourse = $DB->get_record('course', array('id' => $movedown))) {
|
||||
$swapcourse = $DB->get_record('course', array('sortorder' => $movecourse->sortorder + 1));
|
||||
}
|
||||
}
|
||||
if ($swapcourse and $movecourse) {
|
||||
// check course's category
|
||||
if ($movecourse->category != $id) {
|
||||
print_error('coursedoesnotbelongtocategory');
|
||||
}
|
||||
$DB->set_field('course', 'sortorder', $swapcourse->sortorder, array('id' => $movecourse->id));
|
||||
$DB->set_field('course', 'sortorder', $movecourse->sortorder, array('id' => $swapcourse->id));
|
||||
}
|
||||
}
|
||||
|
||||
} // End of editing stuff
|
||||
|
||||
// Print headings
|
||||
$numcategories = $DB->count_records('course_categories');
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strcategories = get_string('categories');
|
||||
$strcategory = get_string('category');
|
||||
$strcourses = get_string('courses');
|
||||
|
||||
if ($editingon && can_edit_in_category()) {
|
||||
// Integrate into the admin tree only if the user can edit categories at the top level,
|
||||
// otherwise the admin block does not appear to this user, and you get an error.
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/category.php');
|
||||
$PAGE->set_context($context); // Ensure that we are actually showing blocks etc for the cat context
|
||||
|
||||
$settingsnode = $PAGE->settingsnav->find_active_node();
|
||||
if ($settingsnode) {
|
||||
$settingsnode->make_inactive();
|
||||
$settingsnode->force_open();
|
||||
$PAGE->navbar->add($settingsnode->text, $settingsnode->action);
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
} else {
|
||||
$PAGE->set_title("$site->shortname: $category->name");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
$PAGE->set_button(print_course_search('', true, 'navbar'));
|
||||
$PAGE->set_pagelayout('coursecategory');
|
||||
echo $OUTPUT->header();
|
||||
move_courses($courses, $data->moveto);
|
||||
}
|
||||
|
||||
// Hide or show a course
|
||||
if (!empty($hide) or !empty($show)) {
|
||||
if (!empty($hide)) {
|
||||
$course = $DB->get_record('course', array('id' => $hide));
|
||||
$visible = 0;
|
||||
} else {
|
||||
$course = $DB->get_record('course', array('id' => $show));
|
||||
$visible = 1;
|
||||
}
|
||||
|
||||
if ($course) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/course:visibility', $coursecontext);
|
||||
// Set the visibility of the course. we set the old flag when user manually changes visibility of course.
|
||||
$DB->update_record('course', array('id' => $course->id, 'visible' => $visible, 'visibleold' => $visible, 'timemodified' => time()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Move a course up or down
|
||||
if (!empty($moveup) or !empty($movedown)) {
|
||||
require_capability('moodle/category:manage', $context);
|
||||
|
||||
// Ensure the course order has continuous ordering
|
||||
fix_course_sortorder();
|
||||
$swapcourse = NULL;
|
||||
|
||||
if (!empty($moveup)) {
|
||||
if ($movecourse = $DB->get_record('course', array('id' => $moveup))) {
|
||||
$swapcourse = $DB->get_record('course', array('sortorder' => $movecourse->sortorder - 1));
|
||||
}
|
||||
} else {
|
||||
if ($movecourse = $DB->get_record('course', array('id' => $movedown))) {
|
||||
$swapcourse = $DB->get_record('course', array('sortorder' => $movecourse->sortorder + 1));
|
||||
}
|
||||
}
|
||||
if ($swapcourse and $movecourse) {
|
||||
// check course's category
|
||||
if ($movecourse->category != $id) {
|
||||
print_error('coursedoesnotbelongtocategory');
|
||||
}
|
||||
$DB->set_field('course', 'sortorder', $swapcourse->sortorder, array('id' => $movecourse->id));
|
||||
$DB->set_field('course', 'sortorder', $movecourse->sortorder, array('id' => $swapcourse->id));
|
||||
}
|
||||
}
|
||||
|
||||
} // End of editing stuff
|
||||
|
||||
// Prepare the standard URL params for this page. We'll need them later.
|
||||
$urlparams = array('id' => $id);
|
||||
if ($page) {
|
||||
$urlparams['page'] = $page;
|
||||
}
|
||||
if ($perpage) {
|
||||
$urlparams['perpage'] = $perpage;
|
||||
}
|
||||
|
||||
// Begin output
|
||||
if ($editingon && can_edit_in_category()) {
|
||||
// Integrate into the admin tree only if the user can edit categories at the top level,
|
||||
// otherwise the admin block does not appear to this user, and you get an error.
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/category.php');
|
||||
$PAGE->set_context($context); // Ensure that we are actually showing blocks etc for the cat context
|
||||
|
||||
$settingsnode = $PAGE->settingsnav->find_active_node();
|
||||
if ($settingsnode) {
|
||||
$settingsnode->make_inactive();
|
||||
$settingsnode->force_open();
|
||||
$PAGE->navbar->add($settingsnode->text, $settingsnode->action);
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
} else {
|
||||
$site = get_site();
|
||||
$PAGE->set_title("$site->shortname: $category->name");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
$PAGE->set_button(print_course_search('', true, 'navbar'));
|
||||
$PAGE->set_pagelayout('coursecategory');
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
/// Print the category selector
|
||||
$displaylist = array();
|
||||
$notused = array();
|
||||
make_categories_list($displaylist, $notused);
|
||||
$displaylist = array();
|
||||
$notused = array();
|
||||
make_categories_list($displaylist, $notused);
|
||||
|
||||
echo '<div class="categorypicker">';
|
||||
$select = new single_select(new moodle_url('category.php'), 'id', $displaylist, $category->id, null, 'switchcategory');
|
||||
$select->set_label($strcategories.':');
|
||||
echo $OUTPUT->render($select);
|
||||
echo '</div>';
|
||||
echo '<div class="categorypicker">';
|
||||
$select = new single_select(new moodle_url('/course/category.php'), 'id', $displaylist, $category->id, null, 'switchcategory');
|
||||
$select->set_label(get_string('categories').':');
|
||||
echo $OUTPUT->render($select);
|
||||
echo '</div>';
|
||||
|
||||
/// Print current category description
|
||||
if (!$editingon && $category->description) {
|
||||
echo $OUTPUT->box_start();
|
||||
$options = new stdClass;
|
||||
$options->noclean = true;
|
||||
$options->para = false;
|
||||
$options->overflowdiv = true;
|
||||
if (!isset($category->descriptionformat)) {
|
||||
$category->descriptionformat = FORMAT_MOODLE;
|
||||
}
|
||||
$text = file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'coursecat', 'description', null);
|
||||
echo format_text($text, $category->descriptionformat, $options);
|
||||
echo $OUTPUT->box_end();
|
||||
if (!$editingon && $category->description) {
|
||||
echo $OUTPUT->box_start();
|
||||
$options = new stdClass;
|
||||
$options->noclean = true;
|
||||
$options->para = false;
|
||||
$options->overflowdiv = true;
|
||||
if (!isset($category->descriptionformat)) {
|
||||
$category->descriptionformat = FORMAT_MOODLE;
|
||||
}
|
||||
$text = file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'coursecat', 'description', null);
|
||||
echo format_text($text, $category->descriptionformat, $options);
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if ($editingon && $canmanage) {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
|
||||
// Print button to update this category
|
||||
$url = new moodle_url('/course/editcategory.php', array('id' => $category->id));
|
||||
echo $OUTPUT->single_button($url, get_string('editcategorythis'), 'get');
|
||||
|
||||
// Print button for creating new categories
|
||||
$url = new moodle_url('/course/editcategory.php', array('parent' => $category->id));
|
||||
echo $OUTPUT->single_button($url, get_string('addsubcategory'), 'get');
|
||||
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
|
||||
// Print out all the sub-categories
|
||||
// In order to view hidden subcategories the user must have the viewhiddencategories
|
||||
// capability in the current category.
|
||||
if (has_capability('moodle/category:viewhiddencategories', $context)) {
|
||||
$categorywhere = '';
|
||||
} else {
|
||||
$categorywhere = 'AND cc.visible = 1';
|
||||
}
|
||||
// We're going to preload the context for the subcategory as we know that we
|
||||
// need it later on for formatting.
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('cc.id', CONTEXT_COURSECAT, 'ctx');
|
||||
$sql = "SELECT cc.* $ctxselect
|
||||
FROM {course_categories} cc
|
||||
$ctxjoin
|
||||
WHERE cc.parent = :parentid
|
||||
$categorywhere
|
||||
ORDER BY cc.sortorder ASC";
|
||||
$subcategories = $DB->get_recordset_sql($sql, array('parentid' => $category->id));
|
||||
// Prepare a table to display the sub categories.
|
||||
$table = new html_table;
|
||||
$table->attributes = array('border' => '0', 'cellspacing' => '2', 'cellpadding' => '4', 'class' => 'generalbox boxaligncenter category_subcategories');
|
||||
$table->head = array(get_string('subcategories'));
|
||||
$table->data = array();
|
||||
$baseurl = new moodle_url('/course/category.php');
|
||||
foreach ($subcategories as $subcategory) {
|
||||
// Preload the context we will need it to format the category name shortly.
|
||||
context_instance_preload($subcategory);
|
||||
$context = get_context_instance(CONTEXT_COURSECAT, $subcategory->id);
|
||||
// Prepare the things we need to create a link to the subcategory
|
||||
$attributes = $subcategory->visible ? array() : array('class' => 'dimmed');
|
||||
$text = format_string($subcategory->name, true, array('context' => $context));
|
||||
// Add the subcategory to the table
|
||||
$baseurl->param('id', $subcategory->id);
|
||||
$table->data[] = array(html_writer::link($baseurl, $text, $attributes));
|
||||
}
|
||||
|
||||
$subcategorieswereshown = (count($table->data) > 0);
|
||||
if ($subcategorieswereshown) {
|
||||
echo html_writer::table($table);
|
||||
}
|
||||
|
||||
// Print out all the courses
|
||||
$courses = get_courses_page($category->id, 'c.sortorder ASC',
|
||||
'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible',
|
||||
$totalcount, $page*$perpage, $perpage);
|
||||
$numcourses = count($courses);
|
||||
|
||||
if (!$courses) {
|
||||
if (empty($subcategorieswereshown)) {
|
||||
echo $OUTPUT->heading(get_string("nocoursesyet"));
|
||||
}
|
||||
|
||||
if ($editingon && has_capability('moodle/category:manage', $context)) {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
} else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) {
|
||||
echo $OUTPUT->box_start('courseboxes');
|
||||
print_courses($category);
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// Print button to update this category
|
||||
$options = array('id' => $category->id);
|
||||
echo $OUTPUT->single_button(new moodle_url('/course/editcategory.php', $options), get_string('editcategorythis'), 'get');
|
||||
|
||||
// Print button for creating new categories
|
||||
$options = array('parent' => $category->id);
|
||||
echo $OUTPUT->single_button(new moodle_url('/course/editcategory.php', $options), get_string('addsubcategory'), 'get');
|
||||
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
|
||||
/// Print out all the sub-categories
|
||||
if ($subcategories = $DB->get_records('course_categories', array('parent' => $category->id), 'sortorder ASC')) {
|
||||
$firstentry = true;
|
||||
foreach ($subcategories as $subcategory) {
|
||||
if ($subcategory->visible || has_capability('moodle/category:viewhiddencategories', $context)) {
|
||||
$subcategorieswereshown = true;
|
||||
if ($firstentry) {
|
||||
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter">';
|
||||
echo '<tr><th scope="col">'.get_string('subcategories').'</th></tr>';
|
||||
echo '<tr><td style="white-space: nowrap">';
|
||||
$firstentry = false;
|
||||
}
|
||||
$catlinkcss = $subcategory->visible ? '' : ' class="dimmed" ';
|
||||
echo '<a '.$catlinkcss.' href="category.php?id='.$subcategory->id.'">'.
|
||||
format_string($subcategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $subcategory->id))).'</a><br />';
|
||||
}
|
||||
}
|
||||
if (!$firstentry) {
|
||||
echo '</td></tr></table>';
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out all the courses
|
||||
$courses = get_courses_page($category->id, 'c.sortorder ASC',
|
||||
'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible',
|
||||
$totalcount, $page*$perpage, $perpage);
|
||||
$numcourses = count($courses);
|
||||
|
||||
if (!$courses) {
|
||||
if (empty($subcategorieswereshown)) {
|
||||
echo $OUTPUT->heading(get_string("nocoursesyet"));
|
||||
}
|
||||
|
||||
} else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) {
|
||||
echo $OUTPUT->box_start('courseboxes');
|
||||
print_courses($category);
|
||||
echo $OUTPUT->box_end();
|
||||
} else {
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "/course/category.php?id=$category->id&perpage=$perpage");
|
||||
|
||||
echo '<form id="movecourses" action="category.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter"><tr>';
|
||||
echo '<th class="header" scope="col">'.get_string('courses').'</th>';
|
||||
if ($editingon) {
|
||||
echo '<th class="header" scope="col">'.get_string('edit').'</th>';
|
||||
echo '<th class="header" scope="col">'.get_string('select').'</th>';
|
||||
} else {
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "/course/category.php?id=$category->id&perpage=$perpage");
|
||||
echo '<th class="header" scope="col"> </th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
|
||||
$strcourses = get_string('courses');
|
||||
$strselect = get_string('select');
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strbackup = get_string('backup');
|
||||
$strrestore = get_string('restore');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
$strupdate = get_string('update');
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
$strsummary = get_string('summary');
|
||||
$strsettings = get_string('settings');
|
||||
$count = 0;
|
||||
$abletomovecourses = false; // for now
|
||||
|
||||
|
||||
echo '<form id="movecourses" action="category.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter"><tr>';
|
||||
echo '<th class="header" scope="col">'.$strcourses.'</th>';
|
||||
if ($editingon) {
|
||||
echo '<th class="header" scope="col">'.$stredit.'</th>';
|
||||
echo '<th class="header" scope="col">'.$strselect.'</th>';
|
||||
// Checking if we are at the first or at the last page, to allow courses to
|
||||
// be moved up and down beyond the paging border
|
||||
if ($totalcount > $perpage) {
|
||||
$atfirstpage = ($page == 0);
|
||||
if ($perpage > 0) {
|
||||
$atlastpage = (($page + 1) == ceil($totalcount / $perpage));
|
||||
} else {
|
||||
echo '<th class="header" scope="col"> </th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
$count = 0;
|
||||
$abletomovecourses = false; // for now
|
||||
|
||||
// Checking if we are at the first or at the last page, to allow courses to
|
||||
// be moved up and down beyond the paging border
|
||||
if ($totalcount > $perpage) {
|
||||
$atfirstpage = ($page == 0);
|
||||
if ($perpage > 0) {
|
||||
$atlastpage = (($page + 1) == ceil($totalcount / $perpage));
|
||||
} else {
|
||||
$atlastpage = true;
|
||||
}
|
||||
} else {
|
||||
$atfirstpage = true;
|
||||
$atlastpage = true;
|
||||
}
|
||||
} else {
|
||||
$atfirstpage = true;
|
||||
$atlastpage = true;
|
||||
}
|
||||
|
||||
foreach ($courses as $acourse) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id);
|
||||
$baseurl = new moodle_url('/course/category.php', $urlparams + array('sesskey' => sesskey()));
|
||||
foreach ($courses as $acourse) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id);
|
||||
|
||||
$count++;
|
||||
$up = ($count > 1 || !$atfirstpage);
|
||||
$down = ($count < $numcourses || !$atlastpage);
|
||||
$count++;
|
||||
$up = ($count > 1 || !$atfirstpage);
|
||||
$down = ($count < $numcourses || !$atlastpage);
|
||||
|
||||
$linkcss = $acourse->visible ? '' : ' class="dimmed" ';
|
||||
echo '<tr>';
|
||||
$coursename = get_course_display_name_for_list($acourse);
|
||||
echo '<td><a '.$linkcss.' href="view.php?id='.$acourse->id.'">'. format_string($coursename) .'</a></td>';
|
||||
if ($editingon) {
|
||||
echo '<td>';
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/edit.php',
|
||||
array('id' => $acourse->id, 'category' => $id, 'returnto' => 'category')),
|
||||
new pix_icon('t/edit', $strsettings));
|
||||
}
|
||||
|
||||
// role assignment link
|
||||
if (has_capability('moodle/course:enrolreview', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/enrol/users.php', array('id' => $acourse->id)),
|
||||
new pix_icon('i/users', get_string('enrolledusers', 'enrol')));
|
||||
}
|
||||
|
||||
if (can_delete_course($acourse->id)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/delete.php', array('id' => $acourse->id)),
|
||||
new pix_icon('t/delete', $strdelete));
|
||||
}
|
||||
|
||||
// MDL-8885, users with no capability to view hidden courses, should not be able to lock themselves out
|
||||
if (has_capability('moodle/course:visibility', $coursecontext) && has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
|
||||
if (!empty($acourse->visible)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'hide' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/hide', $strhide));
|
||||
} else {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'show' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/show', $strshow));
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/backup/backup.php', array('id' => $acourse->id)),
|
||||
new pix_icon('t/backup', $strbackup));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id)),
|
||||
new pix_icon('t/restore', $strrestore));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/category:manage', $context)) {
|
||||
if ($up) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'moveup' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/up', $strmoveup));
|
||||
}
|
||||
|
||||
if ($down) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'movedown' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/down', $strmovedown));
|
||||
}
|
||||
$abletomovecourses = true;
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
echo '<td align="center">';
|
||||
echo '<input type="checkbox" name="c'.$acourse->id.'" />';
|
||||
echo '</td>';
|
||||
} else {
|
||||
echo '<td align="right">';
|
||||
// print enrol info
|
||||
if ($icons = enrol_get_course_info_icons($acourse)) {
|
||||
foreach ($icons as $pix_icon) {
|
||||
echo $OUTPUT->render($pix_icon);
|
||||
}
|
||||
}
|
||||
if (!empty($acourse->summary)) {
|
||||
$link = new moodle_url("/course/info.php?id=$acourse->id");
|
||||
echo $OUTPUT->action_link($link, '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />',
|
||||
new popup_action('click', $link, 'courseinfo'), array('title'=>$strsummary));
|
||||
}
|
||||
echo "</td>";
|
||||
$linkcss = $acourse->visible ? '' : ' class="dimmed" ';
|
||||
echo '<tr>';
|
||||
$coursename = get_course_display_name_for_list($acourse);
|
||||
echo '<td><a '.$linkcss.' href="view.php?id='.$acourse->id.'">'. format_string($coursename) .'</a></td>';
|
||||
if ($editingon) {
|
||||
echo '<td>';
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
$url = new moodle_url('/course/edit.php', array('id' => $acourse->id, 'category' => $id, 'returnto' => 'category'));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/edit', get_string('settings')));
|
||||
}
|
||||
echo "</tr>";
|
||||
|
||||
// role assignment link
|
||||
if (has_capability('moodle/course:enrolreview', $coursecontext)) {
|
||||
$url = new moodle_url('/enrol/users.php', array('id' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('i/users', get_string('enrolledusers', 'enrol')));
|
||||
}
|
||||
|
||||
if (can_delete_course($acourse->id)) {
|
||||
$url = new moodle_url('/course/delete.php', array('id' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/delete', get_string('delete')));
|
||||
}
|
||||
|
||||
// MDL-8885, users with no capability to view hidden courses, should not be able to lock themselves out
|
||||
if (has_capability('moodle/course:visibility', $coursecontext) && has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
|
||||
if (!empty($acourse->visible)) {
|
||||
$url = new moodle_url($baseurl, array('hide' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/hide', get_string('hide')));
|
||||
} else {
|
||||
$url = new moodle_url($baseurl, array('show' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/show', get_string('show')));
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
|
||||
$url = new moodle_url('/backup/backup.php', array('id' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/backup', get_string('backup')));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
|
||||
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/restore', get_string('restore')));
|
||||
}
|
||||
|
||||
if ($canmanage) {
|
||||
if ($up) {
|
||||
$url = new moodle_url($baseurl, array('moveup' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')));
|
||||
}
|
||||
|
||||
if ($down) {
|
||||
$url = new moodle_url($baseurl, array('movedown' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')));
|
||||
}
|
||||
$abletomovecourses = true;
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
echo '<td align="center">';
|
||||
echo '<input type="checkbox" name="c'.$acourse->id.'" />';
|
||||
echo '</td>';
|
||||
} else {
|
||||
echo '<td align="right">';
|
||||
// print enrol info
|
||||
if ($icons = enrol_get_course_info_icons($acourse)) {
|
||||
foreach ($icons as $pix_icon) {
|
||||
echo $OUTPUT->render($pix_icon);
|
||||
}
|
||||
}
|
||||
if (!empty($acourse->summary)) {
|
||||
$url = new moodle_url("/course/info.php?id=$acourse->id");
|
||||
echo $OUTPUT->action_link($url, '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />',
|
||||
new popup_action('click', $url, 'courseinfo'), array('title'=>get_string('summary')));
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
|
||||
if ($abletomovecourses) {
|
||||
$movetocategories = array();
|
||||
$notused = array();
|
||||
make_categories_list($movetocategories, $notused, 'moodle/category:manage');
|
||||
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
|
||||
echo '<tr><td colspan="3" align="right">';
|
||||
echo html_writer::select($movetocategories, 'moveto', $category->id, null, array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
echo '</div></form>';
|
||||
echo '<br />';
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo '<div class="buttons">';
|
||||
if (has_capability('moodle/category:manage', $context) and $numcourses > 1) {
|
||||
/// Print button to re-sort courses by name
|
||||
unset($options);
|
||||
$options['id'] = $category->id;
|
||||
$options['resort'] = 'name';
|
||||
$options['sesskey'] = sesskey();
|
||||
echo $OUTPUT->single_button(new moodle_url('category.php', $options), get_string('resortcoursesbyname'), 'get');
|
||||
if ($abletomovecourses) {
|
||||
$movetocategories = array();
|
||||
$notused = array();
|
||||
make_categories_list($movetocategories, $notused, 'moodle/category:manage');
|
||||
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
|
||||
echo '<tr><td colspan="3" align="right">';
|
||||
echo html_writer::select($movetocategories, 'moveto', $category->id, null, array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:create', $context)) {
|
||||
/// Print button to create a new course
|
||||
unset($options);
|
||||
$options['category'] = $category->id;
|
||||
$options['returnto'] = 'category';
|
||||
echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get');
|
||||
}
|
||||
echo '</table>';
|
||||
echo '</div></form>';
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablecourserequests) && $category->id == $CFG->defaultrequestcategory) {
|
||||
print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<div class="buttons">';
|
||||
if ($canmanage and $numcourses > 1) {
|
||||
// Print button to re-sort courses by name
|
||||
$url = new moodle_url('/course/category.php', array('id' => $category->id, 'resort' => 'name', 'sesskey' => sesskey()));
|
||||
echo $OUTPUT->single_button($url, get_string('resortcoursesbyname'), 'get');
|
||||
}
|
||||
|
||||
print_course_search();
|
||||
if (has_capability('moodle/course:create', $context)) {
|
||||
// Print button to create a new course
|
||||
$url = new moodle_url('/course/edit.php', array('category' => $category->id, 'returnto' => 'category'));
|
||||
echo $OUTPUT->single_button($url, get_string('addnewcourse'), 'get');
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
if (!empty($CFG->enablecourserequests) && $category->id == $CFG->defaultrequestcategory) {
|
||||
print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_course_search();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+14
-6
@@ -18,17 +18,21 @@ M.core_completion.init = function(Y) {
|
||||
|
||||
} else {
|
||||
var current = args.state.get('value');
|
||||
|
||||
var modulename = args.modulename.get('value');
|
||||
if (current == 1) {
|
||||
var altstr = M.str.completion['completion-alt-manual-y'].replace('{$a}', modulename);
|
||||
var titlestr = M.str.completion['completion-title-manual-y'].replace('{$a}', modulename);
|
||||
args.state.set('value', 0);
|
||||
args.image.set('src', M.util.image_url('i/completion-manual-y', 'moodle'));
|
||||
args.image.set('alt', M.str.completion['completion-alt-manual-y']);
|
||||
args.image.set('title', M.str.completion['completion-title-manual-y']);
|
||||
args.image.set('alt', altstr);
|
||||
args.image.set('title', titlestr);
|
||||
} else {
|
||||
var altstr = M.str.completion['completion-alt-manual-n'].replace('{$a}', modulename);
|
||||
var titlestr = M.str.completion['completion-title-manual-n'].replace('{$a}', modulename);
|
||||
args.state.set('value', 1);
|
||||
args.image.set('src', M.util.image_url('i/completion-manual-n', 'moodle'));
|
||||
args.image.set('alt', M.str.completion['completion-alt-manual-n']);
|
||||
args.image.set('title', M.str.completion['completion-title-manual-n']);
|
||||
args.image.set('alt', altstr);
|
||||
args.image.set('title', titlestr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +52,7 @@ M.core_completion.init = function(Y) {
|
||||
var completionstate = 0;
|
||||
var state = null;
|
||||
var image = null;
|
||||
var modulename = null;
|
||||
|
||||
var inputs = Y.Node.getDOMNode(form).getElementsByTagName('input');
|
||||
for (var i=0; i<inputs.length; i++) {
|
||||
@@ -59,6 +64,9 @@ M.core_completion.init = function(Y) {
|
||||
completionstate = inputs[i].value;
|
||||
state = Y.one(inputs[i]);
|
||||
break;
|
||||
case 'modulename':
|
||||
modulename = Y.one(inputs[i]);
|
||||
break;
|
||||
}
|
||||
if (inputs[i].type == 'image') {
|
||||
image = Y.one(inputs[i]);
|
||||
@@ -76,7 +84,7 @@ M.core_completion.init = function(Y) {
|
||||
success: handle_success,
|
||||
failure: handle_failure
|
||||
},
|
||||
arguments: {state: state, image: image, ajax: ajax}
|
||||
arguments: {state: state, image: image, ajax: ajax, modulename: modulename}
|
||||
};
|
||||
|
||||
Y.use('io-base', function(Y) {
|
||||
|
||||
+18
-26
@@ -103,56 +103,48 @@ if ($form->is_cancelled()){
|
||||
|
||||
// Handle aggregation methods
|
||||
// Overall aggregation
|
||||
$aggregation = new completion_aggregation();
|
||||
$aggregation->course = $data->id;
|
||||
$aggregation->criteriatype = null;
|
||||
$aggdata = array(
|
||||
'course' => $data->id,
|
||||
'criteriatype' => null
|
||||
);
|
||||
$aggregation = new completion_aggregation($aggdata);
|
||||
$aggregation->setMethod($data->overall_aggregation);
|
||||
$aggregation->insert();
|
||||
$aggregation->save();
|
||||
|
||||
// Activity aggregation
|
||||
if (empty($data->activity_aggregation)) {
|
||||
$data->activity_aggregation = 0;
|
||||
}
|
||||
|
||||
$aggregation = new completion_aggregation();
|
||||
$aggregation->course = $data->id;
|
||||
$aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_ACTIVITY;
|
||||
$aggdata['criteriatype'] = COMPLETION_CRITERIA_TYPE_ACTIVITY;
|
||||
$aggregation = new completion_aggregation($aggdata);
|
||||
$aggregation->setMethod($data->activity_aggregation);
|
||||
$aggregation->insert();
|
||||
$aggregation->save();
|
||||
|
||||
// Course aggregation
|
||||
if (empty($data->course_aggregation)) {
|
||||
$data->course_aggregation = 0;
|
||||
}
|
||||
|
||||
$aggregation = new completion_aggregation();
|
||||
$aggregation->course = $data->id;
|
||||
$aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_COURSE;
|
||||
$aggdata['criteriatype'] = COMPLETION_CRITERIA_TYPE_COURSE;
|
||||
$aggregation = new completion_aggregation($aggdata);
|
||||
$aggregation->setMethod($data->course_aggregation);
|
||||
$aggregation->insert();
|
||||
$aggregation->save();
|
||||
|
||||
// Role aggregation
|
||||
if (empty($data->role_aggregation)) {
|
||||
$data->role_aggregation = 0;
|
||||
}
|
||||
|
||||
$aggregation = new completion_aggregation();
|
||||
$aggregation->course = $data->id;
|
||||
$aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_ROLE;
|
||||
$aggdata['criteriatype'] = COMPLETION_CRITERIA_TYPE_ROLE;
|
||||
$aggregation = new completion_aggregation($aggdata);
|
||||
$aggregation->setMethod($data->role_aggregation);
|
||||
$aggregation->insert();
|
||||
$aggregation->save();
|
||||
|
||||
// Update course total passing grade
|
||||
if (!empty($data->criteria_grade)) {
|
||||
if ($grade_item = grade_category::fetch_course_category($course->id)->grade_item) {
|
||||
$grade_item->gradepass = $data->criteria_grade_value;
|
||||
if (method_exists($grade_item, 'update')) {
|
||||
$grade_item->update('course/completion.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
add_to_log($course->id, 'course', 'completion updated', 'completion.php?id='.$course->id);
|
||||
|
||||
redirect($CFG->wwwroot."/course/view.php?id=$course->id", get_string('changessaved'));
|
||||
$url = new moodle_url('/course/view.php', array('id' => $course->id));
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -179,10 +179,13 @@ class course_completion_form extends moodleform {
|
||||
$criteria->config_form_display($mform);
|
||||
|
||||
// Completion on course grade
|
||||
$mform->addElement('header', 'grade', get_string('grade'));
|
||||
$mform->addElement('header', 'grade', get_string('coursegrade', 'completion'));
|
||||
|
||||
// Grade enable and passing grade
|
||||
$course_grade = $DB->get_field('grade_items', 'gradepass', array('courseid' => $course->id, 'itemtype' => 'course'));
|
||||
if (!$course_grade) {
|
||||
$course_grade = '0.00000';
|
||||
}
|
||||
$criteria = new completion_criteria_grade($params);
|
||||
$criteria->config_form_display($mform, $course_grade);
|
||||
|
||||
|
||||
@@ -1,9 +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/>.
|
||||
|
||||
/**
|
||||
* Page for creating or editing course category name/parent/description.
|
||||
* When called with an id parameter, edits the category with that id.
|
||||
* Otherwise it creates a new category with default parent from the parent
|
||||
* parameter, which may be 0.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage course
|
||||
* @copyright 2007 Nicolas Connault
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
@@ -108,6 +128,28 @@ if ($mform->is_cancelled()) {
|
||||
redirect('category.php?id='.$newcategory->id.'&categoryedit=on');
|
||||
}
|
||||
|
||||
// Unfortunately the navigation never generates correctly for this page because technically this page doesn't actually
|
||||
// exist on the navigation; you get here through the course management page.
|
||||
// First up we'll try to make the course management page active seeing as that is where the user thinks they are.
|
||||
// The big prolem here is that the course management page is a common page for both editing users and common users and
|
||||
// is only added to the admin tree if the user has permission to edit at the system level.
|
||||
$node = $PAGE->settingsnav->get('root');
|
||||
if ($node) {
|
||||
$node = $node->get('courses');
|
||||
if ($node) {
|
||||
$node = $node->get('coursemgmt');
|
||||
}
|
||||
}
|
||||
if ($node) {
|
||||
// The course management page exists so make that active.
|
||||
$node->make_active();
|
||||
} else {
|
||||
// Failing that we'll override the URL, not as accurate and chances are things
|
||||
// won't be 100% correct all the time but should work most times.
|
||||
// A common reason to arrive here is having the management capability within only a particular category (not at system level).
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryedit' => 'on')));
|
||||
}
|
||||
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
@@ -56,7 +56,7 @@ class core_course_external extends external_api {
|
||||
* @param array $options, not used yet, might be used in later version
|
||||
* @return array
|
||||
*/
|
||||
public static function get_course_contents($courseid, $options) {
|
||||
public static function get_course_contents($courseid, $options = array()) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
|
||||
@@ -258,7 +258,7 @@ class core_course_external extends external_api {
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
public static function get_courses($options) {
|
||||
public static function get_courses($options = array()) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ function callback_topics_request_key() {
|
||||
|
||||
function callback_topics_get_section_name($course, $section) {
|
||||
// We can't add a node without any text
|
||||
if (!empty($section->name)) {
|
||||
if ((string)$section->name !== '') {
|
||||
return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
} else if ($section->section == 0) {
|
||||
return get_string('section0name', 'format_topics');
|
||||
@@ -100,4 +100,4 @@ function callback_topics_ajax_support() {
|
||||
*/
|
||||
function callback_topics_get_section_url($courseid, $sectionnum) {
|
||||
return new moodle_url('/course/view.php', array('id' => $courseid, 'topic' => $sectionnum));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ function callback_weeks_request_key() {
|
||||
*/
|
||||
function callback_weeks_get_section_name($course, $section) {
|
||||
// We can't add a node without text
|
||||
if (!empty($section->name)) {
|
||||
if ((string)$section->name !== '') {
|
||||
// Return the name the user set
|
||||
return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
} else if ($section->section == 0) {
|
||||
|
||||
+2
-1
@@ -177,6 +177,7 @@ if (!$categories = get_categories()) { /// No category yet!
|
||||
$tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id);
|
||||
mark_context_dirty('/'.SYSCONTEXTID);
|
||||
fix_course_sortorder(); // Required to build course_categories.depth and .path.
|
||||
set_config('defaultrequestcategory', $tempcat->id);
|
||||
}
|
||||
|
||||
/// Move a category to a new parent if required
|
||||
@@ -394,4 +395,4 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
|
||||
print_category_edit($cat, $displaylist, $parentslist, $depth+1, $up, $down);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-6
@@ -1515,9 +1515,8 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
// 2. the activity has dates set which do not include current, or
|
||||
// 3. the activity has any other conditions set (regardless of whether
|
||||
// current user meets them)
|
||||
$canviewhidden = has_capability(
|
||||
'moodle/course:viewhiddenactivities',
|
||||
get_context_instance(CONTEXT_MODULE, $mod->id));
|
||||
$modcontext = context_module::instance($mod->id);
|
||||
$canviewhidden = has_capability('moodle/course:viewhiddenactivities', $modcontext);
|
||||
$accessiblebutdim = false;
|
||||
if ($canviewhidden) {
|
||||
$accessiblebutdim = !$mod->visible;
|
||||
@@ -1733,9 +1732,10 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
}
|
||||
if ($completionicon) {
|
||||
$imgsrc = $OUTPUT->pix_url('i/completion-'.$completionicon);
|
||||
$imgalt = s(get_string('completion-alt-'.$completionicon, 'completion'));
|
||||
$formattedname = format_string($mod->name, true, array('context' => $modcontext));
|
||||
$imgalt = get_string('completion-alt-' . $completionicon, 'completion', $formattedname);
|
||||
if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
|
||||
$imgtitle = s(get_string('completion-title-'.$completionicon, 'completion'));
|
||||
$imgtitle = get_string('completion-title-' . $completionicon, 'completion', $formattedname);
|
||||
$newstate =
|
||||
$completiondata->completionstate==COMPLETION_COMPLETE
|
||||
? COMPLETION_INCOMPLETE
|
||||
@@ -1754,6 +1754,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
echo "
|
||||
<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='modulename' value='".s($mod->name)."' />
|
||||
<input type='hidden' name='sesskey' value='".sesskey()."' />
|
||||
<input type='hidden' name='completionstate' value='$newstate' />
|
||||
<input type='image' src='$imgsrc' alt='$imgalt' title='$imgtitle' />
|
||||
@@ -1776,7 +1777,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
// see the activity itself, or for staff)
|
||||
if (!$mod->uservisible) {
|
||||
echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
|
||||
} else if ($canviewhidden && !empty($CFG->enableavailability)) {
|
||||
} else if ($canviewhidden && !empty($CFG->enableavailability) && $mod->visible) {
|
||||
$ci = new condition_info($mod);
|
||||
$fullinfo = $ci->get_full_information();
|
||||
if($fullinfo) {
|
||||
@@ -2090,6 +2091,11 @@ function get_course_category_tree($id = 0, $depth = 0) {
|
||||
return array($categories, $categoryids);
|
||||
}
|
||||
|
||||
if (empty($categoryids)) {
|
||||
// No categories available (probably all hidden).
|
||||
return array();
|
||||
}
|
||||
|
||||
// The depth is 0 this function has just been called so we can finish it off
|
||||
|
||||
list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
@@ -2855,6 +2861,8 @@ function delete_course_module($id) {
|
||||
// very quick on an empty table)
|
||||
$DB->delete_records('course_modules_completion', array('coursemoduleid' => $cm->id));
|
||||
$DB->delete_records('course_modules_availability', array('coursemoduleid'=> $cm->id));
|
||||
$DB->delete_records('course_completion_criteria', array('moduleinstance' => $cm->id,
|
||||
'criteriatype' => COMPLETION_CRITERIA_TYPE_ACTIVITY));
|
||||
|
||||
delete_context(CONTEXT_MODULE, $cm->id);
|
||||
return $DB->delete_records('course_modules', array('id'=>$cm->id));
|
||||
|
||||
+11
-8
@@ -78,7 +78,7 @@ $PAGE->navbar->add($userinfo);
|
||||
$PAGE->set_title("$course->shortname: $strrecentactivity");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo", 3);
|
||||
echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo", 2);
|
||||
|
||||
$mform->display();
|
||||
|
||||
@@ -221,7 +221,9 @@ if (!empty($activities)) {
|
||||
echo $OUTPUT->spacer(array('height'=>30, 'br'=>true)); // should be done with CSS instead
|
||||
}
|
||||
echo $OUTPUT->box_start();
|
||||
echo "<h2>$activity->name</h2>";
|
||||
if (!empty($activity->name)) {
|
||||
echo html_writer::tag('h2', $activity->name);
|
||||
}
|
||||
$inbox = true;
|
||||
|
||||
} else if ($activity->type == 'activity') {
|
||||
@@ -230,16 +232,17 @@ if (!empty($activities)) {
|
||||
$cm = $modinfo->cms[$activity->cmid];
|
||||
|
||||
if ($cm->visible) {
|
||||
$linkformat = '';
|
||||
$class = '';
|
||||
} else {
|
||||
$linkformat = 'class="dimmed"';
|
||||
$class = 'dimmed';
|
||||
}
|
||||
$name = format_string($cm->name);
|
||||
$modfullname = $modnames[$cm->modname];
|
||||
|
||||
$image = "<img src=\"" . $OUTPUT->pix_url('icon', $cm->modname) . "\" class=\"icon\" alt=\"$modfullname\" />";
|
||||
echo "<h4>$image $modfullname".
|
||||
" <a href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id\" $linkformat>$name</a></h4>";
|
||||
$image = $OUTPUT->pix_icon('icon', $modfullname, $cm->modname, array('class' => 'icon smallicon'));
|
||||
$link = html_writer::link(new moodle_url("/mod/$cm->modname/view.php",
|
||||
array("id" => $cm->id)), $name, array('class' => $class));
|
||||
echo html_writer::tag('h3', "$image $modfullname $link");
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -269,7 +272,7 @@ if (!empty($activities)) {
|
||||
|
||||
} else {
|
||||
|
||||
echo '<h4><center>' . get_string('norecentactivity') . '</center></h2>';
|
||||
echo html_writer::tag('h3', get_string('norecentactivity'), array('class' => 'mdl-align'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
+79
-62
@@ -15,10 +15,19 @@
|
||||
$blocklist = optional_param('blocklist', 0, PARAM_INT);
|
||||
$modulelist= optional_param('modulelist', '', PARAM_PLUGIN);
|
||||
|
||||
$PAGE->set_url('/course/search.php', compact('search', 'page', 'perpage', 'blocklist', 'modulelist', 'edit'));
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$search = trim(strip_tags($search)); // trim & clean raw searched string
|
||||
// List of minimum capabilities which user need to have for editing/moving course
|
||||
$capabilities = array('moodle/course:create', 'moodle/category:manage');
|
||||
|
||||
// List of category id's in which current user has course:create and category:manage capability.
|
||||
$usercatlist = array();
|
||||
|
||||
// List of parent category id's
|
||||
$catparentlist = array();
|
||||
|
||||
//Populate usercatlist with list of category id's with required capabilities.
|
||||
make_categories_list($usercatlist, $catparentlist, $capabilities);
|
||||
|
||||
$search = trim(strip_tags($search)); // trim & clean raw searched string
|
||||
if ($search) {
|
||||
$searchterms = explode(" ", $search); // Search for words independently
|
||||
foreach ($searchterms as $key => $searchterm) {
|
||||
@@ -32,7 +41,7 @@
|
||||
$site = get_site();
|
||||
|
||||
$urlparams = array();
|
||||
foreach (array('search', 'page', 'blocklist', 'modulelist') as $param) {
|
||||
foreach (array('search', 'page', 'blocklist', 'modulelist', 'edit') as $param) {
|
||||
if (!empty($$param)) {
|
||||
$urlparams[$param] = $$param;
|
||||
}
|
||||
@@ -41,24 +50,30 @@
|
||||
$urlparams['perpage'] = $perpage;
|
||||
}
|
||||
$PAGE->set_url('/course/search.php', $urlparams);
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
|
||||
if (can_edit_in_category()) {
|
||||
//Editing is possible if user have system or category level create and manage capability
|
||||
if (can_edit_in_category() || !empty($usercatlist)) {
|
||||
if ($edit !== -1) {
|
||||
$USER->editing = $edit;
|
||||
}
|
||||
$adminediting = $PAGE->user_is_editing();
|
||||
|
||||
// Set perpage if user can edit in category
|
||||
if ($perpage != 99999) {
|
||||
$perpage = 30;
|
||||
}
|
||||
} else {
|
||||
$adminediting = false;
|
||||
}
|
||||
|
||||
/// Editing functions
|
||||
if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/course:visibility', context_system::instance())) {
|
||||
/// Hide or show a course
|
||||
if ($hide or $show and confirm_sesskey()) {
|
||||
if ($hide) {
|
||||
@@ -74,11 +89,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
$capabilities = array('moodle/course:create', 'moodle/category:manage');
|
||||
if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM)) && ($perpage != 99999)) {
|
||||
$perpage = 30;
|
||||
}
|
||||
|
||||
$displaylist = array();
|
||||
$parentlist = array();
|
||||
make_categories_list($displaylist, $parentlist);
|
||||
@@ -94,7 +104,7 @@
|
||||
$strfrontpage = get_string('frontpage', 'admin');
|
||||
$strnovalidcourses = get_string('novalidcourses');
|
||||
|
||||
if (empty($search) and empty($blocklist) and empty($modulelist)) {
|
||||
if (empty($search) and empty($blocklist) and empty($modulelist) and empty($moveto) and ($edit != -1)) {
|
||||
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
|
||||
$PAGE->navbar->add($strsearch);
|
||||
$PAGE->set_title("$site->fullname : $strsearch");
|
||||
@@ -114,18 +124,28 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
||||
if (! $destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $data->moveto);
|
||||
if (!$destcategory = $DB->get_record("course_categories", array("id" => $moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $moveto);
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
//User should have manage and create capablity on destination category.
|
||||
require_capability('moodle/category:manage', context_coursecat::instance($moveto));
|
||||
require_capability('moodle/course:create', context_coursecat::instance($moveto));
|
||||
|
||||
foreach ( $data as $key => $value ) {
|
||||
if (preg_match('/^c\d+$/', $key)) {
|
||||
array_push($courses, substr($key, 1));
|
||||
$courseid = substr($key, 1);
|
||||
// user must have category:manage and course:create capability for the course to be moved.
|
||||
$coursecontext = context_course::instance($courseid);
|
||||
foreach ($capabilities as $capability) {
|
||||
require_capability($capability, $coursecontext);
|
||||
array_push($courses, $courseid);
|
||||
}
|
||||
}
|
||||
}
|
||||
move_courses($courses, $data->moveto);
|
||||
move_courses($courses, $moveto);
|
||||
}
|
||||
|
||||
// get list of courses containing blocks if required
|
||||
@@ -148,9 +168,7 @@
|
||||
foreach ($courses as $course) {
|
||||
$courses[$course->id] = $course;
|
||||
}
|
||||
}
|
||||
// get list of courses containing modules if required
|
||||
elseif (!empty($modulelist) and confirm_sesskey()) {
|
||||
} elseif (!empty($modulelist) and confirm_sesskey()) { // get list of courses containing modules
|
||||
$modulename = $modulelist;
|
||||
$sql = "SELECT DISTINCT c.id FROM {".$modulelist."} module, {course} c"
|
||||
." WHERE module.course=c.id";
|
||||
@@ -172,34 +190,26 @@
|
||||
else {
|
||||
$totalcount = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (!empty($searchterm)) { //Donot do search for empty search request.
|
||||
$courses = get_courses_search($searchterms, "fullname ASC",
|
||||
$page, $perpage, $totalcount);
|
||||
}
|
||||
|
||||
$searchform = print_course_search($search, true, "navbar");
|
||||
|
||||
if (!empty($courses) && has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$searchform = '';
|
||||
// not sure if this capability is the best here
|
||||
if (has_capability('moodle/category:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if ($PAGE->user_is_editing()) {
|
||||
$string = get_string("turneditingoff");
|
||||
$edit = "off";
|
||||
} else {
|
||||
$string = get_string("turneditingon");
|
||||
$edit = "on";
|
||||
}
|
||||
|
||||
$aurl = new moodle_url("$CFG->wwwroot/course/search.php", array(
|
||||
'edit' => $edit,
|
||||
'sesskey' => sesskey(),
|
||||
'search' => $search,
|
||||
'page' => $page,
|
||||
'perpage' => $perpage));
|
||||
$searchform = $OUTPUT->single_button($aurl, $string, 'get');
|
||||
$searchform = '';
|
||||
//Turn editing should be visible if user have system or category level capability
|
||||
if (!empty($courses) && (can_edit_in_category() || !empty($usercatlist))) {
|
||||
if ($PAGE->user_is_editing()) {
|
||||
$string = get_string("turneditingoff");
|
||||
$edit = "off";
|
||||
} else {
|
||||
$string = get_string("turneditingon");
|
||||
$edit = "on";
|
||||
}
|
||||
$params = array_merge($urlparams, array('sesskey' => sesskey(), 'edit' => $edit));
|
||||
$aurl = new moodle_url("$CFG->wwwroot/course/search.php", $params);
|
||||
$searchform = $OUTPUT->single_button($aurl, $string, 'get');
|
||||
} else {
|
||||
$searchform = print_course_search($search, true, "navbar");
|
||||
}
|
||||
|
||||
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
|
||||
@@ -228,25 +238,30 @@
|
||||
|
||||
print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink);
|
||||
|
||||
if (!$adminediting) {
|
||||
// Show list of courses
|
||||
if (!$adminediting) { //Not editing mode
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
$course->summary .= "<br /><p class=\"category\">";
|
||||
$course->summary .= "$strcategory: <a href=\"category.php?id=$course->category\">";
|
||||
$course->summary .= $displaylist[$course->category];
|
||||
$course->summary .= "</a></p>";
|
||||
// front page don't belong to any category and block can exist.
|
||||
if ($course->category > 0) {
|
||||
$course->summary .= "<br /><p class=\"category\">";
|
||||
$course->summary .= "$strcategory: <a href=\"category.php?id=$course->category\">";
|
||||
$course->summary .= $displaylist[$course->category];
|
||||
$course->summary .= "</a></p>";
|
||||
}
|
||||
print_course($course, $search);
|
||||
echo $OUTPUT->spacer(array('height'=>5, 'width'=>5, 'br'=>true)); // should be done with CSS instead
|
||||
}
|
||||
} else {
|
||||
/// Show editing UI.
|
||||
} else { //editing mode
|
||||
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
|
||||
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"page\" value=\"$page\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"perpage\" value=\"$perpage\" /></div>\n";
|
||||
if (!empty($modulelist) and confirm_sesskey()) {
|
||||
echo "<input type=\"hidden\" name=\"modulelist\" value=\"$modulelist\" /></div>\n";
|
||||
} else if (!empty($blocklist) and confirm_sesskey()) {
|
||||
echo "<input type=\"hidden\" name=\"blocklist\" value=\"$blocklist\" /></div>\n";
|
||||
}
|
||||
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"4\" class=\"generalbox boxaligncenter\">\n<tr>\n";
|
||||
echo "<th scope=\"col\">$strcourses</th>\n";
|
||||
echo "<th scope=\"col\">$strcategory</th>\n";
|
||||
@@ -255,7 +270,7 @@
|
||||
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
|
||||
|
||||
@@ -278,9 +293,8 @@
|
||||
echo "<td>".$displaylist[$course->category]."</td>\n";
|
||||
echo "<td>\n";
|
||||
|
||||
// this is ok since this will get inherited from course category context
|
||||
// if it is set
|
||||
if (has_capability('moodle/category:manage', $coursecontext)) {
|
||||
// If user has all required capabilities to move course then show selectable checkbox
|
||||
if (has_all_capabilities($capabilities, $coursecontext)) {
|
||||
echo "<input type=\"checkbox\" name=\"c$course->id\" />\n";
|
||||
} else {
|
||||
echo "<input type=\"checkbox\" name=\"c$course->id\" disabled=\"disabled\" />\n";
|
||||
@@ -320,13 +334,15 @@
|
||||
|
||||
// checks whether user can do site backup
|
||||
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
|
||||
echo "<a title=\"".get_string("backup")."\" href=\"../backup/backup.php?id=$course->id\">\n<img".
|
||||
$backupurl = new moodle_url('/backup/backup.php', array('id' => $course->id));
|
||||
echo "<a title=\"".get_string("backup")."\" href=\"".$backupurl."\">\n<img".
|
||||
" src=\"" . $OUTPUT->pix_url('t/backup') . "\" class=\"iconsmall\" alt=\"".get_string("backup")."\" /></a>\n ";
|
||||
}
|
||||
|
||||
// checks whether user can do restore
|
||||
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
|
||||
echo "<a title=\"".get_string("restore")."\" href=\"../files/index.php?id=$course->id&wdir=/backupdata\">\n<img".
|
||||
$restoreurl = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
|
||||
echo "<a title=\"".get_string("restore")."\" href=\"".$restoreurl."\">\n<img".
|
||||
" src=\"" . $OUTPUT->pix_url('t/restore') . "\" class=\"iconsmall\" alt=\"".get_string("restore")."\" /></a>\n ";
|
||||
}
|
||||
|
||||
@@ -336,7 +352,8 @@
|
||||
echo "<br />";
|
||||
echo "<input type=\"button\" onclick=\"checkall()\" value=\"$strselectall\" />\n";
|
||||
echo "<input type=\"button\" onclick=\"checknone()\" value=\"$strdeselectall\" />\n";
|
||||
echo html_writer::select($displaylist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
|
||||
//Select box should only show categories in which user has min capability to move course.
|
||||
echo html_writer::select($usercatlist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo "</td>\n</tr>\n";
|
||||
echo "</table>\n</form>";
|
||||
@@ -382,7 +399,7 @@
|
||||
$defaultperpage = 10;
|
||||
//If user has course:create or category:manage capability the show 30 records.
|
||||
$capabilities = array('moodle/course:create', 'moodle/category:manage');
|
||||
if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_any_capability($capabilities, context_system::instance())) {
|
||||
$defaultperpage = 30;
|
||||
}
|
||||
|
||||
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Defines message providers (types of message sent) for the PayPal enrolment plugin.
|
||||
*
|
||||
* @package enrol_authorize
|
||||
* @copyright 2012 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$messageproviders = array(
|
||||
'authorize_enrolment' => array(),
|
||||
);
|
||||
@@ -144,6 +144,7 @@ $string['invalidacctype'] = 'Invalid account type';
|
||||
$string['isbusinesschecking'] = 'Is business checking?';
|
||||
$string['logindesc'] = 'This option must be ON. <br /><br />Please ensure that you have turned <a href="{$a->url}">loginhttps ON</a> in Admin >> Variables >> Security.<br /><br />Turning this on will make Moodle use a secure https connection just for the login and payment pages.';
|
||||
$string['logininfo'] = 'When configuring your Authorize.Net account, the login name is required and you must enter <strong>either</strong> the transaction key <strong>or</strong> the password in the appropriate box. We recommend you enter the transaction key due to security precautions.';
|
||||
$string['messageprovider:authorize_enrolment'] = 'Authorize.Net enrolment messages';
|
||||
$string['methodcc'] = 'Credit card';
|
||||
$string['methodccdesc'] = 'Select credit card and accepted types below';
|
||||
$string['methodecheck'] = 'eCheck (ACH)';
|
||||
|
||||
@@ -233,7 +233,7 @@ function send_welcome_messages($orderdata) {
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$lastuserid";
|
||||
$a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$lastuserid";
|
||||
$emailmessage = get_string('welcometocoursesemail', 'enrol_authorize', $a);
|
||||
$subject = get_string("enrolmentnew", '', format_string($SITE->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))));
|
||||
$subject = get_string("enrolmentnew", 'enrol', format_string($SITE->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))));
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2011112902; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011112900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_authorize'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 180;
|
||||
|
||||
+15
-1
@@ -410,8 +410,9 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
$sql = $this->db_get_sql($table, array($coursefield=>$course->mapping), $sqlfields);
|
||||
if ($rs = $extdb->Execute($sql)) {
|
||||
if (!$rs->EOF) {
|
||||
$usersearch = array('deleted' => 0);
|
||||
if ($localuserfield === 'username') {
|
||||
$usersearch = array('mnethostid'=>$CFG->mnet_localhost_id, 'deleted' =>0);
|
||||
$usersearch['mnethostid'] = $CFG->mnet_localhost_id;
|
||||
}
|
||||
while ($fields = $rs->FetchRow()) {
|
||||
$fields = array_change_key_case($fields, CASE_LOWER);
|
||||
@@ -689,6 +690,19 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
$newcourse->idnumber = $fields->idnumber;
|
||||
$newcourse->category = $fields->category ? $fields->category : $defaultcategory;
|
||||
|
||||
// Detect duplicate data once again, above we can not find duplicates
|
||||
// in external data using DB collation rules...
|
||||
if ($DB->record_exists('course', array('shortname' => $newcourse->shortname))) {
|
||||
if ($verbose) {
|
||||
mtrace(" can not insert new course, duplicate shortname detected: ".$newcourse->shortname);
|
||||
}
|
||||
continue;
|
||||
} else if (!empty($newcourse->idnumber) and $DB->record_exists('course', array('idnumber' => $newcourse->idnumber))) {
|
||||
if ($verbose) {
|
||||
mtrace(" can not insert new course, duplicate idnumber detected: ".$newcourse->idnumber);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$c = create_course($newcourse);
|
||||
if ($verbose) {
|
||||
mtrace(" creating course: $c->id, $c->fullname, $c->shortname, $c->idnumber, $c->category");
|
||||
|
||||
@@ -143,7 +143,7 @@ class core_enrol_external extends external_api {
|
||||
* }
|
||||
* @return array An array of users
|
||||
*/
|
||||
public static function get_enrolled_users($courseid, $options) {
|
||||
public static function get_enrolled_users($courseid, $options = array()) {
|
||||
global $CFG, $USER, $DB;
|
||||
require_once($CFG->dirroot . "/user/lib.php");
|
||||
|
||||
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Defines message providers (types of message sent) for the PayPal enrolment plugin.
|
||||
*
|
||||
* @package enrol_flatfile
|
||||
* @copyright 2012 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$messageproviders = array(
|
||||
'flatfile_enrolment' => array(),
|
||||
);
|
||||
@@ -30,6 +30,7 @@ $string['location'] = 'File location';
|
||||
$string['mailadmin'] = 'Notify admin by email';
|
||||
$string['mailstudents'] = 'Notify students by email';
|
||||
$string['mailteachers'] = 'Notify teachers by email';
|
||||
$string['messageprovider:flatfile_enrolment'] = 'Flat file enrolment messages';
|
||||
$string['mapping'] = 'Flat file mapping';
|
||||
$string['pluginname'] = 'Flat file (CSV)';
|
||||
$string['pluginname_desc'] = 'This method will repeatedly check for and process a specially-formatted text file in the location that you specify.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2011112901; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011112900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_flatfile'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 60;
|
||||
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Defines message providers (types of message sent) for the PayPal enrolment plugin.
|
||||
*
|
||||
* @package enrol_imsenterprise
|
||||
* @copyright 2012 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$messageproviders = array(
|
||||
'imsenterprise_enrolment' => array(),
|
||||
);
|
||||
@@ -54,6 +54,7 @@ $string['location'] = 'File location';
|
||||
$string['logtolocation'] = 'Log file output location (blank for no logging)';
|
||||
$string['mailadmins'] = 'Notify admin by email';
|
||||
$string['mailusers'] = 'Notify users by email';
|
||||
$string['messageprovider:imsenterprise_enrolment'] = 'IMS Enterprise enrolment messages';
|
||||
$string['miscsettings'] = 'Miscellaneous';
|
||||
$string['processphoto'] = 'Add user photo data to profile';
|
||||
$string['processphotowarning'] = 'Warning: Image processing is likely to add a significant burden to the server. You are recommended not to activate this option if large numbers of students are expected to be processed.';
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2011112901; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011112900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_imsenterprise'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 60;
|
||||
|
||||
+41
-28
@@ -764,20 +764,14 @@ class course_enrolment_manager {
|
||||
$userroles = $this->get_other_users($sort, $direction, $page, $perpage);
|
||||
$roles = $this->get_all_roles();
|
||||
|
||||
$courseid = $this->get_course()->id;
|
||||
$context = $this->get_context();
|
||||
$now = time();
|
||||
$extrafields = get_extra_user_fields($context);
|
||||
|
||||
$users = array();
|
||||
foreach ($userroles as $userrole) {
|
||||
if (!array_key_exists($userrole->id, $users)) {
|
||||
$users[$userrole->id] = array(
|
||||
'userid' => $userrole->id,
|
||||
'courseid' => $courseid,
|
||||
'picture' => new user_picture($userrole),
|
||||
'firstname' => fullname($userrole, true),
|
||||
'email' => $userrole->email,
|
||||
'roles' => array()
|
||||
);
|
||||
$users[$userrole->id] = $this->prepare_user_for_display($userrole, $extrafields, $now);
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->role = $roles[$userrole->roleid]->localname;
|
||||
@@ -800,6 +794,7 @@ class course_enrolment_manager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$users[$userrole->id]['roles'] = array();
|
||||
$users[$userrole->id]['roles'][$userrole->roleid] = array(
|
||||
'text' => $roletext,
|
||||
'unchangeable' => !$changeable
|
||||
@@ -825,7 +820,6 @@ class course_enrolment_manager {
|
||||
$users = $this->get_users($sort, $direction, $page, $perpage);
|
||||
|
||||
$now = time();
|
||||
$strnever = get_string('never');
|
||||
$straddgroup = get_string('addgroup', 'group');
|
||||
$strunenrol = get_string('unenrol', 'enrol');
|
||||
$stredit = get_string('edit');
|
||||
@@ -833,7 +827,6 @@ class course_enrolment_manager {
|
||||
$allroles = $this->get_all_roles();
|
||||
$assignable = $this->get_assignable_roles();
|
||||
$allgroups = $this->get_all_groups();
|
||||
$courseid = $this->get_course()->id;
|
||||
$context = $this->get_context();
|
||||
$canmanagegroups = has_capability('moodle/course:managegroups', $context);
|
||||
|
||||
@@ -842,36 +835,23 @@ class course_enrolment_manager {
|
||||
|
||||
$userdetails = array();
|
||||
foreach ($users as $user) {
|
||||
$details = array(
|
||||
'userid' => $user->id,
|
||||
'courseid' => $courseid,
|
||||
'picture' => new user_picture($user),
|
||||
'firstname' => fullname($user, true),
|
||||
'lastseen' => $strnever,
|
||||
'roles' => array(),
|
||||
'groups' => array(),
|
||||
'enrolments' => array()
|
||||
);
|
||||
foreach ($extrafields as $field) {
|
||||
$details[$field] = $user->{$field};
|
||||
}
|
||||
|
||||
if ($user->lastaccess) {
|
||||
$details['lastseen'] = format_time($now - $user->lastaccess);
|
||||
}
|
||||
$details = $this->prepare_user_for_display($user, $extrafields, $now);
|
||||
|
||||
// Roles
|
||||
$details['roles'] = array();
|
||||
foreach ($this->get_user_roles($user->id) as $rid=>$rassignable) {
|
||||
$details['roles'][$rid] = array('text'=>$allroles[$rid]->localname, 'unchangeable'=>(!$rassignable || !isset($assignable[$rid])));
|
||||
}
|
||||
|
||||
// Users
|
||||
$usergroups = $this->get_user_groups($user->id);
|
||||
$details['groups'] = array();
|
||||
foreach($usergroups as $gid=>$unused) {
|
||||
$details['groups'][$gid] = $allgroups[$gid]->name;
|
||||
}
|
||||
|
||||
// Enrolments
|
||||
$details['enrolments'] = array();
|
||||
foreach ($this->get_user_enrolments($user->id) as $ue) {
|
||||
if ($ue->timestart and $ue->timeend) {
|
||||
$period = get_string('periodstartend', 'enrol', array('start'=>userdate($ue->timestart), 'end'=>userdate($ue->timeend)));
|
||||
@@ -898,6 +878,39 @@ class course_enrolment_manager {
|
||||
return $userdetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a user record for display
|
||||
*
|
||||
* This function is called by both {@link get_users_for_display} and {@link get_other_users_for_display} to correctly
|
||||
* prepare user fields for display
|
||||
*
|
||||
* Please note that this function does not check capability for moodle/coures:viewhiddenuserfields
|
||||
*
|
||||
* @param object $user The user record
|
||||
* @param array $extrafields The list of fields as returned from get_extra_user_fields used to determine which
|
||||
* additional fields may be displayed
|
||||
* @param int $now The time used for lastaccess calculation
|
||||
* @return array The fields to be displayed including userid, courseid, picture, firstname, lastseen and any
|
||||
* additional fields from $extrafields
|
||||
*/
|
||||
private function prepare_user_for_display($user, $extrafields, $now) {
|
||||
$details = array(
|
||||
'userid' => $user->id,
|
||||
'courseid' => $this->get_course()->id,
|
||||
'picture' => new user_picture($user),
|
||||
'firstname' => fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())),
|
||||
'lastseen' => get_string('never'),
|
||||
);
|
||||
foreach ($extrafields as $field) {
|
||||
$details[$field] = $user->{$field};
|
||||
}
|
||||
|
||||
if ($user->lastaccess) {
|
||||
$details['lastseen'] = format_time($now - $user->lastaccess);
|
||||
}
|
||||
return $details;
|
||||
}
|
||||
|
||||
public function get_manual_enrol_buttons() {
|
||||
$plugins = $this->get_enrolment_plugins();
|
||||
$buttons = array();
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2011112901; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011112900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_manual'; // Full name of the plugin (used for diagnostics)
|
||||
|
||||
+5
-1
@@ -379,7 +379,11 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
|
||||
params['role'] = this.get(UEP.BASE).one('.'+CSS.ENROLMENTOPTION+'.'+CSS.ROLE+' select').get('value');
|
||||
params['startdate'] = this.get(UEP.BASE).one('.'+CSS.ENROLMENTOPTION+'.'+CSS.STARTDATE+' select').get('value');
|
||||
params['duration'] = this.get(UEP.BASE).one('.'+CSS.ENROLMENTOPTION+'.'+CSS.DURATION+' select').get('value');
|
||||
params['recovergrades'] = this.get(UEP.BASE).one('#'+CSS.RECOVERGRADES).get('checked')?1:0;
|
||||
if (this.get(UEP.DISABLEGRADEHISTORY) != true) {
|
||||
params['recovergrades'] = this.get(UEP.BASE).one('#'+CSS.RECOVERGRADES).get('checked')?1:0;
|
||||
} else {
|
||||
params['recovergrades'] = 0;
|
||||
}
|
||||
|
||||
Y.io(M.cfg.wwwroot+this.get(UEP.AJAXURL), {
|
||||
method:'POST',
|
||||
|
||||
@@ -145,6 +145,8 @@ class enrol_mnet_mnetservice_enrol {
|
||||
// users {@link http://tracker.moodle.org/browse/MDL-21327}
|
||||
$user = mnet_strip_user((object)$userdata, mnet_fields_to_import($client));
|
||||
$user->mnethostid = $client->id;
|
||||
$user->auth = 'mnet';
|
||||
$user->confirmed = 1;
|
||||
try {
|
||||
$user->id = $DB->insert_record('user', $user);
|
||||
} catch (Exception $e) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user