Compare commits
1683 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 641d113c88 | |||
| 57565dc3b2 | |||
| 26b86f31e5 | |||
| acaeb5ec41 | |||
| b137e02973 | |||
| ac8f106b4d | |||
| e055b85a0f | |||
| 7d05f5813d | |||
| c970b50567 | |||
| 6d82a42353 | |||
| 2b25b67ea1 | |||
| d11786cee3 | |||
| 3bdcd4d8c3 | |||
| f829edb719 | |||
| 68d7e891b9 | |||
| 74329331aa | |||
| ebc09da8a6 | |||
| 1b6e378edb | |||
| c131b96000 | |||
| fdf6208546 | |||
| 5e488f8c22 | |||
| c8cc25caba | |||
| 077ebb2a0b | |||
| 4450d19ae1 | |||
| 21ae044620 | |||
| 3d7b805f4e | |||
| 590c774d37 | |||
| 980e85cd44 | |||
| aa725516d3 | |||
| c5a8065258 | |||
| be056e1b28 | |||
| 8fbff1d453 | |||
| 74d0a7f975 | |||
| a07d13dcbf | |||
| ce447198b8 | |||
| 03b06309e2 | |||
| f8555ac9aa | |||
| 6de5bbb8cd | |||
| c8619b28a3 | |||
| db711f5eca | |||
| 63d170647c | |||
| a74c511e7f | |||
| 0cbe51a856 | |||
| ae1c7f954a | |||
| 4f9f035ae3 | |||
| e8cf2ffd61 | |||
| 0683abccfc | |||
| b720d9dae8 | |||
| 6fa694bef0 | |||
| 6d647878a5 | |||
| fe0ce39b8f | |||
| 90148ed7e1 | |||
| a6cacdd266 | |||
| 71d985ab7d | |||
| 05564a4cc6 | |||
| a97c937033 | |||
| d102e6ad56 | |||
| 8b451d25f2 | |||
| 8787ffaa40 | |||
| 222a97ce76 | |||
| 837b937511 | |||
| 5a3280a18f | |||
| 87bbab5118 | |||
| 5eb8ad87fc | |||
| c3002d2c3f | |||
| 087353f909 | |||
| 1801b90535 | |||
| 88d184b656 | |||
| 10efd23b7c | |||
| d816a900cb | |||
| 9fe8d2e335 | |||
| de33cd0cab | |||
| b17dd2a3d6 | |||
| 329241335f | |||
| da04fb70fa | |||
| 9775bfcbe4 | |||
| 8c6fae4e9c | |||
| 1b33e410b5 | |||
| 37909713bb | |||
| c1f7e7e90e | |||
| 1bcbbe3582 | |||
| 7072009431 | |||
| 0288333c0b | |||
| 11f07048f4 | |||
| 774956a6ee | |||
| 85176022e8 | |||
| fa983cfcc0 | |||
| 00743c0929 | |||
| cd8a0226de | |||
| 3029395e9d | |||
| ffa868a9e1 | |||
| 8000eac408 | |||
| bf3b4f3e86 | |||
| b704717847 | |||
| 0299444710 | |||
| c8058231c1 | |||
| 53036a6886 | |||
| 0442789588 | |||
| a4f994f332 | |||
| 2e2c66d84a | |||
| 7f2e2bfda9 | |||
| 54dcd0146d | |||
| 08a1f3b9f9 | |||
| 202ec23a1f | |||
| 1c26b3143d | |||
| 6768729e08 | |||
| 700029fca5 | |||
| b82e600723 | |||
| f611c727f3 | |||
| 81626948c7 | |||
| 13fd4703f3 | |||
| 25d9974ac6 | |||
| 305f4f69eb | |||
| f13e5f7377 | |||
| 3271e83c6e | |||
| f5779bb101 | |||
| baf8ff9cbf | |||
| 37543ce51e | |||
| 8d3238d858 | |||
| 99775a9f22 | |||
| ba5b59c0af | |||
| bb4030ff27 | |||
| 0d41df6b5a | |||
| 0462786a78 | |||
| 042729af22 | |||
| d21f89cb06 | |||
| 5750d233f9 | |||
| e60058ff98 | |||
| 2076d34b8e | |||
| c504ba4332 | |||
| 57a59d6c5a | |||
| aaae3c8c82 | |||
| c2aad2188a | |||
| eb6b4c2368 | |||
| d6ff9edd4f | |||
| e95f0def95 | |||
| 6f094d4940 | |||
| cb775057fd | |||
| a8a6905039 | |||
| c5572a933a | |||
| 5efc1f9e64 | |||
| 73fd56663b | |||
| 7a429a160d | |||
| 3ecbf154db | |||
| b5cca5ae5a | |||
| b1e5899c25 | |||
| a53d48e0e3 | |||
| 76dacdb051 | |||
| 11bc4876ac | |||
| e95599a57b | |||
| 61ae0c28db | |||
| 2babce1763 | |||
| 022ee47735 | |||
| f143179a66 | |||
| ef43b1d4d6 | |||
| d87e16435e | |||
| 59f6980201 | |||
| a7b8587136 | |||
| b703ef4498 | |||
| 015b3974e7 | |||
| b9118a7481 | |||
| 1e251bd424 | |||
| 35bf4711bb | |||
| 7c12fc2734 | |||
| ffced67c67 | |||
| 1e351f0976 | |||
| 7d0fcb5c86 | |||
| a8b35f9ccd | |||
| 81f43bc6d4 | |||
| 6c057c77dc | |||
| 1e46fb428f | |||
| f046b9a4c5 | |||
| 4ab09853f4 | |||
| 4fa9393def | |||
| 2803c8683b | |||
| 90d8c85ec3 | |||
| 9da6f4d968 | |||
| 2a1855887d | |||
| 3090719d7d | |||
| 66aa172cbb | |||
| d62793fdee | |||
| 28e392a8b6 | |||
| 7b87d98d6e | |||
| 3a37a5e934 | |||
| 6979cf56e2 | |||
| 89f0061e23 | |||
| 3ec69c2ece | |||
| 45fc6559b4 | |||
| 1c38b99cad | |||
| f0aef7abfe | |||
| a07249826a | |||
| 6d4bc5bd34 | |||
| 857617e9db | |||
| cc41793c50 | |||
| c01040214a | |||
| e8d0133ed5 | |||
| 36b88f19ae | |||
| 2d84d30d17 | |||
| 7509d232bc | |||
| 8a43e40247 | |||
| b71ce36030 | |||
| 659bdbd22a | |||
| ceb2167df1 | |||
| 857e34877f | |||
| d5cfbc918f | |||
| 432a90f1ed | |||
| c3fd1e97ba | |||
| 5cddf50e69 | |||
| ae9167bb3b | |||
| 0f198a4f8e | |||
| 29b44cedfc | |||
| 18e58659bb | |||
| cabbda70b1 | |||
| 9dabc4b966 | |||
| f9f74f7a11 | |||
| 8faeb25214 | |||
| 435e4e2a30 | |||
| cbee83840f | |||
| e196d31789 | |||
| 05c15ed931 | |||
| ec2ccabf56 | |||
| 63cc353a06 | |||
| 013149f1a2 | |||
| 204baa0ef6 | |||
| 9dbd8702c6 | |||
| d712722bd5 | |||
| e9ff078d75 | |||
| f8ad868fad | |||
| 885378ca4e | |||
| d282ecf683 | |||
| 40d90f438a | |||
| ef844148a9 | |||
| d51c946700 | |||
| 06dbe955d0 | |||
| 77d9eca5f2 | |||
| 5377f8a263 | |||
| 0d619f41c2 | |||
| 8c815348eb | |||
| 99719b6e89 | |||
| 9f6296e5de | |||
| 82f0ddc7c7 | |||
| 9dbb24fa7a | |||
| d2c80085fd | |||
| 2ffb0309dd | |||
| 1e09c9ac8f | |||
| e6df7dfedd | |||
| cfca487f1f | |||
| cdd11481b4 | |||
| 24966a26c7 | |||
| 4e9e2b0a0a | |||
| 3f9b276b97 | |||
| cc3790d0ea | |||
| 673b598109 | |||
| 92a03f69d2 | |||
| 6109f2348b | |||
| cf398020d5 | |||
| 3d9571d5f0 | |||
| c91da28071 | |||
| ae6072b892 | |||
| 3224e06de4 | |||
| 77fc10710f | |||
| 34e98391e6 | |||
| c8cc46f851 | |||
| d00fbde6d9 | |||
| d4fa19a11e | |||
| 53ea0e2ccf | |||
| 25c8fd74ac | |||
| 65bcb7da0e | |||
| 1480277cfa | |||
| 23a52d1a40 | |||
| 22e94d69f7 | |||
| 644bffca5b | |||
| 3d4a56b4c3 | |||
| 961eb3d1aa | |||
| 90190a6b66 | |||
| 5cbb36cbd8 | |||
| dfb64c5d5b | |||
| e6f06ce994 | |||
| 2245197519 | |||
| 825c2fdf8c | |||
| 1c406559b8 | |||
| e41a56192a | |||
| ce1ec9b4d9 | |||
| 44946baf04 | |||
| 77e4535fd9 | |||
| c8520ca45f | |||
| b5a3388bb1 | |||
| 1ecf5c15ca | |||
| 6b21108b44 | |||
| dde2a79a70 | |||
| 2ce4291183 | |||
| 8be5742cb1 | |||
| 679eab046f | |||
| c3c8cc40be | |||
| 20bf0c45ff | |||
| 7cdeb8be2e | |||
| 6bef258db3 | |||
| 547357df4b | |||
| 45ae297f7a | |||
| 3d702cc227 | |||
| ce0eb44398 | |||
| aa784c4eb4 | |||
| 8517245516 | |||
| ed71c8b1df | |||
| d44efece94 | |||
| e1b9cb14e4 | |||
| 40633c6310 | |||
| 05dfaab2b4 | |||
| fd70f25519 | |||
| 934b1e9832 | |||
| 30e1797f29 | |||
| 694cb8eb21 | |||
| f6c5cfef77 | |||
| ddf14b32fe | |||
| bd74bda383 | |||
| 8504673116 | |||
| 3451a05292 | |||
| c9271388c9 | |||
| fc9f324fe2 | |||
| a845d7d387 | |||
| 3b8c9ab2b8 | |||
| 74e48d168f | |||
| 0f0d0004bd | |||
| d2706c5e58 | |||
| 2d42e6e12c | |||
| e171dc6dbe | |||
| a5db58f4f2 | |||
| 0ca25fe2a9 | |||
| 27fef51d48 | |||
| 728b851eb5 | |||
| 8c46d204a1 | |||
| 351cff7928 | |||
| 4b82c15cdb | |||
| 4af7042e6e | |||
| 2b118a941a | |||
| de81dc8763 | |||
| 8badf71325 | |||
| 6f77c09777 | |||
| da16e3e3dc | |||
| 46a13e37a8 | |||
| 2f9bd2bf90 | |||
| 4ea006e4da | |||
| 49e54ae981 | |||
| bbe8bb0d02 | |||
| a2ac42d40c | |||
| 815c44ce07 | |||
| 66434106ed | |||
| 1872cfcd2f | |||
| e37c1fe23d | |||
| 2f27dca60d | |||
| bd0391d284 | |||
| 64448e1ea9 | |||
| 5ba5a5e31d | |||
| 8373df9687 | |||
| fbfd69a865 | |||
| a706fd79a5 | |||
| 7aeb85770f | |||
| 23de6f3a2d | |||
| 78348dfc4e | |||
| 84f6a716b2 | |||
| 6f0731adc5 | |||
| e78523bff8 | |||
| 1f64f17429 | |||
| 7022b8d9e4 | |||
| 5cc6b3eeb5 | |||
| 41bc5aa587 | |||
| d25a8e3c69 | |||
| e7d10540d9 | |||
| fd91aab1e7 | |||
| fe5b5be1dd | |||
| 0d900be445 | |||
| 091a2630a7 | |||
| 9b8822d2a6 | |||
| f31450578a | |||
| b4deb66146 | |||
| 6e6ba82305 | |||
| 5749f8a4f7 | |||
| 6502ba9a26 | |||
| 1f4670653d | |||
| 805a3a4ed7 | |||
| 445f3e3f4f | |||
| bc346cc34d | |||
| 90ce448189 | |||
| e909bfc70f | |||
| 26c9798596 | |||
| cb03034466 | |||
| 60e9f9083e | |||
| ad7c719de4 | |||
| a539e5605c | |||
| f1dd1cb5e0 | |||
| 75653a3068 | |||
| abc07b53a7 | |||
| 417ef862e4 | |||
| 0174e72ba8 | |||
| adf4ae83fc | |||
| 43c5278ad3 | |||
| 3449816e7f | |||
| f5edb0c638 | |||
| 98645b5be4 | |||
| 5714c88b5f | |||
| ea33609e4b | |||
| 9e0501a611 | |||
| ede461a9a4 | |||
| 43a60f7fd8 | |||
| 2e352cd1fa | |||
| 7a08156eef | |||
| c02324d96a | |||
| 18e27e7bdb | |||
| b71f21bda9 | |||
| a9b3410632 | |||
| 10268ec52e | |||
| efefa2d905 | |||
| c36eea3d28 | |||
| 853508eed3 | |||
| 71098b9524 | |||
| b398f0702a | |||
| d8e07b9f75 | |||
| 2b0b91d7ee | |||
| 024d11a8ab | |||
| 70b123700a | |||
| c1a8f55b86 | |||
| c4c5061d1c | |||
| 219c136003 | |||
| 747ac8e9c4 | |||
| 7b78c329c5 | |||
| 16044f5140 | |||
| c68b4a9d04 | |||
| e9251c0fe5 | |||
| 554b8789d6 | |||
| d607cdd782 | |||
| 9ec2b3e639 | |||
| 970df71df3 | |||
| 2f5fa7109e | |||
| d67991f15a | |||
| 9c533e01dd | |||
| 2610190674 | |||
| 4c00922f2e | |||
| 811808b3d2 | |||
| 48c3e99599 | |||
| e484db7c94 | |||
| 240524049e | |||
| d043aa071b | |||
| 5b18ae4a8a | |||
| 6291e67b11 | |||
| 9376f7d68e | |||
| 3d7f501293 | |||
| 297509d70c | |||
| fdae6f77d6 | |||
| a8d022d814 | |||
| 492a795d67 | |||
| b4bbf31bf1 | |||
| 45ade52173 | |||
| 3650af761a | |||
| fa9243cd85 | |||
| 88cb8b781d | |||
| cba5d8f1de | |||
| ee0d7009e4 | |||
| 13840b978d | |||
| c2384dde13 | |||
| baab37149d | |||
| 2bd2660751 | |||
| 39071b0707 | |||
| 7d241879bf | |||
| 3c49b0e6b6 | |||
| 2e59aee791 | |||
| cf58a2d528 | |||
| ef184ad6e0 | |||
| e65560e3eb | |||
| 3c8de97d00 | |||
| 1c217fa9ee | |||
| 0edc94e316 | |||
| 90cdf50dd9 | |||
| 682282de55 | |||
| 8f205734fb | |||
| 2b9e3510f8 | |||
| f21b5591c6 | |||
| 9c93f67328 | |||
| 716e9deab7 | |||
| b07f2c4691 | |||
| 5687cd044d | |||
| b9e6db9ddc | |||
| f9d8a27f2c | |||
| 6ab10c3d77 | |||
| 0e25774762 | |||
| 6afa07edd1 | |||
| 19ca0aaa6b | |||
| b9201e1b2b | |||
| 0fe269291e | |||
| 711c4775c5 | |||
| 36052f7185 | |||
| 92221e9d44 | |||
| c8cbdfce24 | |||
| 1c2d8c7fb3 | |||
| cb92d20996 | |||
| 5deadc8229 | |||
| 3f278e7803 | |||
| f287b7efbb | |||
| f9ee170a9b | |||
| dfbcdb3ec2 | |||
| eed3d30194 | |||
| 5b123ab8d3 | |||
| 1619d36e99 | |||
| ebaf979c94 | |||
| e86cbd49bb | |||
| 73582bd26e | |||
| f16b871fe2 | |||
| 166a9cec54 | |||
| 73d85fee4f | |||
| 5a0dd0e50d | |||
| dcf4254179 | |||
| 5aeadf0b7b | |||
| e9b779f143 | |||
| 7820177f20 | |||
| c464c08a52 | |||
| a9710e9d94 | |||
| c835d2c8a8 | |||
| 94cb5a662a | |||
| 1399c7e350 | |||
| 0f6fb93653 | |||
| f6873c2e31 | |||
| 5db00dc3c9 | |||
| 0f25080367 | |||
| 8669d43a96 | |||
| 2c28cadac1 | |||
| 7d4c1953d9 | |||
| 64a14f15bc | |||
| 1d055d806b | |||
| 658f84ab0c | |||
| 37fdff573b | |||
| c9e3070465 | |||
| 6fb1fd3183 | |||
| 605528e979 | |||
| 1690a76e62 | |||
| 6fb64a4ec0 | |||
| c9fc116b1d | |||
| 9a53cdb0fc | |||
| 40aa5fe9ab | |||
| 214b9e89d6 | |||
| a2e7a47a6e | |||
| adb21080a3 | |||
| 8274c72ca1 | |||
| 3fb9ad0ea7 | |||
| 39fab18e27 | |||
| 358ac4d476 | |||
| 9cd8f95a74 | |||
| bc178fa038 | |||
| c8d5e54cd1 | |||
| c6956595f7 | |||
| 3a93df8b9a | |||
| 83c64f78c0 | |||
| 7489e4d5b9 | |||
| 78c03392d4 | |||
| e8b3c3e178 | |||
| bddf012b7c | |||
| 5a8d683fb2 | |||
| 54b5941501 | |||
| 55bfb8ab5f | |||
| c7189fb2bb | |||
| 6aaf27af91 | |||
| 67eb557286 | |||
| 4b96d7ce05 | |||
| 51c6cfb69a | |||
| 99feb82ab5 | |||
| 4683e5ff11 | |||
| d6ccd91832 | |||
| bdb22af959 | |||
| c3f771aeba | |||
| a8336b03a0 | |||
| 0b9162bd05 | |||
| 306a0bafed | |||
| 56f5e21f6e | |||
| 0b4e4ca48f | |||
| 215cd2d854 | |||
| 348db7048e | |||
| 02b1868c32 | |||
| 15cd009097 | |||
| ca18d567d7 | |||
| 13e2b19838 | |||
| 0ef25faa73 | |||
| 2cf7bde8e9 | |||
| e7329cd026 | |||
| 7ccb6bb3cc | |||
| f4695ec722 | |||
| add8d846d9 | |||
| ea91e4f97d | |||
| e315e84cf2 | |||
| e91bc73f87 | |||
| 7d4f34cb0d | |||
| c53beb73e5 | |||
| e6890b1164 | |||
| d609207c3e | |||
| 1f0157e137 | |||
| 7c33ba471f | |||
| ff70e84941 | |||
| 9ef1dce6b9 | |||
| 47ea60fd3e | |||
| a38da470af | |||
| a15e507366 | |||
| fa979cd4e1 | |||
| db3da830c1 | |||
| d5458014b3 | |||
| ba926805e2 | |||
| 5aac33c785 | |||
| 99248f6177 | |||
| e159b53b5b | |||
| d0d1e97ab6 | |||
| 2ccbb8ed62 | |||
| 74ad60bfbe | |||
| 0d657cc9b7 | |||
| 123631ad47 | |||
| b2cd17e6a9 | |||
| 0d51ae7ef3 | |||
| 3f3e453632 | |||
| 2b595d96f4 | |||
| 376a79c242 | |||
| 548936a6c9 | |||
| 883ce42127 | |||
| 70ec79f1ba | |||
| 06d7352a0a | |||
| 6bbb7ed570 | |||
| 4cd439887a | |||
| ee14412e21 | |||
| a63f98245c | |||
| efdf25636a | |||
| a15c745936 | |||
| eae3d88bc9 | |||
| adbf7c5a43 | |||
| 222595b1f0 | |||
| a20a2ac704 | |||
| fa54a1a7e2 | |||
| a44987a081 | |||
| 195480e9d7 | |||
| 532ecef010 | |||
| e44e67d725 | |||
| a9d98d5029 | |||
| 9ce10f2f2f | |||
| edf88a3bb3 | |||
| 3b5ae9777d | |||
| 820a91def3 | |||
| 0c98acefc1 | |||
| 60e213470d | |||
| bb14a48851 | |||
| e236259d97 | |||
| f6bafa922c | |||
| 9a2bf09d19 | |||
| 618b223302 | |||
| b30b66c57e | |||
| c06c1a4428 | |||
| fd6078b7eb | |||
| bb0ca2c4a3 | |||
| 4dca6ab54d | |||
| 9a79102a4c | |||
| c2e970779d | |||
| b602463f07 | |||
| 2ee2f53021 | |||
| ef780a0051 | |||
| fc440796e9 | |||
| bc694b4761 | |||
| e503ec17c0 | |||
| f61c5f8a95 | |||
| ae9f5a04b1 | |||
| 2624bb10e2 | |||
| 3f6ede91aa | |||
| f78a8a52a5 | |||
| b7614ab114 | |||
| 33dca94573 | |||
| 4f7bacba82 | |||
| bef37b42dc | |||
| b2d941c16f | |||
| d6076942e3 | |||
| 0fe1ed29d9 | |||
| bbd655b4a8 | |||
| 1796eb181b | |||
| 13596866e7 | |||
| 2ee6e02e21 | |||
| 3bf5fcf277 | |||
| 6307622b28 | |||
| 3a7005c964 | |||
| 24f5828309 | |||
| 89b8efb09b | |||
| db98868d22 | |||
| d7a6e531ee | |||
| 20f808165b | |||
| d9b80a5e69 | |||
| c4172077df | |||
| 2ffd2afdba | |||
| 00a7511580 | |||
| 9390fc5829 | |||
| c8842113a7 | |||
| 63f2c0c664 | |||
| ef2b45a977 | |||
| b63a3b04b1 | |||
| ed0b6f0da4 | |||
| a717d5dc33 | |||
| 2b28ed2371 | |||
| 7394da46e2 | |||
| e1a527c0d4 | |||
| c3b548479b | |||
| c185e4fe21 | |||
| 17b284b937 | |||
| acb3b78804 | |||
| 1727c939ba | |||
| 0bdc578567 | |||
| 37ddc231f8 | |||
| a2fc9a4772 | |||
| 30d1b7d1a7 | |||
| 6dca3ddc71 | |||
| 37c9154c25 | |||
| 4b183d2258 | |||
| f72ca3ce29 | |||
| b244de5612 | |||
| aeb144359d | |||
| 04d6ba8638 | |||
| d7ff2fc28b | |||
| 4ba1a7a1e6 | |||
| a57960ee11 | |||
| f1c1db434a | |||
| 138816b1b1 | |||
| 5731a92aa7 | |||
| 90cac7c049 | |||
| d12cdcbd7d | |||
| 39a5fbeb01 | |||
| dd9f60ee49 | |||
| 0f5e1baf4c | |||
| 6cc9dce202 | |||
| dfeeed062a | |||
| bd94e16e95 | |||
| 15f80bf579 | |||
| 3452ea4265 | |||
| ad54e6353a | |||
| fe294b00ac | |||
| 0d944ce5b0 | |||
| 1290576dab | |||
| e3644cd5c6 | |||
| f318b80a0f | |||
| 121638b23f | |||
| 9da92dc1a9 | |||
| c383366601 | |||
| e43977e2d9 | |||
| 38a0477575 | |||
| 801116a502 | |||
| c3cb1ea063 | |||
| e98f0cf7ff | |||
| 70f0923499 | |||
| 48a0419a72 | |||
| 6b7d74040a | |||
| dd32aa7876 | |||
| 8b4bbe4b49 | |||
| bad062a992 | |||
| 417ec51bb6 | |||
| d300abab0e | |||
| 0984abda60 | |||
| 11838c6562 | |||
| aab270d579 | |||
| b4c23fcb17 | |||
| 20e6024581 | |||
| ae88770b33 | |||
| 786f1270a5 | |||
| 0c23f4e6b6 | |||
| 33b7941d94 | |||
| 9859359fbc | |||
| c907987844 | |||
| fb5343a00c | |||
| bcc3f1e810 | |||
| bccbd3b4eb | |||
| f5bc604de0 | |||
| 76d1f12d15 | |||
| 2481a022d0 | |||
| 8d9dc60b43 | |||
| 1f7565c121 | |||
| 9d492637ec | |||
| bb4a79234b | |||
| 703fca7540 | |||
| 48c091e510 | |||
| 0d7ab3f692 | |||
| d3c607178b | |||
| a235a6e02d | |||
| 5be028ab82 | |||
| cbc6325253 | |||
| e4f6c0c29a | |||
| bd9139463d | |||
| d49f9f280d | |||
| 65774d72b1 | |||
| 0f59848d29 | |||
| 51bc030d19 | |||
| 81f1e31a51 | |||
| 431a3bb674 | |||
| dcc16e155d | |||
| 346657acef | |||
| f567f34b92 | |||
| 83fa59a38c | |||
| be41e4e518 | |||
| caae082025 | |||
| 85ef1adbd0 | |||
| c936af395e | |||
| 457b3ed139 | |||
| 1287039e62 | |||
| 03141d1ae2 | |||
| 053186ba0e | |||
| 08f5fc107a | |||
| 1e9016d8d8 | |||
| 25dbbdf90b | |||
| 438a62f28b | |||
| 8525d8466a | |||
| f9628f871a | |||
| 3e5d0447fd | |||
| abe7ceabfa | |||
| 451df14218 | |||
| c91a59ac42 | |||
| e6b354d99b | |||
| b8979ffe69 | |||
| 2215d5744a | |||
| 79c9ad6277 | |||
| dd69ecb630 | |||
| 68beb75851 | |||
| 081eb156c5 | |||
| 49374833fc | |||
| f7c1c97cac | |||
| 4823de0269 | |||
| 4c3f4d2c2a | |||
| 5436b0ed02 | |||
| 988fb76589 | |||
| 8376557c4c | |||
| 694710d0f2 | |||
| 064f6b5a81 | |||
| 976ba87888 | |||
| 79e4395888 | |||
| 98aaa343f1 | |||
| 475d4345f9 | |||
| 7e9468ed20 | |||
| 647db53d14 | |||
| e975671ca3 | |||
| e28b586b9c | |||
| e35205bfec | |||
| 81053f8cbe | |||
| 1b63ff10f9 | |||
| f3f21c995c | |||
| 2a1c9daccd | |||
| 2adefc21ac | |||
| 82c67ac7f0 | |||
| 6650c66b59 | |||
| 4f964a1ca0 | |||
| 533a7edeae | |||
| 7825ffb1d5 | |||
| e4d61d8321 | |||
| 6a5d9ce4b9 | |||
| 345a010ea4 | |||
| 9655ef534d | |||
| 6d3f2f9036 | |||
| 56a7177741 | |||
| c1d31e42ba | |||
| e9897ee6ef | |||
| 0f80f793df | |||
| 8ece85602a | |||
| c618e93e66 | |||
| 18d6ff7880 | |||
| 536d4d5729 | |||
| 9651175f70 | |||
| ee1052bd18 | |||
| 03d174d733 | |||
| 65992c2d25 | |||
| 2d7b0534d3 | |||
| 8b4510c4cc | |||
| 3406bdd6fa | |||
| 8a844437bf | |||
| e78849e837 | |||
| 20089fb594 | |||
| ad5b7d26e7 | |||
| 235b6e4f06 | |||
| 9d10d64e14 | |||
| 49ccb165cc | |||
| 0e9cda01f1 | |||
| 0e613a1f5b | |||
| 4fa49cc647 | |||
| 9f4e81a81b | |||
| 78b3870c50 | |||
| 6fc5a830d4 | |||
| b6c38f71e2 | |||
| 1a11bf375c | |||
| 856e07e4e7 | |||
| 4881c193b7 | |||
| aa949cb2f9 | |||
| 54a86d8f15 | |||
| c99a5e18eb | |||
| e7d8d22dca | |||
| b62139ab27 | |||
| 757a889b24 | |||
| 26d26413a0 | |||
| de18c36f9f | |||
| 8fe48ac366 | |||
| e2cd8d3c6d | |||
| 296a3aa707 | |||
| fbf290d3b2 | |||
| ca6f717578 | |||
| 563ac282fc | |||
| 1657d0b6a9 | |||
| 1421bf5492 | |||
| e5818c7d09 | |||
| d40b84e253 | |||
| 4509be2296 | |||
| 0f8c06e0f5 | |||
| 59462743e6 | |||
| f52c05d66d | |||
| e63da7ba58 | |||
| 54fd1bb3fa | |||
| 40e53599b3 | |||
| 3a7ae79555 | |||
| 2b32b1fea8 | |||
| fcafde7e48 | |||
| fb9d5e7a17 | |||
| 91e2e5e7a2 | |||
| 85973908a5 | |||
| c482497d52 | |||
| 6478b4e463 | |||
| b999cee9a5 | |||
| efa66e0597 | |||
| 728e195c5e | |||
| 4961e964d2 | |||
| eadebb2445 | |||
| 8a5613f643 | |||
| 4658220b2d | |||
| e2795e8632 | |||
| 1451c07e05 | |||
| 34cd75240e | |||
| 25e0557484 | |||
| 98ee3df14e | |||
| 0e8d6595f4 | |||
| 8a81290525 | |||
| 7ed98e4912 | |||
| 163d280053 | |||
| 3261e9237d | |||
| 4359ef18bb | |||
| 7ce538be0f | |||
| a58fd9710d | |||
| 3a9f0ad138 | |||
| 6a51b279ec | |||
| 6bc6757084 | |||
| d1b4ca921e | |||
| d406ddca03 | |||
| 26c1c01629 | |||
| b4993d29f7 | |||
| e4607502bf | |||
| 4b140685ad | |||
| 5ac4e277fa | |||
| cf81447c74 | |||
| fc23bc85cf | |||
| b57cd16dcf | |||
| 486f7c9555 | |||
| adc3c068bb | |||
| 132106bfef | |||
| 0abe3fe373 | |||
| 755310cbeb | |||
| 8037f32b8a | |||
| f40d707dbf | |||
| 1f07048f02 | |||
| bfea8655f7 | |||
| b6c2829745 | |||
| a0b2b76613 | |||
| 48cf9018fa | |||
| 4e0ac12efa | |||
| b383cec36c | |||
| 28852998f6 | |||
| 1e41e6ddd9 | |||
| f675a8e23a | |||
| f0fca20bdf | |||
| ada9d0fb69 | |||
| a6529e04e6 | |||
| af5f446fa8 | |||
| d461d093bd | |||
| 54a099e989 | |||
| 015e612a5f | |||
| dd9368b43d | |||
| 4fd0bdb2b7 | |||
| 7fcc62c633 | |||
| cb21b5b7fb | |||
| fb77b89fd8 | |||
| e960152141 | |||
| b302d434ae | |||
| 31647f0cc9 | |||
| 2f3b709859 | |||
| 08ec1b4e47 | |||
| 315a0a3aaf | |||
| 49b12fdbd1 | |||
| d04f42254b | |||
| d7abdb64ee | |||
| e6743b4b80 | |||
| fff033322a | |||
| 171d7919b3 | |||
| f33dc783f1 | |||
| 031a275288 | |||
| 73d16fc61d | |||
| e842596d1d | |||
| 58af736dec | |||
| 42afb6c2ac | |||
| a87c7c03ad | |||
| 38b1d6cdd9 | |||
| fd26d7318e | |||
| 496e80e1f5 | |||
| 168635fb6f | |||
| 7416d00ad2 | |||
| 24d8485ea6 | |||
| 8c52eb2a15 | |||
| d3e54578ea | |||
| e742f93303 | |||
| 5d7d0457d2 | |||
| d1db765a64 | |||
| fd5e2ead95 | |||
| 5bdda5e535 | |||
| b04811687c | |||
| 4ee8ec310a | |||
| 02e6350222 | |||
| 69b4a73de8 | |||
| 1cc79637c7 | |||
| ad1ba7f02a | |||
| a88658fbf0 | |||
| 4c72d4bec1 | |||
| b0ae7d082a | |||
| 7f4b6dfe70 | |||
| 680d5c5be6 | |||
| d587dc6f6f | |||
| f31804c01c | |||
| 869320c7f4 | |||
| f86f8c85c1 | |||
| 8df402e401 | |||
| 3b8f3198de | |||
| 9275220de3 | |||
| bb06397130 | |||
| d2c4ff10bf | |||
| b26bc628cf | |||
| 8d7c385203 | |||
| 99df051805 | |||
| 2328bcccde | |||
| 139dfc8b8a | |||
| 2bc3246f93 | |||
| 5c7351a263 | |||
| 1477e62936 | |||
| bcf4a7f076 | |||
| 4a9624af21 | |||
| 1433a07881 | |||
| ecce451878 | |||
| a409707794 | |||
| e395d46b3b | |||
| 3e080111f9 | |||
| 91f841d00f | |||
| 826f61e500 | |||
| 258f54501b | |||
| 051857fcb9 | |||
| 632293b09a | |||
| 025ef39f14 | |||
| ec010c09b3 | |||
| 5eca8239f2 | |||
| 878f4b7ae0 | |||
| 3fd655242d | |||
| b183ace176 | |||
| 5cce9a8fff | |||
| 4cff1e5476 | |||
| cdef2e7d34 | |||
| e57392fabe | |||
| 74c0b5fe91 | |||
| aa78380630 | |||
| e9fd486eb6 | |||
| f372f96656 | |||
| 54c51cc810 | |||
| 237bc01fdf | |||
| 915140bced | |||
| 8be8fb9a2e | |||
| 377a1a4cbb | |||
| 375db4ebc5 | |||
| 5b60901de6 | |||
| cab91b357a | |||
| bf7a643f8a | |||
| 2971d8421c | |||
| 26b4e8580d | |||
| 9b82171b18 | |||
| e3c04bd98a | |||
| 0e8b3d929d | |||
| baa46ac0e2 | |||
| b02295039e | |||
| 916a72bb51 | |||
| 0c2ecefc45 | |||
| 029ec1edfe | |||
| 94eeb7cbdb | |||
| 9e82cab6b6 | |||
| b70c74548b | |||
| 93b2267239 | |||
| eeb8e895da | |||
| 558a6a79d6 | |||
| a4f914b54d | |||
| f486223806 | |||
| 141878736f | |||
| efd9343924 | |||
| dd4ac3d2ce | |||
| 35925a2c06 | |||
| ab9ee20ec7 | |||
| a52f3d9d0b | |||
| 4c3e2bdde7 | |||
| 3a732ec7bb | |||
| 358b10a337 | |||
| 0b048da8c0 | |||
| e63a39e013 | |||
| 6d326e1179 | |||
| 3894262a2f | |||
| 51d31432c8 | |||
| b878578d90 | |||
| dd2e263752 | |||
| caa9cb7124 | |||
| ce8c0126a9 | |||
| 4a87646654 | |||
| 447cf62409 | |||
| 3c2501ac77 | |||
| 863d7ca5aa | |||
| 425817793a | |||
| 11342dbcf8 | |||
| 6092574ddf | |||
| 1a9e8542c5 | |||
| 0cc0f72ceb | |||
| 60ce5848f6 | |||
| dba5826124 | |||
| a610100586 | |||
| df4e047944 | |||
| a9a67db2c9 | |||
| 66915b0ea1 | |||
| b0bb30e2e7 | |||
| d05c2ac7cc | |||
| 64c9b4046c | |||
| 6ba6f13b2c | |||
| 5405354d88 | |||
| 7583efe9f5 | |||
| a0b9bf4998 | |||
| 30146ed1ad | |||
| 4369677af2 | |||
| f68150ad05 | |||
| eb65276e5b | |||
| b678f3309d | |||
| 09896c35f2 | |||
| 2ab36722f2 | |||
| ddeabbc53a | |||
| 822fe4fc15 | |||
| 3152de6a8d | |||
| dd9c292700 | |||
| 87f6dfdedc | |||
| 76f8b36105 | |||
| 0e68db9e83 | |||
| 8bdee69d3e | |||
| 300ace312e | |||
| cfdd8d12dd | |||
| 3f5cae3679 | |||
| 641e7d41a6 | |||
| abf089f2a3 | |||
| 26872a8006 | |||
| e4d9eff640 | |||
| 68c2b72673 | |||
| 389aad6eef | |||
| e36a2f2aa7 | |||
| 174fbacc9b | |||
| 745783fa13 | |||
| bb8bb8e41c | |||
| 56c9d66652 | |||
| 943e290059 | |||
| 5705fd0907 | |||
| 0881745a9e | |||
| 5242a76a4b | |||
| 3e9282d486 | |||
| f79437ef3b | |||
| 4fa58ece62 | |||
| 2b2cad6f0a | |||
| d2d919e478 | |||
| d7ba45290b | |||
| 3becfcd226 | |||
| b3b79085e6 | |||
| bccad386b0 | |||
| 88d7a6a6b7 | |||
| f4a30c5fdf | |||
| d2bba97d77 | |||
| 565f3f25f0 | |||
| f3d9872aa3 | |||
| fd2ce923cf | |||
| 2692af9032 | |||
| c1dd6af98a | |||
| e3d292301e | |||
| 5d89d24bea | |||
| 110965aecd | |||
| a7db60dcf1 | |||
| e4d3ed18ff | |||
| 122c999536 | |||
| 224796f0fa | |||
| 470d59d31f | |||
| 6363c9ade2 | |||
| 19f0685069 | |||
| e6a87bd192 | |||
| dccd9540d0 | |||
| 4b55982446 | |||
| f5b956679e | |||
| ff626f7bb1 | |||
| 9b49ac26d5 | |||
| 197672e26c | |||
| cc3c33f8ba | |||
| 96eaee3daf | |||
| 9aa776a848 | |||
| 6d019541ad | |||
| 9f421a184a | |||
| 168fc2d9ec | |||
| 57e226b96f | |||
| 18e1450b4b | |||
| f1d1a60e0a | |||
| 4cca0082df | |||
| fbe7f1f8ba | |||
| cae2eb357d | |||
| 01a79b4e86 | |||
| 51673a3469 | |||
| 1679485693 | |||
| a52fc1f7a8 | |||
| a2701db412 | |||
| 60908b2187 | |||
| 48a9fd89e0 | |||
| 61f56fd5f9 | |||
| a606f2e2c5 | |||
| f9b3597e21 | |||
| 4e6c9ead6d | |||
| 6b02488559 | |||
| bb4691ec7b | |||
| 08ac68de3e | |||
| b9e05ae65d | |||
| abe4713565 | |||
| 8d9a55a05b | |||
| d8ef541bbc | |||
| 1b9fcbf7a7 | |||
| cba780d418 | |||
| 22a9fed6b2 | |||
| 2cf6b060cd | |||
| 7110a3eed6 | |||
| b3f7f6d096 | |||
| 84fe42d8b6 | |||
| 7d6d0788f2 | |||
| 0b4304b6e3 | |||
| 0552bc77ba | |||
| 098f4337d2 | |||
| 7b319d20a8 | |||
| 0c64c64b48 | |||
| d20ec3606b | |||
| 700522badd | |||
| 013f0b2266 | |||
| 443d34d115 | |||
| ec819f5141 | |||
| 099bca6de6 | |||
| 06634b7550 | |||
| 725fcf3178 | |||
| 0138cb7cf1 | |||
| b8787d5957 | |||
| d5cd1496ce | |||
| 385280469a | |||
| eadd195151 | |||
| 4e737cf37f | |||
| e8a1a5868a | |||
| 60236650d6 | |||
| 80d7aa1813 | |||
| 610ab37f55 | |||
| ff9a93a8b6 | |||
| e3cd0dfc2c | |||
| fa2a9cc933 | |||
| 1588837a9d | |||
| 6ffb51e74c | |||
| b5e7264543 | |||
| e5d9af8c56 | |||
| dc61d1bea0 | |||
| c0aca8f3c7 | |||
| 6976c8e1b5 | |||
| 3fa531ea2c | |||
| ce37a8cc7e | |||
| 50587d71a5 | |||
| a3ce9a453c | |||
| 1a43d6de99 | |||
| b81e81b162 | |||
| bb3e956ed9 | |||
| 72614d74d8 | |||
| f108433bcb | |||
| 8b36f14740 | |||
| ffd392a17b | |||
| 4292318562 | |||
| c1d685b500 | |||
| 1b374b4f2c | |||
| 6e02b56f2a | |||
| 7b546cdb83 | |||
| 3410ff644f | |||
| 41d14d5ca4 | |||
| 8cd0679099 | |||
| 974e820e53 | |||
| 1403c0d57a | |||
| 708be473d6 | |||
| d048e94dfe | |||
| d2e1aa76e1 | |||
| 65da6840f8 | |||
| 8736fbc190 | |||
| 25564a784b | |||
| e20b490da3 | |||
| 8284ffede3 | |||
| 4bfcdfed4e | |||
| 59d3deb9c0 | |||
| 11f2cec1ac | |||
| 1d8d3a0186 | |||
| 0377e78e36 | |||
| 85ba9528c9 | |||
| 9993c1d02c | |||
| 847f10653d | |||
| 3e38589f77 | |||
| 7cdb4266e0 | |||
| 521252d642 | |||
| 457eaef9ec | |||
| b857590479 | |||
| f44f9db418 | |||
| ba211d5678 | |||
| 3cdb015828 | |||
| 8403325c9e | |||
| 10c607a9bc | |||
| b65198b81b | |||
| ccb8edbff5 | |||
| a8dffa2d03 | |||
| eaf01ad4aa | |||
| c62f0a396b | |||
| a4e7e6f345 | |||
| baa8c89a56 | |||
| 39cda40590 | |||
| 600bd182fc | |||
| 6e1bfdda19 | |||
| ff4d8e802c | |||
| df060516ed | |||
| 55595bcfcb | |||
| 4afad1faeb | |||
| 4e133e775c | |||
| 220ca688c1 | |||
| 2c977ceb29 | |||
| d41203c55f | |||
| dcae64d3a3 | |||
| 7a1a9ec635 | |||
| 3d444c4e6d | |||
| b09b1a0a0b | |||
| 5fe6205813 | |||
| b260dec8b7 | |||
| 64cd459648 | |||
| a63cd3e2ca | |||
| 3e882c418b | |||
| e20a041100 | |||
| cb5fb8aea5 | |||
| dc3f4ac929 | |||
| 2b7fda50d9 | |||
| a1036e90f8 | |||
| b3a36eb80d | |||
| fc0c84c04b | |||
| 22c6affdef | |||
| c581517dd7 | |||
| 73aa231f83 | |||
| 4ea34b6d65 | |||
| 7bce505885 | |||
| 6663f615ed | |||
| 307dce6cf3 | |||
| f71a4993c7 | |||
| 10d22cceb5 | |||
| 3bcf2d2895 | |||
| f41e1773e9 | |||
| ee35376e28 | |||
| 010c17d346 | |||
| b91696eeac | |||
| 6cb535f081 | |||
| c86189ae02 | |||
| 48a9856da8 | |||
| dcb623be71 | |||
| 2d08e6565a | |||
| e95db3416c | |||
| 8c2a7f9c38 | |||
| 560ae357a0 | |||
| cf26b6f824 | |||
| a86b75608a | |||
| 71ef4532de | |||
| 06b4ab81a8 | |||
| 6c519fe4d7 | |||
| b6fdcd6071 | |||
| 409da21320 | |||
| 3c016111bd | |||
| d766bbc5b9 | |||
| 3af40cc62e | |||
| e0d0f411cf | |||
| 57422d7158 | |||
| 07a46481fe | |||
| af6c39045e | |||
| e8be9e7646 | |||
| e00e36fa4f | |||
| f987df174f | |||
| 95b7be7f05 | |||
| 10e52ed009 | |||
| 124f314d22 | |||
| ebb250fefb | |||
| 464ddd07d5 | |||
| 10c71d8a2f | |||
| ff3e43eeb0 | |||
| e236dc1446 | |||
| 85ce9b535b | |||
| 97627d2783 | |||
| 23611c3757 | |||
| 08a7915551 | |||
| 01957f1a69 | |||
| 7d4a3d1d07 | |||
| a2b66c7833 | |||
| 3bf572411a | |||
| 3cd76cbecc | |||
| 8fc3d41139 | |||
| cadeb8d21c | |||
| f808e0432a | |||
| 4ea790da9b | |||
| 29c4106e2f | |||
| 24131d08c0 | |||
| 6d326b17d8 | |||
| 2f920d9be8 | |||
| 8cdfa8692b | |||
| a34a305d53 | |||
| f8e2383bdd | |||
| a576da555e | |||
| e53a38c666 | |||
| 233c91e7d0 | |||
| 59be445c15 | |||
| 302104af4b | |||
| 80b6f3b059 | |||
| 9244faa3a4 | |||
| 6b58bb56cb | |||
| d55d207044 | |||
| f0d9af6036 | |||
| abb61e0b02 | |||
| 57fe6616a8 | |||
| 39377f8083 | |||
| 740a81eeb2 | |||
| 8cae085071 | |||
| aa6b85d2b7 | |||
| b68b5f55ca | |||
| b588373656 | |||
| 4786443998 | |||
| 6901981962 | |||
| 34adfcb4ee | |||
| 2034f57fe1 | |||
| 895e005989 | |||
| 97f4556a94 | |||
| 807ba44cc6 | |||
| 42cec80673 | |||
| 3acb294828 | |||
| 61fad215f1 | |||
| 83b9a7c88c | |||
| 10cc00b4af | |||
| 67c0e18ca2 | |||
| 5c1ea9aea5 | |||
| f077e0af7e | |||
| 8326cc5e3e | |||
| 5258525f0a | |||
| 61ac58a887 | |||
| 5e401a2a51 | |||
| 8d6b7f0c6c | |||
| fabe98ac92 | |||
| fe955c5645 | |||
| 9d27b68ce8 | |||
| c6a507e9e7 | |||
| b9819842d9 | |||
| 917923c860 | |||
| 5ec2ce20f5 | |||
| e82c025e60 | |||
| e7ec2f901b | |||
| 970dc511e2 | |||
| 41d335f31a | |||
| 7f8773ffb8 | |||
| aceb84ad76 | |||
| f9bb74c037 | |||
| f250cdbb34 | |||
| 473391b667 | |||
| d381732329 | |||
| 46878ed87f | |||
| f1ae118df3 | |||
| 1c06098b6b | |||
| 109aa07648 | |||
| 91c8d8b130 | |||
| f017a30ff3 | |||
| 6f7daa5e48 | |||
| 4ffbf22046 | |||
| 9cefe2f2b2 | |||
| 04985346a2 | |||
| c260117d15 | |||
| 97812f14c1 | |||
| e3b699eab7 | |||
| b908c1add2 | |||
| 1396cb6346 | |||
| bfb5d3ba26 | |||
| d52e5dd32d | |||
| f013112752 | |||
| adbe17ec68 | |||
| 9501b1eb76 | |||
| 0ea7278f64 | |||
| a569a33097 | |||
| 1b98e553a7 | |||
| 9e51dc406f | |||
| 387f7aae0d | |||
| ebe2fafa8b | |||
| 0ef41ee07d | |||
| 7884ecf24f | |||
| dbe18cd356 | |||
| 3715c59ef9 | |||
| a3d003603a | |||
| ee2187273f | |||
| 7f9fb2c846 | |||
| cfa00fc565 | |||
| 9aeb909d2f | |||
| fc07f6adbc | |||
| a7d75ba5c8 | |||
| 3112c22004 | |||
| 713a2cbb25 | |||
| b0c4f9c21c | |||
| 05cd2ff627 | |||
| 6489a3d455 | |||
| edbcee25c1 | |||
| 387a3a208a | |||
| d8c1a57b99 | |||
| bea5a16203 | |||
| 65a77c7381 | |||
| 7ec475e2d7 | |||
| e4eba4c346 | |||
| c1cd2924ec | |||
| 4111611710 | |||
| f0781f34c9 | |||
| 8c42eef35c | |||
| 4b4280f3e8 | |||
| 1b8cf12a59 | |||
| 748545858c | |||
| 5976a78a95 | |||
| 5f54a8760f | |||
| 0c6554e03c | |||
| efe4210395 | |||
| b3480499c6 | |||
| ee73ec3d3c | |||
| 81a989e6d8 | |||
| 1e1bc82294 | |||
| 1577c5ea20 | |||
| b955ad6a55 | |||
| a0de91e9a0 | |||
| e1eb4fb6d9 | |||
| 7445483873 | |||
| 25e9c56117 | |||
| 8000e6af01 | |||
| 8c9eecdea7 | |||
| 34aeacadcc | |||
| a7370e0dd0 | |||
| bf0a154217 | |||
| 012398a8c2 | |||
| 80364b7b1e | |||
| 02146e0b21 | |||
| e427ae67c2 | |||
| 8b0801c2b8 | |||
| 120a795b4e | |||
| 556cb98d16 | |||
| d87a31d878 | |||
| 777720c833 | |||
| 7315358ead | |||
| 081ac91526 | |||
| 2c3d8a06c8 | |||
| bdb157653b | |||
| 2a56a82c9b | |||
| 12a67a4266 | |||
| 49cbe666a4 | |||
| 8edbd642b4 | |||
| 9d51d8e81f | |||
| 2b6fa07627 | |||
| 28437460d2 | |||
| a938e4096c | |||
| ed00d67c99 | |||
| 9bd6807635 | |||
| d3fa95abf1 | |||
| 5211efb99b | |||
| 417d543aaa | |||
| 78a534dde0 | |||
| e95df45bba | |||
| ec43371a3f | |||
| 0897d6588e | |||
| d735cb5230 | |||
| d470de673c | |||
| 29abde4709 | |||
| feb23f1b96 | |||
| 84ae267c56 | |||
| 2fdd9eed54 | |||
| 1744570b2e | |||
| 38e7a9525f | |||
| 411b5f3a02 | |||
| 6820f36bda | |||
| d77a6026d2 | |||
| b4fcf278c2 | |||
| 409758c035 | |||
| 99618f89bf | |||
| 5bde2c2b62 | |||
| 07a91fd4cc | |||
| dc9353a07b | |||
| 9a73d11cfd | |||
| 1cce91b1bb | |||
| 7e6ef63e5f | |||
| ddb3857cdf | |||
| 9ff02b52b2 | |||
| fd64ae3140 | |||
| 992c5ccfbf | |||
| 63469571c8 | |||
| e968cf1def | |||
| eee87c8a24 | |||
| 4b560e4a8e | |||
| 6472ad5600 | |||
| ef4192b8e7 | |||
| 8317549dff | |||
| 5d96469c8c | |||
| 46ea440b87 | |||
| 9a7671da80 | |||
| 7b4e995015 | |||
| 05df02a0ec | |||
| 223419d92c | |||
| 077edd3038 | |||
| be2e38ed92 | |||
| 486ecb1b89 | |||
| effa7d2ba1 | |||
| ecdfab51a3 | |||
| b78d40e637 | |||
| d6170fe7f8 | |||
| 007dd71c17 | |||
| c39071d32a | |||
| 4a9268b6e7 | |||
| 087b3303a5 | |||
| d995cd47fb | |||
| 2dc93a3769 | |||
| 6db2423551 | |||
| 3e6dabadaa | |||
| 1d59696017 | |||
| f1c9b8de47 | |||
| e590227922 | |||
| 4d5a33e424 | |||
| 8ee2d9c3d4 | |||
| c6c480f786 | |||
| 18c02e9f28 | |||
| 5e8e87aaee | |||
| 268e772a8a | |||
| 4768fa336a | |||
| 1508fa23d2 | |||
| 7251472c83 | |||
| 667e6ebc20 | |||
| f32ee5c54e | |||
| b323508554 | |||
| e76e6bc8bd | |||
| 5f8407d5da | |||
| 78162bf5cf | |||
| 1a765e32b0 | |||
| 88f4b6c75d | |||
| 44ae08383b | |||
| 15ead7a176 | |||
| 19bf156be9 | |||
| 33e385a5fb | |||
| d3e980c4ea | |||
| 4275ea4a43 | |||
| e767ba20fc | |||
| 9304ba2212 | |||
| a571aa9b85 | |||
| fda2fa2680 | |||
| 2c97abeff2 | |||
| 231127ce6c | |||
| aece25138f | |||
| 3420d30762 | |||
| 3dbb8dc598 | |||
| 55b2742724 | |||
| 05ba0b9574 | |||
| 7e781cfc2b | |||
| 592c216520 | |||
| 294f1dbaa3 | |||
| fee3033bc7 | |||
| e105a752c0 | |||
| dbc56205b3 | |||
| dbf0819d92 | |||
| 3ac10fa82a | |||
| a33be61af8 | |||
| 6499085f36 | |||
| bd8a809598 | |||
| 9ae6cd775a | |||
| 0164f50e80 | |||
| 6821ca92ad | |||
| 373a35dd31 | |||
| 6bc8a2e11f | |||
| 1518ce952f | |||
| f09f01fcad | |||
| 6e4e60ef9f |
+3
-2
@@ -5,7 +5,6 @@ node_modules/
|
||||
vendor/
|
||||
admin/tool/policy/amd/src/jquery-eu-cookie-law-popup.js
|
||||
admin/tool/usertours/amd/src/tour.js
|
||||
admin/tool/usertours/amd/src/popper.js
|
||||
auth/cas/CAS/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
@@ -42,7 +41,6 @@ lib/html2text/
|
||||
lib/markdown/
|
||||
lib/recaptchalib.php
|
||||
lib/xhprof/
|
||||
lib/xmlize.php
|
||||
lib/horde/
|
||||
lib/requirejs/
|
||||
lib/amd/src/loglevel.js
|
||||
@@ -59,7 +57,10 @@ lib/maxmind/MaxMind/
|
||||
lib/ltiprovider/
|
||||
lib/amd/src/truncate.js
|
||||
lib/fonts/
|
||||
lib/amd/src/adapter.js
|
||||
lib/validateurlsyntax.php
|
||||
lib/amd/src/popper.js
|
||||
lib/geopattern-php/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
|
||||
+3
-2
@@ -6,7 +6,6 @@ node_modules/
|
||||
vendor/
|
||||
admin/tool/policy/amd/src/jquery-eu-cookie-law-popup.js
|
||||
admin/tool/usertours/amd/src/tour.js
|
||||
admin/tool/usertours/amd/src/popper.js
|
||||
auth/cas/CAS/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
@@ -43,7 +42,6 @@ lib/html2text/
|
||||
lib/markdown/
|
||||
lib/recaptchalib.php
|
||||
lib/xhprof/
|
||||
lib/xmlize.php
|
||||
lib/horde/
|
||||
lib/requirejs/
|
||||
lib/amd/src/loglevel.js
|
||||
@@ -60,7 +58,10 @@ lib/maxmind/MaxMind/
|
||||
lib/ltiprovider/
|
||||
lib/amd/src/truncate.js
|
||||
lib/fonts/
|
||||
lib/amd/src/adapter.js
|
||||
lib/validateurlsyntax.php
|
||||
lib/amd/src/popper.js
|
||||
lib/geopattern-php/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
|
||||
+2
-4
@@ -56,7 +56,7 @@ matrix:
|
||||
include:
|
||||
# Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
|
||||
- php: 7.2
|
||||
env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'
|
||||
env: DB=none TASK=GRUNT NVM_VERSION='8.9'
|
||||
|
||||
exclude:
|
||||
# MySQL - it's just too slow.
|
||||
@@ -207,7 +207,7 @@ before_script:
|
||||
# We need the official upstream for comparison
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
git fetch upstream MOODLE_34_STABLE;
|
||||
git fetch upstream master;
|
||||
export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
|
||||
export GIT_COMMIT="$TRAVIS_COMMIT";
|
||||
export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
|
||||
@@ -263,9 +263,7 @@ script:
|
||||
grunt ;
|
||||
# Add all files to the git index and then run diff --cached to see all changes.
|
||||
# This ensures that we get the status of all files, including new files.
|
||||
# We ignore npm-shrinkwrap.json to make the tasks immune to npm changes.
|
||||
git add . ;
|
||||
git reset -- npm-shrinkwrap.json ;
|
||||
git diff --cached --exit-code ;
|
||||
fi
|
||||
|
||||
|
||||
@@ -219,7 +219,6 @@ $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'n
|
||||
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
|
||||
'oci' => moodle_database::get_driver_instance('oci', 'native'),
|
||||
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
|
||||
'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
|
||||
);
|
||||
foreach ($databases as $type=>$database) {
|
||||
if ($database->driver_installed() !== true) {
|
||||
@@ -443,6 +442,7 @@ if ($interactive) {
|
||||
}
|
||||
}
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->backuptempdir = $CFG->tempdir.'/backup';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
$CFG->localcachedir = $CFG->dataroot.'/localcache';
|
||||
|
||||
|
||||
@@ -131,10 +131,11 @@ if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
$a = new stdClass();
|
||||
$a->oldversion = $oldversion;
|
||||
$a->newversion = $newversion;
|
||||
|
||||
if ($interactive) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = $oldversion;
|
||||
$a->newversion = $newversion;
|
||||
echo cli_heading(get_string('databasechecking', '', $a)) . PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -193,5 +194,5 @@ admin_apply_default_settings(NULL, false);
|
||||
// to immediately start browsing the site.
|
||||
upgrade_themes();
|
||||
|
||||
echo get_string('cliupgradefinished', 'admin')."\n";
|
||||
echo get_string('cliupgradefinished', 'admin', $a)."\n";
|
||||
exit(0); // 0 means success
|
||||
|
||||
@@ -2097,7 +2097,6 @@
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.0.0" level="required">
|
||||
<RESTRICT function="restrict_php_version_73" message="unsupportedphpversion73" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
@@ -2274,7 +2273,6 @@
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.0.0" level="required">
|
||||
<RESTRICT function="restrict_php_version_73" message="unsupportedphpversion73" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
@@ -2437,185 +2435,4 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.6" requires="3.1">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.6" />
|
||||
<VENDOR name="postgres" version="9.4" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.0.0" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+5
-5
@@ -14,16 +14,16 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* Privacy Subsystem implementation for core_admin.
|
||||
* Privacy Subsystem implementation for core_register.
|
||||
*
|
||||
* @package core_admin
|
||||
* @package core_register
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_admin\privacy;
|
||||
namespace core_register\privacy;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
/**
|
||||
* Privacy Subsystem for core_admin implementing null_provider.
|
||||
* Privacy Subsystem for core_register implementing null_provider.
|
||||
*
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -38,4 +38,4 @@ class provider implements \core_privacy\local\metadata\null_provider {
|
||||
public static function get_reason() : string {
|
||||
return 'privacy:metadata';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,8 @@ if ($unregistration && \core\hub\registration::is_registered()) {
|
||||
if ($siteunregistrationform->is_cancelled()) {
|
||||
redirect(new moodle_url('/admin/registration/index.php'));
|
||||
} else if ($data = $siteunregistrationform->get_data()) {
|
||||
\core\hub\registration::unregister($data->unpublishalladvertisedcourses,
|
||||
$data->unpublishalluploadedcourses);
|
||||
if (!\core\hub\registration::is_registered()) {
|
||||
if (\core\hub\registration::unregister($data->unpublishalladvertisedcourses,
|
||||
$data->unpublishalluploadedcourses)) {
|
||||
redirect(new moodle_url('/admin/registration/index.php'));
|
||||
}
|
||||
}
|
||||
@@ -111,7 +110,7 @@ if (\core\hub\registration::is_registered()) {
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('core', 'admin');
|
||||
$renderer = $PAGE->get_renderer('core', 'register');
|
||||
echo $renderer->moodleorg_registration_message();
|
||||
|
||||
$siteregistrationform->display();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Registration renderer.
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @copyright 2010 Moodle Pty Ltd (http://moodle.com)
|
||||
* @author Jerome Mouneyrac
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_register_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display message about the benefits of registering on Moodle.org
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function moodleorg_registration_message() {
|
||||
return format_text(get_string('registermoodlenet', 'admin'), FORMAT_HTML, ['noclean' => true]);
|
||||
}
|
||||
}
|
||||
+1
-10
@@ -1990,7 +1990,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
if (empty($CFG->docroot) or $environment_result->plugin) {
|
||||
$report = get_string($stringtouse, 'admin', $rec);
|
||||
} else {
|
||||
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec), true);
|
||||
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
|
||||
}
|
||||
// Enclose report text in div so feedback text will be displayed underneath it.
|
||||
$report = html_writer::div($report);
|
||||
@@ -2084,13 +2084,4 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $this->warning(get_string('legacylogginginuse'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display message about the benefits of registering on Moodle.org
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function moodleorg_registration_message() {
|
||||
return format_text(get_string('registermoodlenet', 'admin'), FORMAT_HTML, ['noclean' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ $mode = required_param('mode', PARAM_ALPHANUMEXT);
|
||||
$classformode = array(
|
||||
'assign' => 'core_role_allow_assign_page',
|
||||
'override' => 'core_role_allow_override_page',
|
||||
'switch' => 'core_role_allow_switch_page'
|
||||
'switch' => 'core_role_allow_switch_page',
|
||||
'view' => 'core_role_allow_view_page'
|
||||
);
|
||||
if (!isset($classformode[$mode])) {
|
||||
print_error('invalidmode', '', '', $mode);
|
||||
@@ -58,6 +59,9 @@ if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_s
|
||||
case 'switch':
|
||||
$event = \core\event\role_allow_switch_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
case 'view':
|
||||
$event = \core\event\role_allow_view_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
}
|
||||
if ($event) {
|
||||
$event->trigger();
|
||||
|
||||
@@ -33,7 +33,7 @@ class core_role_allow_assign_page extends core_role_allow_role_page {
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_assign($fromroleid, $targetroleid);
|
||||
core_role_set_assign_allowed($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
|
||||
@@ -33,7 +33,7 @@ class core_role_allow_override_page extends core_role_allow_role_page {
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_override($fromroleid, $targetroleid);
|
||||
core_role_set_override_allowed($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
|
||||
@@ -41,7 +41,7 @@ class core_role_allow_switch_page extends core_role_allow_role_page {
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_switch($fromroleid, $targetroleid);
|
||||
core_role_set_switch_allowed($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function is_allowed_target($targetroleid) {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Role view matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2016 onwards Andrew Hancox <andrewdchancox@googlemail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of role_allow_role_page for the Allow views tab.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2016 onwards Andrew Hancox <andrewdchancox@googlemail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_role_allow_view_page extends core_role_allow_role_page {
|
||||
/** @var array */
|
||||
protected $allowedtargetroles;
|
||||
|
||||
/**
|
||||
* core_role_allow_view_page constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_view', 'allowview');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allow from role to view target role.
|
||||
* @param int $fromroleid
|
||||
* @param int $targetroleid
|
||||
*/
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
core_role_set_view_allowed($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tool tip for cell.
|
||||
* @param string $fromrole
|
||||
* @param string $targetrole
|
||||
* @return string
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletoview', 'core_role', $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get intro text for role allow view page.
|
||||
* @return string
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowview', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
protected $allowassign;
|
||||
protected $allowoverride;
|
||||
protected $allowswitch;
|
||||
protected $allowview;
|
||||
|
||||
public function __construct($context, $roleid) {
|
||||
$this->roleid = $roleid;
|
||||
@@ -72,6 +73,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
$this->allowassign = array_keys($this->get_allow_roles_list('assign'));
|
||||
$this->allowoverride = array_keys($this->get_allow_roles_list('override'));
|
||||
$this->allowswitch = array_keys($this->get_allow_roles_list('switch'));
|
||||
$this->allowview = array_keys($this->get_allow_roles_list('view'));
|
||||
|
||||
} else {
|
||||
$this->role = new stdClass;
|
||||
@@ -83,6 +85,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
$this->allowassign = array();
|
||||
$this->allowoverride = array();
|
||||
$this->allowswitch = array();
|
||||
$this->allowview = array();
|
||||
}
|
||||
parent::load_current_permissions();
|
||||
}
|
||||
@@ -164,6 +167,10 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
if (!is_null($allow)) {
|
||||
$this->allowswitch = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowview', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowview = $allow;
|
||||
}
|
||||
|
||||
// Now read the permissions for each capability.
|
||||
parent::read_submitted_permissions();
|
||||
@@ -180,7 +187,8 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
* @param int $roleid role id or 0 for no role
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch',
|
||||
* 'allowview'
|
||||
*/
|
||||
public function force_duplicate($roleid, array $options) {
|
||||
global $DB;
|
||||
@@ -217,6 +225,9 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = array();
|
||||
}
|
||||
if ($options['allowview']) {
|
||||
$this->allowview = array();
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
@@ -262,6 +273,9 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = array_keys($this->get_allow_roles_list('switch', $roleid));
|
||||
}
|
||||
if ($options['allowview']) {
|
||||
$this->allowview = array_keys($this->get_allow_roles_list('view', $roleid));
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
$this->permissions = $DB->get_records_menu('role_capabilities',
|
||||
@@ -282,7 +296,8 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
* @param string $archetype
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch',
|
||||
* 'allowview'
|
||||
*/
|
||||
public function force_archetype($archetype, array $options) {
|
||||
$archetypes = get_role_archetypes();
|
||||
@@ -323,6 +338,9 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = get_default_role_archetype_allows('switch', $archetype);
|
||||
}
|
||||
if ($options['allowview']) {
|
||||
$this->allowview = get_default_role_archetype_allows('view', $archetype);
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
$defaultpermissions = get_default_capabilities($archetype);
|
||||
@@ -342,7 +360,8 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
* @param string $xml
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch',
|
||||
* 'allowview'
|
||||
*/
|
||||
public function force_preset($xml, array $options) {
|
||||
if (!$info = core_role_preset::parse_preset($xml)) {
|
||||
@@ -379,7 +398,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
foreach (array('assign', 'override', 'switch', 'view') as $type) {
|
||||
if ($options['allow'.$type]) {
|
||||
if (isset($info['allow'.$type])) {
|
||||
$this->{'allow'.$type} = $info['allow'.$type];
|
||||
@@ -440,6 +459,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
$this->save_allow('assign');
|
||||
$this->save_allow('override');
|
||||
$this->save_allow('switch');
|
||||
$this->save_allow('view');
|
||||
|
||||
// Permissions.
|
||||
parent::save_changes();
|
||||
@@ -451,7 +471,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
$current = array_keys($this->get_allow_roles_list($type));
|
||||
$wanted = $this->{'allow'.$type};
|
||||
|
||||
$addfunction = 'allow_'.$type;
|
||||
$addfunction = "core_role_set_{$type}_allowed";
|
||||
$deltable = 'role_allow_'.$type;
|
||||
$field = 'allow'.$type;
|
||||
|
||||
@@ -525,7 +545,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
protected function get_allow_roles_list($type, $roleid = null) {
|
||||
global $DB;
|
||||
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override') {
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override' and $type !== 'view') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
@@ -549,11 +569,11 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
/**
|
||||
* Returns an array of roles with the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @param string $type Must be one of: assign, switch, override or view.
|
||||
* @return array Am array of role names with the allowed type
|
||||
*/
|
||||
protected function get_allow_role_control($type) {
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override') {
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override' and $type !== 'view') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return '';
|
||||
}
|
||||
@@ -643,6 +663,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
$this->print_field('menuallowassign', get_string('allowassign', 'core_role'), $this->get_allow_role_control('assign'));
|
||||
$this->print_field('menuallowoverride', get_string('allowoverride', 'core_role'), $this->get_allow_role_control('override'));
|
||||
$this->print_field('menuallowswitch', get_string('allowswitch', 'core_role'), $this->get_allow_role_control('switch'));
|
||||
$this->print_field('menuallowview', get_string('allowview', 'core_role'), $this->get_allow_role_control('view'));
|
||||
if ($risks = $this->get_role_risks_info()) {
|
||||
$this->print_field('', get_string('rolerisks', 'core_role'), $risks);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class core_role_preset {
|
||||
$contextlevels->appendChild($dom->createElement('level', $name));
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
foreach (array('assign', 'override', 'switch', 'view') as $type) {
|
||||
$allows = $dom->createElement('allow'.$type);
|
||||
$top->appendChild($allows);
|
||||
$records = $DB->get_records('role_allow_'.$type, array('roleid'=>$roleid), "allow$type ASC");
|
||||
@@ -205,7 +205,7 @@ class core_role_preset {
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
foreach (array('assign', 'override', 'switch', 'view') as $type) {
|
||||
$values = self::get_node_children_values($dom, '/role/allow'.$type, 'shortname');
|
||||
if (!isset($values)) {
|
||||
$info['allow'.$type] = null;
|
||||
|
||||
@@ -79,6 +79,7 @@ class core_role_preset_form extends moodleform {
|
||||
$mform->addElement('advcheckbox', 'allowassign', get_string('allowassign', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'allowoverride', get_string('allowoverride', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'allowswitch', get_string('allowswitch', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'allowview', get_string('allowview', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'permissions', get_string('permissions', 'core_role'));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,459 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Privacy Subsystem implementation for core_role.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core_role\privacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use \core_privacy\local\metadata\collection;
|
||||
use \core_privacy\local\request\contextlist;
|
||||
use \core_privacy\local\request\approved_contextlist;
|
||||
use \core_privacy\local\request\transform;
|
||||
use \core_privacy\local\request\writer;
|
||||
use \core_privacy\local\request\userlist;
|
||||
use \core_privacy\local\request\approved_userlist;
|
||||
|
||||
/**
|
||||
* Privacy provider for core_role.
|
||||
*
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements
|
||||
\core_privacy\local\metadata\provider,
|
||||
\core_privacy\local\request\subsystem\provider,
|
||||
\core_privacy\local\request\subsystem\plugin_provider,
|
||||
\core_privacy\local\request\user_preference_provider,
|
||||
\core_privacy\local\request\core_userlist_provider {
|
||||
|
||||
/**
|
||||
* Get information about the user data stored by this plugin.
|
||||
*
|
||||
* @param collection $collection An object for storing metadata.
|
||||
* @return collection The metadata.
|
||||
*/
|
||||
public static function get_metadata(collection $collection) : collection {
|
||||
$rolecapabilities = [
|
||||
'roleid' => 'privacy:metadata:role_capabilities:roleid',
|
||||
'capability' => 'privacy:metadata:role_capabilities:capability',
|
||||
'permission' => 'privacy:metadata:role_capabilities:permission',
|
||||
'timemodified' => 'privacy:metadata:role_capabilities:timemodified',
|
||||
'modifierid' => 'privacy:metadata:role_capabilities:modifierid'
|
||||
];
|
||||
$roleassignments = [
|
||||
'roleid' => 'privacy:metadata:role_assignments:roleid',
|
||||
'userid' => 'privacy:metadata:role_assignments:userid',
|
||||
'timemodified' => 'privacy:metadata:role_assignments:timemodified',
|
||||
'modifierid' => 'privacy:metadata:role_assignments:modifierid',
|
||||
'component' => 'privacy:metadata:role_assignments:component',
|
||||
'itemid' => 'privacy:metadata:role_assignments:itemid'
|
||||
];
|
||||
$collection->add_database_table('role_capabilities', $rolecapabilities,
|
||||
'privacy:metadata:role_capabilities:tableexplanation');
|
||||
$collection->add_database_table('role_assignments', $roleassignments,
|
||||
'privacy:metadata:role_assignments:tableexplanation');
|
||||
|
||||
$collection->add_user_preference('definerole_showadvanced',
|
||||
'privacy:metadata:preference:showadvanced');
|
||||
|
||||
return $collection;
|
||||
}
|
||||
/**
|
||||
* Export all user preferences for the plugin.
|
||||
*
|
||||
* @param int $userid The userid of the user whose data is to be exported.
|
||||
*/
|
||||
public static function export_user_preferences(int $userid) {
|
||||
$showadvanced = get_user_preferences('definerole_showadvanced', null, $userid);
|
||||
if ($showadvanced !== null) {
|
||||
writer::export_user_preference('core_role',
|
||||
'definerole_showadvanced',
|
||||
transform::yesno($showadvanced),
|
||||
get_string('privacy:metadata:preference:showadvanced', 'core_role')
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return all contexts for this userid.
|
||||
*
|
||||
* @param int $userid The user ID.
|
||||
* @return contextlist The list of context IDs.
|
||||
*/
|
||||
public static function get_contexts_for_userid(int $userid) : contextlist {
|
||||
global $DB;
|
||||
|
||||
$contextlist = new contextlist();
|
||||
|
||||
// The role_capabilities table contains user data.
|
||||
$contexts = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_USER,
|
||||
CONTEXT_COURSECAT,
|
||||
CONTEXT_COURSE,
|
||||
CONTEXT_MODULE,
|
||||
CONTEXT_BLOCK
|
||||
];
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
|
||||
$sql = "SELECT ctx.id
|
||||
FROM {context} ctx
|
||||
JOIN {role_capabilities} rc
|
||||
ON rc.contextid = ctx.id
|
||||
AND ((ctx.contextlevel {$insql} AND rc.modifierid = :modifierid)
|
||||
OR (ctx.contextlevel = :contextlevel AND ctx.instanceid = :userid))";
|
||||
$params = [
|
||||
'modifierid' => $userid,
|
||||
'contextlevel' => CONTEXT_USER,
|
||||
'userid' => $userid
|
||||
];
|
||||
$params += $inparams;
|
||||
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
|
||||
// The role_assignments table contains user data.
|
||||
$contexts = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_USER,
|
||||
CONTEXT_COURSECAT,
|
||||
CONTEXT_COURSE,
|
||||
CONTEXT_MODULE,
|
||||
CONTEXT_BLOCK
|
||||
];
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
|
||||
$params = [
|
||||
'userid' => $userid,
|
||||
'modifierid' => $userid
|
||||
];
|
||||
$params += $inparams;
|
||||
$sql = "SELECT ctx.id
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} ctx
|
||||
ON ctx.id = ra.contextid
|
||||
AND ctx.contextlevel {$insql}
|
||||
WHERE (ra.userid = :userid
|
||||
OR ra.modifierid = :modifierid)
|
||||
AND ra.component != 'tool_cohortroles'";
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
|
||||
return $contextlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of users within a specific context.
|
||||
*
|
||||
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
|
||||
*/
|
||||
public static function get_users_in_context(userlist $userlist) {
|
||||
|
||||
if (empty($userlist)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $userlist->get_context();
|
||||
|
||||
// Include users who created or modified role capabilities.
|
||||
$sql = "SELECT modifierid as userid
|
||||
FROM {role_capabilities}
|
||||
WHERE contextid = :contextid";
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
|
||||
// Include users that have a role assigned to them.
|
||||
$sql = "SELECT userid
|
||||
FROM {role_assignments}
|
||||
WHERE contextid = :contextid";
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
|
||||
// Include users who created or modified the role assignment.
|
||||
// Differentiate and exclude special cases where tool_cohortroles adds records through the
|
||||
// "Assign user roles to cohort" feature into the role_assignments table.
|
||||
// These records should be separately processed in tool_cohortroles.
|
||||
$sql = "SELECT modifierid as userid
|
||||
FROM {role_assignments}
|
||||
WHERE contextid = :contextid
|
||||
AND component != 'tool_cohortroles'";
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The list of approved contexts for a user.
|
||||
*/
|
||||
public static function export_user_data(approved_contextlist $contextlist) {
|
||||
global $DB;
|
||||
|
||||
if (empty($contextlist)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rolesnames = self::get_roles_name();
|
||||
$userid = $contextlist->get_user()->id;
|
||||
$ctxfields = \context_helper::get_preload_record_columns_sql('ctx');
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
|
||||
|
||||
// Role Assignments export data.
|
||||
$contexts = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_USER,
|
||||
CONTEXT_COURSECAT,
|
||||
CONTEXT_COURSE,
|
||||
CONTEXT_MODULE,
|
||||
CONTEXT_BLOCK
|
||||
];
|
||||
list($inctxsql, $ctxparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
|
||||
$sql = "SELECT ra.id, ra.contextid, ra.roleid, ra.userid, ra.timemodified, ra.modifierid, $ctxfields
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} ctx
|
||||
ON ctx.id = ra.contextid
|
||||
AND ctx.contextlevel {$inctxsql}
|
||||
AND (ra.userid = :userid OR ra.modifierid = :modifierid)
|
||||
AND ra.component != 'tool_cohortroles'
|
||||
JOIN {role} r
|
||||
ON r.id = ra.roleid
|
||||
WHERE ctx.id {$insql}";
|
||||
$params = ['userid' => $userid, 'modifierid' => $userid];
|
||||
$params += $inparams;
|
||||
$params += $ctxparams;
|
||||
$assignments = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($assignments as $assignment) {
|
||||
\context_helper::preload_from_record($assignment);
|
||||
$alldata[$assignment->contextid][$rolesnames[$assignment->roleid]][] = (object)[
|
||||
'timemodified' => transform::datetime($assignment->timemodified),
|
||||
'userid' => transform::user($assignment->userid),
|
||||
'modifierid' => transform::user($assignment->modifierid)
|
||||
];
|
||||
}
|
||||
$assignments->close();
|
||||
if (!empty($alldata)) {
|
||||
array_walk($alldata, function($roledata, $contextid) {
|
||||
$context = \context::instance_by_id($contextid);
|
||||
array_walk($roledata, function($data, $rolename) use ($context) {
|
||||
writer::with_context($context)->export_data(
|
||||
[get_string('privacy:metadata:role_assignments', 'core_role'), $rolename],
|
||||
(object)$data);
|
||||
});
|
||||
});
|
||||
unset($alldata);
|
||||
}
|
||||
|
||||
// Role Capabilities export data.
|
||||
$strpermissions = self::get_permissions_name();
|
||||
$contexts = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_USER,
|
||||
CONTEXT_COURSECAT,
|
||||
CONTEXT_COURSE,
|
||||
CONTEXT_MODULE,
|
||||
CONTEXT_BLOCK
|
||||
];
|
||||
list($inctxsql, $ctxparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
|
||||
$sql = "SELECT rc.id, rc.contextid, rc.capability, rc.permission, rc.timemodified, rc.roleid, $ctxfields
|
||||
FROM {context} ctx
|
||||
JOIN {role_capabilities} rc
|
||||
ON rc.contextid = ctx.id
|
||||
AND ((ctx.contextlevel {$inctxsql} AND rc.modifierid = :modifierid)
|
||||
OR (ctx.contextlevel = :contextlevel AND ctx.instanceid = :userid))
|
||||
WHERE ctx.id {$insql}";
|
||||
$params = [
|
||||
'modifierid' => $userid,
|
||||
'contextlevel' => CONTEXT_USER,
|
||||
'userid' => $userid
|
||||
];
|
||||
$params += $inparams;
|
||||
$params += $ctxparams;
|
||||
$capabilities = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($capabilities as $capability) {
|
||||
\context_helper::preload_from_record($capability);
|
||||
$alldata[$capability->contextid][$rolesnames[$capability->roleid]][] = (object)[
|
||||
'timemodified' => transform::datetime($capability->timemodified),
|
||||
'capability' => $capability->capability,
|
||||
'permission' => $strpermissions[$capability->permission]
|
||||
];
|
||||
}
|
||||
$capabilities->close();
|
||||
if (!empty($alldata)) {
|
||||
array_walk($alldata, function($capdata, $contextid) {
|
||||
$context = \context::instance_by_id($contextid);
|
||||
array_walk($capdata, function($data, $rolename) use ($context) {
|
||||
writer::with_context($context)->export_data(
|
||||
[get_string('privacy:metadata:role_capabilities', 'core_role'), $rolename],
|
||||
(object)$data);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Exports the data relating to tool_cohortroles component on role assignments by
|
||||
* Assign user roles to cohort feature.
|
||||
*
|
||||
* @param int $userid The user ID.
|
||||
*/
|
||||
public static function export_user_role_to_cohort(int $userid) {
|
||||
global $DB;
|
||||
|
||||
$rolesnames = self::get_roles_name();
|
||||
$sql = "SELECT ra.id, ra.contextid, ra.roleid, ra.userid, ra.timemodified, ra.modifierid, r.id as roleid
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} ctx
|
||||
ON ctx.id = ra.contextid
|
||||
AND ctx.contextlevel = :contextlevel
|
||||
AND ra.component = 'tool_cohortroles'
|
||||
JOIN {role} r
|
||||
ON r.id = ra.roleid
|
||||
WHERE ctx.instanceid = :instanceid
|
||||
OR ra.userid = :userid";
|
||||
$params = ['userid' => $userid, 'instanceid' => $userid, 'contextlevel' => CONTEXT_USER];
|
||||
$assignments = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($assignments as $assignment) {
|
||||
$alldata[$assignment->contextid][$rolesnames[$assignment->roleid]][] = (object)[
|
||||
'timemodified' => transform::datetime($assignment->timemodified),
|
||||
'userid' => transform::user($assignment->userid),
|
||||
'modifierid' => transform::user($assignment->modifierid)
|
||||
];
|
||||
}
|
||||
$assignments->close();
|
||||
if (!empty($alldata)) {
|
||||
array_walk($alldata, function($roledata, $contextid) {
|
||||
$context = \context::instance_by_id($contextid);
|
||||
array_walk($roledata, function($data, $rolename) use ($context) {
|
||||
writer::with_context($context)->export_related_data(
|
||||
[get_string('privacy:metadata:role_cohortroles', 'core_role'), $rolename], 'cohortroles',
|
||||
(object)$data);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Delete all user data for this context.
|
||||
*
|
||||
* @param \context $context The context to delete data for.
|
||||
*/
|
||||
public static function delete_data_for_all_users_in_context(\context $context) {
|
||||
global $DB;
|
||||
|
||||
// Don't remove data from role_capabilities.
|
||||
// Because this data affects the whole Moodle, there are override capabilities.
|
||||
// Don't belong to the modifier user.
|
||||
|
||||
// Remove data from role_assignments.
|
||||
$DB->delete_records('role_assignments', ['contextid' => $context->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple users within a single context.
|
||||
*
|
||||
* @param approved_userlist $userlist The approved context and user information to delete information for.
|
||||
*/
|
||||
public static function delete_data_for_users(approved_userlist $userlist) {
|
||||
global $DB;
|
||||
|
||||
// Don't remove data from role_capabilities.
|
||||
// Because this data affects the whole Moodle, there are override capabilities.
|
||||
// Don't belong to the modifier user.
|
||||
$context = $userlist->get_context();
|
||||
$userids = $userlist->get_userids();
|
||||
|
||||
if (empty($userids)) {
|
||||
return;
|
||||
}
|
||||
list($usersql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
|
||||
$params = ['contextid' => $context->id] + $userparams;
|
||||
|
||||
// Remove data from role_assignments.
|
||||
$DB->delete_records_select('role_assignments',
|
||||
"contextid = :contextid AND userid {$usersql}", $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all user data for this user only.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The list of approved contexts for a user.
|
||||
*/
|
||||
public static function delete_data_for_user(approved_contextlist $contextlist) {
|
||||
global $DB;
|
||||
|
||||
// Don't remove data from role_capabilities.
|
||||
// Because this data affects the whole Moodle, there are override capabilities.
|
||||
// Don't belong to the modifier user.
|
||||
|
||||
// Remove data from role_assignments.
|
||||
if (empty($contextlist->count())) {
|
||||
return;
|
||||
}
|
||||
$userid = $contextlist->get_user()->id;
|
||||
$contextids = $contextlist->get_contextids();
|
||||
|
||||
list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
|
||||
$params = ['userid' => $userid] + $contextparams;
|
||||
|
||||
// Only delete the roles assignments where the user is assigned in all contexts.
|
||||
$DB->delete_records_select('role_assignments',
|
||||
"userid = :userid AND contextid {$contextsql}", $params);
|
||||
}
|
||||
/**
|
||||
* Delete user entries in role_assignments related to the feature
|
||||
* Assign user roles to cohort feature.
|
||||
*
|
||||
* @param int $userid The user ID.
|
||||
*/
|
||||
public static function delete_user_role_to_cohort(int $userid) {
|
||||
global $DB;
|
||||
|
||||
// Delete entries where userid is a mentor by tool_cohortroles.
|
||||
$DB->delete_records('role_assignments', ['userid' => $userid, 'component' => 'tool_cohortroles']);
|
||||
}
|
||||
/**
|
||||
* Get all the localised roles name in a simple array.
|
||||
*
|
||||
* @return array Array of name of the roles by roleid.
|
||||
*/
|
||||
protected static function get_roles_name() {
|
||||
$roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
|
||||
$rolesnames = array();
|
||||
foreach ($roles as $role) {
|
||||
$rolesnames[$role->id] = $role->localname;
|
||||
}
|
||||
return $rolesnames;
|
||||
}
|
||||
/**
|
||||
* Get all the permissions name in a simple array.
|
||||
*
|
||||
* @return array Array of permissions name.
|
||||
*/
|
||||
protected static function get_permissions_name() {
|
||||
$strpermissions = array(
|
||||
CAP_INHERIT => get_string('inherit', 'role'),
|
||||
CAP_ALLOW => get_string('allow', 'role'),
|
||||
CAP_PREVENT => get_string('prevent', 'role'),
|
||||
CAP_PROHIBIT => get_string('prohibit', 'role')
|
||||
);
|
||||
return $strpermissions;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,8 @@ if ($action === 'add' and $resettype !== 'none') {
|
||||
'contextlevels' => 1,
|
||||
'allowassign' => 1,
|
||||
'allowoverride' => 1,
|
||||
'allowswitch' => 1);
|
||||
'allowswitch' => 1,
|
||||
'allowview' => 1);
|
||||
if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, 0);
|
||||
} else {
|
||||
@@ -150,7 +151,8 @@ if ($action === 'add' and $resettype !== 'none') {
|
||||
'contextlevels' => $data->contextlevels,
|
||||
'allowassign' => $data->allowassign,
|
||||
'allowoverride' => $data->allowoverride,
|
||||
'allowswitch' => $data->allowswitch);
|
||||
'allowswitch' => $data->allowswitch,
|
||||
'allowview' => $data->allowview);
|
||||
if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, $roleid);
|
||||
} else {
|
||||
|
||||
@@ -29,6 +29,7 @@ $toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), g
|
||||
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'core_role'));
|
||||
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'core_role'));
|
||||
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'core_role'));
|
||||
$toprow[] = new tabobject('view', new moodle_url('/admin/roles/allow.php', ['mode' => 'view']), get_string('allowview', 'core_role'));
|
||||
|
||||
echo $OUTPUT->tabtree($toprow, $currenttab);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<xs:element ref="allowassign" minOccurs="0"/>
|
||||
<xs:element ref="allowoverride" minOccurs="0"/>
|
||||
<xs:element ref="allowswitch" minOccurs="0"/>
|
||||
<xs:element ref="allowview" minOccurs="0"/>
|
||||
<xs:element ref="permissions" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
@@ -45,6 +46,13 @@
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="allowview">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" ref="shortname"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="permissions">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
|
||||
@@ -44,7 +44,7 @@ class core_role_preset_testcase extends advanced_testcase {
|
||||
$contextlevels = get_role_contextlevels($role->id);
|
||||
$this->assertEquals(array_values($contextlevels), array_values($info['contextlevels']));
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
foreach (array('assign', 'override', 'switch', 'view') as $type) {
|
||||
$records = $DB->get_records('role_allow_'.$type, array('roleid'=>$role->id), "allow$type ASC");
|
||||
$allows = array();
|
||||
foreach ($records as $record) {
|
||||
|
||||
@@ -1,747 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Privacy test for core_role
|
||||
*
|
||||
* @package core_role
|
||||
* @category test
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use \core_role\privacy\provider;
|
||||
use \core_privacy\local\request\approved_contextlist;
|
||||
use \core_privacy\local\request\writer;
|
||||
use \core_privacy\tests\provider_testcase;
|
||||
use \core_privacy\local\request\transform;
|
||||
use \tool_cohortroles\api;
|
||||
use \core_privacy\local\request\approved_userlist;
|
||||
|
||||
/**
|
||||
* Privacy test for core_role
|
||||
*
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_role_privacy_testcase extends provider_testcase {
|
||||
/**
|
||||
* Test to check export_user_preferences.
|
||||
* returns user preferences data.
|
||||
*/
|
||||
public function test_export_user_preferences() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
$showadvanced = 1;
|
||||
set_user_preference('definerole_showadvanced', $showadvanced);
|
||||
provider::export_user_preferences($user->id);
|
||||
$writer = writer::with_context(\context_system::instance());
|
||||
$prefs = $writer->get_user_preferences('core_role');
|
||||
$this->assertEquals(transform::yesno($showadvanced), transform::yesno($prefs->definerole_showadvanced->value));
|
||||
$this->assertEquals(get_string('privacy:metadata:preference:showadvanced', 'core_role'),
|
||||
$prefs->definerole_showadvanced->description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all contexts are returned if there is any user data for this user.
|
||||
*/
|
||||
public function test_get_contexts_for_userid() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->assertEmpty(provider::get_contexts_for_userid($user->id));
|
||||
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$usercontext2 = \context_user::instance($user2->id);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
$coursecat = $this->getDataGenerator()->create_category();
|
||||
$cm = $this->getDataGenerator()->create_module('chat', ['course' => $course->id]);
|
||||
$cmcontext = \context_module::instance($cm->cmid);
|
||||
$page = $this->getDataGenerator()->create_module('page', array('course' => $course->id));
|
||||
$cmcontext2 = \context_module::instance($page->cmid);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$coursecontext2 = \context_course::instance($course2->id);
|
||||
$coursecatcontext = \context_coursecat::instance($coursecat->id);
|
||||
$systemcontext = \context_system::instance();
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
$blockcontext = \context_block::instance($block->id);
|
||||
|
||||
$student = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
$manager = $DB->get_record('role', array('shortname' => 'manager'), '*', MUST_EXIST);
|
||||
|
||||
// Role assignments, where the user is assigned.
|
||||
role_assign($student->id, $user->id, $cmcontext2->id);
|
||||
role_assign($student->id, $user->id, $coursecontext2->id);
|
||||
role_assign($student->id, $user->id, $blockcontext->id);
|
||||
role_assign($manager->id, $user->id, $usercontext2->id);
|
||||
// Role assignments, where the user makes assignments.
|
||||
$this->setUser($user);
|
||||
role_assign($student->id, $user2->id, $coursecontext->id);
|
||||
role_assign($manager->id, $user2->id, $coursecatcontext->id);
|
||||
role_assign($manager->id, $user2->id, $systemcontext->id);
|
||||
|
||||
// Role capabilities.
|
||||
$this->setUser($user);
|
||||
$result = assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $student->id, $cmcontext->id);
|
||||
|
||||
$contextlist = provider::get_contexts_for_userid($user->id)->get_contextids();
|
||||
$this->assertCount(8, $contextlist);
|
||||
$this->assertTrue(in_array($cmcontext->id, $contextlist));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that user data is exported correctly.
|
||||
*/
|
||||
public function test_export_user_data() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$usercontext2 = \context_user::instance($user2->id);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
$coursecat = $this->getDataGenerator()->create_category();
|
||||
$cm = $this->getDataGenerator()->create_module('chat', ['course' => $course->id]);
|
||||
$cmcontext = \context_module::instance($cm->cmid);
|
||||
$page = $this->getDataGenerator()->create_module('page', array('course' => $course->id));
|
||||
$cmcontext2 = \context_module::instance($page->cmid);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$coursecontext2 = \context_course::instance($course2->id);
|
||||
$coursecatcontext = \context_coursecat::instance($coursecat->id);
|
||||
$systemcontext = \context_system::instance();
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
$blockcontext = \context_block::instance($block->id);
|
||||
|
||||
$student = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
$manager = $DB->get_record('role', array('shortname' => 'manager'), '*', MUST_EXIST);
|
||||
$rolesnames = self::get_roles_name();
|
||||
|
||||
$subcontextstudent = [
|
||||
get_string('privacy:metadata:role_assignments', 'core_role'),
|
||||
$rolesnames[$student->id]
|
||||
];
|
||||
$subcontextmanager = [
|
||||
get_string('privacy:metadata:role_assignments', 'core_role'),
|
||||
$rolesnames[$manager->id]
|
||||
];
|
||||
$subcontextrc = [
|
||||
get_string('privacy:metadata:role_capabilities', 'core_role'),
|
||||
$rolesnames[$student->id]
|
||||
];
|
||||
|
||||
// Test over role assignments.
|
||||
// Where the user is assigned.
|
||||
role_assign($student->id, $user->id, $cmcontext2->id);
|
||||
role_assign($student->id, $user->id, $coursecontext2->id);
|
||||
role_assign($student->id, $user->id, $blockcontext->id);
|
||||
role_assign($manager->id, $user->id, $usercontext2->id);
|
||||
// Where the user makes assignments.
|
||||
$this->setUser($user);
|
||||
role_assign($manager->id, $user2->id, $coursecatcontext->id);
|
||||
role_assign($manager->id, $user2->id, $systemcontext->id);
|
||||
|
||||
// Test overridable roles in module, course, category, user, system and block.
|
||||
assign_capability('moodle/backup:backupactivity', CAP_ALLOW, $student->id, $cmcontext->id, true);
|
||||
assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $student->id, $coursecontext->id, true);
|
||||
assign_capability('moodle/category:manage', CAP_ALLOW, $student->id, $coursecatcontext->id, true);
|
||||
assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $student->id, $systemcontext->id, true);
|
||||
assign_capability('moodle/block:edit', CAP_ALLOW, $student->id, $blockcontext->id, true);
|
||||
assign_capability('moodle/competency:evidencedelete', CAP_ALLOW, $student->id, $usercontext2->id, true);
|
||||
|
||||
// Retrieve the user's context ids.
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$approvedcontextlist = new approved_contextlist($user, 'core_role', $contextlist->get_contextids());
|
||||
|
||||
$strpermissions = array(
|
||||
CAP_INHERIT => get_string('inherit', 'role'),
|
||||
CAP_ALLOW => get_string('allow', 'role'),
|
||||
CAP_PREVENT => get_string('prevent', 'role'),
|
||||
CAP_PROHIBIT => get_string('prohibit', 'role')
|
||||
);
|
||||
// Retrieve role capabilities and role assignments.
|
||||
provider::export_user_data($approvedcontextlist);
|
||||
foreach ($contextlist as $context) {
|
||||
$writer = writer::with_context($context);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
if ($data = $writer->get_data($subcontextstudent)) {
|
||||
$this->assertEquals($user->id, reset($data)->userid);
|
||||
}
|
||||
if ($data = $writer->get_data($subcontextrc)) {
|
||||
$this->assertEquals('moodle/backup:backupactivity', reset($data)->capability);
|
||||
$this->assertEquals($strpermissions[CAP_ALLOW], reset($data)->permission);
|
||||
}
|
||||
}
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
if ($data = $writer->get_data($subcontextstudent)) {
|
||||
$this->assertEquals($user->id, reset($data)->userid);
|
||||
}
|
||||
if ($data = $writer->get_data($subcontextrc)) {
|
||||
$this->assertEquals('moodle/backup:backupcourse', reset($data)->capability);
|
||||
}
|
||||
}
|
||||
if ($context->contextlevel == CONTEXT_COURSECAT) {
|
||||
if ($data = $writer->get_data($subcontextmanager)) {
|
||||
$this->assertEquals($user->id, reset($data)->modifierid);
|
||||
}
|
||||
if ($data = $writer->get_data($subcontextrc)) {
|
||||
$this->assertEquals('moodle/category:manage', reset($data)->capability);
|
||||
}
|
||||
}
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
if ($data = $writer->get_data($subcontextmanager)) {
|
||||
$this->assertEquals($user->id, reset($data)->modifierid);
|
||||
}
|
||||
if ($data = $writer->get_data($subcontextrc)) {
|
||||
$this->assertEquals('moodle/backup:backupcourse', reset($data)->capability);
|
||||
}
|
||||
}
|
||||
if ($context->contextlevel == CONTEXT_BLOCK) {
|
||||
if ($data = $writer->get_data($subcontextstudent)) {
|
||||
$this->assertEquals($user->id, reset($data)->userid);
|
||||
}
|
||||
if ($data = $writer->get_data($subcontextrc)) {
|
||||
$this->assertEquals('moodle/block:edit', reset($data)->capability);
|
||||
}
|
||||
}
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
if ($data = $writer->get_data($subcontextmanager)) {
|
||||
$this->assertEquals($user->id, reset($data)->userid);
|
||||
}
|
||||
if ($data = $writer->get_data($subcontextrc)) {
|
||||
$this->assertEquals('moodle/competency:evidencedelete', reset($data)->capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::delete_data_for_all_users_in_context().
|
||||
*/
|
||||
public function test_delete_data_for_all_users_in_context() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$usercontext2 = \context_user::instance($user2->id);
|
||||
$user3 = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$coursecat = $this->getDataGenerator()->create_category();
|
||||
$coursecatcontext = \context_coursecat::instance($coursecat->id);
|
||||
$systemcontext = \context_system::instance();
|
||||
$cm = $this->getDataGenerator()->create_module('chat', ['course' => $course->id]);
|
||||
$cmcontext = \context_module::instance($cm->cmid);
|
||||
$student = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
$manager = $DB->get_record('role', array('shortname' => 'manager'), '*', MUST_EXIST);
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
$blockcontext = \context_block::instance($block->id);
|
||||
|
||||
// Role assignments CONTEXT_COURSE.
|
||||
role_assign($student->id, $user->id, $coursecontext->id);
|
||||
role_assign($student->id, $user2->id, $coursecontext->id);
|
||||
role_assign($student->id, $user3->id, $coursecontext->id);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $coursecontext->id]);
|
||||
$this->assertEquals(3, $count);
|
||||
// Role assignments CONTEXT_COURSECAT.
|
||||
role_assign($student->id, $user2->id, $coursecatcontext->id);
|
||||
role_assign($student->id, $user3->id, $coursecatcontext->id);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $coursecatcontext->id]);
|
||||
$this->assertEquals(2, $count);
|
||||
// Role assignments CONTEXT_SYSTEM.
|
||||
role_assign($student->id, $user->id, $systemcontext->id);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $systemcontext->id]);
|
||||
$this->assertEquals(1, $count);
|
||||
// Role assignments CONTEXT_MODULE.
|
||||
role_assign($student->id, $user->id, $cmcontext->id);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $cmcontext->id]);
|
||||
$this->assertEquals(1, $count);
|
||||
// Role assigments CONTEXT_BLOCK.
|
||||
role_assign($student->id, $user->id, $blockcontext->id);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $blockcontext->id]);
|
||||
$this->assertEquals(1, $count);
|
||||
// Role assigments CONTEXT_USER.
|
||||
role_assign($manager->id, $user->id, $usercontext2->id);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $usercontext2->id]);
|
||||
$this->assertEquals(1, $count);
|
||||
|
||||
// Delete data based on CONTEXT_COURSE context.
|
||||
provider::delete_data_for_all_users_in_context($coursecontext);
|
||||
// After deletion, the role_assignments entries for this context should have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $coursecontext->id]);
|
||||
$this->assertEquals(0, $count);
|
||||
// Check it is not removing data on other contexts.
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $coursecatcontext->id]);
|
||||
$this->assertEquals(2, $count);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $systemcontext->id]);
|
||||
$this->assertEquals(1, $count);
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $cmcontext->id]);
|
||||
$this->assertEquals(1, $count);
|
||||
// Delete data based on CONTEXT_COURSECAT context.
|
||||
provider::delete_data_for_all_users_in_context($coursecatcontext);
|
||||
// After deletion, the role_assignments entries for this context should have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $coursecatcontext->id]);
|
||||
$this->assertEquals(0, $count);
|
||||
// Delete data based on CONTEXT_SYSTEM context.
|
||||
provider::delete_data_for_all_users_in_context($systemcontext);
|
||||
// After deletion, the role_assignments entries for this context should have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $systemcontext->id]);
|
||||
$this->assertEquals(0, $count);
|
||||
// Delete data based on CONTEXT_MODULE context.
|
||||
provider::delete_data_for_all_users_in_context($cmcontext);
|
||||
// After deletion, the role_assignments entries for this context should have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $cmcontext->id]);
|
||||
$this->assertEquals(0, $count);
|
||||
// Delete data based on CONTEXT_BLOCK context.
|
||||
provider::delete_data_for_all_users_in_context($usercontext2);
|
||||
// After deletion, the role_assignments entries for this context should have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['contextid' => $usercontext2->id]);
|
||||
$this->assertEquals(0, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::delete_data_for_user().
|
||||
*/
|
||||
public function test_delete_data_for_user() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$usercontext2 = \context_user::instance($user2->id);
|
||||
$user3 = $this->getDataGenerator()->create_user();
|
||||
$usercontext3 = \context_user::instance($user3->id);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
$course3 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$coursecontext2 = \context_course::instance($course2->id);
|
||||
$coursecontext3 = \context_course::instance($course3->id);
|
||||
$coursecat = $this->getDataGenerator()->create_category();
|
||||
$coursecatcontext = \context_coursecat::instance($coursecat->id);
|
||||
$systemcontext = \context_system::instance();
|
||||
$cm = $this->getDataGenerator()->create_module('chat', ['course' => $course->id]);
|
||||
$cmcontext = \context_module::instance($cm->cmid);
|
||||
$student = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
$manager = $DB->get_record('role', array('shortname' => 'manager'), '*', MUST_EXIST);
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
$blockcontext = \context_block::instance($block->id);
|
||||
|
||||
// Role assignments, Where the user is assigned.
|
||||
role_assign($student->id, $user->id, $coursecontext->id);
|
||||
role_assign($student->id, $user->id, $coursecontext2->id);
|
||||
role_assign($student->id, $user->id, $coursecatcontext->id);
|
||||
role_assign($student->id, $user->id, $cmcontext->id);
|
||||
role_assign($student->id, $user->id, $systemcontext->id);
|
||||
role_assign($student->id, $user->id, $blockcontext->id);
|
||||
role_assign($manager->id, $user->id, $usercontext2->id);
|
||||
role_assign($manager->id, $user->id, $usercontext3->id);
|
||||
$count = $DB->count_records('role_assignments', ['userid' => $user->id]);
|
||||
$this->assertEquals(8, $count);
|
||||
// Role assignments, where the user makes assignments.
|
||||
$this->setUser($user);
|
||||
role_assign($student->id, $user2->id, $coursecontext3->id);
|
||||
role_assign($student->id, $user3->id, $coursecontext3->id);
|
||||
$count = $DB->count_records('role_assignments', ['modifierid' => $user->id]);
|
||||
$this->assertEquals(2, $count);
|
||||
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$approvedcontextlist = new approved_contextlist($user, 'core_role', $contextlist->get_contextids());
|
||||
provider::delete_data_for_user($approvedcontextlist);
|
||||
// After deletion, the role_assignments assigned to the user should have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['userid' => $user->id]);
|
||||
$this->assertEquals(0, $count);
|
||||
// After deletion, the role_assignments assigned by the user should not have been deleted.
|
||||
$count = $DB->count_records('role_assignments', ['modifierid' => $user->id]);
|
||||
$this->assertEquals(2, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export for a user with a key against a script where no instance is specified.
|
||||
*/
|
||||
public function test_export_user_role_to_cohort() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
// Assign user roles to cohort.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$contextuser = \context_user::instance($user->id);
|
||||
$teacher = $DB->get_record('role', array('shortname' => 'teacher'), '*', MUST_EXIST);
|
||||
$cohort = $this->getDataGenerator()->create_cohort();
|
||||
$userassignover = $this->getDataGenerator()->create_user();
|
||||
$contextuserassignover = \context_user::instance($userassignover->id);
|
||||
cohort_add_member($cohort->id, $userassignover->id);
|
||||
$this->setAdminUser();
|
||||
$params = (object) array(
|
||||
'userid' => $user->id,
|
||||
'roleid' => $teacher->id,
|
||||
'cohortid' => $cohort->id
|
||||
);
|
||||
api::create_cohort_role_assignment($params);
|
||||
api::sync_all_cohort_roles();
|
||||
$rolesnames = self::get_roles_name();
|
||||
$subcontextteacher = [
|
||||
get_string('privacy:metadata:role_cohortroles', 'core_role'),
|
||||
$rolesnames[$teacher->id]
|
||||
];
|
||||
// Test User is assigned role teacher to cohort.
|
||||
provider::export_user_role_to_cohort($user->id);
|
||||
$writer = writer::with_context($contextuserassignover);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
$exported = $writer->get_related_data($subcontextteacher, 'cohortroles');
|
||||
$this->assertEquals($user->id, reset($exported)->userid);
|
||||
|
||||
// Test User is member of a cohort which User2 is assigned to role to this cohort.
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$cohort2 = $this->getDataGenerator()->create_cohort();
|
||||
cohort_add_member($cohort2->id, $user->id);
|
||||
$params = (object) array(
|
||||
'userid' => $user2->id,
|
||||
'roleid' => $teacher->id,
|
||||
'cohortid' => $cohort2->id
|
||||
);
|
||||
api::create_cohort_role_assignment($params);
|
||||
api::sync_all_cohort_roles();
|
||||
provider::export_user_role_to_cohort($user->id);
|
||||
$writer = writer::with_context($contextuser);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
$exported = $writer->get_related_data($subcontextteacher, 'cohortroles');
|
||||
$this->assertEquals($user2->id, reset($exported)->userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::delete_user_role_to_cohort().
|
||||
*/
|
||||
public function test_delete_user_role_to_cohort() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
// Assign user roles to cohort.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$user3 = $this->getDataGenerator()->create_user();
|
||||
$user4 = $this->getDataGenerator()->create_user();
|
||||
$teacher = $DB->get_record('role', array('shortname' => 'teacher'), '*', MUST_EXIST);
|
||||
$cohort = $this->getDataGenerator()->create_cohort();
|
||||
cohort_add_member($cohort->id, $user2->id);
|
||||
cohort_add_member($cohort->id, $user3->id);
|
||||
cohort_add_member($cohort->id, $user4->id);
|
||||
$this->setAdminUser();
|
||||
$params = (object) array(
|
||||
'userid' => $user->id,
|
||||
'roleid' => $teacher->id,
|
||||
'cohortid' => $cohort->id
|
||||
);
|
||||
api::create_cohort_role_assignment($params);
|
||||
api::sync_all_cohort_roles();
|
||||
|
||||
$count = $DB->count_records('role_assignments', ['userid' => $user->id, 'component' => 'tool_cohortroles']);
|
||||
$this->assertEquals(3, $count);
|
||||
|
||||
provider::delete_user_role_to_cohort($user->id);
|
||||
$count = $DB->count_records('role_assignments', ['userid' => $user->id, 'component' => 'tool_cohortroles']);
|
||||
$this->assertEquals(0, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that only users within a course context are fetched.
|
||||
*/
|
||||
public function test_get_users_in_context() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$component = 'core_role';
|
||||
|
||||
$this->setAdminUser();
|
||||
$admin = \core_user::get_user_by_username('admin');
|
||||
// Create user1.
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
$usercontext1 = \context_user::instance($user1->id);
|
||||
// Create user2.
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$usercontext2 = \context_user::instance($user2->id);
|
||||
// Create course1.
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
// Create course category.
|
||||
$coursecat = $this->getDataGenerator()->create_category();
|
||||
$coursecatcontext = \context_coursecat::instance($coursecat->id);
|
||||
// Create chat module.
|
||||
$cm = $this->getDataGenerator()->create_module('chat', ['course' => $course1->id]);
|
||||
$cmcontext = \context_module::instance($cm->cmid);
|
||||
|
||||
$systemcontext = \context_system::instance();
|
||||
// Create a block.
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
$blockcontext = \context_block::instance($block->id);
|
||||
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
$managerrole = $DB->get_record('role', array('shortname' => 'manager'), '*', MUST_EXIST);
|
||||
|
||||
// Role assignments CONTEXT_COURSE.
|
||||
role_assign($studentrole->id, $user1->id, $coursecontext1->id);
|
||||
role_assign($studentrole->id, $user2->id, $coursecontext1->id);
|
||||
// Role assignments CONTEXT_COURSECAT.
|
||||
role_assign($studentrole->id, $user2->id, $coursecatcontext->id);
|
||||
// Role assignments CONTEXT_SYSTEM.
|
||||
role_assign($studentrole->id, $user1->id, $systemcontext->id);
|
||||
// Role assignments CONTEXT_MODULE.
|
||||
role_assign($studentrole->id, $user2->id, $cmcontext->id);
|
||||
// Role assigments CONTEXT_BLOCK.
|
||||
role_assign($studentrole->id, $user1->id, $blockcontext->id);
|
||||
// Role assigments CONTEXT_USER.
|
||||
role_assign($managerrole->id, $user1->id, $usercontext2->id);
|
||||
|
||||
// Role capabilities.
|
||||
$this->setUser($user1);
|
||||
assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $studentrole->id, $cmcontext->id);
|
||||
|
||||
// The user list for usercontext1 should not return any users.
|
||||
$userlist1 = new \core_privacy\local\request\userlist($usercontext1, $component);
|
||||
provider::get_users_in_context($userlist1);
|
||||
$this->assertCount(0, $userlist1);
|
||||
// The user list for usercontext2 should user1 and admin (role creator).
|
||||
$userlist2 = new \core_privacy\local\request\userlist($usercontext2, $component);
|
||||
provider::get_users_in_context($userlist2);
|
||||
$this->assertCount(2, $userlist2);
|
||||
$expected = [
|
||||
$user1->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist2->get_userids(), '', 0.0, 10, true);
|
||||
|
||||
// The user list for coursecontext1 should user1, user2 and admin (role creator).
|
||||
$userlist3 = new \core_privacy\local\request\userlist($coursecontext1, $component);
|
||||
provider::get_users_in_context($userlist3);
|
||||
$this->assertCount(3, $userlist3);
|
||||
$expected = [
|
||||
$user1->id,
|
||||
$user2->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist3->get_userids(), '', 0.0, 10, true);
|
||||
|
||||
// The user list for coursecatcontext should user2 and admin (role creator).
|
||||
$userlist4 = new \core_privacy\local\request\userlist($coursecatcontext, $component);
|
||||
provider::get_users_in_context($userlist4);
|
||||
$this->assertCount(2, $userlist4);
|
||||
$expected = [
|
||||
$user2->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist4->get_userids(), '', 0.0, 10, true);
|
||||
|
||||
// The user list for systemcontext should user1 and admin (role creator).
|
||||
$userlist6 = new \core_privacy\local\request\userlist($systemcontext, $component);
|
||||
provider::get_users_in_context($userlist6);
|
||||
$this->assertCount(2, $userlist6);
|
||||
$expected = [
|
||||
$user1->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist6->get_userids(), '', 0.0, 10, true);
|
||||
|
||||
// The user list for cmcontext should user1, user2 and admin (role creator).
|
||||
$userlist7 = new \core_privacy\local\request\userlist($cmcontext, $component);
|
||||
provider::get_users_in_context($userlist7);
|
||||
$this->assertCount(3, $userlist7);
|
||||
$expected = [
|
||||
$user1->id,
|
||||
$user2->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist7->get_userids(), '', 0.0, 10, true);
|
||||
|
||||
// The user list for blockcontext should user1 and admin (role creator).
|
||||
$userlist8 = new \core_privacy\local\request\userlist($blockcontext, $component);
|
||||
provider::get_users_in_context($userlist8);
|
||||
$this->assertCount(2, $userlist8);
|
||||
$expected = [
|
||||
$user1->id,
|
||||
$admin->id
|
||||
];
|
||||
$this->assertEquals($expected, $userlist8->get_userids(), '', 0.0, 10, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that data for users in approved userlist is deleted.
|
||||
*/
|
||||
public function test_delete_data_for_users() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$component = 'core_role';
|
||||
|
||||
$this->setAdminUser();
|
||||
$admin = \core_user::get_user_by_username('admin');
|
||||
// Create user1.
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
// Create user2.
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$usercontext2 = \context_user::instance($user2->id);
|
||||
// Create course1.
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
// Create course category.
|
||||
$coursecat = $this->getDataGenerator()->create_category();
|
||||
$coursecatcontext = \context_coursecat::instance($coursecat->id);
|
||||
// Create chat module.
|
||||
$cm = $this->getDataGenerator()->create_module('chat', ['course' => $course1->id]);
|
||||
$cmcontext = \context_module::instance($cm->cmid);
|
||||
|
||||
$systemcontext = \context_system::instance();
|
||||
// Create a block.
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
$blockcontext = \context_block::instance($block->id);
|
||||
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
$managerrole = $DB->get_record('role', array('shortname' => 'manager'), '*', MUST_EXIST);
|
||||
|
||||
// Role assignments CONTEXT_COURSE.
|
||||
role_assign($studentrole->id, $user1->id, $coursecontext1->id);
|
||||
role_assign($studentrole->id, $user2->id, $coursecontext1->id);
|
||||
// Role assignments CONTEXT_COURSECAT.
|
||||
role_assign($studentrole->id, $user2->id, $coursecatcontext->id);
|
||||
// Role assignments CONTEXT_SYSTEM.
|
||||
role_assign($studentrole->id, $user1->id, $systemcontext->id);
|
||||
// Role assignments CONTEXT_MODULE.
|
||||
role_assign($studentrole->id, $user2->id, $cmcontext->id);
|
||||
// Role assigments CONTEXT_BLOCK.
|
||||
role_assign($studentrole->id, $user1->id, $blockcontext->id);
|
||||
// Role assigments CONTEXT_USER.
|
||||
role_assign($managerrole->id, $user1->id, $usercontext2->id);
|
||||
|
||||
// Role capabilities.
|
||||
$this->setUser($user1);
|
||||
assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $studentrole->id, $cmcontext->id);
|
||||
|
||||
// The user list for usercontext2 should user1 and admin (role creator).
|
||||
$userlist1 = new \core_privacy\local\request\userlist($usercontext2, $component);
|
||||
provider::get_users_in_context($userlist1);
|
||||
$this->assertCount(2, $userlist1);
|
||||
// The user list for coursecontext1 should user1, user2 and admin (role creator).
|
||||
$userlist2 = new \core_privacy\local\request\userlist($coursecontext1, $component);
|
||||
provider::get_users_in_context($userlist2);
|
||||
$this->assertCount(3, $userlist2);
|
||||
// The user list for coursecatcontext should user2 and admin (role creator).
|
||||
$userlist3 = new \core_privacy\local\request\userlist($coursecatcontext, $component);
|
||||
provider::get_users_in_context($userlist3);
|
||||
$this->assertCount(2, $userlist3);
|
||||
// The user list for systemcontext should user1 and admin (role creator).
|
||||
$userlist4 = new \core_privacy\local\request\userlist($systemcontext, $component);
|
||||
provider::get_users_in_context($userlist4);
|
||||
$this->assertCount(2, $userlist4);
|
||||
// The user list for cmcontext should user1, user2 and admin (role creator).
|
||||
$userlist5 = new \core_privacy\local\request\userlist($cmcontext, $component);
|
||||
provider::get_users_in_context($userlist5);
|
||||
$this->assertCount(3, $userlist5);
|
||||
// The user list for blockcontext should user1 and admin (role creator).
|
||||
$userlist6 = new \core_privacy\local\request\userlist($blockcontext, $component);
|
||||
provider::get_users_in_context($userlist6);
|
||||
$this->assertCount(2, $userlist6);
|
||||
|
||||
// Convert $userlist1 into an approved_contextlist.
|
||||
$approvedlist1 = new approved_userlist($usercontext2, $component, $userlist1->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist1);
|
||||
// Re-fetch users in usercontext2.
|
||||
$userlist1 = new \core_privacy\local\request\userlist($usercontext2, $component);
|
||||
provider::get_users_in_context($userlist1);
|
||||
$this->assertCount(0, $userlist1);
|
||||
|
||||
// Convert $userlist2 into an approved_contextlist.
|
||||
$approvedlist2 = new approved_userlist($coursecontext1, $component, $userlist2->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist2);
|
||||
// Re-fetch users in coursecontext1.
|
||||
$userlist2 = new \core_privacy\local\request\userlist($coursecontext1, $component);
|
||||
provider::get_users_in_context($userlist2);
|
||||
$this->assertCount(0, $userlist2);
|
||||
|
||||
// Convert $userlist3 into an approved_contextlist.
|
||||
$approvedlist3 = new approved_userlist($coursecatcontext, $component, $userlist3->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist3);
|
||||
// Re-fetch users in coursecatcontext.
|
||||
$userlist3 = new \core_privacy\local\request\userlist($coursecatcontext, $component);
|
||||
provider::get_users_in_context($userlist3);
|
||||
$this->assertCount(0, $userlist3);
|
||||
|
||||
// Convert $userlist4 into an approved_contextlist.
|
||||
$approvedlist4 = new approved_userlist($systemcontext, $component, $userlist4->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist4);
|
||||
// Re-fetch users in systemcontext.
|
||||
$userlist4 = new \core_privacy\local\request\userlist($systemcontext, $component);
|
||||
provider::get_users_in_context($userlist4);
|
||||
// The data from role_capabilities should still be present. The user list should return the admin user.
|
||||
$this->assertCount(1, $userlist4);
|
||||
$expected = [$admin->id];
|
||||
$this->assertEquals($expected, $userlist4->get_userids());
|
||||
|
||||
// Convert $userlist5 into an approved_contextlist.
|
||||
$approvedlist5 = new approved_userlist($cmcontext, $component, $userlist5->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist5);
|
||||
// Re-fetch users in cmcontext.
|
||||
$userlist5 = new \core_privacy\local\request\userlist($cmcontext, $component);
|
||||
provider::get_users_in_context($userlist5);
|
||||
// The data from role_capabilities should still be present. The user list should return user1.
|
||||
$this->assertCount(1, $userlist5);
|
||||
$expected = [$user1->id];
|
||||
$this->assertEquals($expected, $userlist5->get_userids());
|
||||
|
||||
// Convert $userlist6 into an approved_contextlist.
|
||||
$approvedlist6 = new approved_userlist($blockcontext, $component, $userlist6->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist6);
|
||||
// Re-fetch users in blockcontext.
|
||||
$userlist6 = new \core_privacy\local\request\userlist($blockcontext, $component);
|
||||
provider::get_users_in_context($userlist6);
|
||||
$this->assertCount(0, $userlist6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supoort function to get all the localised roles name
|
||||
* in a simple array for testing.
|
||||
*
|
||||
* @return array Array of name of the roles by roleid.
|
||||
*/
|
||||
protected static function get_roles_name() {
|
||||
$roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
|
||||
$rolesnames = array();
|
||||
foreach ($roles as $role) {
|
||||
$rolesnames[$role->id] = $role->localname;
|
||||
}
|
||||
return $rolesnames;
|
||||
}
|
||||
}
|
||||
+107
-88
@@ -28,112 +28,113 @@ admin_externalpage_setup('searchareas');
|
||||
|
||||
$areaid = optional_param('areaid', null, PARAM_ALPHAEXT);
|
||||
$action = optional_param('action', null, PARAM_ALPHA);
|
||||
$indexingenabled = \core_search\manager::is_indexing_enabled(); // This restricts many of the actions on this page.
|
||||
|
||||
// Get a search manager instance, which we'll need for display and to handle some actions.
|
||||
try {
|
||||
$searchmanager = \core_search\manager::instance();
|
||||
} catch (core_search\engine_exception $searchmanagererror) {
|
||||
// In action cases, well throw this exception below. In non-action cases, we produce a lang string error.
|
||||
// Continue, we return an error later depending on the requested action.
|
||||
}
|
||||
|
||||
// Handle all the actions.
|
||||
if ($action) {
|
||||
require_sesskey();
|
||||
|
||||
// If dealing with an areaid, we need to check that the area exists.
|
||||
if ($areaid) {
|
||||
// We need to check that the area exists.
|
||||
$area = \core_search\manager::get_search_area($areaid);
|
||||
if ($area === false) {
|
||||
throw new moodle_exception('invalidrequest');
|
||||
}
|
||||
}
|
||||
|
||||
// All the indexing actions.
|
||||
if (in_array($action, ['delete', 'indexall', 'reindexall', 'deleteall'])) {
|
||||
|
||||
// All of these actions require that indexing is enabled.
|
||||
if ($indexingenabled) {
|
||||
|
||||
// For all of these actions, we strictly need a manager instance.
|
||||
if (isset($searchmanagererror)) {
|
||||
throw $searchmanagererror;
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
$searchmanager->delete_index($areaid);
|
||||
\core\notification::success(get_string('searchindexdeleted', 'admin'));
|
||||
break;
|
||||
case 'indexall':
|
||||
$searchmanager->index();
|
||||
\core\notification::success(get_string('searchindexupdated', 'admin'));
|
||||
break;
|
||||
case 'reindexall':
|
||||
$searchmanager->index(true);
|
||||
\core\notification::success(get_string('searchreindexed', 'admin'));
|
||||
break;
|
||||
case 'deleteall':
|
||||
$searchmanager->delete_index();
|
||||
\core\notification::success(get_string('searchalldeleted', 'admin'));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Redirect back to the main page after taking action.
|
||||
redirect(new moodle_url('/admin/searchareas.php'));
|
||||
}
|
||||
} else if (in_array($action, ['enable', 'disable'])) {
|
||||
switch ($action) {
|
||||
case 'enable':
|
||||
$area->set_enabled(true);
|
||||
\core\notification::success(get_string('searchareaenabled', 'admin'));
|
||||
break;
|
||||
case 'disable':
|
||||
$area->set_enabled(false);
|
||||
core\notification::success(get_string('searchareadisabled', 'admin'));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if ($action !== 'enable' && $action !== 'disable') {
|
||||
// All actions but enable/disable need the search engine to be ready.
|
||||
if (!empty($searchmanagererror)) {
|
||||
throw $searchmanagererror;
|
||||
}
|
||||
|
||||
redirect(new moodle_url('/admin/searchareas.php'));
|
||||
} else {
|
||||
// Invalid action.
|
||||
throw new moodle_exception('invalidaction');
|
||||
// Show confirm prompt for all these actions as they may be inadvisable, or may cause
|
||||
// an interruption in search functionality, on production systems.
|
||||
if (!optional_param('confirm', 0, PARAM_INT)) {
|
||||
// Display confirmation prompt.
|
||||
$a = null;
|
||||
if ($areaid) {
|
||||
$a = html_writer::tag('strong', $area->get_visible_name());
|
||||
}
|
||||
|
||||
$actionparams = ['sesskey' => sesskey(), 'action' => $action, 'confirm' => 1];
|
||||
if ($areaid) {
|
||||
$actionparams['areaid'] = $areaid;
|
||||
}
|
||||
$actionurl = new moodle_url('/admin/searchareas.php', $actionparams);
|
||||
$cancelurl = new moodle_url('/admin/searchareas.php');
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('confirm_' . $action, 'search', $a),
|
||||
new single_button($actionurl, get_string('continue'), 'post', true),
|
||||
new single_button($cancelurl, get_string('cancel'), 'get'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We are now taking an actual action, so require sesskey.
|
||||
require_sesskey();
|
||||
|
||||
// Display.
|
||||
if (isset($searchmanager) && $indexingenabled) {
|
||||
\core\notification::info(get_string('indexinginfo', 'admin'));
|
||||
} else if (isset($searchmanager)) {
|
||||
$params = (object) [
|
||||
'url' => (new moodle_url("/admin/settings.php?section=manageglobalsearch#admin-searchindexwhendisabled"))->out(false)
|
||||
];
|
||||
\core\notification::error(get_string('indexwhendisabledfullnotice', 'search', $params));
|
||||
} else {
|
||||
// In non-action cases, init errors are translated and displayed to the user as error notifications.
|
||||
$errorstr = get_string($searchmanagererror->errorcode, $searchmanagererror->module, $searchmanagererror->a);
|
||||
\core\notification::error($errorstr);
|
||||
switch ($action) {
|
||||
case 'enable':
|
||||
$area->set_enabled(true);
|
||||
\core\notification::add(get_string('searchareaenabled', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
|
||||
break;
|
||||
case 'disable':
|
||||
$area->set_enabled(false);
|
||||
\core\notification::add(get_string('searchareadisabled', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
|
||||
break;
|
||||
case 'delete':
|
||||
$search = \core_search\manager::instance();
|
||||
$search->delete_index($areaid);
|
||||
\core\notification::add(get_string('searchindexdeleted', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
|
||||
break;
|
||||
case 'indexall':
|
||||
$searchmanager->index();
|
||||
\core\notification::add(get_string('searchindexupdated', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
|
||||
break;
|
||||
case 'reindexall':
|
||||
$searchmanager->index(true);
|
||||
\core\notification::add(get_string('searchreindexed', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
|
||||
break;
|
||||
case 'deleteall':
|
||||
$searchmanager->delete_index();
|
||||
\core\notification::add(get_string('searchalldeleted', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
throw new moodle_exception('invalidaction');
|
||||
break;
|
||||
}
|
||||
|
||||
// Redirect back to the main page after taking action.
|
||||
redirect(new moodle_url('/admin/searchareas.php'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$searchareas = \core_search\manager::get_search_areas_list();
|
||||
if (empty($searchmanagererror)) {
|
||||
$areasconfig = $searchmanager->get_areas_config($searchareas);
|
||||
} else {
|
||||
$areasconfig = false;
|
||||
}
|
||||
|
||||
if (!empty($searchmanagererror)) {
|
||||
$errorstr = get_string($searchmanagererror->errorcode, $searchmanagererror->module, $searchmanagererror->a);
|
||||
echo $OUTPUT->notification($errorstr, \core\output\notification::NOTIFY_ERROR);
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('indexinginfo', 'admin'), \core\output\notification::NOTIFY_INFO);
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->id = 'core-search-areas';
|
||||
$table->head = [
|
||||
get_string('searcharea', 'search'),
|
||||
get_string('enable'),
|
||||
get_string('newestdocindexed', 'admin'),
|
||||
get_string('searchlastrun', 'admin'),
|
||||
get_string('searchindexactions', 'admin')
|
||||
];
|
||||
|
||||
$searchareas = \core_search\manager::get_search_areas_list();
|
||||
$areasconfig = isset($searchmanager) ? $searchmanager->get_areas_config($searchareas) : false;
|
||||
$table->head = array(get_string('searcharea', 'search'), get_string('enable'), get_string('newestdocindexed', 'admin'),
|
||||
get_string('searchlastrun', 'admin'), get_string('searchindexactions', 'admin'));
|
||||
|
||||
foreach ($searchareas as $area) {
|
||||
$areaid = $area->get_area_id();
|
||||
$columns = array(new html_table_cell($area->get_visible_name()));
|
||||
@@ -143,7 +144,7 @@ foreach ($searchareas as $area) {
|
||||
new pix_icon('t/hide', get_string('disable'), 'moodle', array('title' => '', 'class' => 'iconsmall')),
|
||||
null, array('title' => get_string('disable')));
|
||||
|
||||
if ($areasconfig && $indexingenabled) {
|
||||
if ($areasconfig) {
|
||||
$columns[] = $areasconfig[$areaid]->lastindexrun;
|
||||
|
||||
if ($areasconfig[$areaid]->indexingstart) {
|
||||
@@ -159,14 +160,20 @@ foreach ($searchareas as $area) {
|
||||
$laststatus = '';
|
||||
}
|
||||
$columns[] = $laststatus;
|
||||
$columns[] = html_writer::link(admin_searcharea_action_url('delete', $areaid), 'Delete index');
|
||||
$accesshide = html_writer::span($area->get_visible_name(), 'accesshide');
|
||||
$actions = [];
|
||||
$actions[] = $OUTPUT->pix_icon('t/delete', '') .
|
||||
html_writer::link(admin_searcharea_action_url('delete', $areaid),
|
||||
get_string('deleteindex', 'search', $accesshide));
|
||||
if ($area->supports_get_document_recordset()) {
|
||||
$actions[] = $OUTPUT->pix_icon('i/reload', '') . html_writer::link(
|
||||
new moodle_url('searchreindex.php', ['areaid' => $areaid]),
|
||||
get_string('gradualreindex', 'search', $accesshide));
|
||||
}
|
||||
$columns[] = html_writer::alist($actions, ['class' => 'unstyled list-unstyled']);
|
||||
|
||||
} else {
|
||||
if (!$areasconfig) {
|
||||
$blankrow = new html_table_cell(get_string('searchnotavailable', 'admin'));
|
||||
} else {
|
||||
$blankrow = new html_table_cell(get_string('indexwhendisabledshortnotice', 'search'));
|
||||
}
|
||||
$blankrow = new html_table_cell(get_string('searchnotavailable', 'admin'));
|
||||
$blankrow->colspan = 3;
|
||||
$columns[] = $blankrow;
|
||||
}
|
||||
@@ -185,7 +192,10 @@ foreach ($searchareas as $area) {
|
||||
}
|
||||
|
||||
// Cross-search area tasks.
|
||||
$options = (isset($searchmanager) && $indexingenabled) ? [] : ['disabled' => true];
|
||||
$options = array();
|
||||
if (!empty($searchmanagererror)) {
|
||||
$options['disabled'] = true;
|
||||
}
|
||||
echo $OUTPUT->box_start('search-areas-actions');
|
||||
echo $OUTPUT->single_button(admin_searcharea_action_url('indexall'), get_string('searchupdateindex', 'admin'), 'get', $options);
|
||||
echo $OUTPUT->single_button(admin_searcharea_action_url('reindexall'), get_string('searchreindexindex', 'admin'), 'get', $options);
|
||||
@@ -194,6 +204,12 @@ echo $OUTPUT->box_end();
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
if (empty($searchmanagererror)) {
|
||||
// Show information about queued index requests for specific contexts.
|
||||
$searchrenderer = $PAGE->get_renderer('core_search');
|
||||
echo $searchrenderer->render_index_requests_info($searchmanager->get_index_requests_info());
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
/**
|
||||
@@ -204,9 +220,12 @@ echo $OUTPUT->footer();
|
||||
* @return moodle_url
|
||||
*/
|
||||
function admin_searcharea_action_url($action, $areaid = false) {
|
||||
$params = array('action' => $action, 'sesskey' => sesskey());
|
||||
$params = array('action' => $action);
|
||||
if ($areaid) {
|
||||
$params['areaid'] = $areaid;
|
||||
}
|
||||
if ($action === 'disable' || $action === 'enable') {
|
||||
$params['sesskey'] = sesskey();
|
||||
}
|
||||
return new moodle_url('/admin/searchareas.php', $params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Adds a search area to the queue for indexing.
|
||||
*
|
||||
* @package core_search
|
||||
* @copyright 2017 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require(__DIR__ . '/../config.php');
|
||||
|
||||
// Check access.
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('searchareas', '', null, (new moodle_url('/admin/searchreindex.php'))->out(false));
|
||||
|
||||
// Get area parameter and check it exists.
|
||||
$areaid = required_param('areaid', PARAM_ALPHAEXT);
|
||||
$area = \core_search\manager::get_search_area($areaid);
|
||||
if ($area === false) {
|
||||
throw new moodle_exception('invalidrequest');
|
||||
}
|
||||
$areaname = $area->get_visible_name();
|
||||
|
||||
// Start page output.
|
||||
$heading = get_string('gradualreindex', 'search', '');
|
||||
$PAGE->set_title($PAGE->title . ': ' . $heading);
|
||||
$PAGE->navbar->add($heading);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($heading);
|
||||
|
||||
// If sesskey is supplied, actually carry out the action.
|
||||
if (optional_param('sesskey', '', PARAM_ALPHANUM)) {
|
||||
require_sesskey();
|
||||
|
||||
// Get all contexts for search area. This query can take time in large cases.
|
||||
\core_php_time_limit::raise(0);
|
||||
$contextiterator = $area->get_contexts_to_reindex();
|
||||
|
||||
$progress = new \core\progress\display_if_slow('');
|
||||
$progress->start_progress($areaname);
|
||||
|
||||
// Request reindexing for each context (with low priority).
|
||||
$count = 0;
|
||||
foreach ($contextiterator as $context) {
|
||||
\core_php_time_limit::raise(30);
|
||||
\core_search\manager::request_index($context, $area->get_area_id(),
|
||||
\core_search\manager::INDEX_PRIORITY_REINDEXING);
|
||||
$progress->progress();
|
||||
$count++;
|
||||
}
|
||||
|
||||
// Unset the iterator which should close the recordset (if there is one).
|
||||
unset($contextiterator);
|
||||
|
||||
$progress->end_progress();
|
||||
|
||||
$a = (object)['name' => html_writer::tag('strong', $areaname), 'count' => $count];
|
||||
echo $OUTPUT->box(get_string('gradualreindex_queued', 'search', $a));
|
||||
|
||||
echo $OUTPUT->continue_button(new moodle_url('/admin/searchareas.php'));
|
||||
} else {
|
||||
// Display confirmation prompt.
|
||||
echo $OUTPUT->confirm(get_string('gradualreindex_confirm', 'search', html_writer::tag('strong', $areaname)),
|
||||
new single_button(new moodle_url('/admin/searchreindex.php', ['areaid' => $areaid,
|
||||
'sesskey' => sesskey()]), get_string('continue'), 'post', true),
|
||||
new single_button(new moodle_url('/admin/searchareas.php'), get_string('cancel'), 'get'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
+1
-2
@@ -38,8 +38,7 @@ if (!($settingspage->check_access())) {
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
|
||||
// Form is submitted with changed settings. Do not want to execute when modifying a block.
|
||||
if ($data = data_submitted() and confirm_sesskey() and isset($data->action) and $data->action == 'save-settings') {
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$count = admin_write_settings($data);
|
||||
// Regardless of whether any setting change was written (a positive count), check validation errors for those that didn't.
|
||||
|
||||
@@ -22,6 +22,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserthemes', new lang_string('allowuserthemes', 'admin'), new lang_string('configallowuserthemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowcoursethemes', new lang_string('allowcoursethemes', 'admin'), new lang_string('configallowcoursethemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowcategorythemes', new lang_string('allowcategorythemes', 'admin'), new lang_string('configallowcategorythemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowcohortthemes', new lang_string('allowcohortthemes', 'admin'), new lang_string('configallowcohortthemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), new lang_string('configallowthemechangeonurl', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), new lang_string('configallowuserblockhiding', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('allowblockstodock', new lang_string('allowblockstodock', 'admin'), new lang_string('configallowblockstodock', 'admin'), 1));
|
||||
|
||||
@@ -14,6 +14,8 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('dndallowtextandlinks', new lang_string('dndallowtextandlinks', 'admin'), new lang_string('configdndallowtextandlinks', 'admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configexecutable('pathtosassc', new lang_string('pathtosassc', 'admin'), new lang_string('pathtosassc_help', 'admin'), ''));
|
||||
|
||||
$ADMIN->add('experimental', $temp);
|
||||
|
||||
// "debugging" settingpage
|
||||
@@ -28,9 +30,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$ADMIN->add('development', $temp);
|
||||
|
||||
// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
|
||||
$xhprofenabled = extension_loaded('tideways_xhprof');
|
||||
$xhprofenabled = $xhprofenabled || extension_loaded('tideways');
|
||||
$xhprofenabled = $xhprofenabled || extension_loaded('xhprof');
|
||||
$xhprofenabled = extension_loaded('xhprof') || extension_loaded('tideways');
|
||||
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'), 'moodle/site:config', !$xhprofenabled);
|
||||
// Main profiling switch.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
||||
|
||||
@@ -42,6 +42,9 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
// enable publishing in exports/imports
|
||||
$temp->add(new admin_setting_configcheckbox('gradepublishing', new lang_string('gradepublishing', 'grades'), new lang_string('gradepublishing_help', 'grades'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('grade_export_exportfeedback', new lang_string('exportfeedback', 'grades'),
|
||||
new lang_string('exportfeedback_desc', 'grades'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configselect('grade_export_displaytype', new lang_string('gradeexportdisplaytype', 'grades'),
|
||||
new lang_string('gradeexportdisplaytype_desc', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
|
||||
|
||||
|
||||
@@ -556,7 +556,7 @@ if ($hassiteconfig) {
|
||||
// Search engine selection.
|
||||
$temp->add(new admin_setting_heading('searchengineheading', new lang_string('searchengine', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configselect('searchengine',
|
||||
new lang_string('selectsearchengine', 'admin'), '', 'solr', $engines));
|
||||
new lang_string('selectsearchengine', 'admin'), '', 'simpledb', $engines));
|
||||
$temp->add(new admin_setting_heading('searchoptionsheading', new lang_string('searchoptions', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox('searchindexwhendisabled',
|
||||
new lang_string('searchindexwhendisabled', 'admin'), new lang_string('searchindexwhendisabled_desc', 'admin'),
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Adds privacy and policies links to admin tree.
|
||||
*
|
||||
* @package core_privacy
|
||||
* @copyright 2018 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($hassiteconfig) {
|
||||
// Privacy settings.
|
||||
$temp = new admin_settingpage('privacysettings', new lang_string('privacysettings', 'admin'));
|
||||
|
||||
$options = array(
|
||||
0 => get_string('no'),
|
||||
1 => get_string('yes')
|
||||
);
|
||||
$url = new moodle_url('/admin/settings.php?section=supportcontact');
|
||||
$url = $url->out();
|
||||
$setting = new admin_setting_configselect('agedigitalconsentverification',
|
||||
new lang_string('agedigitalconsentverification', 'admin'),
|
||||
new lang_string('agedigitalconsentverification_desc', 'admin', $url), 0, $options);
|
||||
$setting->set_force_ltr(true);
|
||||
$temp->add($setting);
|
||||
|
||||
$setting = new admin_setting_agedigitalconsentmap('agedigitalconsentmap',
|
||||
new lang_string('ageofdigitalconsentmap', 'admin'),
|
||||
new lang_string('ageofdigitalconsentmap_desc', 'admin'),
|
||||
// See {@link https://gdpr-info.eu/art-8-gdpr/}.
|
||||
implode(PHP_EOL, [
|
||||
'*, 16',
|
||||
'AT, 14',
|
||||
'CZ, 13',
|
||||
'DE, 14',
|
||||
'DK, 13',
|
||||
'ES, 13',
|
||||
'FI, 15',
|
||||
'GB, 13',
|
||||
'HU, 14',
|
||||
'IE, 13',
|
||||
'LT, 16',
|
||||
'LU, 16',
|
||||
'NL, 16',
|
||||
'PL, 13',
|
||||
'SE, 13',
|
||||
]),
|
||||
PARAM_RAW
|
||||
);
|
||||
$temp->add($setting);
|
||||
|
||||
$ADMIN->add('privacy', $temp);
|
||||
|
||||
// Policy settings.
|
||||
$temp = new admin_settingpage('policysettings', new lang_string('policysettings', 'admin'));
|
||||
$temp->add(new admin_settings_sitepolicy_handler_select('sitepolicyhandler', new lang_string('sitepolicyhandler', 'core_admin'),
|
||||
new lang_string('sitepolicyhandler_desc', 'core_admin')));
|
||||
$temp->add(new admin_setting_configtext('sitepolicy', new lang_string('sitepolicy', 'core_admin'),
|
||||
new lang_string('sitepolicy_help', 'core_admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sitepolicyguest', new lang_string('sitepolicyguest', 'core_admin'),
|
||||
new lang_string('sitepolicyguest_help', 'core_admin'), (isset($CFG->sitepolicy) ? $CFG->sitepolicy : ''), PARAM_RAW));
|
||||
|
||||
$ADMIN->add('privacy', $temp);
|
||||
}
|
||||
@@ -43,6 +43,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configtext('userquota', new lang_string('userquota', 'admin'),
|
||||
new lang_string('configuserquota', 'admin', $params), $defaultuserquota, PARAM_INT, 30));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('forceclean', new lang_string('forceclean', 'core_admin'),
|
||||
new lang_string('forceclean_desc', 'core_admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('allowobjectembed', new lang_string('allowobjectembed', 'admin'), new lang_string('configallowobjectembed', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('enabletrusttext', new lang_string('enabletrusttext', 'admin'), new lang_string('configenabletrusttext', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configselect('maxeditingtime', new lang_string('maxeditingtime','admin'), new lang_string('configmaxeditingtime','admin'), 1800,
|
||||
|
||||
@@ -29,6 +29,7 @@ $ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empt
|
||||
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
|
||||
$ADMIN->add('root', new admin_category('language', new lang_string('language')));
|
||||
$ADMIN->add('root', new admin_category('modules', new lang_string('plugins', 'admin')));
|
||||
$ADMIN->add('root', new admin_category('privacy', new lang_string('privacyandpolicies', 'admin')));
|
||||
$ADMIN->add('root', new admin_category('security', new lang_string('security','admin')));
|
||||
$ADMIN->add('root', new admin_category('appearance', new lang_string('appearance','admin')));
|
||||
$ADMIN->add('root', new admin_category('frontpage', new lang_string('frontpage','admin')));
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
$ADMIN->add('users', new admin_category('accounts', new lang_string('accounts', 'admin')));
|
||||
$ADMIN->add('users', new admin_category('roles', new lang_string('permissions', 'role')));
|
||||
$ADMIN->add('users', new admin_category('privacy', new lang_string('privacyandpolicies', 'admin')));
|
||||
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/user:create', $systemcontext)
|
||||
@@ -29,7 +28,7 @@ if ($hassiteconfig
|
||||
$choices['1'] = new lang_string('emaildisplayyes');
|
||||
$choices['2'] = new lang_string('emaildisplaycourse');
|
||||
$temp->add(new admin_setting_configselect('defaultpreference_maildisplay', new lang_string('emaildisplay'),
|
||||
'', 2, $choices));
|
||||
new lang_string('emaildisplay_help'), 2, $choices));
|
||||
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('textformat');
|
||||
@@ -151,6 +150,7 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configmultiselect('hiddenuserfields', new lang_string('hiddenuserfields', 'admin'),
|
||||
new lang_string('confighiddenuserfields', 'admin'), array(),
|
||||
array('description' => new lang_string('description'),
|
||||
'email' => new lang_string('email'),
|
||||
'city' => new lang_string('city'),
|
||||
'country' => new lang_string('country'),
|
||||
'timezone' => new lang_string('timezone'),
|
||||
@@ -210,48 +210,3 @@ if ($hassiteconfig
|
||||
$ADMIN->add('roles', new admin_externalpage('checkpermissions', new lang_string('checkglobalpermissions', 'role'), "$CFG->wwwroot/$CFG->admin/roles/check.php?contextid=".$systemcontext->id, array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage')));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
// Privacy settings.
|
||||
if ($hassiteconfig) {
|
||||
$temp = new admin_settingpage('privacysettings', new lang_string('privacysettings', 'admin'));
|
||||
|
||||
$options = array(
|
||||
0 => get_string('no'),
|
||||
1 => get_string('yes')
|
||||
);
|
||||
$url = new moodle_url('/admin/settings.php?section=supportcontact');
|
||||
$url = $url->out();
|
||||
$setting = new admin_setting_configselect('agedigitalconsentverification',
|
||||
new lang_string('agedigitalconsentverification', 'admin'),
|
||||
new lang_string('agedigitalconsentverification_desc', 'admin', $url), 0, $options);
|
||||
$setting->set_force_ltr(true);
|
||||
$temp->add($setting);
|
||||
|
||||
// See {@link https://gdpr-info.eu/art-8-gdpr/}.
|
||||
$ageofdigitalconsentmap = implode(PHP_EOL, [
|
||||
'*, 16',
|
||||
'AT, 14',
|
||||
'ES, 14',
|
||||
'US, 13'
|
||||
]);
|
||||
$setting = new admin_setting_agedigitalconsentmap('agedigitalconsentmap',
|
||||
new lang_string('ageofdigitalconsentmap', 'admin'),
|
||||
new lang_string('ageofdigitalconsentmap_desc', 'admin'),
|
||||
$ageofdigitalconsentmap,
|
||||
PARAM_RAW
|
||||
);
|
||||
$temp->add($setting);
|
||||
|
||||
$ADMIN->add('privacy', $temp);
|
||||
|
||||
// Policy settings.
|
||||
$temp = new admin_settingpage('policysettings', new lang_string('policysettings', 'admin'));
|
||||
$temp->add(new admin_settings_sitepolicy_handler_select('sitepolicyhandler', new lang_string('sitepolicyhandler', 'core_admin'),
|
||||
new lang_string('sitepolicyhandler_desc', 'core_admin')));
|
||||
$temp->add(new admin_setting_configtext('sitepolicy', new lang_string('sitepolicy', 'core_admin'),
|
||||
new lang_string('sitepolicy_help', 'core_admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sitepolicyguest', new lang_string('sitepolicyguest', 'core_admin'),
|
||||
new lang_string('sitepolicyguest_help', 'core_admin'), (isset($CFG->sitepolicy) ? $CFG->sitepolicy : ''), PARAM_RAW));
|
||||
|
||||
$ADMIN->add('privacy', $temp);
|
||||
}
|
||||
@@ -40,7 +40,6 @@
|
||||
<div class="settingsform clearfix">
|
||||
{{#params}}
|
||||
<input type="hidden" name="{{name}}" value="{{value}}">
|
||||
<input type="hidden" name="action" value="save-settings">
|
||||
{{/params}}
|
||||
<input type="hidden" name="sesskey" value="{{sesskey}}">
|
||||
<input type="hidden" name="return" value="{{return}}">
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
@core @core_admin
|
||||
Feature: Use the search areas admin screen
|
||||
In order to control search indexing
|
||||
As an admin
|
||||
I need to use the search areas admin screen
|
||||
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Plugins > Search > Search areas" in site administration
|
||||
|
||||
Scenario: Disable and enable a search area
|
||||
When I click on "Disable" "link" in the "Book - resource information" "table_row"
|
||||
Then I should see "Search area disabled" in the ".alert-success" "css_element"
|
||||
And I should see "Search area disabled" in the "Book - resource information" "table_row"
|
||||
|
||||
When I click on "Enable" "link" in the "Book - resource information" "table_row"
|
||||
Then I should see "Search area enabled" in the ".alert-success" "css_element"
|
||||
And I should not see "Search area disabled" in the "Book - resource information" "table_row"
|
||||
|
||||
# Note: Other scenarios are not currently easy to implement in Behat because there is no mock
|
||||
# search engine - we could add testing once Moodle has an internal database search engine.
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Helper class that contains helper functions for cli scripts.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_analytics;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Helper class that contains helper functions for cli scripts.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class clihelper {
|
||||
|
||||
/**
|
||||
* List all models in the system. To be used from cli scripts.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function list_models() {
|
||||
cli_heading("List of models");
|
||||
echo str_pad(get_string('modelid', 'tool_analytics'), 15, ' ') . ' ' . str_pad(get_string('name'), 50, ' ') .
|
||||
' ' . str_pad(get_string('status'), 15, ' ') . "\n";
|
||||
$models = \core_analytics\manager::get_all_models();
|
||||
foreach ($models as $model) {
|
||||
$modelid = $model->get_id();
|
||||
$isenabled = $model->is_enabled() ? get_string('enabled', 'tool_analytics') : get_string('disabled', 'tool_analytics');
|
||||
$name = $model->get_target()->get_name();
|
||||
echo str_pad($modelid, 15, ' ') . ' ' . str_pad($name, 50, ' ') . ' ' . str_pad($isenabled, 15, ' ') . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ $help = "Enables the provided model.
|
||||
|
||||
Options:
|
||||
--modelid Model id
|
||||
--list List models
|
||||
--timesplitting Time splitting method full class name
|
||||
-h, --help Print out this help
|
||||
|
||||
@@ -42,6 +43,7 @@ Example:
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
'list' => false,
|
||||
'modelid' => false,
|
||||
'timesplitting' => false
|
||||
),
|
||||
@@ -55,7 +57,12 @@ if ($options['help']) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['modelid'] === false || $options['timesplitting'] === false) {
|
||||
if ($options['list'] || $options['modelid'] === false) {
|
||||
\tool_analytics\clihelper::list_models();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['timesplitting'] === false) {
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ $help = "Evaluates the provided model.
|
||||
|
||||
Options:
|
||||
--modelid Model id
|
||||
--list List models
|
||||
--non-interactive Not interactive questions
|
||||
--timesplitting Restrict the evaluation to 1 single time splitting method (Optional)
|
||||
--filter Analyser dependant. e.g. A courseid would evaluate the model using a single course (Optional)
|
||||
@@ -47,6 +48,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
'modelid' => false,
|
||||
'list' => false,
|
||||
'timesplitting' => false,
|
||||
'reuse-prev-analysed' => true,
|
||||
'non-interactive' => false,
|
||||
@@ -62,8 +64,8 @@ if ($options['help']) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['modelid'] === false) {
|
||||
echo $help;
|
||||
if ($options['list'] || $options['modelid'] === false) {
|
||||
\tool_analytics\clihelper::list_models();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ $string['clearmodelpredictions'] = 'Are you sure you want to clear all "{$a}" pr
|
||||
$string['clienablemodel'] = 'You can enable the model by selecting a time-splitting method by its ID. Note that you can also enable it later using the web interface (\'none\' to exit).';
|
||||
$string['clievaluationandpredictions'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. You can allow these processes to be executed manually via the web interface by disabling the <a href="{$a}">\'onlycli\'</a> analytics setting.';
|
||||
$string['clievaluationandpredictionsnoadmin'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. It may be enabled by a site administrator.';
|
||||
$string['disabled'] = 'Disabled';
|
||||
$string['editmodel'] = 'Edit "{$a}" model';
|
||||
$string['edittrainedwarning'] = 'This model has already been trained. Note that changing its indicators or its time-splitting method will delete its previous predictions and start generating new predictions.';
|
||||
$string['enabled'] = 'Enabled';
|
||||
@@ -66,6 +67,7 @@ $string['invalidanalysablestable'] = 'Invalid site analysable elements table';
|
||||
$string['invalidprediction'] = 'Invalid to get predictions';
|
||||
$string['invalidtraining'] = 'Invalid to train the model';
|
||||
$string['loginfo'] = 'Log extra info';
|
||||
$string['modelid'] = 'Model ID';
|
||||
$string['modelinvalidanalysables'] = 'Invalid analysable elements for "{$a}" model';
|
||||
$string['modelresults'] = '{$a} results';
|
||||
$string['modeltimesplitting'] = 'Time splitting';
|
||||
|
||||
@@ -23,29 +23,29 @@
|
||||
*/
|
||||
|
||||
$string['aim'] = 'This administration tool helps developers and test writers to create .feature files describing Moodle\'s functionalities and run them automatically. Step definitions available for use in .feature files are listed below.';
|
||||
$string['allavailablesteps'] = 'All available step definitions';
|
||||
$string['allavailablesteps'] = 'All the available steps definitions';
|
||||
$string['errorbehatcommand'] = 'Error running behat CLI command. Try running "{$a} --help" manually from CLI to find out more about the problem.';
|
||||
$string['errorcomposer'] = 'Composer dependencies are not installed.';
|
||||
$string['errordataroot'] = '$CFG->behat_dataroot is not set or is invalid.';
|
||||
$string['errorsetconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot need to be set in config.php.';
|
||||
$string['erroruniqueconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot values need to be different than $CFG->dataroot, $CFG->prefix, $CFG->wwwroot, $CFG->phpunit_dataroot and $CFG->phpunit_prefix values.';
|
||||
$string['fieldvalueargument'] = 'Field value arguments';
|
||||
$string['fieldvalueargument_help'] = 'This argument should be completed by a field value. There are many field types, including simple ones like checkboxes, selects or textareas, or complex ones like date selectors. See the dev documentation <a href="http://docs.moodle.org/dev/Acceptance_testing" target="_blank">Acceptance_testing</a> for details of expected field values.';
|
||||
$string['fieldvalueargument_help'] = 'This argument should be completed by a field value, there are many field types, simple ones like checkboxes, selects or textareas or complex ones like date selectors. You can check <a href="http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps" target="_blank">Field values</a> to see the expected field value depending on the field type you provide.';
|
||||
$string['giveninfo'] = 'Given. Processes to set up the environment';
|
||||
$string['infoheading'] = 'Info';
|
||||
$string['installinfo'] = 'Read {$a} for installation and tests execution info';
|
||||
$string['newstepsinfo'] = 'Read {$a} for info about how to add new step definitions';
|
||||
$string['newstepsinfo'] = 'Read {$a} for info about how to add new steps definitions';
|
||||
$string['newtestsinfo'] = 'Read {$a} for info about how to write new tests';
|
||||
$string['nostepsdefinitions'] = 'There aren\'t any step definitions matching this filter';
|
||||
$string['nostepsdefinitions'] = 'There aren\'t steps definitions matching this filters';
|
||||
$string['pluginname'] = 'Acceptance testing';
|
||||
$string['stepsdefinitionscomponent'] = 'Area';
|
||||
$string['stepsdefinitionscontains'] = 'Contains';
|
||||
$string['stepsdefinitionsfilters'] = 'Step definitions';
|
||||
$string['stepsdefinitionsfilters'] = 'Steps definitions';
|
||||
$string['stepsdefinitionstype'] = 'Type';
|
||||
$string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones';
|
||||
$string['unknownexceptioninfo'] = 'There was a problem with Selenium or your browser. Please ensure you are using the latest version of Selenium. Error:';
|
||||
$string['viewsteps'] = 'Filter';
|
||||
$string['wheninfo'] = 'When. Action that provokes an event';
|
||||
$string['wheninfo'] = 'When. Actions that provokes an event';
|
||||
$string['wrongbehatsetup'] = 'Something is wrong with the behat setup and so step definitions cannot be listed: <b>{$a->errormsg}</b><br/><br/>Please check:<ul>
|
||||
<li>$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot are set in config.php with different values from $CFG->dataroot, $CFG->prefix and $CFG->wwwroot.</li>
|
||||
<li>You ran "{$a->behatinit}" from your Moodle root directory.</li>
|
||||
|
||||
@@ -139,7 +139,7 @@ class tool_behat_renderer extends plugin_renderer_base {
|
||||
$msg = get_string('wrongbehatsetup', 'tool_behat', $a);
|
||||
|
||||
// Error box including generic error string + specific error msg.
|
||||
$html .= $this->output->box_start('box errorbox');
|
||||
$html .= $this->output->box_start('box errorbox alert alert-danger');
|
||||
$html .= html_writer::tag('div', $msg);
|
||||
$html .= $this->output->box_end();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Feature: List the system steps definitions
|
||||
|
||||
@javascript
|
||||
Scenario: Accessing the list
|
||||
Then I should see "Step definitions"
|
||||
Then I should see "Steps definitions"
|
||||
And I should not see "There aren't steps definitions matching this filter"
|
||||
|
||||
@javascript
|
||||
|
||||
@@ -94,7 +94,8 @@ class cohort_role_assignments_table extends table_sql {
|
||||
'idnumber' => $data->cohortidnumber,
|
||||
'description' => $data->cohortdescription,
|
||||
'visible' => $data->cohortvisible,
|
||||
'name' => $data->cohortname
|
||||
'name' => $data->cohortname,
|
||||
'theme' => $data->cohorttheme
|
||||
);
|
||||
$context = context_helper::instance_by_id($data->cohortcontextid);
|
||||
|
||||
@@ -169,7 +170,7 @@ class cohort_role_assignments_table extends table_sql {
|
||||
protected function get_sql_and_params($count = false) {
|
||||
$fields = 'uca.id, uca.cohortid, uca.userid, uca.roleid, ';
|
||||
$fields .= 'c.name as cohortname, c.idnumber as cohortidnumber, c.contextid as cohortcontextid, ';
|
||||
$fields .= 'c.visible as cohortvisible, c.description as cohortdescription, ';
|
||||
$fields .= 'c.visible as cohortvisible, c.description as cohortdescription, c.theme as cohorttheme, ';
|
||||
|
||||
// Add extra user fields that we need for the graded user.
|
||||
$extrafields = get_extra_user_fields($this->context);
|
||||
|
||||
@@ -1,328 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Privacy Subsystem implementation for tool_cohortroles.
|
||||
*
|
||||
* @package tool_cohortroles
|
||||
* @copyright 2018 Zig Tan <zig@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_cohortroles\privacy;
|
||||
|
||||
use core_privacy\local\metadata\collection;
|
||||
use core_privacy\local\request\approved_contextlist;
|
||||
use core_privacy\local\request\context;
|
||||
use core_privacy\local\request\contextlist;
|
||||
use core_privacy\local\request\transform;
|
||||
use core_privacy\local\request\writer;
|
||||
use core_privacy\local\request\userlist;
|
||||
use \core_privacy\local\request\approved_userlist;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Privacy Subsystem for tool_cohortroles implementing metadata and plugin providers.
|
||||
*
|
||||
* @copyright 2018 Zig Tan <zig@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements
|
||||
\core_privacy\local\metadata\provider,
|
||||
\core_privacy\local\request\core_userlist_provider,
|
||||
\core_privacy\local\request\plugin\provider {
|
||||
|
||||
/**
|
||||
* Returns meta data about this system.
|
||||
*
|
||||
* @param collection $collection The initialised collection to add items to.
|
||||
* @return collection A listing of user data stored through this system.
|
||||
*/
|
||||
public static function get_metadata(collection $collection) : collection {
|
||||
// The tool_cohortroles plugin utilises the mdl_tool_cohortroles table.
|
||||
$collection->add_database_table(
|
||||
'tool_cohortroles',
|
||||
[
|
||||
'id' => 'privacy:metadata:tool_cohortroles:id',
|
||||
'cohortid' => 'privacy:metadata:tool_cohortroles:cohortid',
|
||||
'roleid' => 'privacy:metadata:tool_cohortroles:roleid',
|
||||
'userid' => 'privacy:metadata:tool_cohortroles:userid',
|
||||
'timecreated' => 'privacy:metadata:tool_cohortroles:timecreated',
|
||||
'timemodified' => 'privacy:metadata:tool_cohortroles:timemodified',
|
||||
'usermodified' => 'privacy:metadata:tool_cohortroles:usermodified'
|
||||
],
|
||||
'privacy:metadata:tool_cohortroles'
|
||||
);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of contexts that contain user information for the specified user.
|
||||
*
|
||||
* @param int $userid The user to search.
|
||||
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
|
||||
*/
|
||||
public static function get_contexts_for_userid(int $userid) : contextlist {
|
||||
$contextlist = new contextlist();
|
||||
|
||||
// When we process user deletions and expiries, we always delete from the user context.
|
||||
// As a result the cohort role assignments would be deleted, which has a knock-on effect with courses
|
||||
// as roles may change and data may be removed earlier than it should be.
|
||||
|
||||
// Retrieve the context associated with tool_cohortroles records.
|
||||
$sql = "SELECT DISTINCT c.contextid
|
||||
FROM {tool_cohortroles} tc
|
||||
JOIN {cohort} c
|
||||
ON tc.cohortid = c.id
|
||||
JOIN {context} ctx
|
||||
ON ctx.id = c.contextid
|
||||
WHERE tc.userid = :userid
|
||||
AND (ctx.contextlevel = :contextlevel1
|
||||
OR ctx.contextlevel = :contextlevel2)";
|
||||
|
||||
$params = [
|
||||
'userid' => $userid,
|
||||
'contextlevel1' => CONTEXT_SYSTEM,
|
||||
'contextlevel2' => CONTEXT_COURSECAT
|
||||
];
|
||||
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
|
||||
return $contextlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of users within a specific context.
|
||||
*
|
||||
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
|
||||
*/
|
||||
public static function get_users_in_context(userlist $userlist) {
|
||||
$context = $userlist->get_context();
|
||||
|
||||
// When we process user deletions and expiries, we always delete from the user context.
|
||||
// As a result the cohort role assignments would be deleted, which has a knock-on effect with courses
|
||||
// as roles may change and data may be removed earlier than it should be.
|
||||
|
||||
$allowedcontextlevels = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_COURSECAT
|
||||
];
|
||||
|
||||
if (!in_array($context->contextlevel, $allowedcontextlevels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = "SELECT tc.userid as userid
|
||||
FROM {tool_cohortroles} tc
|
||||
JOIN {cohort} c
|
||||
ON tc.cohortid = c.id
|
||||
WHERE c.contextid = :contextid";
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The approved contexts to export information for.
|
||||
*/
|
||||
public static function export_user_data(approved_contextlist $contextlist) {
|
||||
global $DB;
|
||||
|
||||
// Remove contexts different from SYSTEM or COURSECAT.
|
||||
$contextids = array_reduce($contextlist->get_contexts(), function($carry, $context) {
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM || $context->contextlevel == CONTEXT_COURSECAT) {
|
||||
$carry[] = $context->id;
|
||||
}
|
||||
return $carry;
|
||||
}, []);
|
||||
|
||||
if (empty($contextids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userid = $contextlist->get_user()->id;
|
||||
|
||||
list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
|
||||
|
||||
// Retrieve the tool_cohortroles records created for the user.
|
||||
$sql = "SELECT cr.id as cohortroleid,
|
||||
c.name as cohortname,
|
||||
c.idnumber as cohortidnumber,
|
||||
c.description as cohortdescription,
|
||||
c.contextid as contextid,
|
||||
r.shortname as roleshortname,
|
||||
cr.userid as userid,
|
||||
cr.timecreated as timecreated,
|
||||
cr.timemodified as timemodified
|
||||
FROM {tool_cohortroles} cr
|
||||
JOIN {cohort} c ON c.id = cr.cohortid
|
||||
JOIN {role} r ON r.id = cr.roleid
|
||||
WHERE cr.userid = :userid
|
||||
AND c.contextid {$contextsql}";
|
||||
|
||||
$params = ['userid' => $userid] + $contextparams;
|
||||
|
||||
$cohortroles = $DB->get_records_sql($sql, $params);
|
||||
|
||||
foreach ($cohortroles as $cohortrole) {
|
||||
// The tool_cohortroles data export is organised in:
|
||||
// {User Context}/Cohort roles management/{cohort name}/{role shortname}/data.json.
|
||||
$subcontext = [
|
||||
get_string('pluginname', 'tool_cohortroles'),
|
||||
$cohortrole->cohortname,
|
||||
$cohortrole->roleshortname
|
||||
];
|
||||
|
||||
$data = (object) [
|
||||
'cohortname' => $cohortrole->cohortname,
|
||||
'cohortidnumber' => $cohortrole->cohortidnumber,
|
||||
'cohortdescription' => $cohortrole->cohortdescription,
|
||||
'roleshortname' => $cohortrole->roleshortname,
|
||||
'userid' => transform::user($cohortrole->userid),
|
||||
'timecreated' => transform::datetime($cohortrole->timecreated),
|
||||
'timemodified' => transform::datetime($cohortrole->timemodified)
|
||||
];
|
||||
|
||||
$context = \context::instance_by_id($cohortrole->contextid);
|
||||
|
||||
writer::with_context($context)->export_data($subcontext, $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data for all users in the specified context.
|
||||
*
|
||||
* @param context $context The specific context to delete data for.
|
||||
*/
|
||||
public static function delete_data_for_all_users_in_context(\context $context) {
|
||||
global $DB;
|
||||
|
||||
// When we process user deletions and expiries, we always delete from the user context.
|
||||
// As a result the cohort role assignments would be deleted, which has a knock-on effect with courses
|
||||
// as roles may change and data may be removed earlier than it should be.
|
||||
|
||||
$allowedcontextlevels = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_COURSECAT
|
||||
];
|
||||
|
||||
if (!in_array($context->contextlevel, $allowedcontextlevels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cohortids = $DB->get_fieldset_select('cohort', 'id', 'contextid = :contextid',
|
||||
['contextid' => $context->id]);
|
||||
|
||||
// Delete the tool_cohortroles records created in the specific context.
|
||||
$DB->delete_records_list('tool_cohortroles', 'cohortid', $cohortids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple users within a single context.
|
||||
*
|
||||
* @param approved_userlist $userlist The approved context and user information to delete information for.
|
||||
*/
|
||||
public static function delete_data_for_users(approved_userlist $userlist) {
|
||||
global $DB;
|
||||
|
||||
// When we process user deletions and expiries, we always delete from the user context.
|
||||
// As a result the cohort role assignments would be deleted, which has a knock-on effect with courses
|
||||
// as roles may change and data may be removed earlier than it should be.
|
||||
|
||||
$userids = $userlist->get_userids();
|
||||
|
||||
if (empty($userids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $userlist->get_context();
|
||||
|
||||
$allowedcontextlevels = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_COURSECAT
|
||||
];
|
||||
|
||||
if (!in_array($context->contextlevel, $allowedcontextlevels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cohortids = $DB->get_fieldset_select('cohort', 'id', 'contextid = :contextid',
|
||||
['contextid' => $context->id]);
|
||||
|
||||
if (empty($cohortids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
list($cohortsql, $cohortparams) = $DB->get_in_or_equal($cohortids, SQL_PARAMS_NAMED);
|
||||
list($usersql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
|
||||
|
||||
$params = $cohortparams + $userparams;
|
||||
$select = "cohortid {$cohortsql} AND userid {$usersql}";
|
||||
|
||||
// Delete the tool_cohortroles records created in the specific context for an approved list of users.
|
||||
$DB->delete_records_select('tool_cohortroles', $select, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
|
||||
*/
|
||||
public static function delete_data_for_user(approved_contextlist $contextlist) {
|
||||
global $DB;
|
||||
|
||||
// When we process user deletions and expiries, we always delete from the user context.
|
||||
// As a result the cohort role assignments would be deleted, which has a knock-on effect with courses
|
||||
// as roles may change and data may be removed earlier than it should be.
|
||||
|
||||
// Remove contexts different from SYSTEM or COURSECAT.
|
||||
$contextids = array_reduce($contextlist->get_contexts(), function($carry, $context) {
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM || $context->contextlevel == CONTEXT_COURSECAT) {
|
||||
$carry[] = $context->id;
|
||||
}
|
||||
return $carry;
|
||||
}, []);
|
||||
|
||||
if (empty($contextids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userid = $contextlist->get_user()->id;
|
||||
|
||||
list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
|
||||
$selectcontext = "contextid {$contextsql}";
|
||||
// Get the cohorts in the specified contexts.
|
||||
$cohortids = $DB->get_fieldset_select('cohort', 'id', $selectcontext, $contextparams);
|
||||
|
||||
if (empty($cohortids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
list($cohortsql, $cohortparams) = $DB->get_in_or_equal($cohortids, SQL_PARAMS_NAMED);
|
||||
$selectcohort = "cohortid {$cohortsql} AND userid = :userid";
|
||||
$params = ['userid' => $userid] + $cohortparams;
|
||||
|
||||
// Delete the tool_cohortroles records created for the userid.
|
||||
$DB->delete_records_select('tool_cohortroles', $selectcohort, $params);
|
||||
}
|
||||
}
|
||||
@@ -42,11 +42,3 @@ $string['selectrole'] = 'Select role';
|
||||
$string['selectusers'] = 'Select users to assign role';
|
||||
$string['taskname'] = 'Sync cohort role assignments';
|
||||
$string['thisuserroles'] = 'Roles assigned relative to this user';
|
||||
$string['privacy:metadata:tool_cohortroles'] = 'The Cohort roles management plugin stores user cohort role mappings.';
|
||||
$string['privacy:metadata:tool_cohortroles:id'] = 'The ID of the cohort role mapping record';
|
||||
$string['privacy:metadata:tool_cohortroles:cohortid'] = 'The ID of the cohort';
|
||||
$string['privacy:metadata:tool_cohortroles:roleid'] = 'The ID of the role';
|
||||
$string['privacy:metadata:tool_cohortroles:userid'] = 'The ID of the user';
|
||||
$string['privacy:metadata:tool_cohortroles:timecreated'] = 'The time when the cohort role mapping was created';
|
||||
$string['privacy:metadata:tool_cohortroles:timemodified'] = 'The time when the cohort role mapping was modified';
|
||||
$string['privacy:metadata:tool_cohortroles:usermodified'] = 'The ID of the user who last modified the cohort role mapping';
|
||||
|
||||
@@ -31,13 +31,15 @@
|
||||
* idnumber cohort idnumber field
|
||||
* description cohort description field
|
||||
* visible cohort visible field
|
||||
* theme cohort theme field
|
||||
|
||||
Example context (json):
|
||||
{ "id": "1",
|
||||
"name": "Cohort 1",
|
||||
"visible": true,
|
||||
"idnumber": "014",
|
||||
"description": "Some users"
|
||||
"description": "Some users",
|
||||
"theme": "clean"
|
||||
}
|
||||
}}
|
||||
{{> tool_lp/form-cohort-selector-suggestion }}
|
||||
|
||||
@@ -1,379 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the tool_cohortroles implementation of the privacy API.
|
||||
*
|
||||
* @package tool_cohortroles
|
||||
* @category test
|
||||
* @copyright 2018 Zig Tan <zig@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
|
||||
use \core_privacy\local\request\writer;
|
||||
use \core_privacy\local\request\approved_contextlist;
|
||||
use \tool_cohortroles\api;
|
||||
use \tool_cohortroles\privacy\provider;
|
||||
use core_privacy\local\request\approved_userlist;
|
||||
|
||||
/**
|
||||
* Unit tests for the tool_cohortroles implementation of the privacy API.
|
||||
*
|
||||
* @copyright 2018 Zig Tan <zig@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_testcase {
|
||||
|
||||
/**
|
||||
* Overriding setUp() function to always reset after tests.
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->resetAfterTest(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::get_contexts_for_userid().
|
||||
*/
|
||||
public function test_get_contexts_for_userid() {
|
||||
global $DB;
|
||||
|
||||
// Test setup.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create course category.
|
||||
$coursecategory = $this->getDataGenerator()->create_category();
|
||||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id);
|
||||
$systemctx = context_system::instance();
|
||||
// Create course.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursectx = \context_course::instance($course->id);
|
||||
|
||||
$this->setup_test_scenario_data($user->id, $systemctx, 1);
|
||||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
|
||||
'sausageroll2');
|
||||
$this->setup_test_scenario_data($user->id, $coursectx, 1, 'Sausage roll 3',
|
||||
'sausageroll3');
|
||||
|
||||
// Test the User's assigned cohortroles matches 3.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(3, $cohortroles);
|
||||
|
||||
// Test the User's retrieved contextlist returns only the system and course category context.
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$contexts = $contextlist->get_contexts();
|
||||
$this->assertCount(2, $contexts);
|
||||
|
||||
$contextlevels = array_column($contexts, 'contextlevel');
|
||||
$expected = [
|
||||
CONTEXT_SYSTEM,
|
||||
CONTEXT_COURSECAT
|
||||
];
|
||||
// Test the User's contexts equal the system and course category context.
|
||||
$this->assertEquals($expected, $contextlevels, '', 0, 10, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::export_user_data().
|
||||
*/
|
||||
public function test_export_user_data() {
|
||||
// Test setup.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create course category.
|
||||
$coursecategory = $this->getDataGenerator()->create_category();
|
||||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id);
|
||||
$systemctx = context_system::instance();
|
||||
// Create course.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursectx = \context_course::instance($course->id);
|
||||
|
||||
$this->setup_test_scenario_data($user->id, $systemctx, 1);
|
||||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
|
||||
'sausageroll2');
|
||||
$this->setup_test_scenario_data($user->id, $coursectx, 1, 'Sausage roll 3',
|
||||
'sausageroll3');
|
||||
|
||||
// Test the User's retrieved contextlist contains two contexts.
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$contexts = $contextlist->get_contexts();
|
||||
$this->assertCount(2, $contexts);
|
||||
|
||||
// Add a system, course category and course context to the approved context list.
|
||||
$approvedcontextids = [
|
||||
$systemctx->id,
|
||||
$coursecategoryctx->id,
|
||||
$coursectx->id
|
||||
];
|
||||
|
||||
// Retrieve the User's tool_cohortroles data.
|
||||
$approvedcontextlist = new approved_contextlist($user, 'tool_cohortroles', $approvedcontextids);
|
||||
provider::export_user_data($approvedcontextlist);
|
||||
|
||||
// Test the tool_cohortroles data is exported at the system context level.
|
||||
$writer = writer::with_context($systemctx);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
// Test the tool_cohortroles data is exported at the course category context level.
|
||||
$writer = writer::with_context($coursecategoryctx);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
// Test the tool_cohortroles data is not exported at the course context level.
|
||||
$writer = writer::with_context($coursectx);
|
||||
$this->assertFalse($writer->has_any_data());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::delete_data_for_all_users_in_context().
|
||||
*/
|
||||
public function test_delete_data_for_all_users_in_context() {
|
||||
global $DB;
|
||||
|
||||
// Test setup.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create course category.
|
||||
$coursecategory = $this->getDataGenerator()->create_category();
|
||||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id);
|
||||
$systemctx = context_system::instance();
|
||||
|
||||
$this->setup_test_scenario_data($user->id, $systemctx, 1);
|
||||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
|
||||
'sausageroll2');
|
||||
|
||||
// Test the User's assigned cohortroles matches 2.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(2, $cohortroles);
|
||||
|
||||
// Test the User's retrieved contextlist contains two contexts.
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$contexts = $contextlist->get_contexts();
|
||||
$this->assertCount(2, $contexts);
|
||||
|
||||
// Make sure the user data is only being deleted in within the system and course category context.
|
||||
$usercontext = context_user::instance($user->id);
|
||||
// Delete all the User's records in mdl_tool_cohortroles table by the user context.
|
||||
provider::delete_data_for_all_users_in_context($usercontext);
|
||||
|
||||
// Test the cohort roles records in mdl_tool_cohortroles table is still present.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(2, $cohortroles);
|
||||
|
||||
// Delete all the User's records in mdl_tool_cohortroles table by the specified system context.
|
||||
provider::delete_data_for_all_users_in_context($systemctx);
|
||||
|
||||
// The user data in the system context should be deleted.
|
||||
// Test the User's retrieved contextlist contains one context (course category).
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$contexts = $contextlist->get_contexts();
|
||||
$this->assertCount(1, $contexts);
|
||||
|
||||
// Delete all the User's records in mdl_tool_cohortroles table by the specified course category context.
|
||||
provider::delete_data_for_all_users_in_context($coursecategoryctx);
|
||||
|
||||
// Test the cohort roles records in mdl_tool_cohortroles table is equals zero.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(0, $cohortroles);
|
||||
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$contexts = $contextlist->get_contexts();
|
||||
$this->assertCount(0, $contexts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for provider::delete_data_for_user().
|
||||
*/
|
||||
public function test_delete_data_for_user() {
|
||||
global $DB;
|
||||
|
||||
// Test setup.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create course category.
|
||||
$coursecategory = $this->getDataGenerator()->create_category();
|
||||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id);
|
||||
$systemctx = context_system::instance();
|
||||
|
||||
$this->setup_test_scenario_data($user->id, $systemctx, 1);
|
||||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
|
||||
'sausageroll2');
|
||||
|
||||
// Test the User's assigned cohortroles matches 2.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(2, $cohortroles);
|
||||
|
||||
// Test the User's retrieved contextlist contains two contexts.
|
||||
$contextlist = provider::get_contexts_for_userid($user->id);
|
||||
$contexts = $contextlist->get_contexts();
|
||||
$this->assertCount(2, $contexts);
|
||||
|
||||
// Make sure the user data is only being deleted in within the system and the course category contexts.
|
||||
$usercontext = context_user::instance($user->id);
|
||||
// Delete all the User's records in mdl_tool_cohortroles table by the specified approved context list.
|
||||
$approvedcontextlist = new approved_contextlist($user, 'tool_cohortroles', [$usercontext->id]);
|
||||
provider::delete_data_for_user($approvedcontextlist);
|
||||
|
||||
// Test the cohort roles records in mdl_tool_cohortroles table are still present.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(2, $cohortroles);
|
||||
|
||||
// Delete all the User's records in mdl_tool_cohortroles table by the specified approved context list.
|
||||
$approvedcontextlist = new approved_contextlist($user, 'tool_cohortroles', $contextlist->get_contextids());
|
||||
provider::delete_data_for_user($approvedcontextlist);
|
||||
|
||||
// Test the records in mdl_tool_cohortroles table is equals zero.
|
||||
$cohortroles = $DB->get_records('tool_cohortroles', ['userid' => $user->id]);
|
||||
$this->assertCount(0, $cohortroles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that only users within a course context are fetched.
|
||||
*/
|
||||
public function test_get_users_in_context() {
|
||||
$component = 'tool_cohortroles';
|
||||
|
||||
// Create a user.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$usercontext = context_user::instance($user->id);
|
||||
|
||||
// Create course category.
|
||||
$coursecategory = $this->getDataGenerator()->create_category();
|
||||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id);
|
||||
$systemctx = context_system::instance();
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
$userlist = new \core_privacy\local\request\userlist($systemctx, $component);
|
||||
provider::get_users_in_context($userlist);
|
||||
$this->assertCount(0, $userlist);
|
||||
|
||||
$this->setup_test_scenario_data($user->id, $systemctx, 1);
|
||||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
|
||||
'sausageroll2');
|
||||
|
||||
// The list of users within the system context should contain user.
|
||||
provider::get_users_in_context($userlist);
|
||||
$this->assertCount(1, $userlist);
|
||||
$this->assertTrue(in_array($user->id, $userlist->get_userids()));
|
||||
|
||||
// The list of users within the course category context should contain user.
|
||||
$userlist = new \core_privacy\local\request\userlist($coursecategoryctx, $component);
|
||||
provider::get_users_in_context($userlist);
|
||||
$this->assertCount(1, $userlist);
|
||||
$this->assertTrue(in_array($user->id, $userlist->get_userids()));
|
||||
|
||||
// The list of users within the user context should be empty.
|
||||
$userlist2 = new \core_privacy\local\request\userlist($usercontext, $component);
|
||||
provider::get_users_in_context($userlist2);
|
||||
$this->assertCount(0, $userlist2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that data for users in approved userlist is deleted.
|
||||
*/
|
||||
public function test_delete_data_for_users() {
|
||||
$component = 'tool_cohortroles';
|
||||
|
||||
// Create user1.
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
// Create user2.
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
// Create user3.
|
||||
$user3 = $this->getDataGenerator()->create_user();
|
||||
$usercontext3 = context_user::instance($user3->id);
|
||||
|
||||
// Create course category.
|
||||
$coursecategory = $this->getDataGenerator()->create_category();
|
||||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id);
|
||||
$systemctx = context_system::instance();
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
$this->setup_test_scenario_data($user1->id, $systemctx, 1);
|
||||
$this->setup_test_scenario_data($user2->id, $systemctx, 1, 'Sausage roll 2',
|
||||
'sausageroll2');
|
||||
$this->setup_test_scenario_data($user3->id, $coursecategoryctx, 1, 'Sausage roll 3',
|
||||
'sausageroll3');
|
||||
|
||||
$userlist1 = new \core_privacy\local\request\userlist($systemctx, $component);
|
||||
provider::get_users_in_context($userlist1);
|
||||
$this->assertCount(2, $userlist1);
|
||||
$this->assertTrue(in_array($user1->id, $userlist1->get_userids()));
|
||||
$this->assertTrue(in_array($user2->id, $userlist1->get_userids()));
|
||||
|
||||
// Convert $userlist1 into an approved_contextlist.
|
||||
$approvedlist1 = new approved_userlist($systemctx, $component, [$user1->id]);
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist1);
|
||||
|
||||
// Re-fetch users in systemcontext.
|
||||
$userlist1 = new \core_privacy\local\request\userlist($systemctx, $component);
|
||||
provider::get_users_in_context($userlist1);
|
||||
// The user data of user1in systemcontext should be deleted.
|
||||
// The user data of user2 in systemcontext should be still present.
|
||||
$this->assertCount(1, $userlist1);
|
||||
$this->assertTrue(in_array($user2->id, $userlist1->get_userids()));
|
||||
|
||||
// Convert $userlist1 into an approved_contextlist in the user context.
|
||||
$approvedlist2 = new approved_userlist($usercontext3, $component, $userlist1->get_userids());
|
||||
// Delete using delete_data_for_user.
|
||||
provider::delete_data_for_users($approvedlist2);
|
||||
// Re-fetch users in systemcontext.
|
||||
$userlist1 = new \core_privacy\local\request\userlist($systemctx, $component);
|
||||
provider::get_users_in_context($userlist1);
|
||||
// The user data in systemcontext should not be deleted.
|
||||
$this->assertCount(1, $userlist1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to setup tool_cohortroles records for testing a specific user.
|
||||
*
|
||||
* @param int $userid The ID of the user used for testing.
|
||||
* @param int $nocohortroles The number of tool_cohortroles to create for the user.
|
||||
* @param string $rolename The name of the role to be created.
|
||||
* @param string $roleshortname The short name of the role to be created.
|
||||
* @throws \core_competency\invalid_persistent_exception
|
||||
* @throws coding_exception
|
||||
*/
|
||||
protected function setup_test_scenario_data($userid, $context, $nocohortroles, $rolename = 'Sausage Roll',
|
||||
$roleshortname = 'sausageroll') {
|
||||
$roleid = create_role($rolename, $roleshortname, 'mmmm');
|
||||
|
||||
$result = new \stdClass();
|
||||
$result->contextid = $context->id;
|
||||
|
||||
for ($c = 0; $c < $nocohortroles; $c++) {
|
||||
$cohort = $this->getDataGenerator()->create_cohort($result);
|
||||
|
||||
$params = (object)array(
|
||||
'userid' => $userid,
|
||||
'roleid' => $roleid,
|
||||
'cohortid' => $cohort->id
|
||||
);
|
||||
|
||||
api::create_cohort_role_assignment($params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,9 +29,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tool_customlang_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Moodle v3.1.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ $string['checkin'] = 'Save strings to language pack';
|
||||
$string['checkout'] = 'Open language pack for editing';
|
||||
$string['checkoutdone'] = 'Language pack loaded';
|
||||
$string['checkoutinprogress'] = 'Loading language pack';
|
||||
$string['confirmcheckin'] = 'You are about to save modifications to your local language pack. This will export the customised strings from the translator into your site data directory and your site will start using the modified strings. Press \'Continue\' to proceed with saving.';
|
||||
$string['confirmcheckin'] = 'You are about to save modifications to your local language pack. This will export the customised strings from the translator into you Moodle data directory and Moodle will start using the modified strings. Press \'Continue\' to proceed with saving.';
|
||||
$string['customlang:edit'] = 'Edit local translation';
|
||||
$string['customlang:view'] = 'View local translation';
|
||||
$string['filter'] = 'Filter strings';
|
||||
|
||||
@@ -134,13 +134,11 @@ class tool_customlang_renderer extends plugin_renderer_base {
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'translatorsubmitted', 'value'=>1));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'p', 'value'=>$translator->currentpage));
|
||||
$save1 = html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'savecontinue',
|
||||
'value' => get_string('savecontinue', 'tool_customlang'), 'class' => 'btn btn-secondary'));
|
||||
$save2 = html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'savecheckin',
|
||||
'value' => get_string('savecheckin', 'tool_customlang'), 'class' => 'btn btn-secondary'));
|
||||
$output .= html_writer::tag('fieldset', $save1 . ' ' . $save2, array('class' => 'buttonsbar'));
|
||||
$save1 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecontinue', 'value'=>get_string('savecontinue', 'tool_customlang')));
|
||||
$save2 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecheckin', 'value'=>get_string('savecheckin', 'tool_customlang')));
|
||||
$output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar'));
|
||||
$output .= html_writer::table($table);
|
||||
$output .= html_writer::tag('fieldset', $save1 . ' ' . $save2, array('class' => 'buttonsbar'));
|
||||
$output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar'));
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('form');
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={DELETE:'[data-action="deletecategory"]'},h=function(){this.registerEvents()};return h.prototype.registerEvents=function(){a(g.DELETE).click(function(g){g.preventDefault();var h=a(this).data("id"),i=a(this).data("name"),j=[{key:"deletecategory",component:"tool_dataprivacy"},{key:"deletecategorytext",component:"tool_dataprivacy",param:i},{key:"delete"}];d.get_strings(j).then(function(d){var g=d[0],i=d[1],j=d[2];return e.create({title:g,body:i,type:e.types.SAVE_CANCEL}).then(function(d){return d.setSaveButtonText(j),d.getRoot().on(f.save,function(){var d={methodname:"tool_dataprivacy_delete_category",args:{id:h}};b.call([d])[0].done(function(b){b.result?a('tr[data-categoryid="'+h+'"]').remove():c.addNotification({message:b.warnings[0].message,type:"error"})}).fail(c.exception)}),d.getRoot().on(f.hidden,function(){d.destroy()}),d})}).done(function(a){a.show()}).fail(c.exception)})},{init:function(){return new h}}});
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={DELETE:'[data-action="deletecategory"]'},h=function(){this.registerEvents()};return h.prototype.registerEvents=function(){a(g.DELETE).click(function(g){g.preventDefault();var h=a(this).data("id"),i=a(this).data("name"),j=[{key:"deletecategory",component:"tool_dataprivacy",param:i},{key:"deletecategorytext",component:"tool_dataprivacy",param:i}];d.get_strings(j).then(function(d){var g=d[0],i=d[1];return e.create({title:g,body:i,type:e.types.SAVE_CANCEL}).then(function(d){return d.setSaveButtonText(g),d.getRoot().on(f.save,function(){var d={methodname:"tool_dataprivacy_delete_category",args:{id:h}};b.call([d])[0].done(function(b){b.result?a('tr[data-categoryid="'+h+'"]').remove():c.addNotification({message:b.warnings[0].message,type:"error"})}).fail(c.exception)}),d.getRoot().on(f.hidden,function(){d.destroy()}),d})}).done(function(a){a.show()}).fail(c.exception)})},{init:function(){return new h}}});
|
||||
@@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","tool_dataprivacy/events"],function(a,b,c,d,e,f){var g=!1,h={APPROVE_BUTTON:'[data-action="approve"]',DENY_BUTTON:'[data-action="deny"]',COMPLETE_BUTTON:'[data-action="complete"]'},i=function(a){d.call(this,a)};return i.TYPE="tool_dataprivacy-data_request",i.prototype=Object.create(d.prototype),i.prototype.constructor=i,i.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this),this.getModal().on(c.events.activate,h.APPROVE_BUTTON,function(b,c){var d=a.Event(f.approve);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this)),this.getModal().on(c.events.activate,h.DENY_BUTTON,function(b,c){var d=a.Event(f.deny);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this)),this.getModal().on(c.events.activate,h.COMPLETE_BUTTON,function(b,c){var d=a.Event(f.complete);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this))},g||(e.register(i.TYPE,i,"tool_dataprivacy/data_request_modal"),g=!0),i});
|
||||
define(["jquery","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","tool_dataprivacy/events"],function(a,b,c,d,e,f){var g=!1,h={APPROVE_BUTTON:'[data-action="approve"]',DENY_BUTTON:'[data-action="deny"]'},i=function(a){d.call(this,a),this.getFooter().find(h.APPROVE_BUTTON).length||b.exception({message:"No approve button found"}),this.getFooter().find(h.DENY_BUTTON).length||b.exception({message:"No deny button found"})};return i.TYPE="tool_dataprivacy-data_request",i.prototype=Object.create(d.prototype),i.prototype.constructor=i,i.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this),this.getModal().on(c.events.activate,h.APPROVE_BUTTON,function(b,c){var d=a.Event(f.approve);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this)),this.getModal().on(c.events.activate,h.DENY_BUTTON,function(b,c){var d=a.Event(f.deny);this.getRoot().trigger(d,this),d.isDefaultPrevented()||(this.hide(),c.originalEvent.preventDefault())}.bind(this))},g||(e.register(i.TYPE,i,"tool_dataprivacy/data_request_modal"),g=!0),i});
|
||||
@@ -1 +0,0 @@
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates"],function(a,b,c,d,e,f,g){function h(b,d,h,j,k,l,m,n){null!==h&&l.forEach(function(a){a.id===h&&(a.selected=!0)}),null!==j&&m.forEach(function(a){a.id===j&&(a.selected=!0)});var o={contextlevel:d,categoryoptions:l,purposeoptions:m};null!==n&&n.length&&(null===k?o.newactivitydefaults=!0:n.forEach(function(a){k===a.name&&(a.selected=!0)}),o.modemodule=!0,o.activityoptions=n),e.create({title:b,body:g.render("tool_dataprivacy/category_purpose_form",o),type:e.types.SAVE_CANCEL,large:!0}).then(function(b){return b.getRoot().on(f.save,function(){var b=a("#activity"),c="undefined"!=typeof b?b.val():null,d=a("#override"),e="undefined"!=typeof d&&d.is(":checked");i(a("#contextlevel").val(),a("#category").val(),a("#purpose").val(),c,e)}),b.getRoot().on(f.hidden,function(){b.destroy()}),b.show(),b})["catch"](c.exception)}function i(a,c,d,e,f){var g={methodname:"tool_dataprivacy_set_context_defaults",args:{contextlevel:a,category:c,purpose:d,override:f,activity:e}};b.call([g])[0].done(function(a){a.result&&window.location.reload()})}var j={EDIT_LEVEL_DEFAULTS:'[data-action="edit-level-defaults"]',NEW_ACTIVITY_DEFAULTS:'[data-action="new-activity-defaults"]',EDIT_ACTIVITY_DEFAULTS:'[data-action="edit-activity-defaults"]',DELETE_ACTIVITY_DEFAULTS:'[data-action="delete-activity-defaults"]'},k=-1,l=function(){this.registerEvents()};return l.prototype.registerEvents=function(){a(j.EDIT_LEVEL_DEFAULTS).click(function(e){e.preventDefault();var f=a(this),g=f.data("contextlevel"),i=f.data("category"),j=f.data("purpose"),k=[{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}}],l=b.call(k),m=d.get_string("editdefaults","tool_dataprivacy",a("#defaults-header").text());a.when(l[0],l[1],m).then(function(a,b,c){var d=a.options,e=b.options;return h(c,g,i,j,null,d,e,null),!0})["catch"](c.exception)}),a(j.NEW_ACTIVITY_DEFAULTS).click(function(e){e.preventDefault();var f=a(this),g=f.data("contextlevel"),i=[{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}},{methodname:"tool_dataprivacy_get_activity_options",args:{nodefaults:!0}}],j=b.call(i),k=d.get_string("addnewdefaults","tool_dataprivacy");a.when(j[0],j[1],j[2],k).then(function(a,b,c,d){var e=a.options,f=b.options,i=c.options;return h(d,g,null,null,null,e,f,i),!0})["catch"](c.exception)}),a(j.EDIT_ACTIVITY_DEFAULTS).click(function(e){e.preventDefault();var f=a(this),g=f.data("contextlevel"),i=f.data("category"),j=f.data("purpose"),k=f.data("activityname"),l=[{methodname:"tool_dataprivacy_get_category_options",args:{}},{methodname:"tool_dataprivacy_get_purpose_options",args:{}},{methodname:"tool_dataprivacy_get_activity_options",args:{}}],m=b.call(l),n=d.get_string("editmoduledefaults","tool_dataprivacy");a.when(m[0],m[1],m[2],n).then(function(a,b,c,d){var e=a.options,f=b.options,l=c.options;return h(d,g,i,j,k,e,f,l),!0})["catch"](c.exception)}),a(j.DELETE_ACTIVITY_DEFAULTS).click(function(b){b.preventDefault();var h=a(this),j=h.data("contextlevel"),l=h.data("activityname"),m=h.data("activitydisplayname"),n=k,o=k;e.create({title:d.get_string("deletedefaults","tool_dataprivacy",m),body:g.render("tool_dataprivacy/delete_activity_defaults",{activityname:m}),type:e.types.SAVE_CANCEL,large:!0}).then(function(a){return a.setSaveButtonText(d.get_string("delete")),a.getRoot().on(f.save,function(){i(j,n,o,l,!1)}),a.getRoot().on(f.hidden,function(){a.destroy()}),a.show(),!0})["catch"](c.exception)})},{init:function(){return new l}}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define([],function(){return{approve:"tool_dataprivacy-data_request:approve",bulkApprove:"tool_dataprivacy-data_request:bulk_approve",deny:"tool_dataprivacy-data_request:deny",bulkDeny:"tool_dataprivacy-data_request:bulk_deny",complete:"tool_dataprivacy-data_request:complete"}});
|
||||
define([],function(){return{approve:"tool_dataprivacy-data_request:approve",deny:"tool_dataprivacy-data_request:deny"}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={DELETE:'[data-action="deletepurpose"]'},h=function(){this.registerEvents()};return h.prototype.registerEvents=function(){a(g.DELETE).click(function(g){g.preventDefault();var h=a(this).data("id"),i=a(this).data("name"),j=[{key:"deletepurpose",component:"tool_dataprivacy"},{key:"deletepurposetext",component:"tool_dataprivacy",param:i},{key:"delete"}];d.get_strings(j).then(function(d){var g=d[0],i=d[1],j=d[2];return e.create({title:g,body:i,type:e.types.SAVE_CANCEL}).then(function(d){return d.setSaveButtonText(j),d.getRoot().on(f.save,function(){var d={methodname:"tool_dataprivacy_delete_purpose",args:{id:h}};b.call([d])[0].done(function(b){b.result?a('tr[data-purposeid="'+h+'"]').remove():c.addNotification({message:b.warnings[0].message,type:"error"})}).fail(c.exception)}),d.getRoot().on(f.hidden,function(){d.destroy()}),d})}).done(function(a){a.show()}).fail(c.exception)})},{init:function(){return new h}}});
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={DELETE:'[data-action="deletepurpose"]'},h=function(){this.registerEvents()};return h.prototype.registerEvents=function(){a(g.DELETE).click(function(g){g.preventDefault();var h=a(this).data("id"),i=a(this).data("name"),j=[{key:"deletepurpose",component:"tool_dataprivacy",param:i},{key:"deletepurposetext",component:"tool_dataprivacy",param:i}];d.get_strings(j).then(function(d){var g=d[0],i=d[1];return e.create({title:g,body:i,type:e.types.SAVE_CANCEL}).then(function(d){return d.setSaveButtonText(g),d.getRoot().on(f.save,function(){var d={methodname:"tool_dataprivacy_delete_purpose",args:{id:h}};b.call([d])[0].done(function(b){b.result?a('tr[data-purposeid="'+h+'"]').remove():c.addNotification({message:b.warnings[0].message,type:"error"})}).fail(c.exception)}),d.getRoot().on(f.hidden,function(){d.destroy()}),d})}).done(function(a){a.show()}).fail(c.exception)})},{init:function(){return new h}}});
|
||||
@@ -1 +0,0 @@
|
||||
define(["jquery","core/form-autocomplete","core/str","core/notification"],function(a,b,c,d){var e={REQUEST_FILTERS:"#request-filters"},f=function(){var f=[{key:"filter",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}];c.get_strings(f).then(function(a){var c=a[0],d=a[1];return b.enhance(e.REQUEST_FILTERS,!1,"",c,!1,!0,d,!0)}).fail(d.exception);var g=a(e.REQUEST_FILTERS).val();a(e.REQUEST_FILTERS).on("change",function(){var b=a(this).val();g.join(",")!==b.join(",")&&(0===b.length&&a("#filters-cleared").val(1),a(this.form).submit())})};return{init:function(){f()}}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates","tool_dataprivacy/data_request_modal","tool_dataprivacy/events"],function(a,b,c,d,e,f,g,h,i){function j(a){return{wsfunction:"tool_dataprivacy_approve_data_request",wsparams:{requestid:a}}}function k(a){return{wsfunction:"tool_dataprivacy_bulk_approve_data_requests",wsparams:{requestids:a}}}function l(a){return{wsfunction:"tool_dataprivacy_deny_data_request",wsparams:{requestid:a}}}function m(a){return{wsfunction:"tool_dataprivacy_bulk_deny_data_requests",wsparams:{requestids:a}}}function n(a){return{wsfunction:"tool_dataprivacy_mark_complete",wsparams:{requestid:a}}}function o(a,b){var g=[];switch(a){case i.approve:g=[{key:"approverequest",component:"tool_dataprivacy"},{key:"confirmapproval",component:"tool_dataprivacy"}];break;case i.bulkApprove:g=[{key:"bulkapproverequests",component:"tool_dataprivacy"},{key:"confirmbulkapproval",component:"tool_dataprivacy"}];break;case i.deny:g=[{key:"denyrequest",component:"tool_dataprivacy"},{key:"confirmdenial",component:"tool_dataprivacy"}];break;case i.bulkDeny:g=[{key:"bulkdenyrequests",component:"tool_dataprivacy"},{key:"confirmbulkdenial",component:"tool_dataprivacy"}];break;case i.complete:g=[{key:"markcomplete",component:"tool_dataprivacy"},{key:"confirmcompletion",component:"tool_dataprivacy"}]}var h="";d.get_strings(g).then(function(a){h=a[0];var b=a[1];return e.create({title:h,body:b,type:e.types.SAVE_CANCEL})}).then(function(a){a.setSaveButtonText(h),a.getRoot().on(f.save,function(){p(b.wsfunction,b.wsparams)}),a.getRoot().on(f.hidden,function(){a.destroy()}),a.show()})["catch"](c.exception)}function p(a,d){var e={methodname:a,args:d};b.call([e])[0].done(function(a){a.result?window.location.reload():c.addNotification({message:a.warnings[0].message,type:"error"})}).fail(c.exception)}var q={APPROVE_REQUEST:'[data-action="approve"]',DENY_REQUEST:'[data-action="deny"]',VIEW_REQUEST:'[data-action="view"]',MARK_COMPLETE:'[data-action="complete"]',CHANGE_BULK_ACTION:'[id="bulk-action"]',CONFIRM_BULK_ACTION:'[id="confirm-bulk-action"]',SELECT_ALL:'[data-action="selectall"]'},r={APPROVE:1,DENY:2},s={SELECT_REQUEST:".selectrequests"},t=function(){this.registerEvents()};return t.prototype.registerEvents=function(){a(q.VIEW_REQUEST).click(function(d){d.preventDefault();var k=a(this).data("requestid"),m={requestid:k},n={methodname:"tool_dataprivacy_get_data_request",args:m},q=b.call([n]);a.when(q[0]).then(function(a){return a.result?a.result:(c.addNotification({message:a.warnings[0].message,type:"error"}),!1)}).then(function(a){var b=g.render("tool_dataprivacy/request_details",a),c={approvedeny:a.approvedeny,canmarkcomplete:a.canmarkcomplete};return e.create({title:a.typename,body:b,type:h.TYPE,large:!0,templateContext:c})}).then(function(a){a.getRoot().on(i.approve,function(){o(i.approve,j(k))}),a.getRoot().on(i.deny,function(){o(i.deny,l(k))}),a.getRoot().on(i.complete,function(){var a={requestid:k};p("tool_dataprivacy_mark_complete",a)}),a.getRoot().on(f.hidden,function(){a.destroy()}),a.show()})["catch"](c.exception)}),a(q.APPROVE_REQUEST).click(function(b){b.preventDefault();var c=a(this).data("requestid");o(i.approve,j(c))}),a(q.DENY_REQUEST).click(function(b){b.preventDefault();var c=a(this).data("requestid");o(i.deny,l(c))}),a(q.MARK_COMPLETE).click(function(b){b.preventDefault();var c=a(this).data("requestid");o(i.complete,n(c))}),a(q.CONFIRM_BULK_ACTION).click(function(){var b=[],e="",f={},g=[{key:"selectbulkaction",component:"tool_dataprivacy"},{key:"selectdatarequests",component:"tool_dataprivacy"},{key:"ok"}],h=parseInt(a("#bulk-action").val());if(h!=r.APPROVE&&h!=r.DENY)return void d.get_strings(g).done(function(a){c.alert("",a[0],a[2])}).fail(c.exception);if(a(".selectrequests:checked").each(function(){b.push(a(this).val())}),b.length<1)return void d.get_strings(g).done(function(a){c.alert("",a[1],a[2])}).fail(c.exception);switch(h){case r.APPROVE:e=i.bulkApprove,f=k(b);break;case r.DENY:e=i.bulkDeny,f=m(b)}o(e,f)}),a(q.SELECT_ALL).change(function(b){b.preventDefault();var c=a(this).is(":checked");a(s.SELECT_REQUEST).prop("checked",c)})},t});
|
||||
define(["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates","tool_dataprivacy/data_request_modal","tool_dataprivacy/events"],function(a,b,c,d,e,f,g,h,i){function j(a,g){var h=[],j="";switch(a){case i.approve:h=[{key:"approverequest",component:"tool_dataprivacy"},{key:"confirmapproval",component:"tool_dataprivacy"}],j="tool_dataprivacy_approve_data_request";break;case i.deny:h=[{key:"denyrequest",component:"tool_dataprivacy"},{key:"confirmdenial",component:"tool_dataprivacy"}],j="tool_dataprivacy_deny_data_request"}var k="";d.get_strings(h).then(function(a){k=a[0];var b=a[1];return e.create({title:k,body:b,type:e.types.SAVE_CANCEL})}).then(function(a){return a.setSaveButtonText(k),a.getRoot().on(f.save,function(){var a={requestid:g},d={methodname:j,args:a};b.call([d])[0].done(function(a){a.result?window.location.reload():c.addNotification({message:a.warnings[0].message,type:"error"})}).fail(c.exception)}),a.getRoot().on(f.hidden,function(){a.destroy()}),a}).done(function(a){a.show()}).fail(c.exception)}var k={APPROVE_REQUEST:'[data-action="approve"]',DENY_REQUEST:'[data-action="deny"]',VIEW_REQUEST:'[data-action="view"]'},l=function(){this.registerEvents()};return l.prototype.registerEvents=function(){a(k.VIEW_REQUEST).click(function(d){d.preventDefault();var k=a(this).data("requestid"),l={requestid:k},m={methodname:"tool_dataprivacy_get_data_request",args:l},n=b.call([m]),o="",p=e.types.DEFAULT;a.when(n[0]).then(function(a){return a.result?(2==a.result.status&&(p=h.TYPE),o=a.result.typename,g.render("tool_dataprivacy/request_details",a.result)):(c.addNotification({message:a.warnings[0].message,type:"error"}),!1)}).then(function(a){return e.create({title:o,body:a,type:p,large:!0}).then(function(a){return a.getRoot().on(i.approve,function(){j(i.approve,k)}),a.getRoot().on(i.deny,function(){j(i.deny,k)}),a.getRoot().on(f.hidden,function(){a.destroy()}),a})}).done(function(a){a.show()}).fail(c.exception)}),a(k.APPROVE_REQUEST).click(function(b){b.preventDefault();var c=a(this).data("requestid");j(i.approve,c)}),a(k.DENY_REQUEST).click(function(b){b.preventDefault();var c=a(this).data("requestid");j(i.deny,c)})},l});
|
||||
@@ -58,28 +58,25 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents) {
|
||||
var stringkeys = [
|
||||
{
|
||||
key: 'deletecategory',
|
||||
component: 'tool_dataprivacy'
|
||||
component: 'tool_dataprivacy',
|
||||
param: categoryname
|
||||
},
|
||||
{
|
||||
key: 'deletecategorytext',
|
||||
component: 'tool_dataprivacy',
|
||||
param: categoryname
|
||||
},
|
||||
{
|
||||
key: 'delete'
|
||||
}
|
||||
];
|
||||
|
||||
Str.get_strings(stringkeys).then(function(langStrings) {
|
||||
var title = langStrings[0];
|
||||
var confirmMessage = langStrings[1];
|
||||
var buttonText = langStrings[2];
|
||||
return ModalFactory.create({
|
||||
title: title,
|
||||
body: confirmMessage,
|
||||
type: ModalFactory.types.SAVE_CANCEL
|
||||
}).then(function(modal) {
|
||||
modal.setSaveButtonText(buttonText);
|
||||
modal.setSaveButtonText(title);
|
||||
|
||||
// Handle save event.
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
|
||||
@@ -234,7 +234,6 @@ define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates'
|
||||
},
|
||||
fail: Notification.exception
|
||||
}]);
|
||||
return;
|
||||
}).catch(Notification.exception);
|
||||
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@ define(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/m
|
||||
var SELECTORS = {
|
||||
APPROVE_BUTTON: '[data-action="approve"]',
|
||||
DENY_BUTTON: '[data-action="deny"]',
|
||||
COMPLETE_BUTTON: '[data-action="complete"]'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -39,6 +38,14 @@ define(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/m
|
||||
*/
|
||||
var ModalDataRequest = function(root) {
|
||||
Modal.call(this, root);
|
||||
|
||||
if (!this.getFooter().find(SELECTORS.APPROVE_BUTTON).length) {
|
||||
Notification.exception({message: 'No approve button found'});
|
||||
}
|
||||
|
||||
if (!this.getFooter().find(SELECTORS.DENY_BUTTON).length) {
|
||||
Notification.exception({message: 'No deny button found'});
|
||||
}
|
||||
};
|
||||
|
||||
ModalDataRequest.TYPE = 'tool_dataprivacy-data_request';
|
||||
@@ -73,16 +80,6 @@ define(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/m
|
||||
data.originalEvent.preventDefault();
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
this.getModal().on(CustomEvents.events.activate, SELECTORS.COMPLETE_BUTTON, function(e, data) {
|
||||
var completeEvent = $.Event(DataPrivacyEvents.complete);
|
||||
this.getRoot().trigger(completeEvent, this);
|
||||
|
||||
if (!completeEvent.isDefaultPrevented()) {
|
||||
this.hide();
|
||||
data.originalEvent.preventDefault();
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
// Automatically register with the modal registry the first time this module is imported so that you can create modals
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* AMD module for data registry defaults actions.
|
||||
*
|
||||
* @module tool_dataprivacy/defaultsactions
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'core/ajax',
|
||||
'core/notification',
|
||||
'core/str',
|
||||
'core/modal_factory',
|
||||
'core/modal_events',
|
||||
'core/templates'],
|
||||
function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates) {
|
||||
|
||||
/**
|
||||
* List of action selectors.
|
||||
*
|
||||
* @type {{EDIT_LEVEL_DEFAULTS: string}}
|
||||
* @type {{NEW_ACTIVITY_DEFAULTS: string}}
|
||||
* @type {{EDIT_ACTIVITY_DEFAULTS: string}}
|
||||
* @type {{DELETE_ACTIVITY_DEFAULTS: string}}
|
||||
*/
|
||||
var ACTIONS = {
|
||||
EDIT_LEVEL_DEFAULTS: '[data-action="edit-level-defaults"]',
|
||||
NEW_ACTIVITY_DEFAULTS: '[data-action="new-activity-defaults"]',
|
||||
EDIT_ACTIVITY_DEFAULTS: '[data-action="edit-activity-defaults"]',
|
||||
DELETE_ACTIVITY_DEFAULTS: '[data-action="delete-activity-defaults"]'
|
||||
};
|
||||
|
||||
/** @type {{INHERIT: Number}} **/
|
||||
var INHERIT = -1;
|
||||
|
||||
/**
|
||||
* DefaultsActions class.
|
||||
*/
|
||||
var DefaultsActions = function() {
|
||||
this.registerEvents();
|
||||
};
|
||||
|
||||
/**
|
||||
* Register event listeners.
|
||||
*/
|
||||
DefaultsActions.prototype.registerEvents = function() {
|
||||
$(ACTIONS.EDIT_LEVEL_DEFAULTS).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var contextLevel = button.data('contextlevel');
|
||||
var category = button.data('category');
|
||||
var purpose = button.data('purpose');
|
||||
|
||||
// Get options.
|
||||
var requests = [
|
||||
{methodname: 'tool_dataprivacy_get_category_options', args: {}},
|
||||
{methodname: 'tool_dataprivacy_get_purpose_options', args: {}}
|
||||
];
|
||||
|
||||
var promises = Ajax.call(requests);
|
||||
var titlePromise = Str.get_string('editdefaults', 'tool_dataprivacy', $('#defaults-header').text());
|
||||
$.when(promises[0], promises[1], titlePromise).then(function(categoryResponse, purposeResponse, title) {
|
||||
var categories = categoryResponse.options;
|
||||
var purposes = purposeResponse.options;
|
||||
showDefaultsFormModal(title, contextLevel, category, purpose, null, categories, purposes, null);
|
||||
|
||||
return true;
|
||||
}).catch(Notification.exception);
|
||||
});
|
||||
|
||||
$(ACTIONS.NEW_ACTIVITY_DEFAULTS).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var contextLevel = button.data('contextlevel');
|
||||
|
||||
// Get options.
|
||||
var requests = [
|
||||
{methodname: 'tool_dataprivacy_get_category_options', args: {}},
|
||||
{methodname: 'tool_dataprivacy_get_purpose_options', args: {}},
|
||||
{methodname: 'tool_dataprivacy_get_activity_options', args: {'nodefaults': true}}
|
||||
];
|
||||
|
||||
var promises = Ajax.call(requests);
|
||||
var titlePromise = Str.get_string('addnewdefaults', 'tool_dataprivacy');
|
||||
|
||||
$.when(promises[0], promises[1], promises[2], titlePromise).then(
|
||||
function(categoryResponse, purposeResponse, activityResponse, title) {
|
||||
var categories = categoryResponse.options;
|
||||
var purposes = purposeResponse.options;
|
||||
var activities = activityResponse.options;
|
||||
|
||||
showDefaultsFormModal(title, contextLevel, null, null, null, categories, purposes, activities);
|
||||
|
||||
return true;
|
||||
|
||||
}).catch(Notification.exception);
|
||||
}
|
||||
);
|
||||
|
||||
$(ACTIONS.EDIT_ACTIVITY_DEFAULTS).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var contextLevel = button.data('contextlevel');
|
||||
var category = button.data('category');
|
||||
var purpose = button.data('purpose');
|
||||
var activity = button.data('activityname');
|
||||
|
||||
// Get options.
|
||||
var requests = [
|
||||
{methodname: 'tool_dataprivacy_get_category_options', args: {}},
|
||||
{methodname: 'tool_dataprivacy_get_purpose_options', args: {}},
|
||||
{methodname: 'tool_dataprivacy_get_activity_options', args: {}}
|
||||
];
|
||||
|
||||
var promises = Ajax.call(requests);
|
||||
var titlePromise = Str.get_string('editmoduledefaults', 'tool_dataprivacy');
|
||||
|
||||
$.when(promises[0], promises[1], promises[2], titlePromise).then(
|
||||
function(categoryResponse, purposeResponse, activityResponse, title) {
|
||||
var categories = categoryResponse.options;
|
||||
var purposes = purposeResponse.options;
|
||||
var activities = activityResponse.options;
|
||||
|
||||
showDefaultsFormModal(title, contextLevel, category, purpose, activity, categories, purposes, activities);
|
||||
|
||||
return true;
|
||||
|
||||
}).catch(Notification.exception);
|
||||
}
|
||||
);
|
||||
|
||||
$(ACTIONS.DELETE_ACTIVITY_DEFAULTS).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var contextLevel = button.data('contextlevel');
|
||||
var activity = button.data('activityname');
|
||||
var activityDisplayName = button.data('activitydisplayname');
|
||||
// Set category and purpose to inherit (-1).
|
||||
var category = INHERIT;
|
||||
var purpose = INHERIT;
|
||||
|
||||
ModalFactory.create({
|
||||
title: Str.get_string('deletedefaults', 'tool_dataprivacy', activityDisplayName),
|
||||
body: Templates.render('tool_dataprivacy/delete_activity_defaults', {"activityname": activityDisplayName}),
|
||||
type: ModalFactory.types.SAVE_CANCEL,
|
||||
large: true
|
||||
}).then(function(modal) {
|
||||
modal.setSaveButtonText(Str.get_string('delete'));
|
||||
|
||||
// Handle save event.
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
setContextDefaults(contextLevel, category, purpose, activity, false);
|
||||
});
|
||||
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
modal.show();
|
||||
|
||||
return true;
|
||||
}).catch(Notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepares and renders the modal for setting the defaults for the given context level/plugin.
|
||||
*
|
||||
* @param {String} title The modal's title.
|
||||
* @param {Number} contextLevel The context level to set defaults for.
|
||||
* @param {Number} category The current category ID.
|
||||
* @param {Number} purpose The current purpose ID.
|
||||
* @param {String} activity The plugin name of the activity. Optional.
|
||||
* @param {Array} categoryOptions The list of category options.
|
||||
* @param {Array} purposeOptions The list of purpose options.
|
||||
* @param {Array} activityOptions The list of activity options. Optional.
|
||||
*/
|
||||
function showDefaultsFormModal(title, contextLevel, category, purpose, activity,
|
||||
categoryOptions, purposeOptions, activityOptions) {
|
||||
|
||||
if (category !== null) {
|
||||
categoryOptions.forEach(function(currentValue) {
|
||||
if (currentValue.id === category) {
|
||||
currentValue.selected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (purpose !== null) {
|
||||
purposeOptions.forEach(function(currentValue) {
|
||||
if (currentValue.id === purpose) {
|
||||
currentValue.selected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var templateContext = {
|
||||
"contextlevel": contextLevel,
|
||||
"categoryoptions": categoryOptions,
|
||||
"purposeoptions": purposeOptions
|
||||
};
|
||||
|
||||
// Check the activityOptions parameter that was passed.
|
||||
if (activityOptions !== null && activityOptions.length) {
|
||||
// Check the activity parameter that was passed.
|
||||
if (activity === null) {
|
||||
// We're setting a new defaults for a module.
|
||||
templateContext.newactivitydefaults = true;
|
||||
|
||||
} else {
|
||||
// Edit mode. Set selection.
|
||||
activityOptions.forEach(function(currentValue) {
|
||||
if (activity === currentValue.name) {
|
||||
currentValue.selected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
templateContext.modemodule = true;
|
||||
templateContext.activityoptions = activityOptions;
|
||||
}
|
||||
|
||||
ModalFactory.create({
|
||||
title: title,
|
||||
body: Templates.render('tool_dataprivacy/category_purpose_form', templateContext),
|
||||
type: ModalFactory.types.SAVE_CANCEL,
|
||||
large: true
|
||||
}).then(function(modal) {
|
||||
|
||||
// Handle save event.
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
var activity = $('#activity');
|
||||
var activityVal = typeof activity !== 'undefined' ? activity.val() : null;
|
||||
var override = $('#override');
|
||||
var overrideVal = typeof override !== 'undefined' ? override.is(':checked') : false;
|
||||
|
||||
setContextDefaults($('#contextlevel').val(), $('#category').val(), $('#purpose').val(), activityVal, overrideVal);
|
||||
});
|
||||
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
modal.show();
|
||||
|
||||
return modal;
|
||||
}).catch(Notification.exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a the tool_dataprivacy_set_context_defaults WS function.
|
||||
*
|
||||
* @param {Number} contextLevel The context level.
|
||||
* @param {Number} category The category ID.
|
||||
* @param {Number} purpose The purpose ID.
|
||||
* @param {String} activity The plugin name of the activity module.
|
||||
* @param {Boolean} override Whether to override custom instances.
|
||||
*/
|
||||
function setContextDefaults(contextLevel, category, purpose, activity, override) {
|
||||
var request = {
|
||||
methodname: 'tool_dataprivacy_set_context_defaults',
|
||||
args: {
|
||||
'contextlevel': contextLevel,
|
||||
'category': category,
|
||||
'purpose': purpose,
|
||||
'override': override,
|
||||
'activity': activity
|
||||
}
|
||||
};
|
||||
|
||||
Ajax.call([request])[0].done(function(data) {
|
||||
if (data.result) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return /** @alias module:tool_dataprivacy/defaultsactions */ {
|
||||
// Public variables and functions.
|
||||
|
||||
/**
|
||||
* Initialise the module.
|
||||
*
|
||||
* @method init
|
||||
* @return {DefaultsActions}
|
||||
*/
|
||||
'init': function() {
|
||||
return new DefaultsActions();
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -25,9 +25,6 @@
|
||||
define([], function() {
|
||||
return {
|
||||
approve: 'tool_dataprivacy-data_request:approve',
|
||||
bulkApprove: 'tool_dataprivacy-data_request:bulk_approve',
|
||||
deny: 'tool_dataprivacy-data_request:deny',
|
||||
bulkDeny: 'tool_dataprivacy-data_request:bulk_deny',
|
||||
complete: 'tool_dataprivacy-data_request:complete'
|
||||
};
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ define(['jquery', 'core/url', 'core/str'], function($, url, str) {
|
||||
*
|
||||
* @param {object} targetnode The node that we want to expand / collapse
|
||||
* @param {object} thisnode The node that was clicked.
|
||||
* @return {null}
|
||||
*/
|
||||
expandCollapse: function(targetnode, thisnode) {
|
||||
if (targetnode.hasClass('hide')) {
|
||||
@@ -57,6 +58,7 @@ define(['jquery', 'core/url', 'core/str'], function($, url, str) {
|
||||
* Expand or collapse all nodes on this page.
|
||||
*
|
||||
* @param {string} nextstate The next state to change to.
|
||||
* @return {null}
|
||||
*/
|
||||
expandCollapseAll: function(nextstate) {
|
||||
var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';
|
||||
@@ -73,7 +75,6 @@ define(['jquery', 'core/url', 'core/str'], function($, url, str) {
|
||||
|
||||
str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {
|
||||
$('.tool_dataprivacy-expand-all').html(langString);
|
||||
return;
|
||||
}).catch(Notification.exception);
|
||||
|
||||
$(':header i.fa').each(function() {
|
||||
|
||||
@@ -58,28 +58,25 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents) {
|
||||
var stringkeys = [
|
||||
{
|
||||
key: 'deletepurpose',
|
||||
component: 'tool_dataprivacy'
|
||||
component: 'tool_dataprivacy',
|
||||
param: purposename
|
||||
},
|
||||
{
|
||||
key: 'deletepurposetext',
|
||||
component: 'tool_dataprivacy',
|
||||
param: purposename
|
||||
},
|
||||
{
|
||||
key: 'delete'
|
||||
}
|
||||
];
|
||||
|
||||
Str.get_strings(stringkeys).then(function(langStrings) {
|
||||
var title = langStrings[0];
|
||||
var confirmMessage = langStrings[1];
|
||||
var buttonText = langStrings[2];
|
||||
return ModalFactory.create({
|
||||
title: title,
|
||||
body: confirmMessage,
|
||||
type: ModalFactory.types.SAVE_CANCEL
|
||||
}).then(function(modal) {
|
||||
modal.setSaveButtonText(buttonText);
|
||||
modal.setSaveButtonText(title);
|
||||
|
||||
// Handle save event.
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* JS module for the data requests filter.
|
||||
*
|
||||
* @module tool_dataprivacy/request_filter
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'], function($, Autocomplete, Str, Notification) {
|
||||
|
||||
/**
|
||||
* Selectors.
|
||||
*
|
||||
* @access private
|
||||
* @type {{REQUEST_FILTERS: string}}
|
||||
*/
|
||||
var SELECTORS = {
|
||||
REQUEST_FILTERS: '#request-filters'
|
||||
};
|
||||
|
||||
/**
|
||||
* Init function.
|
||||
*
|
||||
* @method init
|
||||
* @private
|
||||
*/
|
||||
var init = function() {
|
||||
var stringkeys = [
|
||||
{
|
||||
key: 'filter',
|
||||
component: 'moodle'
|
||||
},
|
||||
{
|
||||
key: 'nofiltersapplied',
|
||||
component: 'moodle'
|
||||
}
|
||||
];
|
||||
|
||||
Str.get_strings(stringkeys).then(function(langstrings) {
|
||||
var placeholder = langstrings[0];
|
||||
var noSelectionString = langstrings[1];
|
||||
return Autocomplete.enhance(SELECTORS.REQUEST_FILTERS, false, '', placeholder, false, true, noSelectionString, true);
|
||||
}).fail(Notification.exception);
|
||||
|
||||
var last = $(SELECTORS.REQUEST_FILTERS).val();
|
||||
$(SELECTORS.REQUEST_FILTERS).on('change', function() {
|
||||
var current = $(this).val();
|
||||
// Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.
|
||||
if (last.join(',') !== current.join(',')) {
|
||||
// If we're submitting without filters, set the hidden input 'filters-cleared' to 1.
|
||||
if (current.length === 0) {
|
||||
$('#filters-cleared').val(1);
|
||||
}
|
||||
$(this.form).submit();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return /** @alias module:core/form-autocomplete */ {
|
||||
/**
|
||||
* Initialise the unified user filter.
|
||||
*
|
||||
* @method init
|
||||
*/
|
||||
init: function() {
|
||||
init();
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -39,39 +39,11 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
* @type {{APPROVE_REQUEST: string}}
|
||||
* @type {{DENY_REQUEST: string}}
|
||||
* @type {{VIEW_REQUEST: string}}
|
||||
* @type {{MARK_COMPLETE: string}}
|
||||
* @type {{CHANGE_BULK_ACTION: string}}
|
||||
* @type {{CONFIRM_BULK_ACTION: string}}
|
||||
* @type {{SELECT_ALL: string}}
|
||||
*/
|
||||
var ACTIONS = {
|
||||
APPROVE_REQUEST: '[data-action="approve"]',
|
||||
DENY_REQUEST: '[data-action="deny"]',
|
||||
VIEW_REQUEST: '[data-action="view"]',
|
||||
MARK_COMPLETE: '[data-action="complete"]',
|
||||
CHANGE_BULK_ACTION: '[id="bulk-action"]',
|
||||
CONFIRM_BULK_ACTION: '[id="confirm-bulk-action"]',
|
||||
SELECT_ALL: '[data-action="selectall"]'
|
||||
};
|
||||
|
||||
/**
|
||||
* List of available bulk actions.
|
||||
*
|
||||
* @type {{APPROVE: number}}
|
||||
* @type {{DENY: number}}
|
||||
*/
|
||||
var BULK_ACTIONS = {
|
||||
APPROVE: 1,
|
||||
DENY: 2
|
||||
};
|
||||
|
||||
/**
|
||||
* List of selectors.
|
||||
*
|
||||
* @type {{SELECT_REQUEST: string}}
|
||||
*/
|
||||
var SELECTORS = {
|
||||
SELECT_REQUEST: '.selectrequests'
|
||||
VIEW_REQUEST: '[data-action="view"]'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -101,9 +73,16 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
};
|
||||
|
||||
var promises = Ajax.call([request]);
|
||||
var modalTitle = '';
|
||||
var modalType = ModalFactory.types.DEFAULT;
|
||||
$.when(promises[0]).then(function(data) {
|
||||
if (data.result) {
|
||||
return data.result;
|
||||
// Check if the status is awaiting approval.
|
||||
if (data.result.status == 2) {
|
||||
modalType = ModalDataRequest.TYPE;
|
||||
}
|
||||
modalTitle = data.result.typename;
|
||||
return Templates.render('tool_dataprivacy/request_details', data.result);
|
||||
}
|
||||
// Fail.
|
||||
Notification.addNotification({
|
||||
@@ -112,209 +91,61 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
});
|
||||
return false;
|
||||
|
||||
}).then(function(data) {
|
||||
var body = Templates.render('tool_dataprivacy/request_details', data);
|
||||
var templateContext = {
|
||||
approvedeny: data.approvedeny,
|
||||
canmarkcomplete: data.canmarkcomplete
|
||||
};
|
||||
}).then(function(html) {
|
||||
return ModalFactory.create({
|
||||
title: data.typename,
|
||||
body: body,
|
||||
type: ModalDataRequest.TYPE,
|
||||
large: true,
|
||||
templateContext: templateContext
|
||||
});
|
||||
title: modalTitle,
|
||||
body: html,
|
||||
type: modalType,
|
||||
large: true
|
||||
}).then(function(modal) {
|
||||
// Handle approve event.
|
||||
modal.getRoot().on(DataPrivacyEvents.approve, function() {
|
||||
showConfirmation(DataPrivacyEvents.approve, requestId);
|
||||
});
|
||||
|
||||
}).then(function(modal) {
|
||||
// Handle approve event.
|
||||
modal.getRoot().on(DataPrivacyEvents.approve, function() {
|
||||
showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));
|
||||
});
|
||||
// Handle deny event.
|
||||
modal.getRoot().on(DataPrivacyEvents.deny, function() {
|
||||
showConfirmation(DataPrivacyEvents.deny, requestId);
|
||||
});
|
||||
|
||||
// Handle deny event.
|
||||
modal.getRoot().on(DataPrivacyEvents.deny, function() {
|
||||
showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));
|
||||
});
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
// Handle send event.
|
||||
modal.getRoot().on(DataPrivacyEvents.complete, function() {
|
||||
var params = {
|
||||
'requestid': requestId
|
||||
};
|
||||
handleSave('tool_dataprivacy_mark_complete', params);
|
||||
return modal;
|
||||
});
|
||||
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
}).done(function(modal) {
|
||||
// Show the modal!
|
||||
modal.show();
|
||||
|
||||
return;
|
||||
|
||||
}).catch(Notification.exception);
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
|
||||
$(ACTIONS.APPROVE_REQUEST).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var requestId = $(this).data('requestid');
|
||||
showConfirmation(DataPrivacyEvents.approve, approveEventWsData(requestId));
|
||||
showConfirmation(DataPrivacyEvents.approve, requestId);
|
||||
});
|
||||
|
||||
$(ACTIONS.DENY_REQUEST).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var requestId = $(this).data('requestid');
|
||||
showConfirmation(DataPrivacyEvents.deny, denyEventWsData(requestId));
|
||||
});
|
||||
|
||||
$(ACTIONS.MARK_COMPLETE).click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var requestId = $(this).data('requestid');
|
||||
showConfirmation(DataPrivacyEvents.complete, completeEventWsData(requestId));
|
||||
});
|
||||
|
||||
$(ACTIONS.CONFIRM_BULK_ACTION).click(function() {
|
||||
var requestIds = [];
|
||||
var actionEvent = '';
|
||||
var wsdata = {};
|
||||
var bulkActionKeys = [
|
||||
{
|
||||
key: 'selectbulkaction',
|
||||
component: 'tool_dataprivacy'
|
||||
},
|
||||
{
|
||||
key: 'selectdatarequests',
|
||||
component: 'tool_dataprivacy'
|
||||
},
|
||||
{
|
||||
key: 'ok'
|
||||
}
|
||||
];
|
||||
|
||||
var bulkaction = parseInt($('#bulk-action').val());
|
||||
|
||||
if (bulkaction != BULK_ACTIONS.APPROVE && bulkaction != BULK_ACTIONS.DENY) {
|
||||
Str.get_strings(bulkActionKeys).done(function(langStrings) {
|
||||
Notification.alert('', langStrings[0], langStrings[2]);
|
||||
}).fail(Notification.exception);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$(".selectrequests:checked").each(function() {
|
||||
requestIds.push($(this).val());
|
||||
});
|
||||
|
||||
if (requestIds.length < 1) {
|
||||
Str.get_strings(bulkActionKeys).done(function(langStrings) {
|
||||
Notification.alert('', langStrings[1], langStrings[2]);
|
||||
}).fail(Notification.exception);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (bulkaction) {
|
||||
case BULK_ACTIONS.APPROVE:
|
||||
actionEvent = DataPrivacyEvents.bulkApprove;
|
||||
wsdata = bulkApproveEventWsData(requestIds);
|
||||
break;
|
||||
case BULK_ACTIONS.DENY:
|
||||
actionEvent = DataPrivacyEvents.bulkDeny;
|
||||
wsdata = bulkDenyEventWsData(requestIds);
|
||||
}
|
||||
|
||||
showConfirmation(actionEvent, wsdata);
|
||||
});
|
||||
|
||||
$(ACTIONS.SELECT_ALL).change(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var selectAll = $(this).is(':checked');
|
||||
$(SELECTORS.SELECT_REQUEST).prop('checked', selectAll);
|
||||
showConfirmation(DataPrivacyEvents.deny, requestId);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the webservice data for the approve request action.
|
||||
*
|
||||
* @param {Number} requestId The ID of the request.
|
||||
* @return {Object}
|
||||
*/
|
||||
function approveEventWsData(requestId) {
|
||||
return {
|
||||
'wsfunction': 'tool_dataprivacy_approve_data_request',
|
||||
'wsparams': {'requestid': requestId}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the webservice data for the bulk approve request action.
|
||||
*
|
||||
* @param {Array} requestIds The array of request ID's.
|
||||
* @return {Object}
|
||||
*/
|
||||
function bulkApproveEventWsData(requestIds) {
|
||||
return {
|
||||
'wsfunction': 'tool_dataprivacy_bulk_approve_data_requests',
|
||||
'wsparams': {'requestids': requestIds}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the webservice data for the deny request action.
|
||||
*
|
||||
* @param {Number} requestId The ID of the request.
|
||||
* @return {Object}
|
||||
*/
|
||||
function denyEventWsData(requestId) {
|
||||
return {
|
||||
'wsfunction': 'tool_dataprivacy_deny_data_request',
|
||||
'wsparams': {'requestid': requestId}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the webservice data for the bulk deny request action.
|
||||
*
|
||||
* @param {Array} requestIds The array of request ID's.
|
||||
* @return {Object}
|
||||
*/
|
||||
function bulkDenyEventWsData(requestIds) {
|
||||
return {
|
||||
'wsfunction': 'tool_dataprivacy_bulk_deny_data_requests',
|
||||
'wsparams': {'requestids': requestIds}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the webservice data for the complete request action.
|
||||
*
|
||||
* @param {Number} requestId The ID of the request.
|
||||
* @return {Object}
|
||||
*/
|
||||
function completeEventWsData(requestId) {
|
||||
return {
|
||||
'wsfunction': 'tool_dataprivacy_mark_complete',
|
||||
'wsparams': {'requestid': requestId}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the confirmation dialogue.
|
||||
*
|
||||
* @param {String} action The action name.
|
||||
* @param {Object} wsdata Object containing ws data.
|
||||
* @param {Number} requestId The request ID.
|
||||
*/
|
||||
function showConfirmation(action, wsdata) {
|
||||
function showConfirmation(action, requestId) {
|
||||
var keys = [];
|
||||
|
||||
var wsfunction = '';
|
||||
switch (action) {
|
||||
case DataPrivacyEvents.approve:
|
||||
keys = [
|
||||
@@ -327,18 +158,7 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
component: 'tool_dataprivacy'
|
||||
}
|
||||
];
|
||||
break;
|
||||
case DataPrivacyEvents.bulkApprove:
|
||||
keys = [
|
||||
{
|
||||
key: 'bulkapproverequests',
|
||||
component: 'tool_dataprivacy'
|
||||
},
|
||||
{
|
||||
key: 'confirmbulkapproval',
|
||||
component: 'tool_dataprivacy'
|
||||
}
|
||||
];
|
||||
wsfunction = 'tool_dataprivacy_approve_data_request';
|
||||
break;
|
||||
case DataPrivacyEvents.deny:
|
||||
keys = [
|
||||
@@ -351,30 +171,7 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
component: 'tool_dataprivacy'
|
||||
}
|
||||
];
|
||||
break;
|
||||
case DataPrivacyEvents.bulkDeny:
|
||||
keys = [
|
||||
{
|
||||
key: 'bulkdenyrequests',
|
||||
component: 'tool_dataprivacy'
|
||||
},
|
||||
{
|
||||
key: 'confirmbulkdenial',
|
||||
component: 'tool_dataprivacy'
|
||||
}
|
||||
];
|
||||
break;
|
||||
case DataPrivacyEvents.complete:
|
||||
keys = [
|
||||
{
|
||||
key: 'markcomplete',
|
||||
component: 'tool_dataprivacy'
|
||||
},
|
||||
{
|
||||
key: 'confirmcompletion',
|
||||
component: 'tool_dataprivacy'
|
||||
}
|
||||
];
|
||||
wsfunction = 'tool_dataprivacy_deny_data_request';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -392,7 +189,26 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
|
||||
// Handle save event.
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
handleSave(wsdata.wsfunction, wsdata.wsparams);
|
||||
// Confirm the request.
|
||||
var params = {
|
||||
'requestid': requestId
|
||||
};
|
||||
|
||||
var request = {
|
||||
methodname: wsfunction,
|
||||
args: params
|
||||
};
|
||||
|
||||
Ajax.call([request])[0].done(function(data) {
|
||||
if (data.result) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
Notification.addNotification({
|
||||
message: data.warnings[0].message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
|
||||
// Handle hidden event.
|
||||
@@ -401,39 +217,9 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Modal
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
return modal;
|
||||
}).done(function(modal) {
|
||||
modal.show();
|
||||
|
||||
return;
|
||||
|
||||
}).catch(Notification.exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a web service function and reloads the page on success and shows a notification.
|
||||
* Displays an error notification, otherwise.
|
||||
*
|
||||
* @param {String} wsfunction The web service function to call.
|
||||
* @param {Object} params The parameters for the web service functoon.
|
||||
*/
|
||||
function handleSave(wsfunction, params) {
|
||||
// Confirm the request.
|
||||
var request = {
|
||||
methodname: wsfunction,
|
||||
args: params
|
||||
};
|
||||
|
||||
Ajax.call([request])[0].done(function(data) {
|
||||
if (data.result) {
|
||||
// On success, reload the page so that the data request table will be updated.
|
||||
// TODO: Probably in the future, better to reload the table or the target data request via AJAX.
|
||||
window.location.reload();
|
||||
} else {
|
||||
// Add the notification.
|
||||
Notification.addNotification({
|
||||
message: data.warnings[0].message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}).fail(Notification.exception);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
require_login(null, false);
|
||||
|
||||
$url = new moodle_url("/admin/tool/dataprivacy/categories.php");
|
||||
$title = get_string('editcategories', 'tool_dataprivacy');
|
||||
|
||||
@@ -33,7 +31,6 @@ $title = get_string('editcategories', 'tool_dataprivacy');
|
||||
|
||||
$output = $PAGE->get_renderer('tool_dataprivacy');
|
||||
echo $output->header();
|
||||
echo $output->heading($title);
|
||||
|
||||
$categories = \tool_dataprivacy\api::get_categories();
|
||||
$renderable = new \tool_dataprivacy\output\categories($categories);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
use coding_exception;
|
||||
use context_helper;
|
||||
use context_system;
|
||||
use core\invalid_persistent_exception;
|
||||
use core\message\message;
|
||||
@@ -38,10 +37,8 @@ use moodle_url;
|
||||
use required_capability_exception;
|
||||
use stdClass;
|
||||
use tool_dataprivacy\external\data_request_exporter;
|
||||
use tool_dataprivacy\local\helper;
|
||||
use tool_dataprivacy\task\initiate_data_request_task;
|
||||
use tool_dataprivacy\task\process_data_request_task;
|
||||
use tool_dataprivacy\data_request;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -77,7 +74,7 @@ class api {
|
||||
/** The request is now being processed. */
|
||||
const DATAREQUEST_STATUS_PROCESSING = 4;
|
||||
|
||||
/** Information/other request completed. */
|
||||
/** Data request completed. */
|
||||
const DATAREQUEST_STATUS_COMPLETE = 5;
|
||||
|
||||
/** Data request cancelled by the user. */
|
||||
@@ -86,21 +83,6 @@ class api {
|
||||
/** Data request rejected by the DPO. */
|
||||
const DATAREQUEST_STATUS_REJECTED = 7;
|
||||
|
||||
/** Data request download ready. */
|
||||
const DATAREQUEST_STATUS_DOWNLOAD_READY = 8;
|
||||
|
||||
/** Data request expired. */
|
||||
const DATAREQUEST_STATUS_EXPIRED = 9;
|
||||
|
||||
/** Data delete request completed, account is removed. */
|
||||
const DATAREQUEST_STATUS_DELETED = 10;
|
||||
|
||||
/** Approve data request. */
|
||||
const DATAREQUEST_ACTION_APPROVE = 1;
|
||||
|
||||
/** Reject data request. */
|
||||
const DATAREQUEST_ACTION_REJECT = 2;
|
||||
|
||||
/**
|
||||
* Determines whether the user can contact the site's Data Protection Officer via Moodle.
|
||||
*
|
||||
@@ -112,14 +94,18 @@ class api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current user has the capability to manage data requests.
|
||||
* Check's whether the current user has the capability to manage data requests.
|
||||
*
|
||||
* @param int $userid The user ID.
|
||||
* @return bool
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
*/
|
||||
public static function can_manage_data_requests($userid) {
|
||||
// Privacy officers can manage data requests.
|
||||
return self::is_site_dpo($userid);
|
||||
$context = context_system::instance();
|
||||
|
||||
// A user can manage data requests if he/she has the site DPO role and has the capability to manage data requests.
|
||||
return self::is_site_dpo($userid) && has_capability('tool/dataprivacy:managedatarequests', $context, $userid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,59 +126,20 @@ class api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the list of configured privacy officer roles.
|
||||
* Fetches the list of users with the Data Protection Officer role.
|
||||
*
|
||||
* Every time this function is called, it checks each role if they have the 'managedatarequests' capability and removes
|
||||
* any role that doesn't have the required capability anymore.
|
||||
*
|
||||
* @return int[]
|
||||
* @throws dml_exception
|
||||
*/
|
||||
public static function get_assigned_privacy_officer_roles() {
|
||||
$roleids = [];
|
||||
|
||||
// Get roles from config.
|
||||
$configroleids = explode(',', str_replace(' ', '', get_config('tool_dataprivacy', 'dporoles')));
|
||||
if (!empty($configroleids)) {
|
||||
// Fetch roles that have the capability to manage data requests.
|
||||
$capableroles = array_keys(get_roles_with_capability('tool/dataprivacy:managedatarequests'));
|
||||
|
||||
// Extract the configured roles that have the capability from the list of capable roles.
|
||||
$roleids = array_intersect($capableroles, $configroleids);
|
||||
}
|
||||
|
||||
return $roleids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the role shortnames of Data Protection Officer roles.
|
||||
*
|
||||
* @return array An array of the DPO role shortnames
|
||||
*/
|
||||
public static function get_dpo_role_names() : array {
|
||||
global $DB;
|
||||
|
||||
$dporoleids = self::get_assigned_privacy_officer_roles();
|
||||
$dponames = array();
|
||||
|
||||
if (!empty($dporoleids)) {
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($dporoleids);
|
||||
$dponames = $DB->get_fieldset_select('role', 'shortname', "id {$insql}", $inparams);
|
||||
}
|
||||
|
||||
return $dponames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the list of users with the Privacy Officer role.
|
||||
*/
|
||||
public static function get_site_dpos() {
|
||||
// Get role(s) that can manage data requests.
|
||||
$dporoles = self::get_assigned_privacy_officer_roles();
|
||||
$dporoles = explode(',', get_config('tool_dataprivacy', 'dporoles'));
|
||||
|
||||
$dpos = [];
|
||||
$context = context_system::instance();
|
||||
foreach ($dporoles as $roleid) {
|
||||
if (empty($roleid)) {
|
||||
continue;
|
||||
}
|
||||
$allnames = get_all_user_name_fields(true, 'u');
|
||||
$fields = 'u.id, u.confirmed, u.username, '. $allnames . ', ' .
|
||||
'u.maildisplay, u.mailformat, u.maildigest, u.email, u.emailstop, u.city, '.
|
||||
@@ -212,14 +159,15 @@ class api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given user is a site Privacy Officer.
|
||||
* Checks whether a given user is a site DPO.
|
||||
*
|
||||
* @param int $userid The user ID.
|
||||
* @return bool
|
||||
* @throws dml_exception
|
||||
*/
|
||||
public static function is_site_dpo($userid) {
|
||||
$dpos = self::get_site_dpos();
|
||||
return array_key_exists($userid, $dpos) || is_siteadmin();
|
||||
return array_key_exists($userid, $dpos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,34 +176,24 @@ class api {
|
||||
* @param int $foruser The user whom the request is being made for.
|
||||
* @param int $type The request type.
|
||||
* @param string $comments Request comments.
|
||||
* @param int $creationmethod The creation method of the data request.
|
||||
* @return data_request
|
||||
* @throws invalid_persistent_exception
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function create_data_request($foruser, $type, $comments = '',
|
||||
$creationmethod = data_request::DATAREQUEST_CREATION_MANUAL) {
|
||||
public static function create_data_request($foruser, $type, $comments = '') {
|
||||
global $USER;
|
||||
|
||||
$datarequest = new data_request();
|
||||
// The user the request is being made for.
|
||||
$datarequest->set('userid', $foruser);
|
||||
|
||||
// The cron is considered to be a guest user when it creates a data request.
|
||||
// NOTE: This should probably be changed. We should leave the default value for $requestinguser if
|
||||
// the request is not explicitly created by a specific user.
|
||||
$requestinguser = (isguestuser() && $creationmethod == data_request::DATAREQUEST_CREATION_AUTO) ?
|
||||
get_admin()->id : $USER->id;
|
||||
// The user making the request.
|
||||
$datarequest->set('requestedby', $requestinguser);
|
||||
$datarequest->set('requestedby', $USER->id);
|
||||
// Set status.
|
||||
$datarequest->set('status', self::DATAREQUEST_STATUS_PENDING);
|
||||
// Set request type.
|
||||
$datarequest->set('type', $type);
|
||||
// Set request comments.
|
||||
$datarequest->set('comments', $comments);
|
||||
// Set the creation method.
|
||||
$datarequest->set('creationmethod', $creationmethod);
|
||||
|
||||
// Store subject access request.
|
||||
$datarequest->create();
|
||||
@@ -276,164 +214,30 @@ class api {
|
||||
* (e.g. Users with the Data Protection Officer roles)
|
||||
*
|
||||
* @param int $userid The User ID.
|
||||
* @param int[] $statuses The status filters.
|
||||
* @param int[] $types The request type filters.
|
||||
* @param int[] $creationmethods The request creation method filters.
|
||||
* @param string $sort The order by clause.
|
||||
* @param int $offset Amount of records to skip.
|
||||
* @param int $limit Amount of records to fetch.
|
||||
* @return data_request[]
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
*/
|
||||
public static function get_data_requests($userid = 0, $statuses = [], $types = [], $creationmethods = [],
|
||||
$sort = '', $offset = 0, $limit = 0) {
|
||||
global $DB, $USER;
|
||||
public static function get_data_requests($userid = 0) {
|
||||
global $USER;
|
||||
$results = [];
|
||||
$sqlparams = [];
|
||||
$sqlconditions = [];
|
||||
|
||||
// Set default sort.
|
||||
if (empty($sort)) {
|
||||
$sort = 'status ASC, timemodified ASC';
|
||||
}
|
||||
|
||||
// Set status filters.
|
||||
if (!empty($statuses)) {
|
||||
list($statusinsql, $sqlparams) = $DB->get_in_or_equal($statuses, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] = "status $statusinsql";
|
||||
}
|
||||
|
||||
// Set request type filter.
|
||||
if (!empty($types)) {
|
||||
list($typeinsql, $typeparams) = $DB->get_in_or_equal($types, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] = "type $typeinsql";
|
||||
$sqlparams = array_merge($sqlparams, $typeparams);
|
||||
}
|
||||
|
||||
// Set request creation method filter.
|
||||
if (!empty($creationmethods)) {
|
||||
list($typeinsql, $typeparams) = $DB->get_in_or_equal($creationmethods, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] = "creationmethod $typeinsql";
|
||||
$sqlparams = array_merge($sqlparams, $typeparams);
|
||||
}
|
||||
|
||||
if ($userid) {
|
||||
// Get the data requests for the user or data requests made by the user.
|
||||
$sqlconditions[] = "(userid = :userid OR requestedby = :requestedby)";
|
||||
$select = "userid = :userid OR requestedby = :requestedby";
|
||||
$params = [
|
||||
'userid' => $userid,
|
||||
'requestedby' => $userid
|
||||
];
|
||||
|
||||
// Build a list of user IDs that the user is allowed to make data requests for.
|
||||
// Of course, the user should be included in this list.
|
||||
$alloweduserids = [$userid];
|
||||
// Get any users that the user can make data requests for.
|
||||
if ($children = helper::get_children_of_user($userid)) {
|
||||
// Get the list of user IDs of the children and merge to the allowed user IDs.
|
||||
$alloweduserids = array_merge($alloweduserids, array_keys($children));
|
||||
}
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($alloweduserids, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] .= "userid $insql";
|
||||
$select = implode(' AND ', $sqlconditions);
|
||||
$params = array_merge($params, $inparams, $sqlparams);
|
||||
|
||||
$results = data_request::get_records_select($select, $params, $sort, '*', $offset, $limit);
|
||||
$results = data_request::get_records_select($select, $params, 'status DESC, timemodified DESC');
|
||||
} else {
|
||||
// If the current user is one of the site's Data Protection Officers, then fetch all data requests.
|
||||
if (self::is_site_dpo($USER->id)) {
|
||||
if (!empty($sqlconditions)) {
|
||||
$select = implode(' AND ', $sqlconditions);
|
||||
$results = data_request::get_records_select($select, $sqlparams, $sort, '*', $offset, $limit);
|
||||
} else {
|
||||
$results = data_request::get_records(null, $sort, '', $offset, $limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If any are due to expire, expire them and re-fetch updated data.
|
||||
if (empty($statuses)
|
||||
|| in_array(self::DATAREQUEST_STATUS_DOWNLOAD_READY, $statuses)
|
||||
|| in_array(self::DATAREQUEST_STATUS_EXPIRED, $statuses)) {
|
||||
$expiredrequests = data_request::get_expired_requests($userid);
|
||||
|
||||
if (!empty($expiredrequests)) {
|
||||
data_request::expire($expiredrequests);
|
||||
$results = self::get_data_requests($userid, $statuses, $types, $creationmethods, $sort, $offset, $limit);
|
||||
$results = data_request::get_records(null, 'status DESC, timemodified DESC', '');
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the count of data request records based on the given parameters.
|
||||
*
|
||||
* @param int $userid The User ID.
|
||||
* @param int[] $statuses The status filters.
|
||||
* @param int[] $types The request type filters.
|
||||
* @param int[] $creationmethods The request creation method filters.
|
||||
* @return int
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
*/
|
||||
public static function get_data_requests_count($userid = 0, $statuses = [], $types = [], $creationmethods = []) {
|
||||
global $DB, $USER;
|
||||
$count = 0;
|
||||
$sqlparams = [];
|
||||
$sqlconditions = [];
|
||||
if (!empty($statuses)) {
|
||||
list($statusinsql, $sqlparams) = $DB->get_in_or_equal($statuses, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] = "status $statusinsql";
|
||||
}
|
||||
if (!empty($types)) {
|
||||
list($typeinsql, $typeparams) = $DB->get_in_or_equal($types, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] = "type $typeinsql";
|
||||
$sqlparams = array_merge($sqlparams, $typeparams);
|
||||
}
|
||||
if (!empty($creationmethods)) {
|
||||
list($typeinsql, $typeparams) = $DB->get_in_or_equal($creationmethods, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] = "creationmethod $typeinsql";
|
||||
$sqlparams = array_merge($sqlparams, $typeparams);
|
||||
}
|
||||
if ($userid) {
|
||||
// Get the data requests for the user or data requests made by the user.
|
||||
$sqlconditions[] = "(userid = :userid OR requestedby = :requestedby)";
|
||||
$params = [
|
||||
'userid' => $userid,
|
||||
'requestedby' => $userid
|
||||
];
|
||||
|
||||
// Build a list of user IDs that the user is allowed to make data requests for.
|
||||
// Of course, the user should be included in this list.
|
||||
$alloweduserids = [$userid];
|
||||
// Get any users that the user can make data requests for.
|
||||
if ($children = helper::get_children_of_user($userid)) {
|
||||
// Get the list of user IDs of the children and merge to the allowed user IDs.
|
||||
$alloweduserids = array_merge($alloweduserids, array_keys($children));
|
||||
}
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($alloweduserids, SQL_PARAMS_NAMED);
|
||||
$sqlconditions[] .= "userid $insql";
|
||||
$select = implode(' AND ', $sqlconditions);
|
||||
$params = array_merge($params, $inparams, $sqlparams);
|
||||
|
||||
$count = data_request::count_records_select($select, $params);
|
||||
} else {
|
||||
// If the current user is one of the site's Data Protection Officers, then fetch all data requests.
|
||||
if (self::is_site_dpo($USER->id)) {
|
||||
if (!empty($sqlconditions)) {
|
||||
$select = implode(' AND ', $sqlconditions);
|
||||
$count = data_request::count_records_select($select, $sqlparams);
|
||||
} else {
|
||||
$count = data_request::count_records();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether there is already an existing pending/in-progress data request for a user for a given request type.
|
||||
*
|
||||
@@ -451,12 +255,9 @@ class api {
|
||||
self::DATAREQUEST_STATUS_COMPLETE,
|
||||
self::DATAREQUEST_STATUS_CANCELLED,
|
||||
self::DATAREQUEST_STATUS_REJECTED,
|
||||
self::DATAREQUEST_STATUS_DOWNLOAD_READY,
|
||||
self::DATAREQUEST_STATUS_EXPIRED,
|
||||
self::DATAREQUEST_STATUS_DELETED,
|
||||
];
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($nonpendingstatuses, SQL_PARAMS_NAMED, 'st', false);
|
||||
$select = "type = :type AND userid = :userid AND status {$insql}";
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($nonpendingstatuses, SQL_PARAMS_NAMED);
|
||||
$select = 'type = :type AND userid = :userid AND status NOT ' . $insql;
|
||||
$params = array_merge([
|
||||
'type' => $type,
|
||||
'userid' => $userid
|
||||
@@ -465,48 +266,6 @@ class api {
|
||||
return data_request::record_exists_select($select, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find whether any ongoing requests exist for a set of users.
|
||||
*
|
||||
* @param array $userids
|
||||
* @return array
|
||||
*/
|
||||
public static function find_ongoing_request_types_for_users(array $userids) : array {
|
||||
global $DB;
|
||||
|
||||
if (empty($userids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Check if the user already has an incomplete data request of the same type.
|
||||
$nonpendingstatuses = [
|
||||
self::DATAREQUEST_STATUS_COMPLETE,
|
||||
self::DATAREQUEST_STATUS_CANCELLED,
|
||||
self::DATAREQUEST_STATUS_REJECTED,
|
||||
self::DATAREQUEST_STATUS_DOWNLOAD_READY,
|
||||
self::DATAREQUEST_STATUS_EXPIRED,
|
||||
self::DATAREQUEST_STATUS_DELETED,
|
||||
];
|
||||
list($statusinsql, $statusparams) = $DB->get_in_or_equal($nonpendingstatuses, SQL_PARAMS_NAMED, 'st', false);
|
||||
list($userinsql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'us');
|
||||
|
||||
$select = "userid {$userinsql} AND status {$statusinsql}";
|
||||
$params = array_merge($statusparams, $userparams);
|
||||
|
||||
$requests = $DB->get_records_select(data_request::TABLE, $select, $params, 'userid', 'id, userid, type');
|
||||
|
||||
$returnval = [];
|
||||
foreach ($userids as $userid) {
|
||||
$returnval[$userid] = (object) [];
|
||||
}
|
||||
|
||||
foreach ($requests as $request) {
|
||||
$returnval[$request->userid]->{$request->type} = true;
|
||||
}
|
||||
|
||||
return $returnval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a request is active or not based on its status.
|
||||
*
|
||||
@@ -519,9 +278,6 @@ class api {
|
||||
self::DATAREQUEST_STATUS_COMPLETE,
|
||||
self::DATAREQUEST_STATUS_CANCELLED,
|
||||
self::DATAREQUEST_STATUS_REJECTED,
|
||||
self::DATAREQUEST_STATUS_DOWNLOAD_READY,
|
||||
self::DATAREQUEST_STATUS_EXPIRED,
|
||||
self::DATAREQUEST_STATUS_DELETED,
|
||||
];
|
||||
|
||||
return !in_array($status, $finalstatuses);
|
||||
@@ -533,34 +289,17 @@ class api {
|
||||
* @param int $requestid The request identifier.
|
||||
* @param int $status The request status.
|
||||
* @param int $dpoid The user ID of the Data Protection Officer
|
||||
* @param string $comment The comment about the status update.
|
||||
* @return bool
|
||||
* @throws invalid_persistent_exception
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function update_request_status($requestid, $status, $dpoid = 0, $comment = '') {
|
||||
public static function update_request_status($requestid, $status, $dpoid = 0) {
|
||||
// Update the request.
|
||||
$datarequest = new data_request($requestid);
|
||||
$datarequest->set('status', $status);
|
||||
if ($dpoid) {
|
||||
$datarequest->set('dpo', $dpoid);
|
||||
}
|
||||
// Update the comment if necessary.
|
||||
if (!empty(trim($comment))) {
|
||||
$params = [
|
||||
'date' => userdate(time()),
|
||||
'comment' => $comment
|
||||
];
|
||||
$commenttosave = get_string('datecomment', 'tool_dataprivacy', $params);
|
||||
// Check if there's an existing DPO comment.
|
||||
$currentcomment = trim($datarequest->get('dpocomment'));
|
||||
if ($currentcomment) {
|
||||
// Append the new comment to the current comment and give them 1 line space in between.
|
||||
$commenttosave = $currentcomment . PHP_EOL . PHP_EOL . $commenttosave;
|
||||
}
|
||||
$datarequest->set('dpocomment', $commenttosave);
|
||||
}
|
||||
|
||||
return $datarequest->update();
|
||||
}
|
||||
|
||||
@@ -655,6 +394,7 @@ class api {
|
||||
* @param data_request $request The data request
|
||||
* @return int|false
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function notify_dpo($dpo, data_request $request) {
|
||||
@@ -677,7 +417,7 @@ class api {
|
||||
$message->courseid = $SITE->id;
|
||||
$message->component = 'tool_dataprivacy';
|
||||
$message->name = 'contactdataprotectionofficer';
|
||||
$message->userfrom = $requestedby->id;
|
||||
$message->userfrom = $requestedby;
|
||||
$message->replyto = $requestedby->email;
|
||||
$message->replytoname = $requestedby->fullname;
|
||||
$message->subject = $subject;
|
||||
@@ -691,8 +431,6 @@ class api {
|
||||
'requestedby' => $requestedby->fullname,
|
||||
'requesttype' => $typetext,
|
||||
'requestdate' => userdate($requestdata->timecreated),
|
||||
'requestorigin' => $SITE->fullname,
|
||||
'requestoriginurl' => new moodle_url('/'),
|
||||
'requestcomments' => $requestdata->messagehtml,
|
||||
'datarequestsurl' => $datarequestsurl
|
||||
];
|
||||
@@ -715,82 +453,6 @@ class api {
|
||||
return message_send($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a non-DPO user can make a data request for another user.
|
||||
*
|
||||
* @param int $user The user ID of the target user.
|
||||
* @param int $requester The user ID of the user making the request.
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_create_data_request_for_user($user, $requester = null) {
|
||||
$usercontext = \context_user::instance($user);
|
||||
|
||||
return has_capability('tool/dataprivacy:makedatarequestsforchildren', $usercontext, $requester);
|
||||
}
|
||||
|
||||
/**
|
||||
* Require that the current user can make a data request for the specified other user.
|
||||
*
|
||||
* @param int $user The user ID of the target user.
|
||||
* @param int $requester The user ID of the user making the request.
|
||||
* @return bool
|
||||
*/
|
||||
public static function require_can_create_data_request_for_user($user, $requester = null) {
|
||||
$usercontext = \context_user::instance($user);
|
||||
|
||||
require_capability('tool/dataprivacy:makedatarequestsforchildren', $usercontext, $requester);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a user can download a data request.
|
||||
*
|
||||
* @param int $userid Target user id (subject of data request)
|
||||
* @param int $requesterid Requester user id (person who requsted it)
|
||||
* @param int|null $downloaderid Person who wants to download user id (default current)
|
||||
* @return bool
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function can_download_data_request_for_user($userid, $requesterid, $downloaderid = null) {
|
||||
global $USER;
|
||||
|
||||
if (!$downloaderid) {
|
||||
$downloaderid = $USER->id;
|
||||
}
|
||||
|
||||
$usercontext = \context_user::instance($userid);
|
||||
// If it's your own and you have the right capability, you can download it.
|
||||
if ($userid == $downloaderid && has_capability('tool/dataprivacy:downloadownrequest', $usercontext, $downloaderid)) {
|
||||
return true;
|
||||
}
|
||||
// If you can download anyone's in that context, you can download it.
|
||||
if (has_capability('tool/dataprivacy:downloadallrequests', $usercontext, $downloaderid)) {
|
||||
return true;
|
||||
}
|
||||
// If you can have the 'child access' ability to request in that context, and you are the one
|
||||
// who requested it, then you can download it.
|
||||
if ($requesterid == $downloaderid && self::can_create_data_request_for_user($userid, $requesterid)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an action menu link to download a data request.
|
||||
*
|
||||
* @param \context_user $usercontext User context (of user who the data is for)
|
||||
* @param int $requestid Request id
|
||||
* @return \action_menu_link_secondary Action menu link
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function get_download_link(\context_user $usercontext, $requestid) {
|
||||
$downloadurl = moodle_url::make_pluginfile_url($usercontext->id,
|
||||
'tool_dataprivacy', 'export', $requestid, '/', 'export.zip', true);
|
||||
$downloadtext = get_string('download', 'tool_dataprivacy');
|
||||
return new \action_menu_link_secondary($downloadurl, null, $downloadtext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new data purpose.
|
||||
*
|
||||
@@ -798,6 +460,8 @@ class api {
|
||||
* @return \tool_dataprivacy\purpose.
|
||||
*/
|
||||
public static function create_purpose(stdClass $record) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$purpose = new purpose(0, $record);
|
||||
$purpose->create();
|
||||
|
||||
@@ -811,9 +475,7 @@ class api {
|
||||
* @return \tool_dataprivacy\purpose.
|
||||
*/
|
||||
public static function update_purpose(stdClass $record) {
|
||||
if (!isset($record->sensitivedatareasons)) {
|
||||
$record->sensitivedatareasons = '';
|
||||
}
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$purpose = new purpose($record->id);
|
||||
$purpose->from_record($record);
|
||||
@@ -830,6 +492,8 @@ class api {
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete_purpose($id) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$purpose = new purpose($id);
|
||||
if ($purpose->is_used()) {
|
||||
throw new \moodle_exception('Purpose with id ' . $id . ' can not be deleted because it is used.');
|
||||
@@ -843,6 +507,8 @@ class api {
|
||||
* @return \tool_dataprivacy\purpose[]
|
||||
*/
|
||||
public static function get_purposes() {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
return purpose::get_records([], 'name', 'ASC');
|
||||
}
|
||||
|
||||
@@ -853,6 +519,8 @@ class api {
|
||||
* @return \tool_dataprivacy\category.
|
||||
*/
|
||||
public static function create_category(stdClass $record) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$category = new category(0, $record);
|
||||
$category->create();
|
||||
|
||||
@@ -866,6 +534,8 @@ class api {
|
||||
* @return \tool_dataprivacy\category.
|
||||
*/
|
||||
public static function update_category(stdClass $record) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$category = new category($record->id);
|
||||
$category->from_record($record);
|
||||
|
||||
@@ -881,6 +551,8 @@ class api {
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete_category($id) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$category = new category($id);
|
||||
if ($category->is_used()) {
|
||||
throw new \moodle_exception('Category with id ' . $id . ' can not be deleted because it is used.');
|
||||
@@ -894,6 +566,8 @@ class api {
|
||||
* @return \tool_dataprivacy\category[]
|
||||
*/
|
||||
public static function get_categories() {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
return category::get_records([], 'name', 'ASC');
|
||||
}
|
||||
|
||||
@@ -904,6 +578,8 @@ class api {
|
||||
* @return \tool_dataprivacy\context_instance
|
||||
*/
|
||||
public static function set_context_instance($record) {
|
||||
self::check_can_manage_data_registry($record->contextid);
|
||||
|
||||
if ($instance = context_instance::get_record_by_contextid($record->contextid, false)) {
|
||||
// Update.
|
||||
$instance->from_record($record);
|
||||
@@ -930,6 +606,7 @@ class api {
|
||||
* @return null
|
||||
*/
|
||||
public static function unset_context_instance(context_instance $instance) {
|
||||
self::check_can_manage_data_registry($instance->get('contextid'));
|
||||
$instance->delete();
|
||||
}
|
||||
|
||||
@@ -943,6 +620,9 @@ class api {
|
||||
public static function set_contextlevel($record) {
|
||||
global $DB;
|
||||
|
||||
// Only manager at system level can set this.
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
if ($record->contextlevel != CONTEXT_SYSTEM && $record->contextlevel != CONTEXT_USER) {
|
||||
throw new \coding_exception('Only context system and context user can set a contextlevel ' .
|
||||
'purpose and retention');
|
||||
@@ -973,7 +653,8 @@ class api {
|
||||
* @param int $forcedvalue Use this categoryid value as if this was this context instance category.
|
||||
* @return category|false
|
||||
*/
|
||||
public static function get_effective_context_category(\context $context, $forcedvalue = false) {
|
||||
public static function get_effective_context_category(\context $context, $forcedvalue=false) {
|
||||
self::check_can_manage_data_registry($context->id);
|
||||
if (!data_registry::defaults_set()) {
|
||||
return false;
|
||||
}
|
||||
@@ -988,7 +669,8 @@ class api {
|
||||
* @param int $forcedvalue Use this purposeid value as if this was this context instance purpose.
|
||||
* @return purpose|false
|
||||
*/
|
||||
public static function get_effective_context_purpose(\context $context, $forcedvalue = false) {
|
||||
public static function get_effective_context_purpose(\context $context, $forcedvalue=false) {
|
||||
self::check_can_manage_data_registry($context->id);
|
||||
if (!data_registry::defaults_set()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1000,14 +682,16 @@ class api {
|
||||
* Returns the effective category given a context level.
|
||||
*
|
||||
* @param int $contextlevel
|
||||
* @param int $forcedvalue Use this categoryid value as if this was this context level category.
|
||||
* @return category|false
|
||||
*/
|
||||
public static function get_effective_contextlevel_category($contextlevel) {
|
||||
public static function get_effective_contextlevel_category($contextlevel, $forcedvalue=false) {
|
||||
self::check_can_manage_data_registry(\context_system::instance()->id);
|
||||
if (!data_registry::defaults_set()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return data_registry::get_effective_contextlevel_value($contextlevel, 'category');
|
||||
return data_registry::get_effective_contextlevel_value($contextlevel, 'category', $forcedvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1018,6 +702,7 @@ class api {
|
||||
* @return purpose|false
|
||||
*/
|
||||
public static function get_effective_contextlevel_purpose($contextlevel, $forcedvalue=false) {
|
||||
self::check_can_manage_data_registry(\context_system::instance()->id);
|
||||
if (!data_registry::defaults_set()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1032,6 +717,8 @@ class api {
|
||||
* @return \tool_dataprivacy\expired_context
|
||||
*/
|
||||
public static function create_expired_context($contextid) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$record = (object)[
|
||||
'contextid' => $contextid,
|
||||
'status' => expired_context::STATUS_EXPIRED,
|
||||
@@ -1049,6 +736,8 @@ class api {
|
||||
* @return bool True on success.
|
||||
*/
|
||||
public static function delete_expired_context($id) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$expiredcontext = new expired_context($id);
|
||||
return $expiredcontext->delete();
|
||||
}
|
||||
@@ -1061,6 +750,8 @@ class api {
|
||||
* @return null
|
||||
*/
|
||||
public static function set_expired_context_status(expired_context $expiredctx, $status) {
|
||||
self::check_can_manage_data_registry();
|
||||
|
||||
$expiredctx->set('status', $status);
|
||||
$expiredctx->save();
|
||||
}
|
||||
@@ -1073,8 +764,6 @@ class api {
|
||||
* @param int $status the status to set the contexts to.
|
||||
*/
|
||||
public static function add_request_contexts_with_status(contextlist_collection $clcollection, int $requestid, int $status) {
|
||||
$request = new data_request($requestid);
|
||||
$user = \core_user::get_user($request->get('userid'));
|
||||
foreach ($clcollection as $contextlist) {
|
||||
// Convert the \core_privacy\local\request\contextlist into a contextlist persistent and store it.
|
||||
$clp = \tool_dataprivacy\contextlist::from_contextlist($contextlist);
|
||||
@@ -1083,16 +772,6 @@ class api {
|
||||
|
||||
// Store the associated contexts in the contextlist.
|
||||
foreach ($contextlist->get_contextids() as $contextid) {
|
||||
if ($request->get('type') == static::DATAREQUEST_TYPE_DELETE) {
|
||||
$context = \context::instance_by_id($contextid);
|
||||
$purpose = static::get_effective_context_purpose($context);
|
||||
|
||||
// Data can only be deleted from it if the context is either expired, or unprotected.
|
||||
if (!expired_contexts_manager::is_context_expired_or_unprotected_for_user($context, $user)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$context = new contextlist_context();
|
||||
$context->set('contextid', $contextid)
|
||||
->set('contextlistid', $contextlistid)
|
||||
@@ -1189,16 +868,6 @@ class api {
|
||||
}
|
||||
$contexts = [];
|
||||
}
|
||||
|
||||
if ($request->get('type') == static::DATAREQUEST_TYPE_DELETE) {
|
||||
$context = \context::instance_by_id($record->contextid);
|
||||
$purpose = static::get_effective_context_purpose($context);
|
||||
// Data can only be deleted from it if the context is either expired, or unprotected.
|
||||
if (!expired_contexts_manager::is_context_expired_or_unprotected_for_user($context, $foruser)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$contexts[] = $record->contextid;
|
||||
$lastcomponent = $record->component;
|
||||
}
|
||||
@@ -1211,110 +880,4 @@ class api {
|
||||
|
||||
return $approvedcollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the default category and purpose for a given context level (and optionally, a plugin).
|
||||
*
|
||||
* @param int $contextlevel The context level.
|
||||
* @param int $categoryid The ID matching the category.
|
||||
* @param int $purposeid The ID matching the purpose record.
|
||||
* @param int $activity The name of the activity that we're making a defaults configuration for.
|
||||
* @param bool $override Whether to override the purpose/categories of existing instances to these defaults.
|
||||
* @return boolean True if set/unset config succeeds. Otherwise, it throws an exception.
|
||||
*/
|
||||
public static function set_context_defaults($contextlevel, $categoryid, $purposeid, $activity = null, $override = false) {
|
||||
global $DB;
|
||||
|
||||
// Get the class name associated with this context level.
|
||||
$classname = context_helper::get_class_for_level($contextlevel);
|
||||
list($purposevar, $categoryvar) = data_registry::var_names_from_context($classname, $activity);
|
||||
|
||||
// Check the default category to be set.
|
||||
if ($categoryid == context_instance::INHERIT) {
|
||||
unset_config($categoryvar, 'tool_dataprivacy');
|
||||
|
||||
} else {
|
||||
// Make sure the given category ID exists first.
|
||||
$categorypersistent = new category($categoryid);
|
||||
$categorypersistent->read();
|
||||
|
||||
// Then set the new default value.
|
||||
set_config($categoryvar, $categoryid, 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
// Check the default purpose to be set.
|
||||
if ($purposeid == context_instance::INHERIT) {
|
||||
// If the defaults is set to inherit, just unset the config value.
|
||||
unset_config($purposevar, 'tool_dataprivacy');
|
||||
|
||||
} else {
|
||||
// Make sure the given purpose ID exists first.
|
||||
$purposepersistent = new purpose($purposeid);
|
||||
$purposepersistent->read();
|
||||
|
||||
// Then set the new default value.
|
||||
set_config($purposevar, $purposeid, 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
// Unset instances that have been assigned with custom purpose and category, if override was specified.
|
||||
if ($override) {
|
||||
// We'd like to find context IDs that we want to unset.
|
||||
$statements = ["SELECT c.id as contextid FROM {context} c"];
|
||||
// Based on this context level.
|
||||
$params = ['contextlevel' => $contextlevel];
|
||||
|
||||
if ($contextlevel == CONTEXT_MODULE) {
|
||||
// If we're deleting module context instances, we need to make sure the instance ID is in the course modules table.
|
||||
$statements[] = "JOIN {course_modules} cm ON cm.id = c.instanceid";
|
||||
// And that the module is listed on the modules table.
|
||||
$statements[] = "JOIN {modules} m ON m.id = cm.module";
|
||||
|
||||
if ($activity) {
|
||||
// If we're overriding for an activity module, make sure that the context instance matches that activity.
|
||||
$statements[] = "AND m.name = :modname";
|
||||
$params['modname'] = $activity;
|
||||
}
|
||||
}
|
||||
// Make sure this context instance exists in the tool_dataprivacy_ctxinstance table.
|
||||
$statements[] = "JOIN {tool_dataprivacy_ctxinstance} tdc ON tdc.contextid = c.id";
|
||||
// And that the context level of this instance matches the given context level.
|
||||
$statements[] = "WHERE c.contextlevel = :contextlevel";
|
||||
|
||||
// Build our SQL query by gluing the statements.
|
||||
$sql = implode("\n", $statements);
|
||||
|
||||
// Get the context records matching our query.
|
||||
$contextids = $DB->get_fieldset_sql($sql, $params);
|
||||
|
||||
// Delete the matching context instances.
|
||||
foreach ($contextids as $contextid) {
|
||||
if ($instance = context_instance::get_record_by_contextid($contextid, false)) {
|
||||
self::unset_context_instance($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the supplied date interval as a retention period.
|
||||
*
|
||||
* @param \DateInterval $interval
|
||||
* @return string
|
||||
*/
|
||||
public static function format_retention_period(\DateInterval $interval) : string {
|
||||
// It is one or another.
|
||||
if ($interval->y) {
|
||||
$formattedtime = get_string('numyears', 'moodle', $interval->format('%y'));
|
||||
} else if ($interval->m) {
|
||||
$formattedtime = get_string('nummonths', 'moodle', $interval->format('%m'));
|
||||
} else if ($interval->d) {
|
||||
$formattedtime = get_string('numdays', 'moodle', $interval->format('%d'));
|
||||
} else {
|
||||
$formattedtime = get_string('retentionperiodzero', 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
return $formattedtime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
use coding_exception;
|
||||
use core\persistent;
|
||||
use tool_dataprivacy\purpose;
|
||||
use tool_dataprivacy\category;
|
||||
use tool_dataprivacy\contextlevel;
|
||||
use tool_dataprivacy\context_instance;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -41,25 +44,28 @@ require_once($CFG->libdir . '/coursecatlib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class data_registry {
|
||||
|
||||
/**
|
||||
* @var array Inheritance between context levels.
|
||||
*/
|
||||
private static $contextlevelinheritance = [
|
||||
CONTEXT_USER => [CONTEXT_SYSTEM],
|
||||
CONTEXT_COURSECAT => [CONTEXT_SYSTEM],
|
||||
CONTEXT_COURSE => [CONTEXT_COURSECAT, CONTEXT_SYSTEM],
|
||||
CONTEXT_MODULE => [CONTEXT_COURSE, CONTEXT_COURSECAT, CONTEXT_SYSTEM],
|
||||
CONTEXT_BLOCK => [CONTEXT_COURSE, CONTEXT_COURSECAT, CONTEXT_SYSTEM],
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns purpose and category var names from a context class name
|
||||
*
|
||||
* @param string $classname The context level's class.
|
||||
* @param string $pluginname The name of the plugin associated with the context level.
|
||||
* @param string $classname
|
||||
* @return string[]
|
||||
*/
|
||||
public static function var_names_from_context($classname, $pluginname = '') {
|
||||
$pluginname = trim($pluginname);
|
||||
if (!empty($pluginname)) {
|
||||
$categoryvar = $classname . '_' . $pluginname . '_category';
|
||||
$purposevar = $classname . '_' . $pluginname . '_purpose';
|
||||
} else {
|
||||
$categoryvar = $classname . '_category';
|
||||
$purposevar = $classname . '_purpose';
|
||||
}
|
||||
public static function var_names_from_context($classname) {
|
||||
return [
|
||||
$purposevar,
|
||||
$categoryvar
|
||||
$classname . '_purpose',
|
||||
$classname . '_category',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -68,35 +74,22 @@ class data_registry {
|
||||
*
|
||||
* The caller code is responsible of checking that $contextlevel is an integer.
|
||||
*
|
||||
* @param int $contextlevel The context level.
|
||||
* @param string $pluginname The name of the plugin associated with the context level.
|
||||
* @return int[]|false[]
|
||||
* @param int $contextlevel
|
||||
* @return int|false[]
|
||||
*/
|
||||
public static function get_defaults($contextlevel, $pluginname = '') {
|
||||
public static function get_defaults($contextlevel) {
|
||||
|
||||
$classname = \context_helper::get_class_for_level($contextlevel);
|
||||
list($purposevar, $categoryvar) = self::var_names_from_context($classname, $pluginname);
|
||||
list($purposevar, $categoryvar) = self::var_names_from_context($classname);
|
||||
|
||||
$purposeid = get_config('tool_dataprivacy', $purposevar);
|
||||
$categoryid = get_config('tool_dataprivacy', $categoryvar);
|
||||
|
||||
if (!empty($pluginname)) {
|
||||
list($purposevar, $categoryvar) = self::var_names_from_context($classname);
|
||||
// If the plugin-level doesn't have a default purpose set, try the context level.
|
||||
if ($purposeid == false) {
|
||||
$purposeid = get_config('tool_dataprivacy', $purposevar);
|
||||
}
|
||||
|
||||
// If the plugin-level doesn't have a default category set, try the context level.
|
||||
if ($categoryid == false) {
|
||||
$categoryid = get_config('tool_dataprivacy', $categoryvar);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($purposeid)) {
|
||||
$purposeid = context_instance::NOTSET;
|
||||
$purposeid = false;
|
||||
}
|
||||
if (empty($categoryid)) {
|
||||
$categoryid = context_instance::NOTSET;
|
||||
$categoryid = false;
|
||||
}
|
||||
|
||||
return [$purposeid, $categoryid];
|
||||
@@ -178,93 +171,55 @@ class data_registry {
|
||||
* @param int|false $forcedvalue Use this value as if this was this context instance value.
|
||||
* @return persistent|false It return a 'purpose' instance or a 'category' instance, depending on $element
|
||||
*/
|
||||
public static function get_effective_context_value(\context $context, $element, $forcedvalue = false) {
|
||||
global $DB;
|
||||
public static function get_effective_context_value(\context $context, $element, $forcedvalue=false) {
|
||||
|
||||
if ($element !== 'purpose' && $element !== 'category') {
|
||||
throw new coding_exception('Only \'purpose\' and \'category\' are supported.');
|
||||
}
|
||||
$fieldname = $element . 'id';
|
||||
|
||||
if (!empty($forcedvalue) && ($forcedvalue == context_instance::INHERIT)) {
|
||||
// Do not include the current context when calculating the value.
|
||||
// This has the effect that an inheritted value is calculated.
|
||||
$parentcontextids = $context->get_parent_context_ids(false);
|
||||
} else if (!empty($forcedvalue) && ($forcedvalue != context_instance::NOTSET)) {
|
||||
return self::get_element_instance($element, $forcedvalue);
|
||||
} else {
|
||||
// Fetch all parent contexts, including self.
|
||||
$parentcontextids = $context->get_parent_context_ids(true);
|
||||
}
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED);
|
||||
$inparams['contextmodule'] = CONTEXT_MODULE;
|
||||
if ($forcedvalue === false) {
|
||||
$instance = context_instance::get_record_by_contextid($context->id, false);
|
||||
|
||||
if ('purpose' === $element) {
|
||||
$elementjoin = 'LEFT JOIN {tool_dataprivacy_purpose} ele ON ctxins.purposeid = ele.id';
|
||||
$elementfields = purpose::get_sql_fields('ele', 'ele');
|
||||
} else {
|
||||
$elementjoin = 'LEFT JOIN {tool_dataprivacy_category} ele ON ctxins.categoryid = ele.id';
|
||||
$elementfields = category::get_sql_fields('ele', 'ele');
|
||||
}
|
||||
$contextfields = \context_helper::get_preload_record_columns_sql('ctx');
|
||||
$fields = implode(', ', ['ctx.id', 'm.name AS modname', $contextfields, $elementfields]);
|
||||
|
||||
$sql = "SELECT $fields
|
||||
FROM {context} ctx
|
||||
LEFT JOIN {tool_dataprivacy_ctxinstance} ctxins ON ctx.id = ctxins.contextid
|
||||
LEFT JOIN {course_modules} cm ON ctx.contextlevel = :contextmodule AND ctx.instanceid = cm.id
|
||||
LEFT JOIN {modules} m ON m.id = cm.module
|
||||
{$elementjoin}
|
||||
WHERE ctx.id {$insql}
|
||||
ORDER BY ctx.path DESC";
|
||||
$contextinstances = $DB->get_records_sql($sql, $inparams);
|
||||
|
||||
// Check whether this context is a user context, or a child of a user context.
|
||||
// All children of a User context share the same context and cannot be set individually.
|
||||
foreach ($contextinstances as $record) {
|
||||
\context_helper::preload_from_record($record);
|
||||
$parent = \context::instance_by_id($record->id, false);
|
||||
|
||||
if ($parent->contextlevel == CONTEXT_USER) {
|
||||
// Use the context level value for the user.
|
||||
return self::get_effective_contextlevel_value(CONTEXT_USER, $element);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($contextinstances as $record) {
|
||||
$parent = \context::instance_by_id($record->id, false);
|
||||
|
||||
$checkcontextlevel = false;
|
||||
if (empty($record->eleid)) {
|
||||
$checkcontextlevel = true;
|
||||
}
|
||||
|
||||
if (!empty($forcedvalue) && context_instance::NOTSET == $forcedvalue) {
|
||||
$checkcontextlevel = true;
|
||||
}
|
||||
|
||||
if ($checkcontextlevel) {
|
||||
// Check for a value at the contextlevel
|
||||
$forplugin = empty($record->modname) ? '' : $record->modname;
|
||||
list($purposeid, $categoryid) = self::get_effective_default_contextlevel_purpose_and_category(
|
||||
$parent->contextlevel, false, false, $forplugin);
|
||||
|
||||
$instancevalue = $$fieldname;
|
||||
|
||||
if (context_instance::NOTSET != $instancevalue && context_instance::INHERIT != $instancevalue) {
|
||||
// There is an actual value. Return it.
|
||||
return self::get_element_instance($element, $instancevalue);
|
||||
}
|
||||
if (!$instance) {
|
||||
// If the instance does not have a value defaults to not set, so we grab the context level default as its value.
|
||||
$instancevalue = context_instance::NOTSET;
|
||||
} else {
|
||||
$elementclass = "\\tool_dataprivacy\\{$element}";
|
||||
$instance = new $elementclass(null, $elementclass::extract_record($record, 'ele'));
|
||||
$instance->validate();
|
||||
$instancevalue = $instance->get($fieldname);
|
||||
}
|
||||
} else {
|
||||
$instancevalue = $forcedvalue;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
// Not set.
|
||||
if ($instancevalue == context_instance::NOTSET) {
|
||||
|
||||
// The effective value varies depending on the context level.
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
// Use the context level value as we don't allow people to set specific instances values.
|
||||
return self::get_effective_contextlevel_value($context->contextlevel, $element);
|
||||
} else {
|
||||
// Use the default context level value.
|
||||
list($purposeid, $categoryid) = self::get_effective_default_contextlevel_purpose_and_category(
|
||||
$context->contextlevel
|
||||
);
|
||||
return self::get_element_instance($element, $$fieldname);
|
||||
}
|
||||
}
|
||||
|
||||
throw new coding_exception('Something went wrong, system defaults should be set and we should already have a value.');
|
||||
// Specific value for this context instance.
|
||||
if ($instancevalue != context_instance::INHERIT) {
|
||||
return self::get_element_instance($element, $instancevalue);
|
||||
}
|
||||
|
||||
// This context is using inherited so let's return the parent effective value.
|
||||
$parentcontext = $context->get_parent_context();
|
||||
if (!$parentcontext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The forced value should not be transmitted to parent contexts.
|
||||
return self::get_effective_context_value($parentcontext, $element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,9 +231,11 @@ class data_registry {
|
||||
*
|
||||
* @param int $contextlevel
|
||||
* @param string $element 'category' or 'purpose'
|
||||
* @param int $forcedvalue Use this value as if this was this context level purpose.
|
||||
* @return \tool_dataprivacy\purpose|false
|
||||
*/
|
||||
public static function get_effective_contextlevel_value($contextlevel, $element) {
|
||||
public static function get_effective_contextlevel_value($contextlevel, $element, $forcedvalue = false) {
|
||||
|
||||
if ($element !== 'purpose' && $element !== 'category') {
|
||||
throw new coding_exception('Only \'purpose\' and \'category\' are supported.');
|
||||
}
|
||||
@@ -289,30 +246,52 @@ class data_registry {
|
||||
'have a purpose or a category.');
|
||||
}
|
||||
|
||||
list($purposeid, $categoryid) = self::get_effective_default_contextlevel_purpose_and_category($contextlevel);
|
||||
if ($forcedvalue === false) {
|
||||
$instance = contextlevel::get_record_by_contextlevel($contextlevel, false);
|
||||
if (!$instance) {
|
||||
// If the context level does not have a value defaults to not set, so we grab the context level default as
|
||||
// its value.
|
||||
$instancevalue = context_instance::NOTSET;
|
||||
} else {
|
||||
$instancevalue = $instance->get($fieldname);
|
||||
}
|
||||
} else {
|
||||
$instancevalue = $forcedvalue;
|
||||
}
|
||||
|
||||
// Note: The $$fieldname points to either $purposeid, or $categoryid.
|
||||
if (context_instance::NOTSET != $$fieldname && context_instance::INHERIT != $$fieldname) {
|
||||
// There is a specific value set.
|
||||
// Not set -> Use the default context level value.
|
||||
if ($instancevalue == context_instance::NOTSET) {
|
||||
list($purposeid, $categoryid) = self::get_effective_default_contextlevel_purpose_and_category($contextlevel);
|
||||
return self::get_element_instance($element, $$fieldname);
|
||||
}
|
||||
|
||||
throw new coding_exception('Something went wrong, system defaults should be set and we should already have a value.');
|
||||
// Specific value for this context instance.
|
||||
if ($instancevalue != context_instance::INHERIT) {
|
||||
return self::get_element_instance($element, $instancevalue);
|
||||
}
|
||||
|
||||
if ($contextlevel == CONTEXT_SYSTEM) {
|
||||
throw new coding_exception('Something went wrong, system defaults should be set and we should already have a value.');
|
||||
}
|
||||
|
||||
// If we reach this point is that we are inheriting so get the parent context level and repeat.
|
||||
$parentcontextlevel = reset(self::$contextlevelinheritance[$contextlevel]);
|
||||
|
||||
// Forced value are intentionally not passed as the force value should only affect the immediate context level.
|
||||
return self::get_effective_contextlevel_value($parentcontextlevel, $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effective default purpose and category for a context level.
|
||||
*
|
||||
* @param int $contextlevel
|
||||
* @param int|bool $forcedpurposevalue Use this value as if this was this context level purpose.
|
||||
* @param int|bool $forcedcategoryvalue Use this value as if this was this context level category.
|
||||
* @param string $component The name of the component to check.
|
||||
* @param int $forcedpurposevalue Use this value as if this was this context level purpose.
|
||||
* @param int $forcedcategoryvalue Use this value as if this was this context level category.
|
||||
* @return int[]
|
||||
*/
|
||||
public static function get_effective_default_contextlevel_purpose_and_category($contextlevel, $forcedpurposevalue = false,
|
||||
$forcedcategoryvalue = false, $component = '') {
|
||||
// Get the defaults for this context level.
|
||||
list($purposeid, $categoryid) = self::get_defaults($contextlevel, $component);
|
||||
public static function get_effective_default_contextlevel_purpose_and_category($contextlevel, $forcedpurposevalue = false, $forcedcategoryvalue = false) {
|
||||
|
||||
list($purposeid, $categoryid) = self::get_defaults($contextlevel);
|
||||
|
||||
// Honour forced values.
|
||||
if ($forcedpurposevalue) {
|
||||
@@ -322,19 +301,37 @@ class data_registry {
|
||||
$categoryid = $forcedcategoryvalue;
|
||||
}
|
||||
|
||||
if ($contextlevel == CONTEXT_USER) {
|
||||
// Only user context levels inherit from a parent context level.
|
||||
list($parentpurposeid, $parentcategoryid) = self::get_defaults(CONTEXT_SYSTEM);
|
||||
// Not set == INHERIT for defaults.
|
||||
if ($purposeid == context_instance::INHERIT || $purposeid == context_instance::NOTSET) {
|
||||
$purposeid = false;
|
||||
}
|
||||
if ($categoryid == context_instance::INHERIT || $categoryid == context_instance::NOTSET) {
|
||||
$categoryid = false;
|
||||
}
|
||||
|
||||
if (context_instance::INHERIT == $purposeid || context_instance::NOTSET == $purposeid) {
|
||||
$purposeid = (int)$parentpurposeid;
|
||||
}
|
||||
if ($contextlevel != CONTEXT_SYSTEM && ($purposeid === false || $categoryid === false)) {
|
||||
foreach (self::$contextlevelinheritance[$contextlevel] as $parent) {
|
||||
|
||||
if (context_instance::INHERIT == $categoryid || context_instance::NOTSET == $categoryid) {
|
||||
$categoryid = $parentcategoryid;
|
||||
list($parentpurposeid, $parentcategoryid) = self::get_defaults($parent);
|
||||
// Not set == INHERIT for defaults.
|
||||
if ($parentpurposeid == context_instance::INHERIT || $parentpurposeid == context_instance::NOTSET) {
|
||||
$parentpurposeid = false;
|
||||
}
|
||||
if ($parentcategoryid == context_instance::INHERIT || $parentcategoryid == context_instance::NOTSET) {
|
||||
$parentcategoryid = false;
|
||||
}
|
||||
|
||||
if ($purposeid === false && $parentpurposeid) {
|
||||
$purposeid = $parentpurposeid;
|
||||
}
|
||||
|
||||
if ($categoryid === false && $parentcategoryid) {
|
||||
$categoryid = $parentcategoryid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// They may still be false, but we return anyway.
|
||||
return [$purposeid, $categoryid];
|
||||
}
|
||||
|
||||
@@ -347,6 +344,7 @@ class data_registry {
|
||||
* @return \core\persistent
|
||||
*/
|
||||
private static function get_element_instance($element, $id) {
|
||||
|
||||
if ($element !== 'purpose' && $element !== 'category') {
|
||||
throw new coding_exception('No other elements than purpose and category are allowed');
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core\persistent;
|
||||
@@ -39,12 +37,6 @@ class data_request extends persistent {
|
||||
/** The table name this persistent object maps to. */
|
||||
const TABLE = 'tool_dataprivacy_request';
|
||||
|
||||
/** Data request created manually. */
|
||||
const DATAREQUEST_CREATION_MANUAL = 0;
|
||||
|
||||
/** Data request created automatically. */
|
||||
const DATAREQUEST_CREATION_AUTO = 1;
|
||||
|
||||
/**
|
||||
* Return the definition of the properties of this model.
|
||||
*
|
||||
@@ -93,9 +85,6 @@ class data_request extends persistent {
|
||||
api::DATAREQUEST_STATUS_COMPLETE,
|
||||
api::DATAREQUEST_STATUS_CANCELLED,
|
||||
api::DATAREQUEST_STATUS_REJECTED,
|
||||
api::DATAREQUEST_STATUS_DOWNLOAD_READY,
|
||||
api::DATAREQUEST_STATUS_EXPIRED,
|
||||
api::DATAREQUEST_STATUS_DELETED,
|
||||
],
|
||||
'type' => PARAM_INT
|
||||
],
|
||||
@@ -119,173 +108,6 @@ class data_request extends persistent {
|
||||
'type' => PARAM_INT,
|
||||
'default' => FORMAT_PLAIN
|
||||
],
|
||||
'creationmethod' => [
|
||||
'default' => self::DATAREQUEST_CREATION_MANUAL,
|
||||
'choices' => [
|
||||
self::DATAREQUEST_CREATION_MANUAL,
|
||||
self::DATAREQUEST_CREATION_AUTO
|
||||
],
|
||||
'type' => PARAM_INT
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a completed data export request has expired.
|
||||
* The response will be valid regardless of the expiry scheduled task having run.
|
||||
*
|
||||
* @param data_request $request the data request object whose expiry will be checked.
|
||||
* @return bool true if the request has expired.
|
||||
*/
|
||||
public static function is_expired(data_request $request) {
|
||||
$result = false;
|
||||
|
||||
// Only export requests expire.
|
||||
if ($request->get('type') == api::DATAREQUEST_TYPE_EXPORT) {
|
||||
switch ($request->get('status')) {
|
||||
// Expired requests are obviously expired.
|
||||
case api::DATAREQUEST_STATUS_EXPIRED:
|
||||
$result = true;
|
||||
break;
|
||||
// Complete requests are expired if the expiry time has elapsed.
|
||||
case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
|
||||
$expiryseconds = get_config('tool_dataprivacy', 'privacyrequestexpiry');
|
||||
if ($expiryseconds > 0 && time() >= ($request->get('timemodified') + $expiryseconds)) {
|
||||
$result = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch completed data requests which are due to expire.
|
||||
*
|
||||
* @param int $userid Optional user ID to filter by.
|
||||
*
|
||||
* @return array Details of completed requests which are due to expire.
|
||||
*/
|
||||
public static function get_expired_requests($userid = 0) {
|
||||
global $DB;
|
||||
|
||||
$expiryseconds = get_config('tool_dataprivacy', 'privacyrequestexpiry');
|
||||
$expirytime = strtotime("-{$expiryseconds} second");
|
||||
$table = self::TABLE;
|
||||
$sqlwhere = 'type = :export_type AND status = :completestatus AND timemodified <= :expirytime';
|
||||
$params = array(
|
||||
'export_type' => api::DATAREQUEST_TYPE_EXPORT,
|
||||
'completestatus' => api::DATAREQUEST_STATUS_DOWNLOAD_READY,
|
||||
'expirytime' => $expirytime,
|
||||
);
|
||||
$sort = 'id';
|
||||
$fields = 'id, userid';
|
||||
|
||||
// Filter by user ID if specified.
|
||||
if ($userid > 0) {
|
||||
$sqlwhere .= ' AND (userid = :userid OR requestedby = :requestedby)';
|
||||
$params['userid'] = $userid;
|
||||
$params['requestedby'] = $userid;
|
||||
}
|
||||
|
||||
return $DB->get_records_select_menu($table, $sqlwhere, $params, $sort, $fields, 0, 2000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expire a given set of data requests.
|
||||
* Update request status and delete the files.
|
||||
*
|
||||
* @param array $expiredrequests [requestid => userid]
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function expire($expiredrequests) {
|
||||
global $DB;
|
||||
|
||||
$ids = array_keys($expiredrequests);
|
||||
|
||||
if (count($ids) > 0) {
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($ids);
|
||||
$initialparams = array(api::DATAREQUEST_STATUS_EXPIRED, time());
|
||||
$params = array_merge($initialparams, $inparams);
|
||||
|
||||
$update = "UPDATE {" . self::TABLE . "}
|
||||
SET status = ?, timemodified = ?
|
||||
WHERE id $insql";
|
||||
|
||||
if ($DB->execute($update, $params)) {
|
||||
$fs = get_file_storage();
|
||||
|
||||
foreach ($expiredrequests as $id => $userid) {
|
||||
$usercontext = \context_user::instance($userid);
|
||||
$fs->delete_area_files($usercontext->id, 'tool_dataprivacy', 'export', $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this request is in a state appropriate for reset/resubmission.
|
||||
*
|
||||
* Note: This does not check whether any other completed requests exist for this user.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_resettable() : bool {
|
||||
if (api::DATAREQUEST_TYPE_OTHERS == $this->get('type')) {
|
||||
// It is not possible to reset 'other' reqeusts.
|
||||
return false;
|
||||
}
|
||||
|
||||
$resettable = [
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL => true,
|
||||
api::DATAREQUEST_STATUS_APPROVED => true,
|
||||
api::DATAREQUEST_STATUS_REJECTED => true,
|
||||
];
|
||||
|
||||
return isset($resettable[$this->get('status')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this request is 'active'.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_active() : bool {
|
||||
$active = [
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL => true,
|
||||
api::DATAREQUEST_STATUS_APPROVED => true,
|
||||
];
|
||||
|
||||
return isset($active[$this->get('status')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject this request and resubmit it as a fresh request.
|
||||
*
|
||||
* Note: This does not check whether any other completed requests exist for this user.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function resubmit_request() : data_request {
|
||||
if ($this->is_active()) {
|
||||
$this->set('status', api::DATAREQUEST_STATUS_REJECTED)->save();
|
||||
}
|
||||
|
||||
if (!$this->is_resettable()) {
|
||||
throw new \moodle_exception('cannotreset', 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
$currentdata = $this->to_record();
|
||||
unset($currentdata->id);
|
||||
|
||||
$clone = api::create_data_request($this->get('userid'), $this->get('type'));
|
||||
$clone->set('comments', $this->get('comments'));
|
||||
$clone->set('dpo', $this->get('dpo'));
|
||||
$clone->set('requestedby', $this->get('requestedby'));
|
||||
$clone->save();
|
||||
|
||||
return $clone;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Event observers supported by this module.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_dataprivacy\event;
|
||||
|
||||
use \tool_dataprivacy\api;
|
||||
use \tool_dataprivacy\data_request;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event observers supported by this module.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_deleted_observer {
|
||||
|
||||
/**
|
||||
* Create user data deletion request when the user is deleted.
|
||||
*
|
||||
* @param \core\event\user_deleted $event
|
||||
*/
|
||||
public static function create_delete_data_request(\core\event\user_deleted $event) {
|
||||
// Automatic creation of deletion requests must be enabled.
|
||||
if (get_config('tool_dataprivacy', 'automaticdeletionrequests')) {
|
||||
$requesttypes = [api::DATAREQUEST_TYPE_DELETE];
|
||||
$requeststatuses = [api::DATAREQUEST_STATUS_COMPLETE, api::DATAREQUEST_STATUS_DELETED];
|
||||
|
||||
$hasongoingdeleterequests = api::has_ongoing_request($event->objectid, $requesttypes[0]);
|
||||
$hascompleteddeleterequest = (api::get_data_requests_count($event->objectid, $requeststatuses,
|
||||
$requesttypes) > 0) ? true : false;
|
||||
|
||||
if (!$hasongoingdeleterequests && !$hascompleteddeleterequest) {
|
||||
api::create_data_request($event->objectid, $requesttypes[0],
|
||||
get_string('datarequestcreatedupondelete', 'tool_dataprivacy'),
|
||||
data_request::DATAREQUEST_CREATION_AUTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,27 +60,12 @@ class expired_context extends \core\persistent {
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_properties() {
|
||||
return [
|
||||
'contextid' => [
|
||||
return array(
|
||||
'contextid' => array(
|
||||
'type' => PARAM_INT,
|
||||
'description' => 'The context id.',
|
||||
],
|
||||
'defaultexpired' => [
|
||||
'type' => PARAM_INT,
|
||||
'description' => 'Whether to default retention period for the purpose has been reached',
|
||||
'default' => 1,
|
||||
],
|
||||
'expiredroles' => [
|
||||
'type' => PARAM_TEXT,
|
||||
'description' => 'This list of roles to include during deletion',
|
||||
'default' => '',
|
||||
],
|
||||
'unexpiredroles' => [
|
||||
'type' => PARAM_TEXT,
|
||||
'description' => 'This list of roles to exclude during deletion',
|
||||
'default' => '',
|
||||
],
|
||||
'status' => [
|
||||
),
|
||||
'status' => array(
|
||||
'choices' => [
|
||||
self::STATUS_EXPIRED,
|
||||
self::STATUS_APPROVED,
|
||||
@@ -88,8 +73,8 @@ class expired_context extends \core\persistent {
|
||||
],
|
||||
'type' => PARAM_INT,
|
||||
'description' => 'The deletion status of the context.',
|
||||
],
|
||||
];
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,205 +159,4 @@ class expired_context extends \core\persistent {
|
||||
|
||||
return $DB->count_records_sql($sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of role IDs for either expiredroles, or unexpiredroles.
|
||||
*
|
||||
* @param string $field
|
||||
* @param int[] $roleids
|
||||
* @return expired_context
|
||||
*/
|
||||
protected function set_roleids_for(string $field, array $roleids) : expired_context {
|
||||
$roledata = json_encode($roleids);
|
||||
|
||||
$this->raw_set($field, $roledata);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of role IDs for either expiredroles, or unexpiredroles.
|
||||
*
|
||||
* @param string $field
|
||||
* @return int[]
|
||||
*/
|
||||
protected function get_roleids_for(string $field) {
|
||||
$value = $this->raw_get($field);
|
||||
if (empty($value)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return json_decode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of unexpired role IDs.
|
||||
*
|
||||
* @param int[] $roleids
|
||||
* @return expired_context
|
||||
*/
|
||||
protected function set_unexpiredroles(array $roleids) : expired_context {
|
||||
$this->set_roleids_for('unexpiredroles', $roleids);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of role IDs to the list of expired role IDs.
|
||||
*
|
||||
* @param int[] $roleids
|
||||
* @return expired_context
|
||||
*/
|
||||
public function add_expiredroles(array $roleids) : expired_context {
|
||||
$existing = $this->get('expiredroles');
|
||||
$newvalue = array_merge($existing, $roleids);
|
||||
|
||||
$this->set('expiredroles', $newvalue);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of role IDs to the list of unexpired role IDs.
|
||||
*
|
||||
* @param int[] $roleids
|
||||
* @return unexpired_context
|
||||
*/
|
||||
public function add_unexpiredroles(array $roleids) : expired_context {
|
||||
$existing = $this->get('unexpiredroles');
|
||||
$newvalue = array_merge($existing, $roleids);
|
||||
|
||||
$this->set('unexpiredroles', $newvalue);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of expired role IDs.
|
||||
*
|
||||
* @param int[] $roleids
|
||||
* @return expired_context
|
||||
*/
|
||||
protected function set_expiredroles(array $roleids) : expired_context {
|
||||
$this->set_roleids_for('expiredroles', $roleids);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of expired role IDs.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
protected function get_expiredroles() {
|
||||
return $this->get_roleids_for('expiredroles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of unexpired role IDs.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
protected function get_unexpiredroles() {
|
||||
return $this->get_roleids_for('unexpiredroles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new expired_context based on the context, and expiry_info object.
|
||||
*
|
||||
* @param \context $context
|
||||
* @param expiry_info $info
|
||||
* @param boolean $save
|
||||
* @return expired_context
|
||||
*/
|
||||
public static function create_from_expiry_info(\context $context, expiry_info $info, bool $save = true) : expired_context {
|
||||
$record = (object) [
|
||||
'contextid' => $context->id,
|
||||
'status' => self::STATUS_EXPIRED,
|
||||
'defaultexpired' => (int) $info->is_default_expired(),
|
||||
];
|
||||
|
||||
$expiredcontext = new static(0, $record);
|
||||
$expiredcontext->set('expiredroles', $info->get_expired_roles());
|
||||
$expiredcontext->set('unexpiredroles', $info->get_unexpired_roles());
|
||||
|
||||
if ($save) {
|
||||
$expiredcontext->save();
|
||||
}
|
||||
|
||||
return $expiredcontext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the expired_context from an expiry_info object which relates to this context.
|
||||
*
|
||||
* @param expiry_info $info
|
||||
* @return $this
|
||||
*/
|
||||
public function update_from_expiry_info(expiry_info $info) : expired_context {
|
||||
$save = false;
|
||||
|
||||
// Compare the expiredroles.
|
||||
$thisexpired = $this->get('expiredroles');
|
||||
$infoexpired = $info->get_expired_roles();
|
||||
|
||||
sort($thisexpired);
|
||||
sort($infoexpired);
|
||||
if ($infoexpired != $thisexpired) {
|
||||
$this->set('expiredroles', $infoexpired);
|
||||
$save = true;
|
||||
}
|
||||
|
||||
// Compare the unexpiredroles.
|
||||
$thisunexpired = $this->get('unexpiredroles');
|
||||
$infounexpired = $info->get_unexpired_roles();
|
||||
|
||||
sort($thisunexpired);
|
||||
sort($infounexpired);
|
||||
if ($infounexpired != $thisunexpired) {
|
||||
$this->set('unexpiredroles', $infounexpired);
|
||||
$save = true;
|
||||
}
|
||||
|
||||
if (empty($this->get('defaultexpired')) == $info->is_default_expired()) {
|
||||
$this->set('defaultexpired', (int) $info->is_default_expired());
|
||||
$save = true;
|
||||
}
|
||||
|
||||
if ($save) {
|
||||
$this->set('status', self::STATUS_EXPIRED);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this expired_context record is in a state ready for deletion to actually take place.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function can_process_deletion() : bool {
|
||||
return ($this->get('status') == self::STATUS_APPROVED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this expired_context record has already been cleaned.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_complete() : bool {
|
||||
return ($this->get('status') == self::STATUS_CLEANED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this context has 'fully' expired.
|
||||
* That is to say that the default retention period has been reached, and that there are no unexpired roles.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_fully_expired() : bool {
|
||||
return $this->get('defaultexpired') && empty($this->get('unexpiredroles'));
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,135 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Expired contexts manager for CONTEXT_COURSE, CONTEXT_MODULE and CONTEXT_BLOCK.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
use tool_dataprivacy\purpose;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Expired contexts manager for CONTEXT_COURSE, CONTEXT_MODULE and CONTEXT_BLOCK.
|
||||
*
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class expired_course_related_contexts extends \tool_dataprivacy\expired_contexts_manager {
|
||||
|
||||
/**
|
||||
* Course-related context levels.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
protected function get_context_levels() {
|
||||
return [CONTEXT_MODULE, CONTEXT_BLOCK, CONTEXT_COURSE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a recordset with user context instances that are possibly expired (to be confirmed by get_recordset_callback).
|
||||
*
|
||||
* @return \stdClass[]
|
||||
*/
|
||||
protected function get_expired_contexts() {
|
||||
global $DB;
|
||||
|
||||
// Including context info + course end date + purposeid (this last one only if defined).
|
||||
$fields = 'ctx.id AS id, ctxcourse.enddate AS courseenddate, dpctx.purposeid AS purposeid, ' .
|
||||
\context_helper::get_preload_record_columns_sql('ctx');
|
||||
|
||||
// We want all contexts at course-dependant levels.
|
||||
$parentpath = $DB->sql_concat('ctxcourse.path', "'/%'");
|
||||
|
||||
// This SQL query returns all course-dependant contexts (including the course context)
|
||||
// which course end date already passed.
|
||||
$sql = "SELECT $fields
|
||||
FROM {context} ctx
|
||||
JOIN (
|
||||
SELECT c.enddate, subctx.path
|
||||
FROM {context} subctx
|
||||
JOIN {course} c
|
||||
ON subctx.contextlevel = ? AND subctx.instanceid = c.id
|
||||
WHERE c.enddate < ? AND c.enddate > 0
|
||||
) ctxcourse
|
||||
ON ctx.path LIKE {$parentpath} OR ctx.path = ctxcourse.path
|
||||
LEFT JOIN {tool_dataprivacy_ctxinstance} dpctx
|
||||
ON dpctx.contextid = ctx.id
|
||||
LEFT JOIN {tool_dataprivacy_ctxexpired} expiredctx
|
||||
ON ctx.id = expiredctx.contextid
|
||||
WHERE expiredctx.id IS NULL
|
||||
ORDER BY ctx.contextlevel DESC, ctx.path";
|
||||
$possiblyexpired = $DB->get_recordset_sql($sql, [CONTEXT_COURSE, time()]);
|
||||
|
||||
$expiredcontexts = [];
|
||||
$excludedcontextids = [];
|
||||
foreach ($possiblyexpired as $record) {
|
||||
|
||||
\context_helper::preload_from_record($record);
|
||||
|
||||
// No strict checking as the context may already be deleted (e.g. we just deleted a course,
|
||||
// module contexts below it will not exist).
|
||||
$context = \context::instance_by_id($record->id, false);
|
||||
if (!$context) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We pass the value we just got from SQL so get_effective_context_purpose don't need to query
|
||||
// the db again to retrieve it. If there is no tool_dataprovider_ctxinstance record
|
||||
// $record->purposeid will be null which is ok as it would force get_effective_context_purpose
|
||||
// to return the default purpose for the context context level (no db queries involved).
|
||||
$purposevalue = $record->purposeid !== null ? $record->purposeid : context_instance::NOTSET;
|
||||
|
||||
// It should be cheap as system purposes and context level purposes will be retrieved from a cache most of the time.
|
||||
$purpose = api::get_effective_context_purpose($context, $purposevalue);
|
||||
|
||||
$dt = new \DateTime();
|
||||
$dt->setTimestamp($record->courseenddate);
|
||||
$di = new \DateInterval($purpose->get('retentionperiod'));
|
||||
$dt->add($di);
|
||||
|
||||
if (time() < $dt->getTimestamp()) {
|
||||
// Exclude this context ID as it has not reached the retention period yet.
|
||||
$excludedcontextids[] = $context->id;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this context has children that have not yet expired.
|
||||
$hasunexpiredchildren = false;
|
||||
$children = $context->get_child_contexts();
|
||||
foreach ($children as $child) {
|
||||
if (in_array($child->id, $excludedcontextids)) {
|
||||
$hasunexpiredchildren = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasunexpiredchildren) {
|
||||
// Exclude this context ID as it has children that have not yet expired.
|
||||
$excludedcontextids[] = $context->id;
|
||||
continue;
|
||||
}
|
||||
|
||||
$expiredcontexts[$context->id] = $context;
|
||||
}
|
||||
|
||||
return $expiredcontexts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Expired contexts manager for CONTEXT_USER.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
use tool_dataprivacy\purpose;
|
||||
use tool_dataprivacy\context_instance;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Expired contexts manager for CONTEXT_USER.
|
||||
*
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class expired_user_contexts extends \tool_dataprivacy\expired_contexts_manager {
|
||||
|
||||
/**
|
||||
* Only user level.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
protected function get_context_levels() {
|
||||
return [CONTEXT_USER];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user context instances that are expired.
|
||||
*
|
||||
* @return \stdClass[]
|
||||
*/
|
||||
protected function get_expired_contexts() {
|
||||
global $DB;
|
||||
|
||||
// Including context info + last login timestamp.
|
||||
$fields = 'ctx.id AS id, ' . \context_helper::get_preload_record_columns_sql('ctx');
|
||||
|
||||
$purpose = api::get_effective_contextlevel_purpose(CONTEXT_USER);
|
||||
|
||||
// Calculate what is considered expired according to the context level effective purpose (= now + retention period).
|
||||
$expiredtime = new \DateTime();
|
||||
$retention = new \DateInterval($purpose->get('retentionperiod'));
|
||||
$expiredtime->sub($retention);
|
||||
|
||||
$sql = "SELECT $fields FROM {context} ctx
|
||||
JOIN {user} u ON ctx.contextlevel = ? AND ctx.instanceid = u.id
|
||||
LEFT JOIN {tool_dataprivacy_ctxexpired} expiredctx ON ctx.id = expiredctx.contextid
|
||||
WHERE u.lastaccess <= ? AND u.lastaccess > 0 AND expiredctx.id IS NULL
|
||||
ORDER BY ctx.path, ctx.contextlevel ASC";
|
||||
$possiblyexpired = $DB->get_recordset_sql($sql, [CONTEXT_USER, $expiredtime->getTimestamp()]);
|
||||
|
||||
$expiredcontexts = [];
|
||||
foreach ($possiblyexpired as $record) {
|
||||
|
||||
\context_helper::preload_from_record($record);
|
||||
|
||||
// No strict checking as the context may already be deleted (e.g. we just deleted a course,
|
||||
// module contexts below it will not exist).
|
||||
$context = \context::instance_by_id($record->id, false);
|
||||
if (!$context) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_siteadmin($context->instanceid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$courses = enrol_get_users_courses($context->instanceid, false, ['enddate']);
|
||||
foreach ($courses as $course) {
|
||||
if (!$course->enddate) {
|
||||
// We can not know it what is going on here, so we prefer to be conservative.
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if ($course->enddate >= time()) {
|
||||
// Future or ongoing course.
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$expiredcontexts[$context->id] = $context;
|
||||
}
|
||||
|
||||
return $expiredcontexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes user data from the provided context.
|
||||
*
|
||||
* Overwritten to delete the user.
|
||||
*
|
||||
* @param \core_privacy\manager $privacymanager
|
||||
* @param \tool_dataprivacy\expired_context $expiredctx
|
||||
* @return \context|false
|
||||
*/
|
||||
protected function delete_expired_context(\core_privacy\manager $privacymanager, \tool_dataprivacy\expired_context $expiredctx) {
|
||||
if (!$context = parent::delete_expired_context($privacymanager, $expiredctx)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the user.
|
||||
$user = \core_user::get_user($context->instanceid, '*', MUST_EXIST);
|
||||
delete_user($user);
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Expiry Data.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
use core_privacy\manager;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Expiry Data.
|
||||
*
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class expiry_info {
|
||||
|
||||
/** @var bool Whether this context is fully expired */
|
||||
protected $fullyexpired = false;
|
||||
|
||||
/** @var bool Whether the default expiry value of this purpose has been reached */
|
||||
protected $defaultexpiryreached = false;
|
||||
|
||||
/** @var bool Whether the default purpose is protected */
|
||||
protected $defaultprotected = false;
|
||||
|
||||
/** @var int[] List of expires roles */
|
||||
protected $expired = [];
|
||||
|
||||
/** @var int[] List of unexpires roles */
|
||||
protected $unexpired = [];
|
||||
|
||||
/** @var int[] List of unexpired roles which are also protected */
|
||||
protected $protectedroles = [];
|
||||
|
||||
/**
|
||||
* Constructor for the expiry_info class.
|
||||
*
|
||||
* @param bool $default Whether the default expiry period for this context has been reached.
|
||||
* @param bool $defaultprotected Whether the default expiry is protected.
|
||||
* @param int[] $expired A list of roles in this context which have explicitly expired.
|
||||
* @param int[] $unexpired A list of roles in this context which have not yet expired.
|
||||
* @param int[] $protectedroles A list of unexpired roles in this context which are protected.
|
||||
*/
|
||||
public function __construct(bool $default, bool $defaultprotected, array $expired, array $unexpired, array $protectedroles) {
|
||||
$this->defaultexpiryreached = $default;
|
||||
$this->defaultprotected = $defaultprotected;
|
||||
$this->expired = $expired;
|
||||
$this->unexpired = $unexpired;
|
||||
$this->protectedroles = $protectedroles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this context has 'fully' expired.
|
||||
* That is to say that the default retention period has been reached, and that there are no unexpired roles.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_fully_expired() : bool {
|
||||
return $this->defaultexpiryreached && empty($this->unexpired);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether any part of this context has expired.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_any_expired() : bool {
|
||||
if ($this->is_fully_expired()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!empty($this->get_expired_roles())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->is_default_expired()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of explicitly expired role IDs.
|
||||
* Note: This does not list roles which have been expired via the default retention policy being reached.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function get_expired_roles() : array {
|
||||
if ($this->is_default_expired()) {
|
||||
return [];
|
||||
}
|
||||
return $this->expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the specified role is explicitly expired.
|
||||
* Note: This does not list roles which have been expired via the default retention policy being reached.
|
||||
*
|
||||
* @param int $roleid
|
||||
* @return bool
|
||||
*/
|
||||
public function is_role_expired(int $roleid) : bool {
|
||||
return false !== array_search($roleid, $this->expired);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the default retention policy has been reached.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_default_expired() : bool {
|
||||
return $this->defaultexpiryreached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the default purpose is protected.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_default_protected() : bool {
|
||||
return $this->defaultprotected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of unexpired role IDs.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function get_unexpired_roles() : array {
|
||||
return $this->unexpired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of unexpired protected roles.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function get_unexpired_protected_roles() : array {
|
||||
return array_keys(array_filter($this->protectedroles));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all overridden roles which are unprotected.
|
||||
* @return int[]
|
||||
*/
|
||||
public function get_unprotected_overridden_roles() : array {
|
||||
$allroles = array_merge($this->expired, $this->unexpired);
|
||||
|
||||
return array_diff($allroles, $this->protectedroles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge this expiry_info object with another belonging to a child context in order to set the 'safest' heritage.
|
||||
*
|
||||
* It is not possible to delete any part of a context that is not deleted by a parent.
|
||||
* So if a course's retention policy has been reached, then only parts where the children have also expired can be
|
||||
* deleted.
|
||||
*
|
||||
* @param expiry_info $child The child record to merge with.
|
||||
* @return $this
|
||||
*/
|
||||
public function merge_with_child(expiry_info $child) : expiry_info {
|
||||
if ($child->is_fully_expired()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
// If the child is not fully expired, then none of the parents can be either.
|
||||
$this->fullyexpired = false;
|
||||
|
||||
// Remove any role in this node which is not expired in the child.
|
||||
foreach ($this->expired as $key => $roleid) {
|
||||
if (!$child->is_role_expired($roleid)) {
|
||||
unset($this->expired[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
array_merge($this->unexpired, $child->get_unexpired_roles());
|
||||
|
||||
if (!$child->is_default_expired()) {
|
||||
$this->defaultexpiryreached = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,6 @@ namespace tool_dataprivacy\external;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core\external\persistent_exporter;
|
||||
use tool_dataprivacy\category;
|
||||
use tool_dataprivacy\context_instance;
|
||||
|
||||
/**
|
||||
* Class for exporting field data.
|
||||
@@ -55,25 +53,4 @@ class category_exporter extends persistent_exporter {
|
||||
'context' => 'context',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function that fetches a category name from the given ID.
|
||||
*
|
||||
* @param int $categoryid The category ID. Could be INHERIT (false, -1), NOT_SET (0), or the actual ID.
|
||||
* @return string The purpose name.
|
||||
*/
|
||||
public static function get_name($categoryid) {
|
||||
global $PAGE;
|
||||
if ($categoryid === false || $categoryid == context_instance::INHERIT) {
|
||||
return get_string('inherit', 'tool_dataprivacy');
|
||||
} else if ($categoryid == context_instance::NOTSET) {
|
||||
return get_string('notset', 'tool_dataprivacy');
|
||||
} else {
|
||||
$purpose = new category($categoryid);
|
||||
$output = $PAGE->get_renderer('tool_dataprivacy');
|
||||
$exporter = new self($purpose, ['context' => \context_system::instance()]);
|
||||
$data = $exporter->export($output);
|
||||
return $data->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,16 +102,6 @@ class data_request_exporter extends persistent_exporter {
|
||||
'optional' => true,
|
||||
'default' => false
|
||||
],
|
||||
'approvedeny' => [
|
||||
'type' => PARAM_BOOL,
|
||||
'optional' => true,
|
||||
'default' => false
|
||||
],
|
||||
'canmarkcomplete' => [
|
||||
'type' => PARAM_BOOL,
|
||||
'optional' => true,
|
||||
'default' => false
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -150,19 +140,14 @@ class data_request_exporter extends persistent_exporter {
|
||||
|
||||
$values['messagehtml'] = text_to_html($this->persistent->get('comments'));
|
||||
|
||||
$requesttype = $this->persistent->get('type');
|
||||
$values['typename'] = helper::get_request_type_string($requesttype);
|
||||
$values['typenameshort'] = helper::get_shortened_request_type_string($requesttype);
|
||||
$values['typename'] = helper::get_request_type_string($this->persistent->get('type'));
|
||||
$values['typenameshort'] = helper::get_shortened_request_type_string($this->persistent->get('type'));
|
||||
|
||||
$values['canreview'] = false;
|
||||
$values['approvedeny'] = false;
|
||||
$values['statuslabel'] = helper::get_request_status_string($this->persistent->get('status'));
|
||||
|
||||
switch ($this->persistent->get('status')) {
|
||||
case api::DATAREQUEST_STATUS_PENDING:
|
||||
$values['statuslabelclass'] = 'label-info';
|
||||
// Request can be manually completed for general enquiry requests.
|
||||
$values['canmarkcomplete'] = $requesttype == api::DATAREQUEST_TYPE_OTHERS;
|
||||
$values['statuslabelclass'] = 'label-default';
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_PREPROCESSING:
|
||||
$values['statuslabelclass'] = 'label-default';
|
||||
@@ -171,8 +156,6 @@ class data_request_exporter extends persistent_exporter {
|
||||
$values['statuslabelclass'] = 'label-info';
|
||||
// DPO can review the request once it's ready.
|
||||
$values['canreview'] = true;
|
||||
// Whether the DPO can approve or deny the request.
|
||||
$values['approvedeny'] = in_array($requesttype, [api::DATAREQUEST_TYPE_EXPORT, api::DATAREQUEST_TYPE_DELETE]);
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_APPROVED:
|
||||
$values['statuslabelclass'] = 'label-info';
|
||||
@@ -181,8 +164,6 @@ class data_request_exporter extends persistent_exporter {
|
||||
$values['statuslabelclass'] = 'label-info';
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_COMPLETE:
|
||||
case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
|
||||
case api::DATAREQUEST_STATUS_DELETED:
|
||||
$values['statuslabelclass'] = 'label-success';
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_CANCELLED:
|
||||
@@ -191,9 +172,6 @@ class data_request_exporter extends persistent_exporter {
|
||||
case api::DATAREQUEST_STATUS_REJECTED:
|
||||
$values['statuslabelclass'] = 'label-important';
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_EXPIRED:
|
||||
$values['statuslabelclass'] = 'label-default';
|
||||
break;
|
||||
}
|
||||
|
||||
return $values;
|
||||
|
||||
+13
-28
@@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use coding_exception;
|
||||
use core\external\persistent_exporter;
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use renderer_base;
|
||||
use tool_dataprivacy\context_instance;
|
||||
use tool_dataprivacy\purpose;
|
||||
|
||||
/**
|
||||
@@ -78,9 +78,6 @@ class purpose_exporter extends persistent_exporter {
|
||||
'multiple' => true,
|
||||
'optional' => true
|
||||
],
|
||||
'roleoverrides' => [
|
||||
'type' => PARAM_TEXT
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -127,35 +124,23 @@ class purpose_exporter extends persistent_exporter {
|
||||
|
||||
$retentionperiod = $this->persistent->get('retentionperiod');
|
||||
if ($retentionperiod) {
|
||||
$formattedtime = \tool_dataprivacy\api::format_retention_period(new \DateInterval($retentionperiod));
|
||||
$interval = new DateInterval($retentionperiod);
|
||||
|
||||
// It is one or another.
|
||||
if ($interval->y) {
|
||||
$formattedtime = get_string('numyears', 'moodle', $interval->format('%y'));
|
||||
} else if ($interval->m) {
|
||||
$formattedtime = get_string('nummonths', 'moodle', $interval->format('%m'));
|
||||
} else if ($interval->d) {
|
||||
$formattedtime = get_string('numdays', 'moodle', $interval->format('%d'));
|
||||
} else {
|
||||
$formattedtime = get_string('retentionperiodzero', 'tool_dataprivacy');
|
||||
}
|
||||
} else {
|
||||
$formattedtime = get_string('retentionperiodnotdefined', 'tool_dataprivacy');
|
||||
}
|
||||
$values['formattedretentionperiod'] = $formattedtime;
|
||||
|
||||
$values['roleoverrides'] = !empty($this->persistent->get_purpose_overrides());
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function that fetches a purpose name from the given ID.
|
||||
*
|
||||
* @param int $purposeid The purpose ID. Could be INHERIT (false, -1), NOT_SET (0), or the actual ID.
|
||||
* @return string The purpose name.
|
||||
*/
|
||||
public static function get_name($purposeid) {
|
||||
global $PAGE;
|
||||
if ($purposeid === false || $purposeid == context_instance::INHERIT) {
|
||||
return get_string('inherit', 'tool_dataprivacy');
|
||||
} else if ($purposeid == context_instance::NOTSET) {
|
||||
return get_string('notset', 'tool_dataprivacy');
|
||||
} else {
|
||||
$purpose = new purpose($purposeid);
|
||||
$output = $PAGE->get_renderer('tool_dataprivacy');
|
||||
$exporter = new self($purpose, ['context' => \context_system::instance()]);
|
||||
$data = $exporter->export($output);
|
||||
return $data->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* An implementation of a userlist which has been filtered and approved.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_dataprivacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* An implementation of a userlist which can be filtered by role.
|
||||
*
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class filtered_userlist extends \core_privacy\local\request\approved_userlist {
|
||||
|
||||
/**
|
||||
* Apply filters to only remove users in the expireduserids list, and to remove any who are in the unexpired list.
|
||||
* The unexpired list wins where a user is in both lists.
|
||||
*
|
||||
* @param int[] $expireduserids The list of userids for users who should be expired.
|
||||
* @param int[] $unexpireduserids The list of userids for those users who should not be expired.
|
||||
* @return $this
|
||||
*/
|
||||
public function apply_expired_context_filters(array $expireduserids, array $unexpireduserids) : filtered_userlist {
|
||||
// The current userlist content.
|
||||
$userids = $this->get_userids();
|
||||
|
||||
if (!empty($expireduserids)) {
|
||||
// Now remove any not on the list of expired users.
|
||||
$userids = array_intersect($userids, $expireduserids);
|
||||
}
|
||||
|
||||
if (!empty($unexpireduserids)) {
|
||||
// Remove any on the list of unexpiredusers users.
|
||||
$userids = array_diff($userids, $unexpireduserids);
|
||||
}
|
||||
|
||||
$this->set_userids($userids);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use tool_dataprivacy\api;
|
||||
use tool_dataprivacy\data_registry;
|
||||
use tool_dataprivacy\purpose;
|
||||
|
||||
/**
|
||||
* Context instance data form.
|
||||
@@ -56,7 +55,6 @@ class context_instance extends \core\form\persistent {
|
||||
$subjectscope = get_string('noassignedroles', 'tool_dataprivacy');
|
||||
}
|
||||
$this->_form->addElement('static', 'subjectscope', get_string('subjectscope', 'tool_dataprivacy'), $subjectscope);
|
||||
$this->_form->addHelpButton('subjectscope', 'subjectscope', 'tool_dataprivacy');
|
||||
|
||||
$this->add_purpose_category($this->_customdata['context']->contextlevel);
|
||||
|
||||
@@ -81,7 +79,6 @@ class context_instance extends \core\form\persistent {
|
||||
$addcategory = $mform->createElement('button', 'addcategory', $addcategorytext, ['data-add-element' => 'category']);
|
||||
$mform->addElement('group', 'categorygroup', get_string('category', 'tool_dataprivacy'),
|
||||
[$categoryselect, $addcategory], null, false);
|
||||
$mform->addHelpButton('categorygroup', 'category', 'tool_dataprivacy');
|
||||
$mform->setType('categoryid', PARAM_INT);
|
||||
$mform->setDefault('categoryid', 0);
|
||||
|
||||
@@ -90,14 +87,12 @@ class context_instance extends \core\form\persistent {
|
||||
$addpurpose = $mform->createElement('button', 'addpurpose', $addpurposetext, ['data-add-element' => 'purpose']);
|
||||
$mform->addElement('group', 'purposegroup', get_string('purpose', 'tool_dataprivacy'),
|
||||
[$purposeselect, $addpurpose], null, false);
|
||||
$mform->addHelpButton('purposegroup', 'purpose', 'tool_dataprivacy');
|
||||
$mform->setType('purposeid', PARAM_INT);
|
||||
$mform->setDefault('purposeid', 0);
|
||||
|
||||
if (!empty($this->_customdata['currentretentionperiod'])) {
|
||||
$mform->addElement('static', 'retention_current', get_string('retentionperiod', 'tool_dataprivacy'),
|
||||
$this->_customdata['currentretentionperiod']);
|
||||
$mform->addHelpButton('retention_current', 'retentionperiod', 'tool_dataprivacy');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,12 +140,12 @@ class context_instance extends \core\form\persistent {
|
||||
$persistent->set('contextid', $context->id);
|
||||
}
|
||||
|
||||
$purposes = [];
|
||||
foreach (api::get_purposes() as $purpose) {
|
||||
$purposes[$purpose->get('id')] = $purpose;
|
||||
}
|
||||
$purposeoptions = \tool_dataprivacy\output\data_registry_page::purpose_options($purposes);
|
||||
$categoryoptions = \tool_dataprivacy\output\data_registry_page::category_options(api::get_categories());
|
||||
$purposeoptions = \tool_dataprivacy\output\data_registry_page::purpose_options(
|
||||
api::get_purposes()
|
||||
);
|
||||
$categoryoptions = \tool_dataprivacy\output\data_registry_page::category_options(
|
||||
api::get_categories()
|
||||
);
|
||||
|
||||
$customdata = [
|
||||
'context' => $context,
|
||||
@@ -168,14 +163,9 @@ class context_instance extends \core\form\persistent {
|
||||
$context);
|
||||
|
||||
$customdata['purposeretentionperiods'] = [];
|
||||
foreach (array_keys($purposeoptions) as $optionvalue) {
|
||||
|
||||
if (isset($purposes[$optionvalue])) {
|
||||
$purpose = $purposes[$optionvalue];
|
||||
} else {
|
||||
// Get the effective purpose if $optionvalue would be the selected value.
|
||||
$purpose = api::get_effective_context_purpose($context, $optionvalue);
|
||||
}
|
||||
foreach ($purposeoptions as $optionvalue => $unused) {
|
||||
// Get the effective purpose if $optionvalue would be the selected value.
|
||||
$purpose = api::get_effective_context_purpose($context, $optionvalue);
|
||||
|
||||
$retentionperiod = self::get_retention_display_text(
|
||||
$purpose,
|
||||
@@ -192,12 +182,12 @@ class context_instance extends \core\form\persistent {
|
||||
/**
|
||||
* Returns the purpose display text.
|
||||
*
|
||||
* @param purpose $effectivepurpose
|
||||
* @param \tool_dataprivacy\purpose $effectivepurpose
|
||||
* @param int $retentioncontextlevel
|
||||
* @param \context $context The context, just for displaying (filters) purposes.
|
||||
* @return string
|
||||
*/
|
||||
protected static function get_retention_display_text(purpose $effectivepurpose, $retentioncontextlevel, \context $context) {
|
||||
protected static function get_retention_display_text(\tool_dataprivacy\purpose $effectivepurpose, $retentioncontextlevel, \context $context) {
|
||||
global $PAGE;
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_dataprivacy');
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the defaults form.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_dataprivacy\form;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use \tool_dataprivacy\output\data_registry_page;
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
|
||||
|
||||
/**
|
||||
* Context levels defaults form.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class defaults extends \moodleform {
|
||||
|
||||
/**
|
||||
* Define the form.
|
||||
*/
|
||||
public function definition() {
|
||||
global $OUTPUT;
|
||||
|
||||
$mform = $this->_form;
|
||||
$mform->setDisableShortforms();
|
||||
|
||||
$notification = $OUTPUT->notification(get_string('defaultsinfo', 'tool_dataprivacy'),
|
||||
\core\output\notification::NOTIFY_INFO);
|
||||
$mform->addElement('html', $notification);
|
||||
|
||||
foreach ($this->_customdata['levels'] as $level => $classname) {
|
||||
|
||||
$mform->addElement('header', $classname . '-header',
|
||||
get_string('contextlevelname' . $level, 'tool_dataprivacy'));
|
||||
|
||||
list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname);
|
||||
|
||||
$includeinherit = true;
|
||||
if ($level == CONTEXT_SYSTEM) {
|
||||
$includeinherit = false;
|
||||
}
|
||||
|
||||
$categoryoptions = data_registry_page::category_options($this->_customdata['categories'], false, $includeinherit);
|
||||
$purposeoptions = data_registry_page::category_options($this->_customdata['purposes'], false, $includeinherit);
|
||||
|
||||
$mform->addElement('select', $categoryvar, get_string('category', 'tool_dataprivacy'), $categoryoptions);
|
||||
$mform->setType($categoryvar, PARAM_INT);
|
||||
|
||||
$mform->addElement('select', $purposevar, get_string('purpose', 'tool_dataprivacy'), $purposeoptions);
|
||||
$mform->setType($purposevar, PARAM_INT);
|
||||
}
|
||||
|
||||
$this->add_action_buttons(true, get_string('savechanges'));
|
||||
}
|
||||
}
|
||||
@@ -41,11 +41,6 @@ class purpose extends persistent {
|
||||
*/
|
||||
protected static $persistentclass = 'tool_dataprivacy\\purpose';
|
||||
|
||||
/**
|
||||
* @var array The list of current overrides.
|
||||
*/
|
||||
protected $existingoverrides = [];
|
||||
|
||||
/**
|
||||
* Define the form - called by parent constructor
|
||||
*/
|
||||
@@ -61,16 +56,41 @@ class purpose extends persistent {
|
||||
$mform->setType('description', PARAM_CLEANHTML);
|
||||
|
||||
// Field for selecting lawful bases (from GDPR Article 6.1).
|
||||
$this->add_field($this->get_lawful_base_field());
|
||||
$lawfulbases = [];
|
||||
foreach (\tool_dataprivacy\purpose::GDPR_ART_6_1_ITEMS as $article) {
|
||||
$key = 'gdpr_art_6_1_' . $article;
|
||||
$lawfulbases[$key] = get_string($key . '_name', 'tool_dataprivacy');
|
||||
}
|
||||
$options = array(
|
||||
'multiple' => true,
|
||||
);
|
||||
$mform->addElement('autocomplete', 'lawfulbases', get_string('lawfulbases', 'tool_dataprivacy'), $lawfulbases, $options);
|
||||
$mform->addRule('lawfulbases', get_string('required'), 'required', null, 'server');
|
||||
$mform->addHelpButton('lawfulbases', 'lawfulbases', 'tool_dataprivacy');
|
||||
|
||||
// Optional field for selecting reasons for collecting sensitive personal data (from GDPR Article 9.2).
|
||||
$this->add_field($this->get_sensitive_base_field());
|
||||
$sensitivereasons = [];
|
||||
foreach (\tool_dataprivacy\purpose::GDPR_ART_9_2_ITEMS as $article) {
|
||||
$key = 'gdpr_art_9_2_' . $article;
|
||||
$sensitivereasons[$key] = get_string($key . '_name', 'tool_dataprivacy');
|
||||
}
|
||||
$mform->addElement('autocomplete', 'sensitivedatareasons', get_string('sensitivedatareasons', 'tool_dataprivacy'),
|
||||
$sensitivereasons, $options);
|
||||
$mform->addHelpButton('sensitivedatareasons', 'sensitivedatareasons', 'tool_dataprivacy');
|
||||
|
||||
$this->add_field($this->get_retention_period_fields());
|
||||
$this->add_field($this->get_protected_field());
|
||||
$number = $mform->createElement('text', 'retentionperiodnumber', null, ['size' => 8]);
|
||||
$unitoptions = [
|
||||
'Y' => get_string('years'),
|
||||
'M' => strtolower(get_string('months')),
|
||||
'D' => strtolower(get_string('days'))
|
||||
];
|
||||
$unit = $mform->createElement('select', 'retentionperiodunit', '', $unitoptions);
|
||||
$mform->addGroup(['number' => $number, 'unit' => $unit], 'retentionperiod',
|
||||
get_string('retentionperiod', 'tool_dataprivacy'), null, false);
|
||||
$mform->setType('retentionperiodnumber', PARAM_INT);
|
||||
|
||||
$this->add_override_fields();
|
||||
$this->_form->addElement('advcheckbox', 'protected', get_string('protected', 'tool_dataprivacy'),
|
||||
get_string('protectedlabel', 'tool_dataprivacy'));
|
||||
|
||||
if (!empty($this->_customdata['showbuttons'])) {
|
||||
if (!$this->get_persistent()->get('id')) {
|
||||
@@ -82,360 +102,16 @@ class purpose extends persistent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a fieldset to the current form.
|
||||
*
|
||||
* @param \stdClass $data
|
||||
*/
|
||||
protected function add_field(\stdClass $data) {
|
||||
foreach ($data->fields as $field) {
|
||||
$this->_form->addElement($field);
|
||||
}
|
||||
|
||||
if (!empty($data->helps)) {
|
||||
foreach ($data->helps as $fieldname => $helpdata) {
|
||||
$help = array_merge([$fieldname], $helpdata);
|
||||
call_user_func_array([$this->_form, 'addHelpButton'], $help);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data->types)) {
|
||||
foreach ($data->types as $fieldname => $type) {
|
||||
$this->_form->setType($fieldname, $type);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data->rules)) {
|
||||
foreach ($data->rules as $fieldname => $ruledata) {
|
||||
$rule = array_merge([$fieldname], $ruledata);
|
||||
call_user_func_array([$this->_form, 'addRule'], $rule);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data->defaults)) {
|
||||
foreach ($data->defaults as $fieldname => $default) {
|
||||
$this->_form($fieldname, $default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle addition of relevant repeated element fields for role overrides.
|
||||
*/
|
||||
protected function add_override_fields() {
|
||||
$purpose = $this->get_persistent();
|
||||
|
||||
if (empty($purpose->get('id'))) {
|
||||
// It is not possible to use repeated elements in a modal form yet.
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = [
|
||||
$this->get_role_override_id('roleoverride_'),
|
||||
$this->get_role_field('roleoverride_'),
|
||||
$this->get_retention_period_fields('roleoverride_'),
|
||||
$this->get_protected_field('roleoverride_'),
|
||||
$this->get_lawful_base_field('roleoverride_'),
|
||||
$this->get_sensitive_base_field('roleoverride_'),
|
||||
];
|
||||
|
||||
$options = [
|
||||
'type' => [],
|
||||
'helpbutton' => [],
|
||||
];
|
||||
|
||||
// Start by adding the title.
|
||||
$overrideelements = [
|
||||
$this->_form->createElement('header', 'roleoverride', get_string('roleoverride', 'tool_dataprivacy')),
|
||||
$this->_form->createElement(
|
||||
'static',
|
||||
'roleoverrideoverview',
|
||||
'',
|
||||
get_string('roleoverrideoverview', 'tool_dataprivacy')
|
||||
),
|
||||
];
|
||||
|
||||
foreach ($fields as $fielddata) {
|
||||
foreach ($fielddata->fields as $field) {
|
||||
$overrideelements[] = $field;
|
||||
}
|
||||
|
||||
if (!empty($fielddata->helps)) {
|
||||
foreach ($fielddata->helps as $name => $help) {
|
||||
if (!isset($options[$name])) {
|
||||
$options[$name] = [];
|
||||
}
|
||||
$options[$name]['helpbutton'] = $help;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fielddata->types)) {
|
||||
foreach ($fielddata->types as $name => $type) {
|
||||
if (!isset($options[$name])) {
|
||||
$options[$name] = [];
|
||||
}
|
||||
$options[$name]['type'] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fielddata->rules)) {
|
||||
foreach ($fielddata->rules as $name => $rule) {
|
||||
if (!isset($options[$name])) {
|
||||
$options[$name] = [];
|
||||
}
|
||||
$options[$name]['rule'] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fielddata->defaults)) {
|
||||
foreach ($fielddata->defaults as $name => $default) {
|
||||
if (!isset($options[$name])) {
|
||||
$options[$name] = [];
|
||||
}
|
||||
$options[$name]['default'] = $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fielddata->advanceds)) {
|
||||
foreach ($fielddata->advanceds as $name => $advanced) {
|
||||
if (!isset($options[$name])) {
|
||||
$options[$name] = [];
|
||||
}
|
||||
$options[$name]['advanced'] = $advanced;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->existingoverrides = $purpose->get_purpose_overrides();
|
||||
$existingoverridecount = count($this->existingoverrides);
|
||||
|
||||
$this->repeat_elements(
|
||||
$overrideelements,
|
||||
$existingoverridecount,
|
||||
$options,
|
||||
'overrides',
|
||||
'addoverride',
|
||||
1,
|
||||
get_string('addroleoverride', 'tool_dataprivacy')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts fields.
|
||||
*
|
||||
* @param \stdClass $data
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function filter_data_for_persistent($data) {
|
||||
$data = parent::filter_data_for_persistent($data);
|
||||
|
||||
$classname = static::$persistentclass;
|
||||
$properties = $classname::properties_definition();
|
||||
|
||||
$data = (object) array_filter((array) $data, function($value, $key) use ($properties) {
|
||||
return isset($properties[$key]);
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field for the role name.
|
||||
*
|
||||
* @param string $prefix The prefix to apply to the field
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_role_override_id(string $prefix = '') : \stdClass {
|
||||
$fieldname = "{$prefix}id";
|
||||
|
||||
$fielddata = (object) [
|
||||
'fields' => [],
|
||||
];
|
||||
|
||||
$fielddata->fields[] = $this->_form->createElement('hidden', $fieldname);
|
||||
$fielddata->types[$fieldname] = PARAM_INT;
|
||||
|
||||
return $fielddata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field for the role name.
|
||||
*
|
||||
* @param string $prefix The prefix to apply to the field
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_role_field(string $prefix = '') : \stdClass {
|
||||
$fieldname = "{$prefix}roleid";
|
||||
|
||||
$fielddata = (object) [
|
||||
'fields' => [],
|
||||
'helps' => [],
|
||||
];
|
||||
|
||||
$roles = [
|
||||
'' => get_string('none'),
|
||||
];
|
||||
foreach (role_get_names() as $roleid => $role) {
|
||||
$roles[$roleid] = $role->localname;
|
||||
}
|
||||
|
||||
$fielddata->fields[] = $this->_form->createElement('select', $fieldname, get_string('role'),
|
||||
$roles,
|
||||
[
|
||||
'multiple' => false,
|
||||
]
|
||||
);
|
||||
$fielddata->helps[$fieldname] = ['role', 'tool_dataprivacy'];
|
||||
$fielddata->defaults[$fieldname] = null;
|
||||
|
||||
return $fielddata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mform field for lawful bases.
|
||||
*
|
||||
* @param string $prefix The prefix to apply to the field
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_lawful_base_field(string $prefix = '') : \stdClass {
|
||||
$fieldname = "{$prefix}lawfulbases";
|
||||
|
||||
$data = (object) [
|
||||
'fields' => [],
|
||||
];
|
||||
|
||||
$bases = [];
|
||||
foreach (\tool_dataprivacy\purpose::GDPR_ART_6_1_ITEMS as $article) {
|
||||
$key = 'gdpr_art_6_1_' . $article;
|
||||
$bases[$key] = get_string("{$key}_name", 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
$data->fields[] = $this->_form->createElement('autocomplete', $fieldname, get_string('lawfulbases', 'tool_dataprivacy'),
|
||||
$bases,
|
||||
[
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$data->helps = [
|
||||
$fieldname => ['lawfulbases', 'tool_dataprivacy'],
|
||||
];
|
||||
|
||||
$data->advanceds = [
|
||||
$fieldname => true,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mform field for sensitive bases.
|
||||
*
|
||||
* @param string $prefix The prefix to apply to the field
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_sensitive_base_field(string $prefix = '') : \stdClass {
|
||||
$fieldname = "{$prefix}sensitivedatareasons";
|
||||
|
||||
$data = (object) [
|
||||
'fields' => [],
|
||||
];
|
||||
|
||||
$bases = [];
|
||||
foreach (\tool_dataprivacy\purpose::GDPR_ART_9_2_ITEMS as $article) {
|
||||
$key = 'gdpr_art_9_2_' . $article;
|
||||
$bases[$key] = get_string("{$key}_name", 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
$data->fields[] = $this->_form->createElement(
|
||||
'autocomplete',
|
||||
$fieldname,
|
||||
get_string('sensitivedatareasons', 'tool_dataprivacy'),
|
||||
$bases,
|
||||
[
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
$data->helps = [
|
||||
$fieldname => ['sensitivedatareasons', 'tool_dataprivacy'],
|
||||
];
|
||||
|
||||
$data->advanceds = [
|
||||
$fieldname => true,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the retention period fields.
|
||||
*
|
||||
* @param string $prefix The name of the main field, and prefix for the subfields.
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_retention_period_fields(string $prefix = '') : \stdClass {
|
||||
$prefix = "{$prefix}retentionperiod";
|
||||
$data = (object) [
|
||||
'fields' => [],
|
||||
'types' => [],
|
||||
];
|
||||
|
||||
$number = $this->_form->createElement('text', "{$prefix}number", null, ['size' => 8]);
|
||||
$data->types["{$prefix}number"] = PARAM_INT;
|
||||
|
||||
$unitoptions = [
|
||||
'Y' => get_string('years'),
|
||||
'M' => strtolower(get_string('months')),
|
||||
'D' => strtolower(get_string('days'))
|
||||
];
|
||||
$unit = $this->_form->createElement('select', "{$prefix}unit", '', $unitoptions);
|
||||
|
||||
$data->fields[] = $this->_form->createElement(
|
||||
'group',
|
||||
$prefix,
|
||||
get_string('retentionperiod', 'tool_dataprivacy'),
|
||||
[
|
||||
'number' => $number,
|
||||
'unit' => $unit,
|
||||
],
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mform field for the protected flag.
|
||||
*
|
||||
* @param string $prefix The prefix to apply to the field
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_protected_field(string $prefix = '') : \stdClass {
|
||||
$fieldname = "{$prefix}protected";
|
||||
|
||||
return (object) [
|
||||
'fields' => [
|
||||
$this->_form->createElement(
|
||||
'advcheckbox',
|
||||
$fieldname,
|
||||
get_string('protected', 'tool_dataprivacy'),
|
||||
get_string('protectedlabel', 'tool_dataprivacy')
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts data to data suitable for storage.
|
||||
*
|
||||
* @param \stdClass $data
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected static function convert_fields(\stdClass $data) {
|
||||
$data = parent::convert_fields($data);
|
||||
|
||||
if (!empty($data->lawfulbases) && is_array($data->lawfulbases)) {
|
||||
if (is_array($data->lawfulbases)) {
|
||||
$data->lawfulbases = implode(',', $data->lawfulbases);
|
||||
}
|
||||
if (!empty($data->sensitivedatareasons) && is_array($data->sensitivedatareasons)) {
|
||||
@@ -446,7 +122,6 @@ class purpose extends persistent {
|
||||
$data->retentionperiod = 'P' . $data->retentionperiodnumber . $data->retentionperiodunit;
|
||||
unset($data->retentionperiodnumber);
|
||||
unset($data->retentionperiodunit);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -458,16 +133,6 @@ class purpose extends persistent {
|
||||
protected function get_default_data() {
|
||||
$data = parent::get_default_data();
|
||||
|
||||
return $this->convert_existing_data_to_values($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalise any values stored in existing data.
|
||||
*
|
||||
* @param \stdClass $data
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function convert_existing_data_to_values(\stdClass $data) : \stdClass {
|
||||
$data->lawfulbases = explode(',', $data->lawfulbases);
|
||||
if (!empty($data->sensitivedatareasons)) {
|
||||
$data->sensitivedatareasons = explode(',', $data->sensitivedatareasons);
|
||||
@@ -481,94 +146,4 @@ class purpose extends persistent {
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the role override data from the list of submitted data.
|
||||
*
|
||||
* @param \stdClass $data The complete set of processed data
|
||||
* @return \stdClass[] The list of overrides
|
||||
*/
|
||||
public function get_role_overrides_from_data(\stdClass $data) {
|
||||
$overrides = [];
|
||||
if (!empty($data->overrides)) {
|
||||
$searchkey = 'roleoverride_';
|
||||
|
||||
for ($i = 0; $i < $data->overrides; $i++) {
|
||||
$overridedata = (object) [];
|
||||
foreach ((array) $data as $fieldname => $value) {
|
||||
if (strpos($fieldname, $searchkey) !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$overridefieldname = substr($fieldname, strlen($searchkey));
|
||||
$overridedata->$overridefieldname = $value[$i];
|
||||
}
|
||||
|
||||
if (empty($overridedata->roleid) || empty($overridedata->retentionperiodnumber)) {
|
||||
// Skip this one.
|
||||
// There is no value and it will be delete.
|
||||
continue;
|
||||
}
|
||||
|
||||
$override = static::convert_fields($overridedata);
|
||||
|
||||
$overrides[$i] = $override;
|
||||
}
|
||||
}
|
||||
|
||||
return $overrides;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define extra validation mechanims.
|
||||
*
|
||||
* @param stdClass $data Data to validate.
|
||||
* @param array $files Array of files.
|
||||
* @param array $errors Currently reported errors.
|
||||
* @return array of additional errors, or overridden errors.
|
||||
*/
|
||||
protected function extra_validation($data, $files, array &$errors) {
|
||||
$overrides = $this->get_role_overrides_from_data($data);
|
||||
|
||||
// Check role overrides to ensure that:
|
||||
// - roles are unique; and
|
||||
// - specifeid retention periods are numeric.
|
||||
$seenroleids = [];
|
||||
foreach ($overrides as $id => $override) {
|
||||
$override->purposeid = 0;
|
||||
$persistent = new \tool_dataprivacy\purpose_override($override->id, $override);
|
||||
|
||||
if (isset($seenroleids[$persistent->get('roleid')])) {
|
||||
$errors["roleoverride_roleid[{$id}]"] = get_string('duplicaterole');
|
||||
}
|
||||
$seenroleids[$persistent->get('roleid')] = true;
|
||||
|
||||
$errors = array_merge($errors, $persistent->get_errors());
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load in existing data as form defaults. Usually new entry defaults are stored directly in
|
||||
* form definition (new entry form); this function is used to load in data where values
|
||||
* already exist and data is being edited (edit entry form).
|
||||
*
|
||||
* @param stdClass $data
|
||||
*/
|
||||
public function set_data($data) {
|
||||
$purpose = $this->get_persistent();
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->existingoverrides as $override) {
|
||||
$overridedata = $this->convert_existing_data_to_values($override->to_record());
|
||||
foreach ($overridedata as $key => $value) {
|
||||
$keyname = "roleoverride_{$key}[{$count}]";
|
||||
$data->$keyname = $value;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
parent::set_data($data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Filter selector field.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_dataprivacy\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use MoodleQuickForm_autocomplete;
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/form/autocomplete.php');
|
||||
|
||||
/**
|
||||
* Form field type for choosing a user on the data request creation form.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class request_user_autocomplete extends MoodleQuickForm_autocomplete {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $elementname Element name
|
||||
* @param mixed $elementlabel Label(s) for an element
|
||||
* @param array $options Options to control the element's display
|
||||
* Valid options are:
|
||||
* - multiple bool Whether or not the field accepts more than one values.
|
||||
*/
|
||||
public function __construct($elementname = null, $elementlabel = null, $options = array()) {
|
||||
$validattributes = array(
|
||||
'ajax' => 'tool_dataprivacy/form-user-selector',
|
||||
);
|
||||
if (!empty($options['multiple'])) {
|
||||
$validattributes['multiple'] = 'multiple';
|
||||
}
|
||||
|
||||
parent::__construct($elementname, $elementlabel, array(), $validattributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of this element.
|
||||
*
|
||||
* @param string|array $value The value to set.
|
||||
* @return boolean
|
||||
*/
|
||||
public function setValue($value) {
|
||||
global $DB;
|
||||
$values = (array) $value;
|
||||
$ids = [];
|
||||
foreach ($values as $onevalue) {
|
||||
if (!empty($onevalue) && (!$this->optionExists($onevalue)) &&
|
||||
($onevalue !== '_qf__force_multiselect_submission')) {
|
||||
array_push($ids, $onevalue);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($ids)) {
|
||||
return $this->setSelected([]);
|
||||
}
|
||||
|
||||
$toselect = [];
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED);
|
||||
$allusernames = get_all_user_name_fields(true);
|
||||
// Exclude admins and guest user.
|
||||
$excludedusers = array_keys(get_admins()) + [guest_user()->id];
|
||||
$sort = 'firstname ASC';
|
||||
$fields = 'id, email, ' . $allusernames;
|
||||
// Fetch the selected users, exclude the admins and guest users.
|
||||
$users = get_users(true, '', true, $excludedusers, $sort, '', '', 0, 30, $fields, "id $insql", $inparams);
|
||||
foreach ($users as $user) {
|
||||
$userdata = (object)[
|
||||
'name' => fullname($user),
|
||||
'email' => $user->email
|
||||
];
|
||||
$this->addOption(get_string('nameemail', 'tool_dataprivacy', $userdata), $user->id);
|
||||
array_push($toselect, $user->id);
|
||||
}
|
||||
|
||||
return $this->setSelected($toselect);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
use coding_exception;
|
||||
use moodle_exception;
|
||||
use tool_dataprivacy\api;
|
||||
use tool_dataprivacy\data_request;
|
||||
|
||||
/**
|
||||
* Class containing helper functions for the data privacy tool.
|
||||
@@ -36,23 +35,6 @@ use tool_dataprivacy\data_request;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class helper {
|
||||
/** The default number of results to be shown per page. */
|
||||
const DEFAULT_PAGE_SIZE = 20;
|
||||
|
||||
/** Filter constant associated with the request type filter. */
|
||||
const FILTER_TYPE = 1;
|
||||
|
||||
/** Filter constant associated with the request status filter. */
|
||||
const FILTER_STATUS = 2;
|
||||
|
||||
/** Filter constant associated with the request creation filter. */
|
||||
const FILTER_CREATION = 3;
|
||||
|
||||
/** The request filters preference key. */
|
||||
const PREF_REQUEST_FILTERS = 'tool_dataprivacy_request-filters';
|
||||
|
||||
/** The number of data request records per page preference key. */
|
||||
const PREF_REQUEST_PERPAGE = 'tool_dataprivacy_request-perpage';
|
||||
|
||||
/**
|
||||
* Retrieves the human-readable text value of a data request type.
|
||||
@@ -63,11 +45,16 @@ class helper {
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function get_request_type_string($requesttype) {
|
||||
$types = self::get_request_types();
|
||||
if (!isset($types[$requesttype])) {
|
||||
throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
|
||||
switch ($requesttype) {
|
||||
case api::DATAREQUEST_TYPE_EXPORT:
|
||||
return get_string('requesttypeexport', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_TYPE_DELETE:
|
||||
return get_string('requesttypedelete', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_TYPE_OTHERS:
|
||||
return get_string('requesttypeothers', 'tool_dataprivacy');
|
||||
default:
|
||||
throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
|
||||
}
|
||||
return $types[$requesttype];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,37 +66,16 @@ class helper {
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function get_shortened_request_type_string($requesttype) {
|
||||
$types = self::get_request_types_short();
|
||||
if (!isset($types[$requesttype])) {
|
||||
throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
|
||||
switch ($requesttype) {
|
||||
case api::DATAREQUEST_TYPE_EXPORT:
|
||||
return get_string('requesttypeexportshort', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_TYPE_DELETE:
|
||||
return get_string('requesttypedeleteshort', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_TYPE_OTHERS:
|
||||
return get_string('requesttypeothersshort', 'tool_dataprivacy');
|
||||
default:
|
||||
throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
|
||||
}
|
||||
return $types[$requesttype];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key value-pairs of request type code and their string value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_request_types() {
|
||||
return [
|
||||
api::DATAREQUEST_TYPE_EXPORT => get_string('requesttypeexport', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_TYPE_DELETE => get_string('requesttypedelete', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_TYPE_OTHERS => get_string('requesttypeothers', 'tool_dataprivacy'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key value-pairs of request type code and their shortened string value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_request_types_short() {
|
||||
return [
|
||||
api::DATAREQUEST_TYPE_EXPORT => get_string('requesttypeexportshort', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_TYPE_DELETE => get_string('requesttypedeleteshort', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_TYPE_OTHERS => get_string('requesttypeothersshort', 'tool_dataprivacy'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,135 +83,29 @@ class helper {
|
||||
*
|
||||
* @param int $status The request status.
|
||||
* @return string
|
||||
* @throws coding_exception
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function get_request_status_string($status) {
|
||||
$statuses = self::get_request_statuses();
|
||||
if (!isset($statuses[$status])) {
|
||||
throw new moodle_exception('errorinvalidrequeststatus', 'tool_dataprivacy');
|
||||
switch ($status) {
|
||||
case api::DATAREQUEST_STATUS_PENDING:
|
||||
return get_string('statuspending', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_PREPROCESSING:
|
||||
return get_string('statuspreprocessing', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_AWAITING_APPROVAL:
|
||||
return get_string('statusawaitingapproval', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_APPROVED:
|
||||
return get_string('statusapproved', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_PROCESSING:
|
||||
return get_string('statusprocessing', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_COMPLETE:
|
||||
return get_string('statuscomplete', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_CANCELLED:
|
||||
return get_string('statuscancelled', 'tool_dataprivacy');
|
||||
case api::DATAREQUEST_STATUS_REJECTED:
|
||||
return get_string('statusrejected', 'tool_dataprivacy');
|
||||
default:
|
||||
throw new moodle_exception('errorinvalidrequeststatus', 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
return $statuses[$status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key value-pairs of request status code and string value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_request_statuses() {
|
||||
return [
|
||||
api::DATAREQUEST_STATUS_PENDING => get_string('statuspending', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_PREPROCESSING => get_string('statuspreprocessing', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL => get_string('statusawaitingapproval', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_APPROVED => get_string('statusapproved', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_PROCESSING => get_string('statusprocessing', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_COMPLETE => get_string('statuscomplete', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_DOWNLOAD_READY => get_string('statusready', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_EXPIRED => get_string('statusexpired', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_CANCELLED => get_string('statuscancelled', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_REJECTED => get_string('statusrejected', 'tool_dataprivacy'),
|
||||
api::DATAREQUEST_STATUS_DELETED => get_string('statusdeleted', 'tool_dataprivacy'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the human-readable value of a data request creation method.
|
||||
*
|
||||
* @param int $creation The request creation method.
|
||||
* @return string
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function get_request_creation_method_string($creation) {
|
||||
$creationmethods = self::get_request_creation_methods();
|
||||
if (!isset($creationmethods[$creation])) {
|
||||
throw new moodle_exception('errorinvalidrequestcreationmethod', 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
return $creationmethods[$creation];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key value-pairs of request creation method code and string value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_request_creation_methods() {
|
||||
return [
|
||||
data_request::DATAREQUEST_CREATION_MANUAL => get_string('creationmanual', 'tool_dataprivacy'),
|
||||
data_request::DATAREQUEST_CREATION_AUTO => get_string('creationauto', 'tool_dataprivacy'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the users that a user can make data request for.
|
||||
*
|
||||
* E.g. User having a parent role and has the 'tool/dataprivacy:makedatarequestsforchildren' capability.
|
||||
* @param int $userid The user's ID.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_children_of_user($userid) {
|
||||
global $DB;
|
||||
|
||||
// Get users that the user has role assignments to.
|
||||
$allusernames = get_all_user_name_fields(true, 'u');
|
||||
$sql = "SELECT u.id, $allusernames
|
||||
FROM {role_assignments} ra, {context} c, {user} u
|
||||
WHERE ra.userid = :userid
|
||||
AND ra.contextid = c.id
|
||||
AND c.instanceid = u.id
|
||||
AND c.contextlevel = :contextlevel";
|
||||
$params = [
|
||||
'userid' => $userid,
|
||||
'contextlevel' => CONTEXT_USER
|
||||
];
|
||||
|
||||
// The final list of users that we will return.
|
||||
$finalresults = [];
|
||||
|
||||
// Our prospective list of users.
|
||||
if ($candidates = $DB->get_records_sql($sql, $params)) {
|
||||
foreach ($candidates as $key => $child) {
|
||||
$childcontext = \context_user::instance($child->id);
|
||||
if (has_capability('tool/dataprivacy:makedatarequestsforchildren', $childcontext, $userid)) {
|
||||
$finalresults[$key] = $child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $finalresults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get options for the data requests filter.
|
||||
*
|
||||
* @return array
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function get_request_filter_options() {
|
||||
$filters = [
|
||||
self::FILTER_TYPE => (object)[
|
||||
'name' => get_string('requesttype', 'tool_dataprivacy'),
|
||||
'options' => self::get_request_types_short()
|
||||
],
|
||||
self::FILTER_STATUS => (object)[
|
||||
'name' => get_string('requeststatus', 'tool_dataprivacy'),
|
||||
'options' => self::get_request_statuses()
|
||||
],
|
||||
self::FILTER_CREATION => (object)[
|
||||
'name' => get_string('requestcreation', 'tool_dataprivacy'),
|
||||
'options' => self::get_request_creation_methods()
|
||||
],
|
||||
];
|
||||
$options = [];
|
||||
foreach ($filters as $category => $filtercategory) {
|
||||
foreach ($filtercategory->options as $key => $name) {
|
||||
$option = (object)[
|
||||
'category' => $filtercategory->name,
|
||||
'name' => $name
|
||||
];
|
||||
$options["{$category}:{$key}"] = get_string('filteroption', 'tool_dataprivacy', $option);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Class \tool_dataprivacy\manager_observer.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_dataprivacy;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* A failure observer for the \core_privacy\manager.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class manager_observer implements \core_privacy\manager_observer {
|
||||
/**
|
||||
* Notifies all DPOs that an exception occurred.
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @param string $component
|
||||
* @param string $interface
|
||||
* @param string $methodname
|
||||
* @param array $params
|
||||
*/
|
||||
public function handle_component_failure($e, $component, $interface, $methodname, array $params) {
|
||||
// Get the list of the site Data Protection Officers.
|
||||
$dpos = api::get_site_dpos();
|
||||
|
||||
$messagesubject = get_string('exceptionnotificationsubject', 'tool_dataprivacy');
|
||||
$a = (object)[
|
||||
'fullmethodname' => \core_privacy\manager::get_provider_classname_for_component($component) . '::' . $methodname,
|
||||
'component' => $component,
|
||||
'message' => $e->getMessage(),
|
||||
'backtrace' => $e->getTraceAsString()
|
||||
];
|
||||
$messagebody = get_string('exceptionnotificationbody', 'tool_dataprivacy', $a);
|
||||
|
||||
// Email the data request to the Data Protection Officer(s)/Admin(s).
|
||||
foreach ($dpos as $dpo) {
|
||||
$message = new \core\message\message();
|
||||
$message->courseid = SITEID;
|
||||
$message->component = 'tool_dataprivacy';
|
||||
$message->name = 'notifyexceptions';
|
||||
$message->userfrom = \core_user::get_noreply_user();
|
||||
$message->subject = $messagesubject;
|
||||
$message->fullmessageformat = FORMAT_HTML;
|
||||
$message->notification = 1;
|
||||
$message->userto = $dpo;
|
||||
$message->fullmessagehtml = $messagebody;
|
||||
$message->fullmessage = html_to_text($messagebody);
|
||||
|
||||
// Send message.
|
||||
message_send($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,6 @@ class metadata_registry {
|
||||
*/
|
||||
public function get_registry_metadata() {
|
||||
$manager = new \core_privacy\manager();
|
||||
$manager->set_observer(new \tool_dataprivacy\manager_observer());
|
||||
|
||||
$pluginman = \core_plugin_manager::instance();
|
||||
$contributedplugins = $this->get_contrib_list();
|
||||
$metadata = $manager->get_metadata_for_components();
|
||||
@@ -58,10 +56,6 @@ class metadata_registry {
|
||||
if (isset($metadata[$component])) {
|
||||
$collection = $metadata[$component]->get_collection();
|
||||
$internaldata = $this->format_metadata($collection, $component, $internaldata);
|
||||
} else if ($manager->is_empty_subsystem($component)) {
|
||||
// This is an unused subsystem.
|
||||
// Use the generic string.
|
||||
$internaldata['nullprovider'] = get_string('privacy:subsystem:empty', 'core_privacy');
|
||||
} else {
|
||||
// Call get_reason for null provider.
|
||||
$internaldata['nullprovider'] = get_string($manager->get_null_provider_reason($component), $component);
|
||||
@@ -70,37 +64,11 @@ class metadata_registry {
|
||||
$internaldata['compliant'] = false;
|
||||
}
|
||||
// Check to see if we are an external plugin.
|
||||
// Plugin names can contain _ characters, limit to 2 to just remove initial plugintype.
|
||||
$componentshortname = explode('_', $component, 2);
|
||||
$componentshortname = explode('_', $component);
|
||||
$shortname = array_pop($componentshortname);
|
||||
if (isset($contributedplugins[$plugintype][$shortname])) {
|
||||
$internaldata['external'] = true;
|
||||
}
|
||||
|
||||
// Additional interface checks.
|
||||
if (!$manager->is_empty_subsystem($component)) {
|
||||
$classname = $manager->get_provider_classname_for_component($component);
|
||||
if (class_exists($classname)) {
|
||||
$componentclass = new $classname();
|
||||
// Check if the interface is deprecated.
|
||||
if ($componentclass instanceof \core_privacy\local\deprecated) {
|
||||
$internaldata['deprecated'] = true;
|
||||
}
|
||||
|
||||
// Check that the core_userlist_provider is implemented for all user data providers.
|
||||
if ($componentclass instanceof \core_privacy\local\request\core_user_data_provider
|
||||
&& !$componentclass instanceof \core_privacy\local\request\core_userlist_provider) {
|
||||
$internaldata['userlistnoncompliance'] = true;
|
||||
}
|
||||
|
||||
// Check that any type of userlist_provider is implemented for all shared data providers.
|
||||
if ($componentclass instanceof \core_privacy\local\request\shared_data_provider
|
||||
&& !$componentclass instanceof \core_privacy\local\request\userlist_provider) {
|
||||
$internaldata['userlistnoncompliance'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $internaldata;
|
||||
}, $leaves['plugins']);
|
||||
$fullyrichtree[$branch]['plugin_type_raw'] = $plugintype;
|
||||
@@ -154,15 +122,11 @@ class metadata_registry {
|
||||
* @return array An array of plugin types which contain plugin data.
|
||||
*/
|
||||
protected function get_full_component_list() {
|
||||
global $CFG;
|
||||
|
||||
$list = \core_component::get_component_list();
|
||||
$list['core']['core'] = "{$CFG->dirroot}/lib";
|
||||
$formattedlist = [];
|
||||
foreach ($list as $plugintype => $plugin) {
|
||||
$formattedlist[] = ['plugin_type' => $plugintype, 'plugins' => array_keys($plugin)];
|
||||
}
|
||||
|
||||
return $formattedlist;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace tool_dataprivacy\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use coding_exception;
|
||||
use dml_exception;
|
||||
use moodle_exception;
|
||||
use moodle_url;
|
||||
use renderable;
|
||||
@@ -33,7 +34,7 @@ use single_select;
|
||||
use stdClass;
|
||||
use templatable;
|
||||
use tool_dataprivacy\data_request;
|
||||
use tool_dataprivacy\local\helper;
|
||||
use tool_dataprivacy\output\expired_contexts_table;
|
||||
|
||||
/**
|
||||
* Class containing data for a user's data requests.
|
||||
@@ -43,6 +44,9 @@ use tool_dataprivacy\local\helper;
|
||||
*/
|
||||
class data_deletion_page implements renderable, templatable {
|
||||
|
||||
/** The default number of results to be shown per page. */
|
||||
const DEFAULT_PAGE_SIZE = 20;
|
||||
|
||||
/** @var data_request[] $requests List of data requests. */
|
||||
protected $filter = null;
|
||||
|
||||
@@ -53,7 +57,7 @@ class data_deletion_page implements renderable, templatable {
|
||||
* Construct this renderable.
|
||||
*
|
||||
* @param \tool_dataprivacy\data_request[] $filter
|
||||
* @param expired_contexts_table $expiredcontextstable
|
||||
* @param \tool_dataprivacy\expired_contexts_table $expiredcontextstable
|
||||
*/
|
||||
public function __construct($filter, expired_contexts_table $expiredcontextstable) {
|
||||
$this->filter = $filter;
|
||||
@@ -66,6 +70,7 @@ class data_deletion_page implements renderable, templatable {
|
||||
* @param renderer_base $output
|
||||
* @return stdClass
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
@@ -82,7 +87,7 @@ class data_deletion_page implements renderable, templatable {
|
||||
$data->filter = $filterselector->export_for_template($output);
|
||||
|
||||
ob_start();
|
||||
$this->expiredcontextstable->out(helper::DEFAULT_PAGE_SIZE, true);
|
||||
$this->expiredcontextstable->out(self::DEFAULT_PAGE_SIZE, true);
|
||||
$expiredcontexts = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$data->expiredcontexts = $expiredcontexts;
|
||||
|
||||
@@ -101,10 +101,6 @@ class data_registry_page implements renderable, templatable {
|
||||
$data->actions = $actionmenu->export_for_template($output);
|
||||
|
||||
if (!data_registry::defaults_set()) {
|
||||
$data->info = (object)[
|
||||
'message' => get_string('dataregistryinfo', 'tool_dataprivacy'),
|
||||
'announce' => 1
|
||||
];
|
||||
$data->nosystemdefaults = (object)[
|
||||
'message' => get_string('nosystemdefaults', 'tool_dataprivacy'),
|
||||
'announce' => 1
|
||||
@@ -135,7 +131,7 @@ class data_registry_page implements renderable, templatable {
|
||||
'text' => get_string('user'),
|
||||
'contextlevel' => CONTEXT_USER,
|
||||
], [
|
||||
'text' => get_string('categories'),
|
||||
'text' => get_string('categories', 'tool_dataprivacy'),
|
||||
'branches' => $categorybranches,
|
||||
'expandelement' => 'category',
|
||||
], [
|
||||
@@ -316,23 +312,29 @@ class data_registry_page implements renderable, templatable {
|
||||
|
||||
$branches = [];
|
||||
|
||||
$children = $coursecontext->get_child_contexts();
|
||||
foreach ($children as $childcontext) {
|
||||
$blockinstances = \core_block_external::get_course_blocks($coursecontext->instanceid);
|
||||
if (empty($blockinstances['blocks'])) {
|
||||
return $branches;
|
||||
}
|
||||
|
||||
if ($childcontext->contextlevel !== CONTEXT_BLOCK) {
|
||||
continue;
|
||||
foreach ($blockinstances['blocks'] as $bi) {
|
||||
if (function_exists('block_instance_by_id')) {
|
||||
$blockinstance = block_instance_by_id($bi['instanceid']);
|
||||
} else {
|
||||
// TODO To be removed when MDL-61621 gets integrated.
|
||||
$blockinstance = $DB->get_record('block_instances', ['id' => $bi['instanceid']]);
|
||||
$blockinstance = block_instance($blockinstance->blockname, $blockinstance);
|
||||
}
|
||||
|
||||
$blockinstance = block_instance_by_id($childcontext->instanceid);
|
||||
$displayname = shorten_text(format_string($blockinstance->get_title(), true, ['context' => $childcontext]));
|
||||
$blockcontext = \context_block::instance($bi['instanceid']);
|
||||
$displayname = shorten_text(format_string($blockinstance->get_title(), true, ['context' => $blockcontext->id]));
|
||||
$branches[] = self::complete([
|
||||
'text' => $displayname,
|
||||
'contextid' => $childcontext->id,
|
||||
'contextid' => $blockcontext->id,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
return $branches;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,7 +428,7 @@ class data_registry_page implements renderable, templatable {
|
||||
/**
|
||||
* From a list of purpose persistents to a list of id => name purposes.
|
||||
*
|
||||
* @param \tool_dataprivacy\purpose[] $purposes
|
||||
* @param \tool_dataprivacy\purpose $purposes
|
||||
* @param bool $includenotset
|
||||
* @param bool $includeinherit
|
||||
* @return string[]
|
||||
@@ -443,7 +445,7 @@ class data_registry_page implements renderable, templatable {
|
||||
/**
|
||||
* From a list of category persistents to a list of id => name categories.
|
||||
*
|
||||
* @param \tool_dataprivacy\category[] $categories
|
||||
* @param \tool_dataprivacy\category $categories
|
||||
* @param bool $includenotset
|
||||
* @param bool $includeinherit
|
||||
* @return string[]
|
||||
|
||||
@@ -24,17 +24,20 @@
|
||||
namespace tool_dataprivacy\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use action_menu;
|
||||
use action_menu_link_secondary;
|
||||
use coding_exception;
|
||||
use context_system;
|
||||
use dml_exception;
|
||||
use moodle_exception;
|
||||
use moodle_url;
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use single_select;
|
||||
use stdClass;
|
||||
use templatable;
|
||||
use tool_dataprivacy\api;
|
||||
use tool_dataprivacy\local\helper;
|
||||
use tool_dataprivacy\data_request;
|
||||
use tool_dataprivacy\external\data_request_exporter;
|
||||
|
||||
/**
|
||||
* Class containing data for a user's data requests.
|
||||
@@ -44,21 +47,16 @@ use tool_dataprivacy\local\helper;
|
||||
*/
|
||||
class data_requests_page implements renderable, templatable {
|
||||
|
||||
/** @var data_requests_table $table The data requests table. */
|
||||
protected $table;
|
||||
|
||||
/** @var int[] $filters The applied filters. */
|
||||
protected $filters = [];
|
||||
/** @var data_request[] $requests List of data requests. */
|
||||
protected $requests = [];
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
*
|
||||
* @param data_requests_table $table The data requests table.
|
||||
* @param int[] $filters The applied filters.
|
||||
* @param data_request[] $requests
|
||||
*/
|
||||
public function __construct($table, $filters) {
|
||||
$this->table = $table;
|
||||
$this->filters = $filters;
|
||||
public function __construct($requests) {
|
||||
$this->requests = $requests;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,22 +73,43 @@ class data_requests_page implements renderable, templatable {
|
||||
$data->newdatarequesturl = new moodle_url('/admin/tool/dataprivacy/createdatarequest.php');
|
||||
$data->newdatarequesturl->param('manage', true);
|
||||
|
||||
if (!is_https()) {
|
||||
$httpwarningmessage = get_string('httpwarning', 'tool_dataprivacy');
|
||||
$data->httpsite = array('message' => $httpwarningmessage, 'announce' => 1);
|
||||
$requests = [];
|
||||
foreach ($this->requests as $request) {
|
||||
$requestid = $request->get('id');
|
||||
$status = $request->get('status');
|
||||
$requestexporter = new data_request_exporter($request, ['context' => context_system::instance()]);
|
||||
$item = $requestexporter->export($output);
|
||||
|
||||
// Prepare actions.
|
||||
$actions = [];
|
||||
|
||||
// View action.
|
||||
$actionurl = new moodle_url('#');
|
||||
$actiondata = ['data-action' => 'view', 'data-requestid' => $requestid];
|
||||
$actiontext = get_string('viewrequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
|
||||
if ($status == api::DATAREQUEST_STATUS_AWAITING_APPROVAL) {
|
||||
// Approve.
|
||||
$actiondata['data-action'] = 'approve';
|
||||
$actiontext = get_string('approverequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
|
||||
// Deny.
|
||||
$actiondata['data-action'] = 'deny';
|
||||
$actiontext = get_string('denyrequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
}
|
||||
|
||||
$actionsmenu = new action_menu($actions);
|
||||
$actionsmenu->set_menu_trigger(get_string('actions'));
|
||||
$actionsmenu->set_owner_selector('request-actions-' . $requestid);
|
||||
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
|
||||
$item->actions = $actionsmenu->export_for_template($output);
|
||||
|
||||
$requests[] = $item;
|
||||
}
|
||||
|
||||
$url = new moodle_url('/admin/tool/dataprivacy/datarequests.php');
|
||||
$filteroptions = helper::get_request_filter_options();
|
||||
$filter = new request_filter($filteroptions, $this->filters, $url);
|
||||
$data->filter = $filter->export_for_template($output);
|
||||
|
||||
ob_start();
|
||||
$this->table->out($this->table->get_requests_per_page(), true);
|
||||
$requests = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$data->datarequests = $requests;
|
||||
$data->requests = $requests;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Contains the class used for the displaying the data requests table.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta <jun@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
use action_menu;
|
||||
use action_menu_link_secondary;
|
||||
use coding_exception;
|
||||
use dml_exception;
|
||||
use html_writer;
|
||||
use moodle_url;
|
||||
use stdClass;
|
||||
use table_sql;
|
||||
use tool_dataprivacy\api;
|
||||
use tool_dataprivacy\external\data_request_exporter;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* The class for displaying the data requests table.
|
||||
*
|
||||
* @copyright 2018 Jun Pataleta <jun@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class data_requests_table extends table_sql {
|
||||
|
||||
/** @var int The user ID. */
|
||||
protected $userid = 0;
|
||||
|
||||
/** @var int[] The status filters. */
|
||||
protected $statuses = [];
|
||||
|
||||
/** @var int[] The request type filters. */
|
||||
protected $types = [];
|
||||
|
||||
/** @var bool Whether this table is being rendered for managing data requests. */
|
||||
protected $manage = false;
|
||||
|
||||
/** @var \tool_dataprivacy\data_request[] Array of data request persistents. */
|
||||
protected $datarequests = [];
|
||||
|
||||
/** @var \stdClass[] List of userids and whether they have any ongoing active requests. */
|
||||
protected $ongoingrequests = [];
|
||||
|
||||
/** @var int The number of data request to be displayed per page. */
|
||||
protected $perpage;
|
||||
|
||||
/** @var int[] The available options for the number of data request to be displayed per page. */
|
||||
protected $perpageoptions = [25, 50, 100, 250];
|
||||
|
||||
/**
|
||||
* data_requests_table constructor.
|
||||
*
|
||||
* @param int $userid The user ID
|
||||
* @param int[] $statuses
|
||||
* @param int[] $types
|
||||
* @param int[] $creationmethods
|
||||
* @param bool $manage
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function __construct($userid = 0, $statuses = [], $types = [], $creationmethods = [], $manage = false) {
|
||||
parent::__construct('data-requests-table');
|
||||
|
||||
$this->userid = $userid;
|
||||
$this->statuses = $statuses;
|
||||
$this->types = $types;
|
||||
$this->creationmethods = $creationmethods;
|
||||
$this->manage = $manage;
|
||||
|
||||
$checkboxattrs = [
|
||||
'title' => get_string('selectall'),
|
||||
'data-action' => 'selectall'
|
||||
];
|
||||
|
||||
$columnheaders = [
|
||||
'select' => html_writer::checkbox('selectall', 1, false, null, $checkboxattrs),
|
||||
'type' => get_string('requesttype', 'tool_dataprivacy'),
|
||||
'userid' => get_string('user', 'tool_dataprivacy'),
|
||||
'timecreated' => get_string('daterequested', 'tool_dataprivacy'),
|
||||
'requestedby' => get_string('requestby', 'tool_dataprivacy'),
|
||||
'status' => get_string('requeststatus', 'tool_dataprivacy'),
|
||||
'comments' => get_string('message', 'tool_dataprivacy'),
|
||||
'actions' => '',
|
||||
];
|
||||
|
||||
$this->define_columns(array_keys($columnheaders));
|
||||
$this->define_headers(array_values($columnheaders));
|
||||
$this->no_sorting('select', 'actions');
|
||||
}
|
||||
|
||||
/**
|
||||
* The select column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_select($data) {
|
||||
if ($data->status == \tool_dataprivacy\api::DATAREQUEST_STATUS_AWAITING_APPROVAL) {
|
||||
$stringdata = [
|
||||
'username' => $data->foruser->fullname,
|
||||
'requesttype' => \core_text::strtolower($data->typenameshort)
|
||||
];
|
||||
|
||||
return \html_writer::checkbox('requestids[]', $data->id, false, '',
|
||||
['class' => 'selectrequests', 'title' => get_string('selectuserdatarequest',
|
||||
'tool_dataprivacy', $stringdata)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_type($data) {
|
||||
if ($this->manage) {
|
||||
return $data->typenameshort;
|
||||
}
|
||||
return $data->typename;
|
||||
}
|
||||
|
||||
/**
|
||||
* The user column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function col_userid($data) {
|
||||
$user = $data->foruser;
|
||||
return html_writer::link($user->profileurl, $user->fullname, ['title' => get_string('viewprofile')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The context information column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_timecreated($data) {
|
||||
return userdate($data->timecreated);
|
||||
}
|
||||
|
||||
/**
|
||||
* The requesting user's column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function col_requestedby($data) {
|
||||
$user = $data->requestedbyuser;
|
||||
return html_writer::link($user->profileurl, $user->fullname, ['title' => get_string('viewprofile')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The status column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function col_status($data) {
|
||||
return html_writer::span($data->statuslabel, 'label ' . $data->statuslabelclass);
|
||||
}
|
||||
|
||||
/**
|
||||
* The comments column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_comments($data) {
|
||||
return shorten_text($data->comments, 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* The actions column.
|
||||
*
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_actions($data) {
|
||||
global $OUTPUT;
|
||||
|
||||
$requestid = $data->id;
|
||||
$status = $data->status;
|
||||
|
||||
// Prepare actions.
|
||||
$actions = [];
|
||||
|
||||
// View action.
|
||||
$actionurl = new moodle_url('#');
|
||||
$actiondata = ['data-action' => 'view', 'data-requestid' => $requestid];
|
||||
$actiontext = get_string('viewrequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
|
||||
switch ($status) {
|
||||
case api::DATAREQUEST_STATUS_PENDING:
|
||||
// Add action to mark a general enquiry request as complete.
|
||||
if ($data->type == api::DATAREQUEST_TYPE_OTHERS) {
|
||||
$actiondata['data-action'] = 'complete';
|
||||
$nameemail = (object)[
|
||||
'name' => $data->foruser->fullname,
|
||||
'email' => $data->foruser->email
|
||||
];
|
||||
$actiondata['data-requestid'] = $data->id;
|
||||
$actiondata['data-replytoemail'] = get_string('nameemail', 'tool_dataprivacy', $nameemail);
|
||||
$actiontext = get_string('markcomplete', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
}
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_AWAITING_APPROVAL:
|
||||
// Approve.
|
||||
$actiondata['data-action'] = 'approve';
|
||||
$actiontext = get_string('approverequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
|
||||
// Deny.
|
||||
$actiondata['data-action'] = 'deny';
|
||||
$actiontext = get_string('denyrequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
|
||||
$userid = $data->foruser->id;
|
||||
$usercontext = \context_user::instance($userid, IGNORE_MISSING);
|
||||
// If user has permission to view download link, show relevant action item.
|
||||
if ($usercontext && api::can_download_data_request_for_user($userid, $data->requestedbyuser->id)) {
|
||||
$actions[] = api::get_download_link($usercontext, $requestid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->manage) {
|
||||
$persistent = $this->datarequests[$requestid];
|
||||
$canreset = $persistent->is_active() || empty($this->ongoingrequests[$data->foruser->id]->{$data->type});
|
||||
$canreset = $canreset && $persistent->is_resettable();
|
||||
if ($canreset) {
|
||||
$reseturl = new moodle_url('/admin/tool/dataprivacy/resubmitrequest.php', [
|
||||
'requestid' => $requestid,
|
||||
]);
|
||||
$actiondata = ['data-action' => 'reset', 'data-requestid' => $requestid];
|
||||
$actiontext = get_string('resubmitrequestasnew', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($reseturl, null, $actiontext, $actiondata);
|
||||
}
|
||||
}
|
||||
|
||||
$actionsmenu = new action_menu($actions);
|
||||
$actionsmenu->set_menu_trigger(get_string('actions'));
|
||||
$actionsmenu->set_owner_selector('request-actions-' . $requestid);
|
||||
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
|
||||
$actionsmenu->set_constraint('[data-region=data-requests-table] > .no-overflow');
|
||||
|
||||
return $OUTPUT->render($actionsmenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the database for results to display in the table.
|
||||
*
|
||||
* @param int $pagesize size of page for paginated displayed table.
|
||||
* @param bool $useinitialsbar do you want to use the initials bar.
|
||||
* @throws dml_exception
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function query_db($pagesize, $useinitialsbar = true) {
|
||||
global $PAGE;
|
||||
|
||||
// Set dummy page total until we fetch full result set.
|
||||
$this->pagesize($pagesize, $pagesize + 1);
|
||||
|
||||
$sort = $this->get_sql_sort();
|
||||
|
||||
// Get data requests from the given conditions.
|
||||
$datarequests = api::get_data_requests($this->userid, $this->statuses, $this->types,
|
||||
$this->creationmethods, $sort, $this->get_page_start(), $this->get_page_size());
|
||||
|
||||
// Count data requests from the given conditions.
|
||||
$total = api::get_data_requests_count($this->userid, $this->statuses, $this->types,
|
||||
$this->creationmethods);
|
||||
$this->pagesize($pagesize, $total);
|
||||
|
||||
$this->rawdata = [];
|
||||
$context = \context_system::instance();
|
||||
$renderer = $PAGE->get_renderer('tool_dataprivacy');
|
||||
|
||||
$forusers = [];
|
||||
foreach ($datarequests as $persistent) {
|
||||
$this->datarequests[$persistent->get('id')] = $persistent;
|
||||
$exporter = new data_request_exporter($persistent, ['context' => $context]);
|
||||
$this->rawdata[] = $exporter->export($renderer);
|
||||
$forusers[] = $persistent->get('userid');
|
||||
}
|
||||
|
||||
// Fetch the list of all ongoing requests for the users currently shown.
|
||||
// This is used to determine whether any non-active request can be resubmitted.
|
||||
// There can only be one ongoing request of a type for each user.
|
||||
$this->ongoingrequests = api::find_ongoing_request_types_for_users($forusers);
|
||||
|
||||
// Set initial bars.
|
||||
if ($useinitialsbar) {
|
||||
$this->initialbars($total > $pagesize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default implementation to display a more meaningful information to the user.
|
||||
*/
|
||||
public function print_nothing_to_display() {
|
||||
global $OUTPUT;
|
||||
echo $this->render_reset_button();
|
||||
$this->print_initials_bar();
|
||||
if (!empty($this->statuses) || !empty($this->types)) {
|
||||
$message = get_string('nodatarequestsmatchingfilter', 'tool_dataprivacy');
|
||||
} else {
|
||||
$message = get_string('nodatarequests', 'tool_dataprivacy');
|
||||
}
|
||||
echo $OUTPUT->notification($message, 'warning');
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the table's show_hide_link method to prevent the show/hide links from rendering.
|
||||
*
|
||||
* @param string $column the column name, index into various names.
|
||||
* @param int $index numerical index of the column.
|
||||
* @return string HTML fragment.
|
||||
*/
|
||||
protected function show_hide_link($column, $index) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the table's wrap_html_finish method in order to render the bulk actions and
|
||||
* records per page options.
|
||||
*/
|
||||
public function wrap_html_finish() {
|
||||
global $OUTPUT;
|
||||
|
||||
$data = new stdClass();
|
||||
$data->options = [
|
||||
[
|
||||
'value' => 0,
|
||||
'name' => ''
|
||||
],
|
||||
[
|
||||
'value' => \tool_dataprivacy\api::DATAREQUEST_ACTION_APPROVE,
|
||||
'name' => get_string('approve', 'tool_dataprivacy')
|
||||
],
|
||||
[
|
||||
'value' => \tool_dataprivacy\api::DATAREQUEST_ACTION_REJECT,
|
||||
'name' => get_string('deny', 'tool_dataprivacy')
|
||||
]
|
||||
];
|
||||
|
||||
$perpageoptions = array_combine($this->perpageoptions, $this->perpageoptions);
|
||||
$perpageselect = new \single_select(new moodle_url(''), 'perpage',
|
||||
$perpageoptions, get_user_preferences('tool_dataprivacy_request-perpage'), null, 'selectgroup');
|
||||
$perpageselect->label = get_string('perpage', 'moodle');
|
||||
$data->perpage = $OUTPUT->render($perpageselect);
|
||||
|
||||
echo $OUTPUT->render_from_template('tool_dataprivacy/data_requests_bulk_actions', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of data request records to be displayed per page.
|
||||
*
|
||||
* @param int $perpage The number of data request records.
|
||||
*/
|
||||
public function set_requests_per_page(int $perpage) {
|
||||
$this->perpage = $perpage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of data request records to be displayed per page.
|
||||
*
|
||||
* @return int The number of data request records.
|
||||
*/
|
||||
public function get_requests_per_page() : int {
|
||||
return $this->perpage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the available options for the number of data request to be displayed per page.
|
||||
*
|
||||
* @param array $perpageoptions The available options for the number of data request to be displayed per page.
|
||||
*/
|
||||
public function set_requests_per_page_options(array $perpageoptions) {
|
||||
$this->$perpageoptions = $perpageoptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available options for the number of data request to be displayed per page.
|
||||
*
|
||||
* @return array The available options for the number of data request to be displayed per page.
|
||||
*/
|
||||
public function get_requests_per_page_options() : array {
|
||||
return $this->perpageoptions;
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Class containing data for the data registry defaults.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use action_menu_link_primary;
|
||||
use coding_exception;
|
||||
use moodle_exception;
|
||||
use moodle_url;
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use stdClass;
|
||||
use templatable;
|
||||
use tool_dataprivacy\data_registry;
|
||||
use tool_dataprivacy\external\category_exporter;
|
||||
use tool_dataprivacy\external\purpose_exporter;
|
||||
|
||||
/**
|
||||
* Class containing data for the data registry defaults.
|
||||
*
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class defaults_page implements renderable, templatable {
|
||||
|
||||
/** @var int $mode The display mode. */
|
||||
protected $mode = null;
|
||||
|
||||
/** @var int $category The default category for the given mode. */
|
||||
protected $category = null;
|
||||
|
||||
/** @var int $purpose The default purpose for the given mode. */
|
||||
protected $purpose = null;
|
||||
|
||||
/** @var stdClass[] $otherdefaults Other defaults for the given mode. */
|
||||
protected $otherdefaults = [];
|
||||
|
||||
/** @var bool $canedit Whether editing is allowed. */
|
||||
protected $canedit = false;
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
*
|
||||
* @param int $mode The display mode.
|
||||
* @param int $category The default category for the given mode.
|
||||
* @param int $purpose The default purpose for the given mode.
|
||||
* @param stdClass[] $otherdefaults Other defaults for the given mode.
|
||||
* @param bool $canedit Whether editing is allowed.
|
||||
*/
|
||||
public function __construct($mode, $category, $purpose, $otherdefaults = [], $canedit = false) {
|
||||
$this->mode = $mode;
|
||||
$this->category = $category;
|
||||
$this->purpose = $purpose;
|
||||
$this->otherdefaults = $otherdefaults;
|
||||
$this->canedit = $canedit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* @return stdClass
|
||||
* @throws coding_exception
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$data = new stdClass();
|
||||
|
||||
// Set tab URLs.
|
||||
$coursecaturl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_COURSECAT]);
|
||||
$courseurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_COURSE]);
|
||||
$moduleurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_MODULE]);
|
||||
$blockurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_BLOCK]);
|
||||
$data->coursecaturl = $coursecaturl;
|
||||
$data->courseurl = $courseurl;
|
||||
$data->moduleurl = $moduleurl;
|
||||
$data->blockurl = $blockurl;
|
||||
|
||||
// Set display mode.
|
||||
switch ($this->mode) {
|
||||
case CONTEXT_COURSECAT:
|
||||
$data->modecoursecat = true;
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
$data->modecourse = true;
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$data->modemodule = true;
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
$data->modeblock = true;
|
||||
break;
|
||||
default:
|
||||
$data->modecoursecat = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set config variables.
|
||||
$configname = \context_helper::get_class_for_level($this->mode);
|
||||
list($purposevar, $categoryvar) = data_registry::var_names_from_context($configname);
|
||||
$data->categoryvar = $categoryvar;
|
||||
$data->purposevar = $purposevar;
|
||||
|
||||
// Set default category.
|
||||
$data->categoryid = $this->category;
|
||||
$data->category = category_exporter::get_name($this->category);
|
||||
|
||||
// Set default purpose.
|
||||
$data->purposeid = $this->purpose;
|
||||
$data->purpose = purpose_exporter::get_name($this->purpose);
|
||||
|
||||
// Set other defaults.
|
||||
$otherdefaults = [];
|
||||
$url = new moodle_url('#');
|
||||
foreach ($this->otherdefaults as $pluginname => $values) {
|
||||
$defaults = [
|
||||
'name' => $values->name,
|
||||
'category' => category_exporter::get_name($values->category),
|
||||
'purpose' => purpose_exporter::get_name($values->purpose),
|
||||
];
|
||||
if ($this->canedit) {
|
||||
$actions = [];
|
||||
// Edit link.
|
||||
$editattrs = [
|
||||
'data-action' => 'edit-activity-defaults',
|
||||
'data-contextlevel' => $this->mode,
|
||||
'data-activityname' => $pluginname,
|
||||
'data-category' => $values->category,
|
||||
'data-purpose' => $values->purpose,
|
||||
];
|
||||
$editlink = new action_menu_link_primary($url, new \pix_icon('t/edit', get_string('edit')),
|
||||
get_string('edit'), $editattrs);
|
||||
$actions[] = $editlink->export_for_template($output);
|
||||
|
||||
// Delete link.
|
||||
$deleteattrs = [
|
||||
'data-action' => 'delete-activity-defaults',
|
||||
'data-contextlevel' => $this->mode,
|
||||
'data-activityname' => $pluginname,
|
||||
'data-activitydisplayname' => $values->name,
|
||||
];
|
||||
$deletelink = new action_menu_link_primary($url, new \pix_icon('t/delete', get_string('delete')),
|
||||
get_string('delete'), $deleteattrs);
|
||||
$actions[] = $deletelink->export_for_template($output);
|
||||
|
||||
$defaults['actions'] = $actions;
|
||||
}
|
||||
$otherdefaults[] = (object)$defaults;
|
||||
}
|
||||
$data->otherdefaults = $otherdefaults;
|
||||
|
||||
$data->canedit = $this->canedit;
|
||||
$data->contextlevel = $this->mode;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -57,15 +57,9 @@ class expired_contexts_table extends table_sql {
|
||||
*/
|
||||
protected $selectall = true;
|
||||
|
||||
/** @var purpose[] Array of purposes by their id. */
|
||||
/** @var purpose[] Array of purposes mapped to the contexts. */
|
||||
protected $purposes = [];
|
||||
|
||||
/** @var purpose[] Map of context => purpose. */
|
||||
protected $purposemap = [];
|
||||
|
||||
/** @var array List of roles. */
|
||||
protected $roles = [];
|
||||
|
||||
/**
|
||||
* expired_contexts_table constructor.
|
||||
*
|
||||
@@ -83,7 +77,6 @@ class expired_contexts_table extends table_sql {
|
||||
'purpose' => get_string('purpose', 'tool_dataprivacy'),
|
||||
'category' => get_string('category', 'tool_dataprivacy'),
|
||||
'retentionperiod' => get_string('retentionperiod', 'tool_dataprivacy'),
|
||||
'tobedeleted' => get_string('tobedeleted', 'tool_dataprivacy'),
|
||||
'timecreated' => get_string('expiry', 'tool_dataprivacy'),
|
||||
];
|
||||
$checkboxattrs = [
|
||||
@@ -100,25 +93,21 @@ class expired_contexts_table extends table_sql {
|
||||
$this->no_sorting('purpose');
|
||||
$this->no_sorting('category');
|
||||
$this->no_sorting('retentionperiod');
|
||||
$this->no_sorting('tobedeleted');
|
||||
|
||||
// Make this table sorted by first name by default.
|
||||
$this->sortable(true, 'timecreated');
|
||||
|
||||
// We use roles in several places.
|
||||
$this->roles = role_get_names();
|
||||
}
|
||||
|
||||
/**
|
||||
* The context name column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function col_name($expiredctx) {
|
||||
public function col_name($data) {
|
||||
global $OUTPUT;
|
||||
$context = context_helper::instance_by_id($expiredctx->get('contextid'));
|
||||
$context = context_helper::instance_by_id($data->contextid);
|
||||
$parent = $context->get_parent_context();
|
||||
$contextdata = (object)[
|
||||
'name' => $context->get_context_name(false, true),
|
||||
@@ -139,14 +128,14 @@ class expired_contexts_table extends table_sql {
|
||||
/**
|
||||
* The context information column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function col_info($expiredctx) {
|
||||
public function col_info($data) {
|
||||
global $OUTPUT;
|
||||
|
||||
$context = context_helper::instance_by_id($expiredctx->get('contextid'));
|
||||
$context = context_helper::instance_by_id($data->contextid);
|
||||
|
||||
$children = $context->get_child_contexts();
|
||||
if (empty($children)) {
|
||||
@@ -167,13 +156,13 @@ class expired_contexts_table extends table_sql {
|
||||
/**
|
||||
* The category name column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return mixed
|
||||
* @throws coding_exception
|
||||
* @throws dml_exception
|
||||
*/
|
||||
public function col_category($expiredctx) {
|
||||
$context = context_helper::instance_by_id($expiredctx->get('contextid'));
|
||||
public function col_category($data) {
|
||||
$context = context_helper::instance_by_id($data->contextid);
|
||||
$category = api::get_effective_context_category($context);
|
||||
|
||||
return s($category->get('name'));
|
||||
@@ -182,12 +171,12 @@ class expired_contexts_table extends table_sql {
|
||||
/**
|
||||
* The purpose column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function col_purpose($expiredctx) {
|
||||
$purpose = $this->get_purpose_for_expiry($expiredctx);
|
||||
public function col_purpose($data) {
|
||||
$purpose = $this->purposes[$data->contextid];
|
||||
|
||||
return s($purpose->get('name'));
|
||||
}
|
||||
@@ -195,114 +184,42 @@ class expired_contexts_table extends table_sql {
|
||||
/**
|
||||
* The retention period column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function col_retentionperiod($expiredctx) {
|
||||
$purpose = $this->get_purpose_for_expiry($expiredctx);
|
||||
public function col_retentionperiod($data) {
|
||||
global $PAGE;
|
||||
|
||||
$expiries = [];
|
||||
$purpose = $this->purposes[$data->contextid];
|
||||
|
||||
$expiry = html_writer::tag('dt', get_string('default'), ['class' => 'col-sm-3']);
|
||||
if ($expiredctx->get('defaultexpired')) {
|
||||
$expiries[get_string('default')] = get_string('expiredrolewithretention', 'tool_dataprivacy', (object) [
|
||||
'retention' => api::format_retention_period(new \DateInterval($purpose->get('retentionperiod'))),
|
||||
]);
|
||||
} else {
|
||||
$expiries[get_string('default')] = get_string('unexpiredrolewithretention', 'tool_dataprivacy', (object) [
|
||||
'retention' => api::format_retention_period(new \DateInterval($purpose->get('retentionperiod'))),
|
||||
]);
|
||||
}
|
||||
$exporter = new purpose_exporter($purpose, ['context' => \context_system::instance()]);
|
||||
$exportedpurpose = $exporter->export($PAGE->get_renderer('core'));
|
||||
|
||||
if (!$expiredctx->is_fully_expired()) {
|
||||
$purposeoverrides = $purpose->get_purpose_overrides();
|
||||
|
||||
foreach ($expiredctx->get('unexpiredroles') as $roleid) {
|
||||
$role = $this->roles[$roleid];
|
||||
$override = $purposeoverrides[$roleid];
|
||||
|
||||
$expiries[$role->localname] = get_string('unexpiredrolewithretention', 'tool_dataprivacy', (object) [
|
||||
'retention' => api::format_retention_period(new \DateInterval($override->get('retentionperiod'))),
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($expiredctx->get('expiredroles') as $roleid) {
|
||||
$role = $this->roles[$roleid];
|
||||
$override = $purposeoverrides[$roleid];
|
||||
|
||||
$expiries[$role->localname] = get_string('expiredrolewithretention', 'tool_dataprivacy', (object) [
|
||||
'retention' => api::format_retention_period(new \DateInterval($override->get('retentionperiod'))),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$output = array_map(function($rolename, $expiry) {
|
||||
$return = html_writer::tag('dt', $rolename, ['class' => 'col-sm-3']);
|
||||
$return .= html_writer::tag('dd', $expiry, ['class' => 'col-sm-9']);
|
||||
|
||||
return $return;
|
||||
}, array_keys($expiries), $expiries);
|
||||
|
||||
return html_writer::tag('dl', implode($output), ['class' => 'row']);
|
||||
return $exportedpurpose->formattedretentionperiod;
|
||||
}
|
||||
|
||||
/**
|
||||
* The timecreated a.k.a. the context expiry date column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_timecreated($expiredctx) {
|
||||
return userdate($expiredctx->get('timecreated'));
|
||||
public function col_timecreated($data) {
|
||||
return userdate($data->timecreated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the select column.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @param stdClass $data The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_select($expiredctx) {
|
||||
$id = $expiredctx->get('id');
|
||||
public function col_select($data) {
|
||||
$id = $data->id;
|
||||
return html_writer::checkbox('expiredcontext_' . $id, $id, $this->selectall, '', ['class' => 'selectcontext']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for the 'tobedeleted' column which indicates in a friendlier fashion whose data will be removed.
|
||||
*
|
||||
* @param stdClass $expiredctx The row data.
|
||||
* @return string
|
||||
*/
|
||||
public function col_tobedeleted($expiredctx) {
|
||||
if ($expiredctx->is_fully_expired()) {
|
||||
return get_string('defaultexpired', 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
$purpose = $this->get_purpose_for_expiry($expiredctx);
|
||||
|
||||
$a = (object) [];
|
||||
|
||||
$expiredroles = [];
|
||||
foreach ($expiredctx->get('expiredroles') as $roleid) {
|
||||
$expiredroles[] = html_writer::tag('li', $this->roles[$roleid]->localname);
|
||||
}
|
||||
$a->expired = html_writer::tag('ul', implode($expiredroles));
|
||||
|
||||
$unexpiredroles = [];
|
||||
foreach ($expiredctx->get('unexpiredroles') as $roleid) {
|
||||
$unexpiredroles[] = html_writer::tag('li', $this->roles[$roleid]->localname);
|
||||
}
|
||||
$a->unexpired = html_writer::tag('ul', implode($unexpiredroles));
|
||||
|
||||
if ($expiredctx->get('defaultexpired')) {
|
||||
return get_string('defaultexpiredexcept', 'tool_dataprivacy', $a);
|
||||
} else if (empty($unexpiredroles)) {
|
||||
return get_string('defaultunexpired', 'tool_dataprivacy', $a);
|
||||
} else {
|
||||
return get_string('defaultunexpiredwithexceptions', 'tool_dataprivacy', $a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the database for results to display in the table.
|
||||
*
|
||||
@@ -324,15 +241,16 @@ class expired_contexts_table extends table_sql {
|
||||
// Only load expired contexts that are awaiting confirmation.
|
||||
$expiredcontexts = expired_context::get_records_by_contextlevel($this->contextlevel, expired_context::STATUS_EXPIRED,
|
||||
$sort, $this->get_page_start(), $this->get_page_size());
|
||||
|
||||
$this->rawdata = [];
|
||||
$contextids = [];
|
||||
foreach ($expiredcontexts as $persistent) {
|
||||
$this->rawdata[] = $persistent;
|
||||
$contextids[] = $persistent->get('contextid');
|
||||
}
|
||||
$data = $persistent->to_record();
|
||||
|
||||
$this->preload_contexts($contextids);
|
||||
$context = context_helper::instance_by_id($data->contextid);
|
||||
|
||||
$purpose = api::get_effective_context_purpose($context);
|
||||
$this->purposes[$data->contextid] = $purpose;
|
||||
$this->rawdata[] = $data;
|
||||
}
|
||||
|
||||
// Set initial bars.
|
||||
if ($useinitialsbar) {
|
||||
@@ -363,48 +281,4 @@ class expired_contexts_table extends table_sql {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the purpose for the specified expired context.
|
||||
*
|
||||
* @param expired_context $expiredcontext
|
||||
* @return purpose
|
||||
*/
|
||||
protected function get_purpose_for_expiry(expired_context $expiredcontext) : purpose {
|
||||
$context = context_helper::instance_by_id($expiredcontext->get('contextid'));
|
||||
|
||||
if (empty($this->purposemap[$context->id])) {
|
||||
$purpose = api::get_effective_context_purpose($context);
|
||||
$this->purposemap[$context->id] = $purpose->get('id');
|
||||
|
||||
if (empty($this->purposes[$purpose->get('id')])) {
|
||||
$this->purposes[$purpose->get('id')] = $purpose;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->purposes[$this->purposemap[$context->id]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload context records given a set of contextids.
|
||||
*
|
||||
* @param array $contextids
|
||||
*/
|
||||
protected function preload_contexts(array $contextids) {
|
||||
global $DB;
|
||||
|
||||
if (empty($contextids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ctxfields = \context_helper::get_preload_record_columns_sql('ctx');
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
|
||||
$sql = "SELECT {$ctxfields} FROM {context} ctx WHERE ctx.id {$insql}";
|
||||
$contextlist = $DB->get_recordset_sql($sql, $inparams);
|
||||
foreach ($contextlist as $contextdata) {
|
||||
\context_helper::preload_from_record($contextdata);
|
||||
}
|
||||
$contextlist->close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,41 +67,18 @@ class my_data_requests_page implements renderable, templatable {
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
global $USER;
|
||||
|
||||
$data = new stdClass();
|
||||
$data->newdatarequesturl = new moodle_url('/admin/tool/dataprivacy/createdatarequest.php');
|
||||
|
||||
if (!is_https()) {
|
||||
$httpwarningmessage = get_string('httpwarning', 'tool_dataprivacy');
|
||||
$data->httpsite = array('message' => $httpwarningmessage, 'announce' => 1);
|
||||
}
|
||||
|
||||
$requests = [];
|
||||
foreach ($this->requests as $request) {
|
||||
$requestid = $request->get('id');
|
||||
$status = $request->get('status');
|
||||
$userid = $request->get('userid');
|
||||
$type = $request->get('type');
|
||||
|
||||
$usercontext = context_user::instance($userid, IGNORE_MISSING);
|
||||
if (!$usercontext) {
|
||||
// Use the context system.
|
||||
$outputcontext = \context_system::instance();
|
||||
} else {
|
||||
$outputcontext = $usercontext;
|
||||
}
|
||||
|
||||
$requestexporter = new data_request_exporter($request, ['context' => $outputcontext]);
|
||||
$usercontext = context_user::instance($userid);
|
||||
$requestexporter = new data_request_exporter($request, ['context' => $usercontext]);
|
||||
$item = $requestexporter->export($output);
|
||||
|
||||
$self = $request->get('userid') == $USER->id;
|
||||
if (!$self) {
|
||||
// Append user name if it differs from $USER.
|
||||
$a = (object)['typename' => $item->typename, 'user' => $item->foruser->fullname];
|
||||
$item->typename = get_string('requesttypeuser', 'tool_dataprivacy', $a);
|
||||
}
|
||||
|
||||
$candownload = false;
|
||||
$cancancel = true;
|
||||
switch ($status) {
|
||||
@@ -109,28 +86,7 @@ class my_data_requests_page implements renderable, templatable {
|
||||
$item->statuslabelclass = 'label-success';
|
||||
$item->statuslabel = get_string('statuscomplete', 'tool_dataprivacy');
|
||||
$cancancel = false;
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
|
||||
$item->statuslabelclass = 'label-success';
|
||||
$item->statuslabel = get_string('statusready', 'tool_dataprivacy');
|
||||
$cancancel = false;
|
||||
$candownload = true;
|
||||
|
||||
if ($usercontext) {
|
||||
$candownload = api::can_download_data_request_for_user(
|
||||
$request->get('userid'), $request->get('requestedby'));
|
||||
}
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_DELETED:
|
||||
$item->statuslabelclass = 'label-success';
|
||||
$item->statuslabel = get_string('statusdeleted', 'tool_dataprivacy');
|
||||
$cancancel = false;
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_EXPIRED:
|
||||
$item->statuslabelclass = 'label-default';
|
||||
$item->statuslabel = get_string('statusexpired', 'tool_dataprivacy');
|
||||
$item->statuslabeltitle = get_string('downloadexpireduser', 'tool_dataprivacy');
|
||||
$cancancel = false;
|
||||
break;
|
||||
case api::DATAREQUEST_STATUS_CANCELLED:
|
||||
case api::DATAREQUEST_STATUS_REJECTED:
|
||||
@@ -146,8 +102,11 @@ class my_data_requests_page implements renderable, templatable {
|
||||
$canceltext = get_string('cancelrequest', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($cancelurl, null, $canceltext, $canceldata);
|
||||
}
|
||||
if ($candownload && $usercontext) {
|
||||
$actions[] = api::get_download_link($usercontext, $requestid);
|
||||
if ($candownload) {
|
||||
$downloadurl = moodle_url::make_pluginfile_url($usercontext->id, 'tool_dataprivacy', 'export', $requestid, '/',
|
||||
'export.zip', true);
|
||||
$downloadtext = get_string('download', 'tool_dataprivacy');
|
||||
$actions[] = new action_menu_link_secondary($downloadurl, null, $downloadtext);
|
||||
}
|
||||
if (!empty($actions)) {
|
||||
$actionsmenu = new action_menu($actions);
|
||||
|
||||
@@ -62,8 +62,7 @@ class renderer extends plugin_renderer_base {
|
||||
public function render_contact_dpo_link($replytoemail) {
|
||||
$params = [
|
||||
'data-action' => 'contactdpo',
|
||||
'data-replytoemail' => $replytoemail,
|
||||
'class' => 'contactdpo'
|
||||
'data-replytoemail' => $replytoemail
|
||||
];
|
||||
return html_writer::link('#', get_string('contactdataprotectionofficer', 'tool_dataprivacy'), $params);
|
||||
}
|
||||
@@ -139,15 +138,4 @@ class renderer extends plugin_renderer_base {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_dataprivacy/data_deletion', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the user data retention summary page.
|
||||
*
|
||||
* @param summary_page $page
|
||||
* @return string html for the page.
|
||||
*/
|
||||
public function render_summary_page(summary_page $page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_dataprivacy/summary', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Class containing the filter options data for rendering the autocomplete element for the data requests page.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy\output;
|
||||
|
||||
use moodle_url;
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use stdClass;
|
||||
use templatable;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Class containing the filter options data for rendering the autocomplete element for the data requests page.
|
||||
*
|
||||
* @copyright 2018 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class request_filter implements renderable, templatable {
|
||||
|
||||
/** @var array $filteroptions The filter options. */
|
||||
protected $filteroptions;
|
||||
|
||||
/** @var array $selectedoptions The list of selected filter option values. */
|
||||
protected $selectedoptions;
|
||||
|
||||
/** @var moodle_url|string $baseurl The url with params needed to call up this page. */
|
||||
protected $baseurl;
|
||||
|
||||
/**
|
||||
* request_filter constructor.
|
||||
*
|
||||
* @param array $filteroptions The filter options.
|
||||
* @param array $selectedoptions The list of selected filter option values.
|
||||
* @param string|moodle_url $baseurl The url with params needed to call up this page.
|
||||
*/
|
||||
public function __construct($filteroptions, $selectedoptions, $baseurl = null) {
|
||||
$this->filteroptions = $filteroptions;
|
||||
$this->selectedoptions = $selectedoptions;
|
||||
if (!empty($baseurl)) {
|
||||
$this->baseurl = new moodle_url($baseurl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to export the renderer data in a format that is suitable for a mustache template.
|
||||
*
|
||||
* @param renderer_base $output Used to do a final render of any components that need to be rendered for export.
|
||||
* @return stdClass|array
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
global $PAGE;
|
||||
$data = new stdClass();
|
||||
if (empty($this->baseurl)) {
|
||||
$this->baseurl = $PAGE->url;
|
||||
}
|
||||
$data->action = $this->baseurl->out(false);
|
||||
|
||||
foreach ($this->selectedoptions as $option) {
|
||||
if (!isset($this->filteroptions[$option])) {
|
||||
$this->filteroptions[$option] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
$data->filteroptions = [];
|
||||
foreach ($this->filteroptions as $value => $label) {
|
||||
$selected = in_array($value, $this->selectedoptions);
|
||||
$filteroption = (object)[
|
||||
'value' => $value,
|
||||
'label' => $label
|
||||
];
|
||||
$filteroption->selected = $selected;
|
||||
$data->filteroptions[] = $filteroption;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Summary page renderable.
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2018 Adrian Greeve
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_dataprivacy\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use templatable;
|
||||
|
||||
|
||||
/**
|
||||
* Class containing the summary page renderable.
|
||||
*
|
||||
* @copyright 2018 Adrian Greeve
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class summary_page implements renderable, templatable {
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* @return array
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$contextlevels = [
|
||||
'contextlevelname10' => CONTEXT_SYSTEM,
|
||||
'contextlevelname30' => CONTEXT_USER,
|
||||
'contextlevelname40' => CONTEXT_COURSECAT,
|
||||
'contextlevelname50' => CONTEXT_COURSE,
|
||||
'contextlevelname70' => CONTEXT_MODULE,
|
||||
'contextlevelname80' => CONTEXT_BLOCK
|
||||
];
|
||||
|
||||
$data = [];
|
||||
$context = \context_system::instance();
|
||||
|
||||
foreach ($contextlevels as $levelname => $level) {
|
||||
$classname = \context_helper::get_class_for_level($level);
|
||||
list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname);
|
||||
$purposeid = get_config('tool_dataprivacy', $purposevar);
|
||||
$categoryid = get_config('tool_dataprivacy', $categoryvar);
|
||||
|
||||
$section = [];
|
||||
$section['contextname'] = get_string($levelname, 'tool_dataprivacy');
|
||||
|
||||
if (empty($purposeid)) {
|
||||
list($purposeid, $categoryid) =
|
||||
\tool_dataprivacy\data_registry::get_effective_default_contextlevel_purpose_and_category($level);
|
||||
}
|
||||
if ($purposeid == -1) {
|
||||
$purposeid = 0;
|
||||
}
|
||||
$purpose = new \tool_dataprivacy\purpose($purposeid);
|
||||
$export = new \tool_dataprivacy\external\purpose_exporter($purpose, ['context' => $context]);
|
||||
$purposedata = $export->export($output);
|
||||
$section['purpose'] = $purposedata;
|
||||
|
||||
if (empty($categoryid)) {
|
||||
list($purposeid, $categoryid) =
|
||||
\tool_dataprivacy\data_registry::get_effective_default_contextlevel_purpose_and_category($level);
|
||||
}
|
||||
if ($categoryid == -1) {
|
||||
$categoryid = 0;
|
||||
}
|
||||
$category = new \tool_dataprivacy\category($categoryid);
|
||||
$export = new \tool_dataprivacy\external\category_exporter($category, ['context' => $context]);
|
||||
$categorydata = $export->export($output);
|
||||
$section['category'] = $categorydata;
|
||||
$data['contexts'][] = $section;
|
||||
}
|
||||
|
||||
// Get activity module plugin info.
|
||||
$pluginmanager = \core_plugin_manager::instance();
|
||||
$modplugins = $pluginmanager->get_enabled_plugins('mod');
|
||||
|
||||
foreach ($modplugins as $name) {
|
||||
$classname = \context_helper::get_class_for_level($contextlevels['contextlevelname70']);
|
||||
list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname, $name);
|
||||
$categoryid = get_config('tool_dataprivacy', $categoryvar);
|
||||
$purposeid = get_config('tool_dataprivacy', $purposevar);
|
||||
if ($categoryid === false && $purposeid === false) {
|
||||
// If no purpose and category has been set for this plugin, then there's no need to show this on the list.
|
||||
continue;
|
||||
}
|
||||
|
||||
$section = [];
|
||||
$section['contextname'] = $pluginmanager->plugin_name('mod_' . $name);
|
||||
|
||||
if ($purposeid == -1) {
|
||||
$purposeid = 0;
|
||||
}
|
||||
$purpose = new \tool_dataprivacy\purpose($purposeid);
|
||||
$export = new \tool_dataprivacy\external\purpose_exporter($purpose, ['context' => $context]);
|
||||
$purposedata = $export->export($output);
|
||||
$section['purpose'] = $purposedata;
|
||||
|
||||
if ($categoryid == -1) {
|
||||
$categoryid = 0;
|
||||
}
|
||||
$category = new \tool_dataprivacy\category($categoryid);
|
||||
$export = new \tool_dataprivacy\external\category_exporter($category, ['context' => $context]);
|
||||
$categorydata = $export->export($output);
|
||||
$section['category'] = $categorydata;
|
||||
|
||||
$data['contexts'][] = $section;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user