Compare commits
1899 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 28980dbee6 | |||
| 39616d39c4 | |||
| 178af4770e | |||
| fe38aff3a7 | |||
| e78a2d0e44 | |||
| 3caeaa448e | |||
| 3e230a757c | |||
| c8b1ecedc7 | |||
| 4520f30def | |||
| d1af85a398 | |||
| 75cf024576 | |||
| b5f9a3b0e3 | |||
| 13ad8def1b | |||
| f246359c29 | |||
| 3bc786adb1 | |||
| e75bd18064 | |||
| 7a35f9f9fc | |||
| 6026b9157d | |||
| da337c3f39 | |||
| ef103c84bb | |||
| d65c2e5d44 | |||
| 03b992e43b | |||
| e8bc65a85e | |||
| c7aac02925 | |||
| 832a19829b | |||
| d0ddf08dc0 | |||
| ed016dd8fc | |||
| afe1dde0c8 | |||
| 1fdb431dfe | |||
| 5a407be1d4 | |||
| 8793ba310d | |||
| 74d458916b | |||
| 370f95edf0 | |||
| 79dc70d99c | |||
| 4b23a6fa05 | |||
| 7a3b3ac4d2 | |||
| 85ed2ec89b | |||
| 2bcfd98eab | |||
| 6cef890fbc | |||
| afd76d0c5d | |||
| 0fc55f1d0a | |||
| 83f27b6cca | |||
| 530e43776b | |||
| 8e4c96c519 | |||
| 7e8638914f | |||
| 36d31f8081 | |||
| d8669d5bef | |||
| ee3433a44b | |||
| 7d64b40db1 | |||
| 08d19eaeb9 | |||
| e3559db951 | |||
| 4c37aadb32 | |||
| e4e6173568 | |||
| 58605be7f2 | |||
| 9684aab5a2 | |||
| 4acc7c0106 | |||
| 279f7582a4 | |||
| f8758dc3d3 | |||
| 0f567efc8f | |||
| 727c220c7a | |||
| 33fec82b0a | |||
| ba55a0f6c9 | |||
| ea6deb7e09 | |||
| 433bba6b2f | |||
| 0534f2dd9b | |||
| 1e27536646 | |||
| cd118a23e7 | |||
| 4e66dc96b3 | |||
| 81ff8adcc5 | |||
| 527b36b905 | |||
| ab2d7d4f3d | |||
| 426e9c79ac | |||
| 2254ea48a9 | |||
| 1be71b3131 | |||
| 7064882041 | |||
| 56f24fadd4 | |||
| 91b9fb3749 | |||
| a8416f35c5 | |||
| 95899cab2f | |||
| 0d435a3d7c | |||
| abb767192f | |||
| f0a60c5f2f | |||
| ee262fa7f5 | |||
| c951ff9d39 | |||
| 17f8a9f75f | |||
| 1b883b8c20 | |||
| fc4f36be11 | |||
| 5689cb3a27 | |||
| 6050809347 | |||
| f08bce9a54 | |||
| 67051eb403 | |||
| 6dc4e89073 | |||
| 5f6877ddee | |||
| 381f53e27e | |||
| 466fb01621 | |||
| a8f5f4b6e2 | |||
| af5e39e1b6 | |||
| 661d4816df | |||
| 184309fa55 | |||
| 26af11ece6 | |||
| 4bc9eec96f | |||
| 1eb3364a9e | |||
| fef821d726 | |||
| 334827b61e | |||
| 69127087c9 | |||
| b43863f6a9 | |||
| 86cef7fbca | |||
| b1cd2f8248 | |||
| 80e86364f4 | |||
| 59c487a7f3 | |||
| 18c49b1420 | |||
| d161d6bbe9 | |||
| 981ca84aef | |||
| e8efd1fbe2 | |||
| 796819b631 | |||
| a62d50ffb8 | |||
| 4b350436cd | |||
| 7452709d69 | |||
| 07173cac05 | |||
| ab97bc0a1e | |||
| 79b958a4a7 | |||
| c93707771f | |||
| 790b3da848 | |||
| da51402724 | |||
| 4973a0cb41 | |||
| e3d9d02381 | |||
| 3822616ba6 | |||
| db7d0186ee | |||
| d0720e784e | |||
| c68f17dfc5 | |||
| 202d7e6ad3 | |||
| 5821a7c5f1 | |||
| b4aba7cac2 | |||
| a6bc89e4d2 | |||
| f6868f9c9d | |||
| 1fc4e2b414 | |||
| 2f64dd6dc8 | |||
| 9372820a6e | |||
| f2237bd7dc | |||
| b014bb8b4c | |||
| b9f0a2b869 | |||
| 8fbb62c9bc | |||
| e859dfdfb8 | |||
| 0efd7e9d2e | |||
| 14e8af6687 | |||
| 0bfeff4c5e | |||
| a60b7797cd | |||
| 72e810ca24 | |||
| c7b085daa0 | |||
| 5fa41023da | |||
| 376ba9f726 | |||
| 12cc56072a | |||
| 9ec19c21d2 | |||
| 07b248886d | |||
| d835ad6935 | |||
| 2e91dfc66c | |||
| c7f4deecbd | |||
| 0047905f91 | |||
| 452ff25284 | |||
| 1a9dc90313 | |||
| 3155dcf541 | |||
| 06737a22ea | |||
| c5dd64f1e9 | |||
| abafd9a81b | |||
| c41a6dfcd3 | |||
| 869a5896d0 | |||
| f568a40ac7 | |||
| 06a42cff90 | |||
| cda91161df | |||
| aa39783515 | |||
| f26c65003d | |||
| 2b4dbc30ee | |||
| cdc4b4647d | |||
| c6a86e6686 | |||
| 6796b5630c | |||
| bfa8f562f7 | |||
| 390cb87e76 | |||
| 22ecd9658c | |||
| ad7577e144 | |||
| 498cc62c33 | |||
| ce09c74ab1 | |||
| 9aa1fe0f77 | |||
| 51c14ac9d3 | |||
| 053617fcb6 | |||
| 74f48cfa05 | |||
| 1d2247bed6 | |||
| 5039961852 | |||
| be09a8982b | |||
| ea3f5b5d95 | |||
| a6e4a83d99 | |||
| ae14fe3bb6 | |||
| 1a60cd4e5c | |||
| 9e532d0ca3 | |||
| 00410c03d7 | |||
| b6a2a20236 | |||
| 2980ec2eea | |||
| b19a900a9b | |||
| 5878abf8c6 | |||
| b4b50810d4 | |||
| eea2c47d6f | |||
| 164cc5f0e9 | |||
| 504dc60048 | |||
| 052f235f24 | |||
| ecd106d68d | |||
| 1498e85483 | |||
| ebb5c53b51 | |||
| 93334057de | |||
| 685ed22b13 | |||
| 86ebf30fcf | |||
| 2c6fe0c698 | |||
| da6fc6fe17 | |||
| 8460efc65b | |||
| 7d6f0b8224 | |||
| 9d146cf08a | |||
| ac23d64400 | |||
| 1c4b87211d | |||
| 461bac938a | |||
| be58294484 | |||
| a01c00333c | |||
| 05342e935c | |||
| 093aeffbea | |||
| 822f3e1178 | |||
| d6a0927ba1 | |||
| a3d12f993a | |||
| 0460f175d2 | |||
| 5d2b57a822 | |||
| 95ddab5f31 | |||
| 057def4fa5 | |||
| d2a0dce409 | |||
| 574abfafc6 | |||
| 65f2bb0984 | |||
| b7ee8b96a9 | |||
| 49ca7310a3 | |||
| 29c8710bf5 | |||
| 397b5c063e | |||
| 9a17f7d3cc | |||
| 929088ec57 | |||
| 336f2df35d | |||
| 214dd19aa2 | |||
| 683fbbb8d7 | |||
| 682f6d57cd | |||
| dacf5b62e8 | |||
| aa713f26bd | |||
| 9da794f8aa | |||
| b7c61a8b99 | |||
| 0c3fe2f5f0 | |||
| bde942541e | |||
| 1fed67296c | |||
| 60c61daebe | |||
| f30c9280d4 | |||
| 82c3032d98 | |||
| 0d4706dd22 | |||
| 205a3cd8a0 | |||
| da18133994 | |||
| 01a3633cc7 | |||
| 9bec0c088f | |||
| cd08b5c878 | |||
| 1cdbc04d86 | |||
| c8cada1552 | |||
| ff77405577 | |||
| 8b8bd17aac | |||
| 9655e2e335 | |||
| 4e60c378cf | |||
| ff1fb4619b | |||
| 4523e6af16 | |||
| 4f6f2013bf | |||
| 9ed79d1801 | |||
| 066c7987b2 | |||
| bb925bb8ba | |||
| 1f3be76708 | |||
| 5e0e88e5a3 | |||
| 9260f1bdd2 | |||
| 9dae491a94 | |||
| 8e3c3ac499 | |||
| 4cf35a316e | |||
| a04662aad4 | |||
| c60752f45c | |||
| a62e342c3d | |||
| ad739cd700 | |||
| 5886e039ec | |||
| bc6bf8d1e6 | |||
| 0d62d8196e | |||
| 7544d10492 | |||
| 50a4b42ed7 | |||
| 7831560995 | |||
| 58940c96c4 | |||
| 1a449aa5e7 | |||
| 855b35604d | |||
| 20ea7f2f79 | |||
| 2d2b3c39b3 | |||
| 9f837ac934 | |||
| 89478f00cd | |||
| e66647085e | |||
| d76bba6e24 | |||
| d8bbfdfbe0 | |||
| 405d2962d2 | |||
| 4474895d37 | |||
| d9debeb038 | |||
| 18cf2255f0 | |||
| ccf721640c | |||
| a2de489c3e | |||
| 994d7ebdc3 | |||
| bc583cacfd | |||
| a7228f586b | |||
| 9f124aa5ad | |||
| f620ae6c11 | |||
| 5cae1b013f | |||
| 76edea3d61 | |||
| 558f2de1b9 | |||
| 174405bd5d | |||
| 1bdb3dcd2b | |||
| 643786623e | |||
| ae5e95af2d | |||
| 35dc874292 | |||
| c291dd69ea | |||
| 4fae47dedc | |||
| 688c3bffbd | |||
| 6026121e10 | |||
| 762789f5d7 | |||
| f25af6571f | |||
| e4f1467a75 | |||
| ddc6c118c6 | |||
| 12de66b2bf | |||
| 514132f8a8 | |||
| c181c6137d | |||
| 3bf3451872 | |||
| 2c66b71ab4 | |||
| 95455fc76a | |||
| 658c7b8a7a | |||
| ee2316f022 | |||
| dd0f944141 | |||
| 537d8f8a58 | |||
| 2a2d53bd97 | |||
| 114c924d94 | |||
| 622425d2fb | |||
| 2215cc347a | |||
| ed79029f0e | |||
| 286232d695 | |||
| 97d98e9920 | |||
| 3b0c725de1 | |||
| 4dcd073864 | |||
| 800c5757c3 | |||
| 4cc817aa33 | |||
| 41ffd24e82 | |||
| 1f304be72c | |||
| 304343830b | |||
| d3dc9a334c | |||
| bb6cacb913 | |||
| 4eff6ed9fe | |||
| 954ba4bce4 | |||
| b7aac8b6d1 | |||
| be9cd2ff26 | |||
| b719bf20b4 | |||
| d79c15550f | |||
| 92cfad95c8 | |||
| f4f853f8cd | |||
| 51cefce972 | |||
| f0be68a15e | |||
| c8d8b400f9 | |||
| 6ef0160a64 | |||
| 919251f295 | |||
| 712bcc3e09 | |||
| ed928e942c | |||
| a16ec93666 | |||
| 28c8189c7f | |||
| c004ced96b | |||
| ef84ab84bf | |||
| b5906ea400 | |||
| 76e6fbd776 | |||
| 7e51747ede | |||
| 22785530b9 | |||
| d8732ee8b7 | |||
| c11ea21997 | |||
| 1619a06942 | |||
| bc6835b1d1 | |||
| 122d59390f | |||
| cb4beb2d2c | |||
| c3f4867a41 | |||
| ca6904b6c9 | |||
| 955172a5a0 | |||
| d1e2ee9eec | |||
| 5832a8f737 | |||
| 1edad3fd90 | |||
| 01d2c82e1b | |||
| 4b450df00d | |||
| e09fc9f3c1 | |||
| ea0b123d07 | |||
| 301d9518ed | |||
| 3c108a95df | |||
| 8ae15861de | |||
| ec99b59381 | |||
| 1596dca3d0 | |||
| ba8a53a4f9 | |||
| 86e56e40bd | |||
| 3db9731fb6 | |||
| 3d6b490b81 | |||
| 2122af37b6 | |||
| c45ca47759 | |||
| d121290607 | |||
| bdd014e2c2 | |||
| 7bcdac4882 | |||
| c982630a94 | |||
| dc56547079 | |||
| fe4bb9a3f6 | |||
| 96cf04159c | |||
| 1de08a0e60 | |||
| 4207e4771a | |||
| 81c7328717 | |||
| da660f362b | |||
| 4417a705cf | |||
| cc6641f040 | |||
| 6e4059838c | |||
| 211c473452 | |||
| 9505fcffe4 | |||
| 7759839612 | |||
| 9cf6081027 | |||
| 6d4fe99033 | |||
| bf296d3cf3 | |||
| 98159ddec2 | |||
| 2c8e21ac35 | |||
| 073a972375 | |||
| 40818b7d48 | |||
| b64526c715 | |||
| 8be321e3d9 | |||
| 134a6ddcf0 | |||
| 478cac84e1 | |||
| c07c4324c7 | |||
| bebd6a6cef | |||
| 272105604a | |||
| 8401eb9425 | |||
| 2e6cc99352 | |||
| 23f186b5c8 | |||
| af06f5def5 | |||
| 46c30b7e1b | |||
| c8802b6e6c | |||
| 392aa3ff35 | |||
| 5008f4fffd | |||
| 7b8783b751 | |||
| 8fb30e9d1f | |||
| dfdea57b26 | |||
| c4eab12234 | |||
| 57efe7bdba | |||
| 11270c4b2d | |||
| f7c0e172c6 | |||
| 79cb5006f9 | |||
| bea68c50d6 | |||
| 288ab0b16c | |||
| 4978c2ae05 | |||
| f5dd4b478c | |||
| bcdda24942 | |||
| 8c12e634ea | |||
| 433222d6c0 | |||
| d39e66a6cd | |||
| bce7ef0bd5 | |||
| 6e74e428af | |||
| 0ad16081a2 | |||
| 8fd47854a6 | |||
| e7d8c56098 | |||
| ffb486a996 | |||
| 2a31efea1b | |||
| c1dfb624bf | |||
| 1ebac4eab3 | |||
| c5250462f6 | |||
| 351f4729e2 | |||
| b26a15ff67 | |||
| f41aaa2551 | |||
| dc44a83f83 | |||
| a3ad98f25d | |||
| 9ab6e7d851 | |||
| 24e89189a7 | |||
| 48919dba12 | |||
| 3f7511f022 | |||
| e4737333eb | |||
| e9ec512875 | |||
| 60a6533433 | |||
| 4fe8c2c799 | |||
| 5dbb8b3909 | |||
| e7b6fc35bf | |||
| 1db4d513a7 | |||
| 4964633e3a | |||
| 5dc899f004 | |||
| 8348ec06ea | |||
| d80b2c736e | |||
| 69d963254e | |||
| 24c954c181 | |||
| 1cf70434e2 | |||
| 0454409240 | |||
| 13cea3d030 | |||
| 20043f4392 | |||
| 6c227b64e2 | |||
| d4eb62d66b | |||
| 031e2352da | |||
| 29c2cafaee | |||
| 6c413970b7 | |||
| 60fcc78c1f | |||
| 91f07e7e8b | |||
| 520f292699 | |||
| 82f43805fe | |||
| cbb612d2bf | |||
| 64a21db766 | |||
| 84031db72b | |||
| 4dd5ce20ff | |||
| 960a321544 | |||
| 13c6a81607 | |||
| f078a515c7 | |||
| 58d9daa435 | |||
| 416b9b3803 | |||
| b0237a093f | |||
| b9cdd1150e | |||
| 118242be26 | |||
| 7165b1586f | |||
| 09b91f0fff | |||
| d000c1a380 | |||
| e4ddfbe0f8 | |||
| 25f9cba3d2 | |||
| b9e16a5137 | |||
| 4802b1ed8e | |||
| 0dc499ec7f | |||
| 4c8664099e | |||
| d86662e14e | |||
| fc97a877fd | |||
| d60d1d0db8 | |||
| 4746dc557a | |||
| b4a8c66cca | |||
| b0997b27fc | |||
| d4ef1bbbcf | |||
| 771b35c6fe | |||
| 613b32bbb8 | |||
| 813db77aa2 | |||
| e4c30d9639 | |||
| 954e384783 | |||
| d1bb51aaad | |||
| 4db0ad5756 | |||
| 29b18e6c68 | |||
| 93cf55eb72 | |||
| 8069eac74b | |||
| 74d4a8e314 | |||
| 8228d7a653 | |||
| 9e5d7687e3 | |||
| db13f65136 | |||
| 734581a35e | |||
| 20431aacf8 | |||
| 27bab164f2 | |||
| 48dedbe914 | |||
| 752fb7113d | |||
| a33fc4907e | |||
| c0f5255cb9 | |||
| aefa1b0e3e | |||
| ae61eea349 | |||
| b78cd7b0c9 | |||
| 8574fb6f41 | |||
| 7bf288a640 | |||
| 24a3f392ba | |||
| 7500249a74 | |||
| 847f1dd489 | |||
| fce7fd554c | |||
| d04e51bd18 | |||
| 6134a1f844 | |||
| 5ffd03ea74 | |||
| 4fffc06f65 | |||
| 48f747b8da | |||
| c8b05c3e83 | |||
| 1deb9c4d18 | |||
| b3ae0c52bf | |||
| a67482cb0e | |||
| cd9dab04b9 | |||
| 829b842997 | |||
| 02338685a8 | |||
| 7c742620d2 | |||
| 7934b786a9 | |||
| 43b13e92b8 | |||
| bf2bee168a | |||
| 5c9ce5a281 | |||
| 89ad278957 | |||
| a3106cf3eb | |||
| 58c28d44e0 | |||
| 1fdba7b992 | |||
| f8e60e04b9 | |||
| 713b818c40 | |||
| 038fd6e78f | |||
| 4453f3255f | |||
| be06282e1b | |||
| e60224a32a | |||
| 0733e9883a | |||
| ec01b3201d | |||
| 5efc195a32 | |||
| f0697b7088 | |||
| 8a06e21c2a | |||
| 17bca7a2b9 | |||
| c22a0ad980 | |||
| 617947c0b7 | |||
| fad64c0d6b | |||
| 8fedda2fc4 | |||
| b27636c4db | |||
| 0db0bcd60b | |||
| 133defa353 | |||
| de78a8b251 | |||
| 6b3ca4dd2c | |||
| 512f5d9086 | |||
| dfd948b0f0 | |||
| 6336c04705 | |||
| 0377e4fbc9 | |||
| 18d5870e8b | |||
| d55eadbc92 | |||
| a1972f5717 | |||
| 0571a6856d | |||
| 3c61d125c4 | |||
| 8fec03bc81 | |||
| ef5ec161ee | |||
| 167c498cc8 | |||
| 235aa1b1d1 | |||
| 4205983fad | |||
| 0408edbb13 | |||
| fb69297c66 | |||
| 3557f63112 | |||
| bb597bbc1a | |||
| 73e7cca3c2 | |||
| 949a68d987 | |||
| 7a73b806c3 | |||
| eb30de6812 | |||
| 313b6da1b2 | |||
| bcd8c30b45 | |||
| e038687c55 | |||
| fd6e84c5be | |||
| fbe50c0945 | |||
| 98f8613822 | |||
| a87523d86e | |||
| f34634eaf3 | |||
| 573534c441 | |||
| 82a69ceaa0 | |||
| d6d685fd71 | |||
| ec2d67fd80 | |||
| e09afa5184 | |||
| a32772051f | |||
| aa6d532b45 | |||
| 5c635f6c62 | |||
| b97e174acf | |||
| 84d356f73c | |||
| eb2080240a | |||
| d5420db934 | |||
| d39925c792 | |||
| 7f92387c85 | |||
| 6642c7d756 | |||
| da4bd770f2 | |||
| 9d02febe9b | |||
| feeb14b941 | |||
| 8d7f911c96 | |||
| 17a5b5a094 | |||
| 93c5c3b02c | |||
| 3f999f8120 | |||
| 5f5ff2b680 | |||
| 1d79b726d7 | |||
| fd469033fa | |||
| 54a3ce69e9 | |||
| cd8f8a8cb5 | |||
| ec00601863 | |||
| c2fd66ab6e | |||
| 3cba96e344 | |||
| e5bc3e3dde | |||
| 781383a946 | |||
| ce4af8c4fe | |||
| a6b0fc1c93 | |||
| eff38644cf | |||
| cf0d08f661 | |||
| 4b280ca679 | |||
| b5e41dac94 | |||
| 0572012ef3 | |||
| 1a77c6c263 | |||
| 54061d7cbf | |||
| 217eeccb26 | |||
| b6f8473cdb | |||
| 5fde58a593 | |||
| b15eea6009 | |||
| 1df3b0ae24 | |||
| 20c171f284 | |||
| 5899b85fd6 | |||
| 06340a114f | |||
| 7b178abfbb | |||
| 501afed36a | |||
| ac9d18dfa4 | |||
| 242ef4590f | |||
| 31dda933e6 | |||
| 9479d76a14 | |||
| 8d0835e64b | |||
| fc7f2b1a2f | |||
| b73f62ef9b | |||
| 0ddf951c15 | |||
| f23877abfb | |||
| a20eeda845 | |||
| 0426c0dfac | |||
| 56463941a8 | |||
| fb1cb65868 | |||
| 2fc7799975 | |||
| ef2a243345 | |||
| d927075f0c | |||
| 0f491109ca | |||
| 319fc5cb74 | |||
| d8da3c0f5b | |||
| 2ec2d00dc8 | |||
| c1288cd726 | |||
| 43ded6701d | |||
| bffe667ae0 | |||
| 02d61e0481 | |||
| ccd8763ce2 | |||
| 4d69adc760 | |||
| a67e827913 | |||
| 0f60e9fe53 | |||
| f1c2a058ad | |||
| 442406d3ec | |||
| eb244d3b87 | |||
| 0dc15de222 | |||
| 7b6ed67e0a | |||
| 35b10e19af | |||
| d8d636dfe4 | |||
| be9d851c07 | |||
| eecd7b4412 | |||
| 609d262c17 | |||
| 5a682ca6f9 | |||
| 858131c09c | |||
| 75156589fd | |||
| 41b2eb8400 | |||
| da7b1ecb12 | |||
| 34877d21af | |||
| fb0698f344 | |||
| dd9b396af4 | |||
| a1ffe7e235 | |||
| e2bceb5018 | |||
| 6476ff5a7c | |||
| 00f0d5c97f | |||
| e4f7ad5d55 | |||
| 9ffffa5ec7 | |||
| 7de740be35 | |||
| 7e1c6bf8b4 | |||
| 38fdbcf001 | |||
| b3c1e4b131 | |||
| c0f02f7c89 | |||
| a7fce60867 | |||
| 70351389f7 | |||
| 7017ce1a30 | |||
| 923f470056 | |||
| 3fb4ce7d58 | |||
| 49b18efa4e | |||
| 6f9d4498d2 | |||
| d9ea44e5a3 | |||
| 8927b51d23 | |||
| 58498bde56 | |||
| f530a1f868 | |||
| 0f987021a3 | |||
| 3e7b95b431 | |||
| 77474a85a1 | |||
| 2d57c26b8b | |||
| 6b32bf8520 | |||
| 5831c40c5c | |||
| 9a3d0206da | |||
| 0b8cda3b9e | |||
| 261aae298b | |||
| 3aba4326d4 | |||
| 442e59e785 | |||
| f368e4a731 | |||
| c6be1389b7 | |||
| ff1e26aba4 | |||
| 9c65b19cb5 | |||
| 61c9217b2a | |||
| 7dc22c4ef1 | |||
| ce024436be | |||
| fdeb0d80ed | |||
| 414095a014 | |||
| ee02d17466 | |||
| ca61ed1bbe | |||
| 709c441e89 | |||
| 7b443f87dd | |||
| 2a4eeac067 | |||
| 5559857f9e | |||
| c8fbd8b0c3 | |||
| 37eadb417b | |||
| 9723842bc0 | |||
| 2c2544877d | |||
| d902ffe847 | |||
| d4aca421df | |||
| 79ed1fe6c6 | |||
| 22687af45a | |||
| d75a987e36 | |||
| e1267ba041 | |||
| 3fd370acde | |||
| 499c16040d | |||
| fb1b6c4fbc | |||
| b920c4096c | |||
| 6f69ef749e | |||
| d9a277684f | |||
| 0c60dae522 | |||
| 98ccd4fa20 | |||
| 501dd08c6b | |||
| 3054e59f40 | |||
| 8154dd8350 | |||
| d7b2888810 | |||
| aec4f1e956 | |||
| 6318a38885 | |||
| 1a038ed7d9 | |||
| 312ad653e9 | |||
| 73433c0995 | |||
| 2e0b7de1b1 | |||
| 7fcffb98bb | |||
| 3b44cab37b | |||
| d298661993 | |||
| 76bb36da6f | |||
| 0d80c1cc7a | |||
| 8803e9c7e1 | |||
| c32c6c1c24 | |||
| f8e976e56a | |||
| ccbe8ca79e | |||
| ea4841fbef | |||
| bb244cb482 | |||
| ea99087d08 | |||
| efc0be399e | |||
| 464ab7894b | |||
| 461ccadab0 | |||
| 20d52c6b9c | |||
| d203a50c02 | |||
| 1e803a3e45 | |||
| dd79ab10b3 | |||
| ef9c4b6ef5 | |||
| 7af74e7f19 | |||
| 1f02e1548f | |||
| 5ac9166740 | |||
| 25105b650a | |||
| 6bf520165b | |||
| 6e0b5a725d | |||
| ce520e0470 | |||
| 7a5f3762d0 | |||
| a68e6026ca | |||
| 6c5a661606 | |||
| 42cff3b54a | |||
| aa17028b35 | |||
| 870f78b0fd | |||
| d4a997b7d7 | |||
| 7ec3994f78 | |||
| 5c58c88545 | |||
| 4d06b6a841 | |||
| 50a9a7d498 | |||
| d20826dc4c | |||
| 3220058b14 | |||
| 931eff3b84 | |||
| 112c8e8812 | |||
| 871a4102dc | |||
| caf6774576 | |||
| 1b68e51133 | |||
| 0d9a2ce8e0 | |||
| 3133c8e4ac | |||
| 1fbe4f46ba | |||
| 4e7aef7651 | |||
| 5bad124045 | |||
| eda9f7bd43 | |||
| 3a44f70e62 | |||
| a1ec118378 | |||
| 166102e9b3 | |||
| 1802cb2536 | |||
| 58404f0ab4 | |||
| 720b0f5eb0 | |||
| 892c4e1bc6 | |||
| 883050603c | |||
| 6b9fc96f8e | |||
| dec2c2086f | |||
| 927416c2f3 | |||
| 69778612db | |||
| dea31c3040 | |||
| 989a8abc44 | |||
| cfbdf4d2a0 | |||
| a95fb6895d | |||
| 239fb7ac41 | |||
| 0816f853fa | |||
| f6a2e02702 | |||
| d11c78a127 | |||
| a387569134 | |||
| de6e4874ef | |||
| eecfff557d | |||
| 8874028e9e | |||
| cfd41befd5 | |||
| 5c0877079c | |||
| b795853f5b | |||
| 0ab296bd10 | |||
| 99a66861b7 | |||
| 0852e56af6 | |||
| 3a509e1a6a | |||
| 4ea004cf9e | |||
| 11799954dc | |||
| ddc9ca757d | |||
| 18c3001eb4 | |||
| 9e8c6c7bff | |||
| 5364ee6b09 | |||
| 7ecf4f1360 | |||
| 1e659c865a | |||
| 704e2ecaaa | |||
| bd11908373 | |||
| 76593ae5e6 | |||
| 3519df7631 | |||
| 079a76bb37 | |||
| 362add0f4f | |||
| 3a5cb521c9 | |||
| b7f0af199d | |||
| 20a98af525 | |||
| 5ac884c9a3 | |||
| 5c2a800bfa | |||
| 70a9bf863b | |||
| 819ad10fa3 | |||
| 9c14f808ed | |||
| b2c04be9c5 | |||
| ecfa79b801 | |||
| 0c61dbecf7 | |||
| f034c23b0a | |||
| 536780c5de | |||
| f246415143 | |||
| e8803d5293 | |||
| 56054396c4 | |||
| 1936dbe341 | |||
| fe33d24cab | |||
| 994bc95e2a | |||
| bbf86cd4f3 | |||
| 843093789d | |||
| 821c60617e | |||
| 673ff9d82e | |||
| 59c5f4cd35 | |||
| 0fe975bbf2 | |||
| 25ce2cfbeb | |||
| 85c361d3ea | |||
| 48bf094142 | |||
| cacbbb46ce | |||
| 11ba99ea72 | |||
| 914624d51d | |||
| ba97fbe855 | |||
| fe33e80077 | |||
| 06b3c7e961 | |||
| a9cb8b73c8 | |||
| d0732e589f | |||
| 0e91ef2d66 | |||
| 6299d9a1a7 | |||
| a5a3618c66 | |||
| db5cbad673 | |||
| 33c1b04c2a | |||
| b055a241b8 | |||
| eb6f546b1b | |||
| 9fcdee8692 | |||
| 864a5cfd2f | |||
| d2db86448e | |||
| 417d004cad | |||
| 3adedb6f00 | |||
| 65f302ac4d | |||
| 9992ee729e | |||
| d9e93de2eb | |||
| 7a257bb0f7 | |||
| 37b6904b8c | |||
| 519c20adb8 | |||
| b9ef2c9607 | |||
| 4b5c4e2637 | |||
| 6d1e592c2a | |||
| 526bcd44cd | |||
| 6ef445a515 | |||
| 50701d1e89 | |||
| 3bb4d9b400 | |||
| 9df92fcacb | |||
| 3ab41b9779 | |||
| 6c402aa73d | |||
| 6e2f8aa9f1 | |||
| 81c8a28c72 | |||
| fb3ff98014 | |||
| bf07f4e212 | |||
| 7588627b8b | |||
| 9427beaf77 | |||
| 6407ca6927 | |||
| 8bcca79594 | |||
| e285f93242 | |||
| d4aac84fbe | |||
| 7765766512 | |||
| 87342f4cfb | |||
| e4095955ed | |||
| 5efd762f7a | |||
| 581e9db8e0 | |||
| 745a0dc660 | |||
| dc122b32b3 | |||
| 82f27d5bbd | |||
| bc353318b2 | |||
| 4b6963eb6d | |||
| 60d7878a3a | |||
| f0f28e3c3b | |||
| 8cdc6bfc4f | |||
| 15d001fc28 | |||
| 59faf92e1f | |||
| 332e3c0153 | |||
| 708c1b7fc8 | |||
| 38b7d50139 | |||
| f6a52da112 | |||
| d4ce77f624 | |||
| 834a0c1a55 | |||
| f402d3225f | |||
| 0cb081f51f | |||
| 00e2eb15a6 | |||
| 147400d846 | |||
| 54aabc8200 | |||
| 92ce0a63cb | |||
| 6bc755274a | |||
| 573571d727 | |||
| 1e9f48c9bc | |||
| 0713cc584d | |||
| ee40219d6a | |||
| 2ff2d96916 | |||
| d1fa204c0f | |||
| 7b62eec877 | |||
| 29f8c0937a | |||
| 01d6191b81 | |||
| ddd11cbf0b | |||
| cd824e74d8 | |||
| abf0c9fc9e | |||
| 54c0c9e58e | |||
| 7c78db604b | |||
| ffbc0d6f2f | |||
| 16442e5cfd | |||
| 3d8c5cb044 | |||
| fe9f42de4d | |||
| a812924762 | |||
| ea8393591f | |||
| 5c18a83649 | |||
| ecbf8aee6e | |||
| 8513176415 | |||
| b7295e8e5d | |||
| 6b2510f4c7 | |||
| 4969eb20ac | |||
| db23afadac | |||
| e8c660394d | |||
| a1ba9e89d9 | |||
| fc427a8cbc | |||
| eeb0efd7d8 | |||
| ddaf467f31 | |||
| b3a5ae03d0 | |||
| d4677b4059 | |||
| 0e79c3ee74 | |||
| f1820fdd6a | |||
| 2b2d3244cd | |||
| 86070a3ed9 | |||
| 7a28bba4d3 | |||
| a8a71bbad3 | |||
| aebfad51a0 | |||
| 484dcc9b90 | |||
| 967bfb4334 | |||
| 46640b7e53 | |||
| a22f7cb864 | |||
| 13bb9cee30 | |||
| 2f286d7658 | |||
| 7b8110d4b0 | |||
| 6a34b93223 | |||
| c9b9abc090 | |||
| bc8e5bce36 | |||
| 4ee9853a78 | |||
| ff28c81cb6 | |||
| b3af55b363 | |||
| 494c554bf3 | |||
| 58c8b68c3c | |||
| 5d61ac8012 | |||
| 89bcfc4aac | |||
| 95d3b8e1f2 | |||
| d55276ee51 | |||
| c16e466de2 | |||
| 0e4511877e | |||
| 5c8860f735 | |||
| 586fff6894 | |||
| 9dc58f9b26 | |||
| 0d9c836ab2 | |||
| db0175400b | |||
| 5dd43226a0 | |||
| 20cb544cdd | |||
| 5ac03639ca | |||
| 67c858414a | |||
| e1be68f296 | |||
| ebfdc35f2a | |||
| d6d470ae15 | |||
| 057f509fad | |||
| f73c7d410b | |||
| f4b9cea5fc | |||
| 4d25fc3208 | |||
| 3658d00c2b | |||
| fdbb450f5f | |||
| 3d6fb349eb | |||
| 3cc745a16c | |||
| ef01018a00 | |||
| bc144ebbe0 | |||
| cc59085352 | |||
| 3000c6bde7 | |||
| add7b5a250 | |||
| 1707b741b6 | |||
| 57b0cfaaf1 | |||
| 2498509cfd | |||
| fa1a43c43e | |||
| 9593527b54 | |||
| 099b7986a5 | |||
| c694545650 | |||
| c23f9efc64 | |||
| a05b00c686 | |||
| 469025580f | |||
| eecdec4d5b | |||
| af27002b54 | |||
| 29f07d932a | |||
| 00d4e02598 | |||
| 032b80ea4b | |||
| 7581032c96 | |||
| b0aca71569 | |||
| 083b0a54aa | |||
| 6c2dec31f5 | |||
| 4856fb65b2 | |||
| bbdbe0a490 | |||
| 26431c6f94 | |||
| 892ee7ee56 | |||
| fb2ac5029c | |||
| 653c7d4a27 | |||
| 6153c8040d | |||
| b158bcce98 | |||
| 6a218739e4 | |||
| 92e5923857 | |||
| a608b0e670 | |||
| 4ea25c227c | |||
| 75822af579 | |||
| 53c66110a8 | |||
| fc58c234ed | |||
| 8b0318d538 | |||
| b62c8a06ad | |||
| 6013e16b25 | |||
| 04c258ee19 | |||
| d2dbe64ba4 | |||
| c2cd6618d2 | |||
| 97f7bfc457 | |||
| a78c180efa | |||
| 850d33e658 | |||
| 58110adcc6 | |||
| ca35d1c6b6 | |||
| fcb404faac | |||
| 5a9b867cec | |||
| f9bbcc5302 | |||
| f810487764 | |||
| 498ee7d44b | |||
| 704d82627c | |||
| 49f853bfcb | |||
| 5defa8f05e | |||
| 4d30065a0a | |||
| 627f31b52c | |||
| c24b75e257 | |||
| 445146552a | |||
| 19075a2120 | |||
| eac27523b5 | |||
| 5fe2acd17b | |||
| 79e21e7d75 | |||
| d5c6c474c2 | |||
| fad56ea4be | |||
| 4c4ea10c3f | |||
| 73646066a4 | |||
| 507507352b | |||
| 37cb15e634 | |||
| e6e074cc70 | |||
| f881b74bd8 | |||
| a5c4a76848 | |||
| 4f1538728a | |||
| 2d931ca93b | |||
| 382b3d7596 | |||
| db0c7b4e7b | |||
| 823b45cb49 | |||
| 1a9d07fb59 | |||
| a5ce98d52f | |||
| 5fe9dcbbed | |||
| 1a44518a64 | |||
| 3424086143 | |||
| 6ff9929833 | |||
| 203338ab02 | |||
| c9c205e450 | |||
| 6b5dc09867 | |||
| 45551ed4df | |||
| a083389c63 | |||
| 0d260e54da | |||
| c49adb8e18 | |||
| 06c108f879 | |||
| aee5f1f4d8 | |||
| 56d22f190e | |||
| 45dc254910 | |||
| 351cd1416f | |||
| 7a3a576617 | |||
| c7746a0f7f | |||
| b1703e2951 | |||
| 349a6fde37 | |||
| 2225d0cfe6 | |||
| 16296b4a84 | |||
| d432ff9e99 | |||
| d863b93f5c | |||
| 49ac497117 | |||
| ee04accfba | |||
| 5ddaf0a8ff | |||
| 097404cd2b | |||
| 950fead105 | |||
| fc84419f34 | |||
| 8e628ee242 | |||
| 2fc00b3a5d | |||
| 53a993e103 | |||
| e9d41cebe5 | |||
| b5476a34bc | |||
| 8fbdd7cd1e | |||
| fc511c8e48 | |||
| e2b55c9c34 | |||
| bf0c578f16 | |||
| e23d098117 | |||
| e3f6d84b15 | |||
| 86c1de421f | |||
| 5fef447ee3 | |||
| ff7a518119 | |||
| 0141a869eb | |||
| ad3e244afd | |||
| 99720e73a6 | |||
| f3e186ab55 | |||
| fd8c97d264 | |||
| 0e3d1236f8 | |||
| 3026cb9910 | |||
| ddc03b10d5 | |||
| ff1d6556a7 | |||
| 9d0c759ed1 | |||
| 4086097935 | |||
| bc11a70203 | |||
| 047f7aa46c | |||
| a2f6f882c4 | |||
| f4fb6d9898 | |||
| 86c2bbd5f2 | |||
| b6f49c741d | |||
| 53a054c8dd | |||
| 2102aee45c | |||
| ec0fef3294 | |||
| b402f6ddc3 | |||
| 5bcea4d315 | |||
| 3884b0624e | |||
| 31c94e5cb3 | |||
| 2ad68b8c95 | |||
| a2b5f389de | |||
| fd6d738db4 | |||
| 4a9c28b513 | |||
| ffcc444fa7 | |||
| acdf4859b5 | |||
| 41d397e68b | |||
| 9b6485865c | |||
| 33b5464e96 | |||
| 59cb24ff0c | |||
| b4d0144d09 | |||
| 03fd922158 | |||
| 229e69a1c0 | |||
| aea372a659 | |||
| 58a43ebebe | |||
| 09de5eb3de | |||
| 73e15efa4b | |||
| 5b98dd1e85 | |||
| 47d8bb6e25 | |||
| a31370452a | |||
| b20c4d58db | |||
| fbf87b8143 | |||
| efdb676e84 | |||
| 553e19b443 | |||
| 6d5f4fd536 | |||
| db41eeb8bd | |||
| 353fac6f48 | |||
| c605d0b9c6 | |||
| dbdcc42eee | |||
| 25da216389 | |||
| 519375f9fe | |||
| ccc32eba06 | |||
| 09931f8158 | |||
| abc3a22f42 | |||
| 6cf9f04cd6 | |||
| 3da2415167 | |||
| 80accd23bb | |||
| d3a2b63143 | |||
| 017382e6d3 | |||
| 0eab91dcce | |||
| 2c9a28bbe6 | |||
| bc2de4ab0e | |||
| cac8708d0b | |||
| af5d66f999 | |||
| 8b2034bc7b | |||
| bac188fa71 | |||
| 526bff4c64 | |||
| dcaeeda60c | |||
| e2d9006792 | |||
| 2de3659810 | |||
| 5baa26c105 | |||
| dc85a9e833 | |||
| 9f887c6c79 | |||
| 8616f9380c | |||
| b9dc4c3cbe | |||
| 1d16b7f80c | |||
| 0e6d8bc952 | |||
| f2d81d1e54 | |||
| 04116863fb | |||
| 176f08e90c | |||
| 8ab37b5fca | |||
| 7da5b49bc4 | |||
| 007cd537d0 | |||
| b59f90efa4 | |||
| 3c754bb442 | |||
| 99aa14d1ff | |||
| e456586166 | |||
| cd1792a902 | |||
| b626992e09 | |||
| e0d4f2b66c | |||
| e57a314de8 | |||
| 3bcf80e9f2 | |||
| d854035ffe | |||
| 27e79a40ce | |||
| 44a29a501a | |||
| 7298cf7db3 | |||
| 50890e037e | |||
| d5822fbfd7 | |||
| 2647ebb63c | |||
| 4ce7de34ca | |||
| 747e16f7b0 | |||
| 52c86533d9 | |||
| 47ae7ebe35 | |||
| e42c4ee260 | |||
| 125d26d23c | |||
| bd11fca3aa | |||
| 65828d8652 | |||
| b7f894a403 | |||
| 9ed92b3bd2 | |||
| 76b177f6c3 | |||
| 2c9f35960f | |||
| bfc80ec4e8 | |||
| 64d4729f3d | |||
| 3677b2ecf3 | |||
| 3fd6f7e088 | |||
| da071ee1d2 | |||
| 2cb6f68179 | |||
| 8b447463ad | |||
| 3e0ddd4cfd | |||
| ec4663f863 | |||
| ecd60630ac | |||
| 8917ec5117 | |||
| a6bd6fcd41 | |||
| 56f84f2b99 | |||
| a07fe914d0 | |||
| bb22d0696e | |||
| 216e2e5b7f | |||
| 9388982eab | |||
| 3a64e6eb02 | |||
| baea79cca4 | |||
| 5c15ab2b4a | |||
| 6d168299ae | |||
| 002178276f | |||
| 3fbba4bf48 | |||
| 722907c7b0 | |||
| 770eed82fd | |||
| 447475e5d7 | |||
| 3f7a6d5331 | |||
| a8e927e26c | |||
| 56364dcec0 | |||
| ba7b0fb3b3 | |||
| 337c3fa74c | |||
| 351aeeeba6 | |||
| d070222f69 | |||
| 05ec4d9d20 | |||
| 8003618cd1 | |||
| 54bc823b80 | |||
| 4786eca8f2 | |||
| 2c24a252c5 | |||
| d987453bd4 | |||
| 498a14ef8b | |||
| 0241200633 | |||
| 1b2ab57a92 | |||
| f89712dc6d | |||
| becce23e4a | |||
| 674e0a210d | |||
| e63aff8479 | |||
| 3cf3ecd90f | |||
| 9f9bc1f0ab | |||
| 92a7501ac6 | |||
| afcc12e80b | |||
| adedab33de | |||
| 3cb0325122 | |||
| 2a97de2671 | |||
| bb5ebb6280 | |||
| 6a1e566152 | |||
| cd6e980e66 | |||
| 47795b2126 | |||
| 21126fc5e8 | |||
| 353db49bfb | |||
| 18d4c3120a | |||
| f1b7893d57 | |||
| e978e6b5f5 | |||
| d2e360710f | |||
| 48a5b81346 | |||
| 584eca0871 | |||
| 15652ea93c | |||
| 481e8f7105 | |||
| a9c75fdc75 | |||
| 151d0c574d | |||
| 611314c096 | |||
| 3e72333f0c | |||
| e7a68ca017 | |||
| 72e5445732 | |||
| 799be0ba8c | |||
| db246a14e0 | |||
| 4d572da1b3 | |||
| e86e05ebf0 | |||
| 452a704ae9 | |||
| 362b124e69 | |||
| 4636cf771c | |||
| a50cdcc0fd | |||
| 86afa1d00f | |||
| 233046ea5e | |||
| 5d7411e92b | |||
| 54b96ced13 | |||
| 70328cc2e7 | |||
| d53ba71a24 | |||
| 4fb6eeb518 | |||
| 401dc3dbb9 | |||
| c257025ccd | |||
| df93b156a7 | |||
| 9c0349b416 | |||
| f0e846b410 | |||
| 87eb1d645f | |||
| fb28b75b74 | |||
| a64df7558c | |||
| ad4d0c5e05 | |||
| 95755113bf | |||
| 153292da44 | |||
| fa85892b0a | |||
| 7e2184125c | |||
| b213281ba1 | |||
| 8ca54dbbf3 | |||
| 7700ec42c1 | |||
| d31a080f91 | |||
| 990c247841 | |||
| 1c7c33b314 | |||
| 13d03939a6 | |||
| 83d4aee03c | |||
| c57ed76265 | |||
| 1bb2d65bb2 | |||
| 3dae8bcedd | |||
| 9f8b8bbd37 | |||
| 82cb942bff | |||
| facd17c1ce | |||
| 76c98ace9a | |||
| f5222c7416 | |||
| 3a6152ceac | |||
| 0e5bf3c4af | |||
| 528b5b7dac | |||
| bd541e24b3 | |||
| d828e8c678 | |||
| b1886826de | |||
| 4e63dc5e5d | |||
| cf3e5c4965 | |||
| 349fc3edfc | |||
| dc5e0d1665 | |||
| be8bc2de54 | |||
| e081622b9b | |||
| ebe2f5a19c | |||
| 876ba8faec | |||
| 9970d909a3 | |||
| a8dc59fc54 | |||
| e6052102ec | |||
| 72389d1133 | |||
| 3895b3459e | |||
| 55cf5dfd8b | |||
| 3396c400eb | |||
| 58d633f0b2 | |||
| a19a913d7d | |||
| 76657ed83c | |||
| 4ef2160966 | |||
| 171c3af461 | |||
| c44fe3050e | |||
| 6ee3f386bd | |||
| cf82c45de9 | |||
| 537e4d1897 | |||
| bf14c15fb5 | |||
| 9afa0e696e | |||
| c5d97a96e4 | |||
| 55fc886ea7 | |||
| 2b18a45e61 | |||
| 2d8e189825 | |||
| 0147636391 | |||
| 7def53379b | |||
| 425894422b | |||
| feb30eda03 | |||
| 065a7d5b4f | |||
| f2130033d4 | |||
| cf75be653b | |||
| e8835af020 | |||
| 6b519ea6cc | |||
| 999a594039 | |||
| 48410be620 | |||
| c21089c81e | |||
| 36d7050ded | |||
| e7052c0349 | |||
| 5132e88b10 | |||
| 2540839f58 | |||
| 7b85d7a014 | |||
| e4863a1668 | |||
| db1f584cc2 | |||
| 3fc3fcd333 | |||
| 9044bc2f8b | |||
| c5a078b25e | |||
| 6aafb32f8b | |||
| d8613ef967 | |||
| 90cbde0cb7 | |||
| 30595c294a | |||
| d08da96c20 | |||
| 7a82b70970 | |||
| 69f83828fc | |||
| e08dbd1076 | |||
| 7288582633 | |||
| 6babcc30ad | |||
| c7e4ebf3f3 | |||
| 70688fd72e | |||
| 38d2c7642d | |||
| 0baee36398 | |||
| 5bd1e381aa | |||
| c1a8fb414e | |||
| 0218dd4ccb | |||
| d8088a359e | |||
| 37784b037e | |||
| 9d49ca31b1 | |||
| a79b88e20c | |||
| d9babbcce1 | |||
| d4c4b845b8 | |||
| 391e361387 | |||
| 03e63438da | |||
| 96d6ab3a12 | |||
| 545b77c8f2 | |||
| 3b8535a386 | |||
| b4d896505b | |||
| c01b82d4e4 | |||
| b3e8f06d20 | |||
| 17c88e6ec9 | |||
| bff4fc86e1 | |||
| f939cf3159 | |||
| 2dcbaaa68c | |||
| f6d09222a2 | |||
| 8cb601ad4d | |||
| ee8044f2e6 | |||
| 93b38fc5a6 | |||
| b03d9255ee | |||
| 00dba5bb11 | |||
| 94c4afe13a | |||
| b90eab06c7 | |||
| 88d7468a3b | |||
| a809b827f1 | |||
| b54015e60d | |||
| 6cf6c3806f | |||
| 7e7c23fcad | |||
| 625098abc5 | |||
| 7977c782e8 | |||
| 842524812a | |||
| 80b6e318fb | |||
| 7c2046b727 | |||
| 3e90b10ad8 | |||
| 8c11e08765 | |||
| ffdca1520b | |||
| 4dcede552e | |||
| 198279d303 | |||
| 283f877719 | |||
| 8a646b55f7 | |||
| 53c07f1644 | |||
| 72cece6ff4 | |||
| 1e503b8925 | |||
| 9b7b6fa33c | |||
| dce48cf576 | |||
| af8a122872 | |||
| e75fe1a7bd | |||
| a78ba9a827 | |||
| 487a6fcc8c | |||
| 840193d514 | |||
| 324e0aa540 | |||
| 69199e4aa2 | |||
| e893d6b032 | |||
| 1c5d23e281 | |||
| 0b55c44e68 | |||
| 43bfcff941 | |||
| a4611b9d02 | |||
| 5be009245b | |||
| 5a2c33b107 | |||
| a50bf852e4 | |||
| 9c3ef35763 | |||
| be8868900d | |||
| 3c3ca35fee | |||
| ada5df1069 | |||
| e014ed78dd | |||
| 562782a48d | |||
| b56324b829 | |||
| 490e604bae | |||
| 47ee76344e | |||
| 844cb63fed | |||
| a668f57e75 | |||
| 543fc34ed9 | |||
| c3775f93ab | |||
| 0a32dca4bb | |||
| 65a550c484 | |||
| 7c08fb89fb | |||
| 38727c6bc6 | |||
| 0f83a143b0 | |||
| 793c431543 | |||
| 7059a421ef | |||
| 2e25f806fb | |||
| f923f7aefe | |||
| cb838a36b2 | |||
| 56f4d0ed80 | |||
| 6c806e8384 | |||
| 5b6e74c85f | |||
| c33a96f676 | |||
| 9910a5d7eb | |||
| 7c8fb69b1c | |||
| 3dcd751a4b | |||
| ef42830b87 | |||
| 05f8741cee | |||
| 9a1ac11640 | |||
| 04ab55dd4f | |||
| b2e3fb3dc9 | |||
| d72a0aa2c8 | |||
| 2be82d5e13 | |||
| 019cc4eae4 | |||
| 2726d2a6a4 | |||
| 9f1396fb23 | |||
| 0c49b6c445 | |||
| 83a23ea878 | |||
| 331bbb7f05 | |||
| f849d1f6fc | |||
| 217d7979b9 | |||
| 2e8da707a0 | |||
| f4537d5676 | |||
| 850aa189e4 | |||
| c5e96ad32f | |||
| 9acc49eb93 | |||
| 662cfbc7e1 | |||
| d389a2f7f4 | |||
| 321554d35f | |||
| 102903f7ab | |||
| da2ea965dc | |||
| 181b7f5fea | |||
| e04f57c95b | |||
| b9639c524d | |||
| 56003ca491 | |||
| 192cb8f894 | |||
| 2d7c42275f | |||
| ac41913cea | |||
| 359c790b1c | |||
| 49a66d4b68 | |||
| 1a5a5f8e9c | |||
| 3735e3d289 | |||
| 2c6b79365b | |||
| 1565171e07 | |||
| 0c1be2af21 | |||
| e5d70123c9 | |||
| 3d6b1bf4e3 | |||
| 0d268d71d2 | |||
| b164a8904a | |||
| 78ac8558e0 | |||
| 118e933e2d | |||
| 363ed37e76 | |||
| 3b800be056 | |||
| ef227f1e0f | |||
| 6606784c3f | |||
| a17b3a200e | |||
| d63a406b02 | |||
| e6a3c6e1a1 | |||
| 356513cc80 | |||
| b1dc798512 | |||
| 697871ddcf | |||
| 602150068a | |||
| eeeac779c8 | |||
| c0333c98ea | |||
| d59467dfc9 | |||
| c731018d50 | |||
| e17644cca3 | |||
| d71b142446 | |||
| b61dd8b299 | |||
| 41bbc35471 | |||
| 0af4bf40ee | |||
| b09c5ac837 | |||
| 3f897939b2 | |||
| 3124654247 | |||
| 9a57563b9f | |||
| 190b5e7cbe | |||
| a8f8537965 | |||
| f938b1a89b | |||
| 2a39a4e01c | |||
| ab7d4ea7ba | |||
| ac4404e0cc | |||
| 0fe16db123 | |||
| 5c0dd1fadd | |||
| a7eec81ec6 | |||
| e03782efdd | |||
| eb2d6a23ab | |||
| a48b376978 | |||
| 544f0f9b11 | |||
| 322af447f5 | |||
| ec39bd51dd | |||
| bbb750e1ba | |||
| 73dd2ee2d5 | |||
| a1ccc146ac | |||
| 7a6f073415 | |||
| 76fa287781 | |||
| 94c5a8fe82 | |||
| d3fdafc358 | |||
| 606c07ae3e | |||
| c6b458edce | |||
| a8ccdd2880 | |||
| 656581fa2c | |||
| 785a713b82 | |||
| cf04387947 | |||
| eddec24752 | |||
| f454c9884f | |||
| 53f7c0c641 | |||
| 2de5b09d84 | |||
| 70c31beef7 | |||
| 901dd625f8 | |||
| 7d3341b000 | |||
| 1f60fe8a23 | |||
| 730271af49 | |||
| 8a35efacd7 | |||
| cfa9c7e1d0 | |||
| acb011dc20 | |||
| a7a1adf4e0 | |||
| e60bae3575 | |||
| ddb5fb5980 | |||
| b70a545c88 | |||
| c383f33bbf | |||
| 13683200d6 | |||
| 7be97bd89d | |||
| cd281ce1b4 | |||
| adc1d7b2a5 | |||
| b4454b133f | |||
| 520a601f14 | |||
| 0409483d5f | |||
| 2d07933c17 | |||
| 6eabdb6d8c | |||
| 291455cecd | |||
| b76204d589 | |||
| e8e9393e76 | |||
| 231f758404 | |||
| e92d664dd2 | |||
| 973fe984cd | |||
| 4548df3155 | |||
| c874cee03a | |||
| caeb7f90b0 | |||
| da264959f2 | |||
| 41e1109c5f | |||
| 209b2f7b3e | |||
| 503325ddcb | |||
| 41575c5571 | |||
| 73f60c1886 | |||
| dc7c91ae67 | |||
| 15dbd27efa | |||
| 9a05bd0f8f | |||
| 524e1ce789 | |||
| 3d4de0bc4e | |||
| 1264dd11a0 | |||
| 599e7fe006 | |||
| b768c6f77a | |||
| 4651e4e464 | |||
| 4c7e6ea021 | |||
| 46b0673732 | |||
| 9c2d41fce2 | |||
| c5148e0ab6 | |||
| 8bd65e7aaa | |||
| 4dbdc18fd8 | |||
| 9789d825c2 | |||
| 8f0019214e | |||
| 45cff73a1b | |||
| aa0cd4a7ef | |||
| 785e3deb4d | |||
| 7a4b7c5e18 | |||
| dc5c56e90c | |||
| 26679bee33 | |||
| 1076d79905 | |||
| 0034f04164 | |||
| 1ff2b56319 | |||
| 4d9b4e9782 | |||
| f51fdc9bb7 | |||
| f1c403dcec | |||
| ab1f9aa3a4 | |||
| 1ce6bdd1dd | |||
| e20e67161c | |||
| c545dcad4f | |||
| 9e9dd64c35 | |||
| c6c7a7be8c | |||
| e958133ca6 | |||
| 9261144beb | |||
| 71cc181bac | |||
| cf617e112f | |||
| 865485fc54 | |||
| a595b4dacb | |||
| 7c431a345f | |||
| 4dbc9b0a64 | |||
| 9242214612 | |||
| 4832c70022 | |||
| 54fdd4c0e9 | |||
| 0324045e4f | |||
| fac9ba991b | |||
| ae5ecea065 | |||
| 6357dd08b6 | |||
| c15b286f88 | |||
| 4afa0b50c7 | |||
| b90b9b83bd | |||
| 79bf1e37ca | |||
| 95ae9d9e5e | |||
| 7027fe4538 | |||
| 50f3d7b5ea | |||
| 22fc0c5e9b | |||
| 6ff1745873 | |||
| 505530eaf5 | |||
| a2630c08ae | |||
| fddbdb79db | |||
| 1c90b9976d | |||
| 35cb0e4a4c | |||
| ada098890b | |||
| 2e8b836243 | |||
| b004c163ee | |||
| 6d0c04c208 | |||
| 29a7d7a1c1 | |||
| eda1d3f37a | |||
| 6466396f38 | |||
| 5b2313c26c | |||
| 473eadfe10 | |||
| 52d4168038 | |||
| c6bd16545e | |||
| 517a2dbe84 | |||
| 88d48cd51f | |||
| a5ff28cc9f | |||
| 1b2cf98bb0 | |||
| 86e28894f4 | |||
| c125bb553d | |||
| 4ac455d9a4 | |||
| 3b7a18f2e5 | |||
| a13a1707bc | |||
| 6812769f8f | |||
| 2f860b4ded | |||
| d84c21dfcc | |||
| 0e3c1231da | |||
| 71e8ee1c33 | |||
| 8938f0848e | |||
| 0e73e16460 | |||
| 9321379b10 | |||
| c91c7fcded | |||
| 0663096dc6 | |||
| 7a9e253405 | |||
| 5e6b64571c | |||
| c446a0fca2 | |||
| 07f89a017c | |||
| b8b1926e2f | |||
| 4d5970ea63 | |||
| 656cea20a6 | |||
| e9f8261131 | |||
| d87a55fc2b | |||
| b0c87306a6 | |||
| 38ab68e6ab | |||
| 0e7cadca03 | |||
| efd08cdc2b | |||
| 7e61737f3d | |||
| 138025470f | |||
| 8b72167d0e | |||
| f92305bfa9 | |||
| 0b4767ca50 | |||
| 1c50e53a05 | |||
| a3301036d6 | |||
| c7a34ab704 | |||
| 1b696de61b | |||
| f4d4c73899 | |||
| da0cf7f883 | |||
| 7c3f70812e | |||
| f5eabd12db | |||
| db1dd3e550 | |||
| f48902e139 | |||
| 7b03292e24 | |||
| 2a6e3435d0 | |||
| 0411eed2cb | |||
| 365ef195b5 | |||
| 8c3547554b | |||
| 324efa55e3 | |||
| 0b7c52dd4c | |||
| cf31390c6f | |||
| 5af62aa90a | |||
| cf839b4396 | |||
| 257a5d1299 | |||
| e6d4708fcf | |||
| f9870842bd | |||
| 2d7173d0c7 | |||
| 4682fc7c38 | |||
| 15a77653e4 | |||
| 9b1f784178 | |||
| 44bfbe1e15 | |||
| 0c767bf6cc | |||
| 81c89dd705 | |||
| b46ee168ef | |||
| e399d32694 | |||
| 606e2c8ebe | |||
| c6e0d385c3 | |||
| 31a3bcc933 | |||
| acade5443f | |||
| 113105bf9c | |||
| dd9f2b1cca | |||
| 90d740364b | |||
| 89bc7e7b6e | |||
| 5c58a540ea | |||
| 325e266e95 |
@@ -1,3 +0,0 @@
|
||||
--errors=errors,duplicate-properties
|
||||
--warnings=known-properties,display-property-grouping,empty-rules,important
|
||||
--exclude-list=vendor/,lib/editor/tinymce/,lib/yuilib/,theme/bootstrapbase/style/
|
||||
@@ -30,8 +30,3 @@ phpunit.xml
|
||||
composer.phar
|
||||
composer.lock
|
||||
/vendor/
|
||||
/behat.yml
|
||||
*/yui/build/*/*-coverage.js
|
||||
/lib/yuilib/*/build/*/*-coverage.js
|
||||
# lib/yuilib/version/module/module-coverage.js
|
||||
/lib/yuilib/*/*/*-coverage.js
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"browser": true,
|
||||
"yui": true,
|
||||
"bitwise": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nomen": false,
|
||||
"onevar": false,
|
||||
"plusplus": false,
|
||||
"regexp": false,
|
||||
"strict": false,
|
||||
"trailing": true,
|
||||
"unused": true,
|
||||
"white": false,
|
||||
"asi": false,
|
||||
"boss": false,
|
||||
"debug": false,
|
||||
"eqnull": false,
|
||||
"es5": false,
|
||||
"esnext": false,
|
||||
"evil": false,
|
||||
"expr": false,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"iterator": false,
|
||||
"lastsemic": false,
|
||||
"laxbreak": true,
|
||||
"laxcomma": false,
|
||||
"loopfunc": false,
|
||||
"multistr": false,
|
||||
"onecase": false,
|
||||
"proto": false,
|
||||
"regexdash": false,
|
||||
"scripturl": false,
|
||||
"shadow": false,
|
||||
"smarttabs": false,
|
||||
"sub": false,
|
||||
"supernew": false,
|
||||
"maxerr": 500,
|
||||
"maxlen": 180,
|
||||
"passfail": false,
|
||||
"latedef": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"coverage": false,
|
||||
"lint": "config",
|
||||
"clean": true
|
||||
}
|
||||
+2
-4
@@ -51,8 +51,7 @@ switch ($action) {
|
||||
if ($auth == $CFG->registerauth) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
session_gc(); // remove stale sessions
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
@@ -62,8 +61,7 @@ switch ($action) {
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
session_gc(); // remove stale sessions
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
|
||||
+11
-23
@@ -64,8 +64,6 @@ echo "<form id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
|
||||
echo "<div>\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"auth\" value=\"".$auth."\" />\n";
|
||||
// HACK to prevent browsers from automatically inserting the user's password into the wrong fields.
|
||||
echo prevent_form_autofill_password();
|
||||
|
||||
// auth plugin description
|
||||
echo $OUTPUT->box_start();
|
||||
@@ -80,9 +78,6 @@ echo '<p style="text-align: center"><input type="submit" value="' . get_string("
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
$PAGE->requires->string_for_js('unmaskpassword', 'core_form');
|
||||
$PAGE->requires->yui_module('moodle-auth-passwordunmask', 'M.auth.passwordunmask');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
@@ -92,8 +87,8 @@ exit;
|
||||
// but some may want a custom one if they are offering
|
||||
// other options
|
||||
// Note: lockconfig_ fields have special handling.
|
||||
function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts, $updateopts, $customfields = array()) {
|
||||
global $DB, $OUTPUT;
|
||||
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
|
||||
global $OUTPUT;
|
||||
echo '<tr><td colspan="3">';
|
||||
if ($retrieveopts) {
|
||||
echo $OUTPUT->heading(get_string('auth_data_mapping', 'auth'));
|
||||
@@ -112,21 +107,14 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
|
||||
$pluginconfig = get_config("auth/$auth");
|
||||
|
||||
// Helptext is on a field with rowspan.
|
||||
// helptext is on a field with rowspan
|
||||
if (empty($helptext)) {
|
||||
$helptext = ' ';
|
||||
$helptext = ' ';
|
||||
}
|
||||
|
||||
// If we have custom fields then merge them with user fields.
|
||||
if (!empty($customfields)) {
|
||||
$user_fields = array_merge($user_fields, $customfields);
|
||||
}
|
||||
|
||||
if (!empty($customfields)) {
|
||||
$customfieldname = $DB->get_records('user_info_field', null, '', 'shortname, name');
|
||||
}
|
||||
foreach ($user_fields as $field) {
|
||||
// Define some vars we'll work with.
|
||||
|
||||
// Define some vars we'll work with
|
||||
if (!isset($pluginconfig->{"field_map_$field"})) {
|
||||
$pluginconfig->{"field_map_$field"} = '';
|
||||
}
|
||||
@@ -140,14 +128,10 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
$pluginconfig->{"field_lock_$field"} = '';
|
||||
}
|
||||
|
||||
// Define the fieldname we display to the user.
|
||||
// define the fieldname we display to the user
|
||||
$fieldname = $field;
|
||||
if ($fieldname === 'lang') {
|
||||
$fieldname = get_string('language');
|
||||
} elseif (!empty($customfields) && in_array($field, $customfields)) {
|
||||
// If custom field then pick name from database.
|
||||
$fieldshortname = str_replace('profile_field_', '', $fieldname);
|
||||
$fieldname = $customfieldname[$fieldshortname]->name;
|
||||
} elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
|
||||
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
|
||||
} elseif ($fieldname == 'url') {
|
||||
@@ -171,6 +155,8 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
echo html_writer::select($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, false);
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
|
||||
@@ -189,3 +175,5 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
// block.php - allows admin to edit all local configuration variables for a block
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
|
||||
if(!$blockrecord = blocks_get_record($blockid)) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('blocksetting'.$blockrecord->name);
|
||||
|
||||
$block = block_instance($blockrecord->name);
|
||||
if($block === false) {
|
||||
print_error('blockcannotinistantiate', 'error');
|
||||
}
|
||||
|
||||
// Define the data we're going to silently include in the instance config form here,
|
||||
// so we can strip them from the submitted data BEFORE handling it.
|
||||
$hiddendata = array(
|
||||
'block' => $blockid,
|
||||
'sesskey' => sesskey()
|
||||
);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
print_error('blockcannotconfig', 'error');
|
||||
}
|
||||
$remove = array_keys($hiddendata);
|
||||
foreach($remove as $item) {
|
||||
unset($config->$item);
|
||||
}
|
||||
$block->config_save($config);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading($strblockname);
|
||||
|
||||
echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
|
||||
'It must be updated by a developer to use a settings.php file.');
|
||||
|
||||
echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
echo '<p>';
|
||||
foreach($hiddendata as $name => $val) {
|
||||
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
|
||||
}
|
||||
echo '</p>';
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
include($CFG->dirroot.'/blocks/'. $block->name() .'/config_global.html');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo '</form>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
+50
-33
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Allows the admin to configure blocks (hide/show, uninstall and configure)
|
||||
// Allows the admin to configure blocks (hide/show, delete and configure)
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -11,13 +11,14 @@
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$unprotect = optional_param('unprotect', 0, PARAM_INT);
|
||||
$protect = optional_param('protect', 0, PARAM_INT);
|
||||
|
||||
/// Print headings
|
||||
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
$strdelete = get_string('delete');
|
||||
$strversion = get_string('version');
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
@@ -36,7 +37,6 @@
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -79,6 +78,35 @@
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', "block_$block->name")) {
|
||||
$strblockname = get_string('pluginname', "block_$block->name");
|
||||
} else {
|
||||
$strblockname = $block->name;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete='.$block->id.'&confirm=1', 'blocks.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
uninstall_plugin('block', $block->name);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->block = $strblockname;
|
||||
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
|
||||
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
|
||||
@@ -96,11 +124,10 @@
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strsettings, $struninstall));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('class', 'admintable blockstable generaltable');
|
||||
$table->set_attribute('id', 'compatibleblockstable');
|
||||
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
|
||||
$table->setup();
|
||||
$tablerows = array();
|
||||
|
||||
@@ -114,18 +141,17 @@
|
||||
$blocknames[$blockid] = $blockname;
|
||||
}
|
||||
}
|
||||
core_collator::asort($blocknames);
|
||||
collatorlib::asort($blocknames);
|
||||
|
||||
foreach ($blocknames as $blockid=>$strblockname) {
|
||||
$block = $blocks[$blockid];
|
||||
$blockname = $block->name;
|
||||
$dbversion = get_config('block_'.$block->name, 'version');
|
||||
|
||||
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blockobject = false;
|
||||
$strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = $dbversion;
|
||||
$plugin->version = $block->version;
|
||||
|
||||
} else {
|
||||
$plugin = new stdClass();
|
||||
@@ -140,11 +166,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$blockname, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
} else {
|
||||
$uninstall = '';
|
||||
}
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if ($blockobject and $blockobject->has_config()) {
|
||||
@@ -183,13 +205,13 @@
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.sesskey().'" title="'.$strshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a>';
|
||||
$class = 'dimmed_text';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
|
||||
if ($dbversion == $plugin->version) {
|
||||
$version = $dbversion;
|
||||
if ($block->version == $plugin->version) {
|
||||
$version = $block->version;
|
||||
} else {
|
||||
$version = "$dbversion ($plugin->version)";
|
||||
$version = "$block->version ($plugin->version)";
|
||||
}
|
||||
|
||||
if (!$blockobject) {
|
||||
@@ -204,15 +226,15 @@
|
||||
}
|
||||
|
||||
$row = array(
|
||||
$strblockname,
|
||||
'<span'.$class.'>'.$strblockname.'</span>',
|
||||
$blocklist,
|
||||
$version,
|
||||
'<span'.$class.'>'.$version.'</span>',
|
||||
$visible,
|
||||
$undeletable,
|
||||
$settings,
|
||||
$uninstall,
|
||||
$delete,
|
||||
$settings
|
||||
);
|
||||
$table->add_data($row, $class);
|
||||
$table->add_data($row);
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
@@ -222,8 +244,8 @@
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
$table->define_columns(array('block', 'uninstall'));
|
||||
$table->define_headers(array($strname, $struninstall));
|
||||
$table->define_columns(array('block', 'delete'));
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('class', 'incompatibleblockstable generaltable');
|
||||
@@ -231,14 +253,9 @@
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$block->name, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
} else {
|
||||
$uninstall = '';
|
||||
}
|
||||
$table->add_data(array(
|
||||
$block->name,
|
||||
$uninstall,
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>',
|
||||
));
|
||||
}
|
||||
$table->print_html();
|
||||
|
||||
+22
-20
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* This file is used to display a categories sub categories, external pages, and settings.
|
||||
*
|
||||
* @since Moodle 2.3
|
||||
* @since 2.3
|
||||
* @package admin
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -67,6 +67,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
}
|
||||
$adminroot = admin_get_root(true); //reload tree
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
}
|
||||
|
||||
@@ -96,26 +97,27 @@ foreach ($settingspage->children as $childpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link($childpage->url, $childpage->visiblename), 3);
|
||||
} else if ($childpage instanceof admin_settingpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/settings.php', array('section' => $childpage->name)), $childpage->visiblename), 3);
|
||||
// If its a settings page and has settings lets display them.
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
} else if ($childpage instanceof admin_category) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/category.php', array('category' => $childpage->name)), get_string('admincategory', 'admin', $childpage->visiblename)), 3);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
}
|
||||
if ($savebutton) {
|
||||
@@ -155,4 +157,4 @@ echo $outputhtml;
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This hack is intended for clustered sites that do not want
|
||||
* to use shared cachedir for component cache.
|
||||
*
|
||||
* This file needs to be called after any change in PHP files in dataroot,
|
||||
* that is before upgrade and install.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Petr Skoda (skodak) {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('ABORT_AFTER_CONFIG', true); // We need just the values from config.php.
|
||||
define('CACHE_DISABLE_ALL', true); // This prevents reading of existing caches.
|
||||
define('IGNORE_COMPONENT_CACHE', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'file' => false,
|
||||
'rebuild' => false,
|
||||
'print' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
|
||||
}
|
||||
|
||||
if (!$options['rebuild'] and !$options['file'] and !$options['print']) {
|
||||
$help =
|
||||
"Create alternative component cache file
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
--rebuild Rebuild \$CFG->alternative_component_cache file
|
||||
--file=filepath Save component cache to file
|
||||
--print Print component cache file content
|
||||
|
||||
Example:
|
||||
\$ php admin/cli/rebuild_alternative_component_cache.php --rebuild
|
||||
";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$content = core_component::get_cache_content();
|
||||
|
||||
if ($options['print']) {
|
||||
echo $content;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['rebuild']) {
|
||||
if (empty($CFG->alternative_component_cache)) {
|
||||
fwrite(STDERR, 'config.php does not contain $CFG->alternative_component_cache setting');
|
||||
fwrite(STDERR, "\n");
|
||||
exit(2);
|
||||
}
|
||||
$target = $CFG->alternative_component_cache;
|
||||
} else {
|
||||
$target = $options['file'];
|
||||
}
|
||||
|
||||
if (!$target) {
|
||||
fwrite(STDERR, "Invalid target file $target");
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$bytes = file_put_contents($target, $content);
|
||||
|
||||
if (!$bytes) {
|
||||
fwrite(STDERR, "Error writing to $target");
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Success.
|
||||
echo "File $target was updated\n";
|
||||
exit(0);
|
||||
@@ -75,7 +75,8 @@ if (!empty($CFG->showcronsql)) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
$CFG->debugdisplay = true;
|
||||
}
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script allows to do backup.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Lancaster University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', 1);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array(
|
||||
'courseid' => false,
|
||||
'courseshortname' => '',
|
||||
'destination' => '',
|
||||
'help' => false,
|
||||
), array('h' => 'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help'] || !($options['courseid'] || $options['courseshortname'])) {
|
||||
$help = <<<EOL
|
||||
Perform backup of the given course.
|
||||
|
||||
Options:
|
||||
--courseid=INTEGER Course ID for backup.
|
||||
--courseshortname=STRING Course shortname for backup.
|
||||
--destination=STRING Path where to store backup file. If not set the backup
|
||||
will be stored within the course backup file area.
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/\n
|
||||
EOL;
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
$admin = get_admin();
|
||||
if (!$admin) {
|
||||
mtrace("Error: No admin account was found");
|
||||
die;
|
||||
}
|
||||
|
||||
// Do we need to store backup somewhere else?
|
||||
$dir = rtrim($options['destination'], '/');
|
||||
if (!empty($dir)) {
|
||||
if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
|
||||
mtrace("Destination directory does not exists or not writable.");
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the course exists.
|
||||
if ($options['courseid']) {
|
||||
$course = $DB->get_record('course', array('id' => $options['courseid']), '*', MUST_EXIST);
|
||||
} else if ($options['courseshortname']) {
|
||||
$course = $DB->get_record('course', array('shortname' => $options['courseshortname']), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
cli_heading('Performing backup...');
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE,
|
||||
backup::INTERACTIVE_YES, backup::MODE_GENERAL, $admin->id);
|
||||
// Set the default filename.
|
||||
$format = $bc->get_format();
|
||||
$type = $bc->get_type();
|
||||
$id = $bc->get_id();
|
||||
$users = $bc->get_plan()->get_setting('users')->get_value();
|
||||
$anonymised = $bc->get_plan()->get_setting('anonymize')->get_value();
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $id, $users, $anonymised);
|
||||
$bc->get_plan()->get_setting('filename')->set_value($filename);
|
||||
|
||||
// Execution.
|
||||
$bc->finish_ui();
|
||||
$bc->execute_plan();
|
||||
$results = $bc->get_results();
|
||||
$file = $results['backup_destination']; // May be empty if file already moved to target location.
|
||||
|
||||
// Do we need to store backup somewhere else?
|
||||
if (!empty($dir)) {
|
||||
if ($file) {
|
||||
mtrace("Writing " . $dir.'/'.$filename);
|
||||
if ($file->copy_content_to($dir.'/'.$filename)) {
|
||||
$file->delete();
|
||||
mtrace("Backup completed.");
|
||||
} else {
|
||||
mtrace("Destination directory does not exist or is not writable. Leaving the backup in the course backup file area.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mtrace("Backup completed, the new file is listed in the backup area of the given course");
|
||||
}
|
||||
$bc->destroy();
|
||||
exit(0);
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixed incorrectly deleted users.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'courses' => false,
|
||||
'fix' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
'c' => 'courses',
|
||||
'f' => 'fix'
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['help'] || empty($options['courses'])) {
|
||||
$help =
|
||||
"Checks and fixes that course modules and sections reference each other correctly.
|
||||
|
||||
Compares DB fields course_sections.sequence and course_modules.section
|
||||
checking that:
|
||||
- course_sections.sequence contains each module id not more than once in the course
|
||||
- for each moduleid from course_sections.sequence the field course_modules.section
|
||||
refers to the same section id (this means course_sections.sequence is more
|
||||
important if they are different)
|
||||
- each module in the course is present in one of course_sections.sequence
|
||||
- section sequences do not contain non-existing course modules
|
||||
|
||||
If there are any mismatches, the message is displayed. If --fix is specified,
|
||||
the records in DB are corrected.
|
||||
|
||||
This script may run for a long time on big systems if called for all courses.
|
||||
|
||||
Avoid executing the script when another user may simultaneously edit any of the
|
||||
courses being checked (recommended to run in mainenance mode).
|
||||
|
||||
Options:
|
||||
-c, --courses List courses that need to be checked (comma-separated
|
||||
values or * for all). Required
|
||||
-f, --fix Fix the mismatches in DB. If not specified check only and
|
||||
report problems to STDERR
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=*
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=2,3,4 --fix
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
$courseslist = preg_split('/\s*,\s*/', $options['courses'], -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (in_array('*', $courseslist)) {
|
||||
$where = '';
|
||||
$params = array();
|
||||
} else {
|
||||
list($sql, $params) = $DB->get_in_or_equal($courseslist, SQL_PARAMS_NAMED, 'id');
|
||||
$where = 'WHERE id '. $sql;
|
||||
}
|
||||
$coursescount = $DB->get_field_sql('SELECT count(id) FROM {course} '. $where, $params);
|
||||
|
||||
if (!$coursescount) {
|
||||
cli_error('No courses found');
|
||||
}
|
||||
echo "Checking $coursescount courses...\n\n";
|
||||
|
||||
require_once($CFG->dirroot. '/course/lib.php');
|
||||
|
||||
$problems = array();
|
||||
$courses = $DB->get_fieldset_sql('SELECT id FROM {course} '. $where, $params);
|
||||
foreach ($courses as $courseid) {
|
||||
$errors = course_integrity_check($courseid, null, null, true, empty($options['fix']));
|
||||
if ($errors) {
|
||||
if (!empty($options['fix'])) {
|
||||
// Reset the course cache to make sure cache is recalculated next time the course is viewed.
|
||||
rebuild_course_cache($courseid, true);
|
||||
}
|
||||
foreach ($errors as $error) {
|
||||
cli_problem($error);
|
||||
}
|
||||
$problems[] = $courseid;
|
||||
} else {
|
||||
echo "Course [$courseid] is OK\n";
|
||||
}
|
||||
}
|
||||
if (!count($problems)) {
|
||||
echo "\n...All courses are OK\n";
|
||||
} else {
|
||||
if (!empty($options['fix'])) {
|
||||
echo "\n...Found and fixed ".count($problems)." courses with problems". "\n";
|
||||
} else {
|
||||
echo "\n...Found ".count($problems)." courses with problems. To fix run:\n";
|
||||
echo "\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=".join(',', $problems)." --fix". "\n";
|
||||
}
|
||||
}
|
||||
+13
-86
@@ -36,12 +36,6 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when preparing test environment.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
$help =
|
||||
"Command line Moodle installer, creates config.php and initializes database.
|
||||
Please note you must execute this script with the same uid as apache
|
||||
@@ -64,8 +58,7 @@ Options:
|
||||
--dbname=NAME Database name. Default is moodle
|
||||
--dbuser=USERNAME Database user. Default is root
|
||||
--dbpass=PASSWORD Database password. Default is blank
|
||||
--dbport=NUMBER Use database port.
|
||||
--dbsocket=PATH Use database socket, 1 means default. Available for some databases only.
|
||||
--dbsocket Use database sockets. Available for some databases only.
|
||||
--prefix=STRING Table prefix for above database tables. Default is mdl_
|
||||
--fullname=STRING The fullname of the site
|
||||
--shortname=STRING The shortname of the site
|
||||
@@ -134,24 +127,19 @@ if (function_exists('date_default_timezone_set') and function_exists('date_defau
|
||||
/** Used by library scripts to check they are being called by Moodle */
|
||||
define('MOODLE_INTERNAL', true);
|
||||
|
||||
// Disables all caching.
|
||||
// Disables caching.. just in case.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
define('PHPUNIT_TEST', false);
|
||||
|
||||
define('IGNORE_COMPONENT_CACHE', true);
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.4.4") < 0) {
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// set up configuration
|
||||
global $CFG;
|
||||
$CFG = new stdClass();
|
||||
$CFG->lang = 'en';
|
||||
$CFG->dirroot = dirname(dirname(dirname(__FILE__)));
|
||||
@@ -161,11 +149,6 @@ $CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
$CFG->dboptions = array();
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugdeveloper = true;
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
|
||||
$CFG->admin = array_pop($parts);
|
||||
@@ -174,14 +157,10 @@ $CFG->admin = array_pop($parts);
|
||||
//the problem is that we need specific version of quickforms and hacked excel files :-(
|
||||
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
|
||||
|
||||
require_once($CFG->libdir.'/classes/component.php');
|
||||
require_once($CFG->libdir.'/classes/text.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager_install.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager_standard.php');
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/setuplib.php');
|
||||
require_once($CFG->libdir.'/textlib.class.php');
|
||||
require_once($CFG->libdir.'/weblib.php');
|
||||
require_once($CFG->libdir.'/dmllib.php');
|
||||
require_once($CFG->libdir.'/moodlelib.php');
|
||||
@@ -190,32 +169,11 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
require_once($CFG->dirroot.'/cache/lib.php');
|
||||
|
||||
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
|
||||
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
|
||||
if (defined('COMPONENT_CLASSLOADER')) {
|
||||
spl_autoload_register(COMPONENT_CLASSLOADER);
|
||||
} else {
|
||||
spl_autoload_register('core_component::classloader');
|
||||
}
|
||||
|
||||
require($CFG->dirroot.'/version.php');
|
||||
$CFG->target_release = $release;
|
||||
|
||||
\core\session\manager::init_empty_session();
|
||||
global $SESSION;
|
||||
global $USER;
|
||||
|
||||
global $COURSE;
|
||||
$COURSE = new stdClass();
|
||||
$COURSE->id = 1;
|
||||
|
||||
global $SITE;
|
||||
$SITE = $COURSE;
|
||||
define('SITEID', 1);
|
||||
|
||||
//Database types
|
||||
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
|
||||
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
|
||||
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
|
||||
'oci' => moodle_database::get_driver_instance('oci', 'native'),
|
||||
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
|
||||
@@ -245,8 +203,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'dbname' => 'moodle',
|
||||
'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
|
||||
'dbpass' => '',
|
||||
'dbport' => '',
|
||||
'dbsocket' => '',
|
||||
'dbsocket' => false,
|
||||
'prefix' => 'mdl_',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
@@ -336,8 +293,6 @@ if ($interactive) {
|
||||
}
|
||||
}
|
||||
$CFG->directorypermissions = $chmod;
|
||||
$CFG->filepermissions = ($CFG->directorypermissions & 0666);
|
||||
$CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
|
||||
|
||||
//We need wwwroot before we test dataroot
|
||||
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
|
||||
@@ -424,9 +379,8 @@ if ($interactive) {
|
||||
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
|
||||
}
|
||||
}
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
$CFG->localcachedir = $CFG->dataroot.'/localcache';
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
|
||||
// download required lang packs
|
||||
if ($CFG->lang !== 'en') {
|
||||
@@ -542,34 +496,6 @@ if ($interactive) {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
}
|
||||
|
||||
// ask for db port
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseport', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbport']);
|
||||
$CFG->dboptions['dbport'] = (int)cli_input($prompt, $options['dbport']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbport'] = (int)$options['dbport'];
|
||||
}
|
||||
if ($CFG->dboptions['dbport'] <= 0) {
|
||||
$CFG->dboptions['dbport'] = '';
|
||||
}
|
||||
|
||||
// ask for db socket
|
||||
if ($CFG->ostype === 'WINDOWS') {
|
||||
$CFG->dboptions['dbsocket'] = '';
|
||||
|
||||
} else if ($interactive and empty($CFG->dboptions['dbport'])) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbsocket']);
|
||||
$CFG->dboptions['dbsocket'] = cli_input($prompt, $options['dbsocket']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
|
||||
// ask for db user
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
@@ -598,14 +524,14 @@ if ($interactive) {
|
||||
|
||||
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
|
||||
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']), $distro);
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']), $distro);
|
||||
}
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
} while ($hint_database !== '');
|
||||
|
||||
} else {
|
||||
$CFG->dbpass = $options['dbpass'];
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
if ($hint_database !== '') {
|
||||
cli_error(get_string('dbconnectionerror', 'install'));
|
||||
}
|
||||
@@ -745,8 +671,9 @@ if (!$envstatus) {
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
@@ -29,19 +29,12 @@
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when preparing test environment.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
$help =
|
||||
"Advanced command line Moodle database installer.
|
||||
Please note you must execute this script with the same uid as apache.
|
||||
@@ -62,10 +55,10 @@ Example:
|
||||
";
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.4.4") < 0) {
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -167,8 +160,9 @@ if (!$envstatus) {
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
+10
-46
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,7 +16,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Enable or disable maintenance mode.
|
||||
* Enable or disable maintenance mode
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
@@ -25,13 +26,12 @@
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/adminlib.php");
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'enablelater'=>0, 'enableold'=>false, 'disable'=>false, 'help'=>false),
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'disable'=>false, 'help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
@@ -45,14 +45,12 @@ if ($options['help']) {
|
||||
Current status displayed if not option specified.
|
||||
|
||||
Options:
|
||||
--enable Enable CLI maintenance mode
|
||||
--enablelater=MINUTES Number of minutes before entering CLI maintenance mode
|
||||
--enableold Enable legacy half-maintenance mode
|
||||
--enable Enable maintenance mode
|
||||
--disable Disable maintenance mode
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
@@ -61,52 +59,18 @@ Example:
|
||||
|
||||
cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
|
||||
|
||||
if ($options['enablelater']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// Already enabled, sorry.
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
$time = time() + ($options['enablelater']*60);
|
||||
set_config('maintenance_later', $time);
|
||||
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($time))."\n";
|
||||
return 0;
|
||||
|
||||
} else if ($options['enable']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// The maintenance is already enabled, nothing to do.
|
||||
} else {
|
||||
enable_cli_maintenance_mode();
|
||||
}
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceoncli', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['enableold']) {
|
||||
if ($options['enable']) {
|
||||
set_config('maintenance_enabled', 1);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceon', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['disable']) {
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
unlink("$CFG->dataroot/climaintenance.html");
|
||||
}
|
||||
echo get_string('sitemaintenanceoff', 'admin')."\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!empty($CFG->maintenance_enabled) or file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
if (!empty($CFG->maintenance_enabled)) {
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
|
||||
} else if (isset($CFG->maintenance_later)) {
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($CFG->maintenance_later))."\n";
|
||||
|
||||
} else {
|
||||
echo get_string('clistatusdisabled', 'admin')."\n";
|
||||
}
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL table row compression tool tool.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Petr Skoda <petr.skoda@totaralms.com>
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(__FILE__).'/../../config.php');
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This script is used for MySQL databases only.');
|
||||
}
|
||||
|
||||
$engine = strtolower($DB->get_dbengine());
|
||||
if ($engine !== 'innodb' and $engine !== 'xtradb') {
|
||||
cli_error('This script is for MySQL servers using InnoDB or XtraDB engines only.');
|
||||
}
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array('help' => false, 'info' => false, 'list' => false, 'fix' => false, 'showsql' => false),
|
||||
array('h' => 'help', 'i' => 'info', 'l' => 'list', 'f' => 'fix', 's' => 'showsql')
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"Script for detection of row size problems in MySQL InnoDB tables.
|
||||
|
||||
By default InnoDB storage table is using legacy Antelope file format
|
||||
which has major restriction on database row size.
|
||||
Use this script to detect and fix database tables with potential data
|
||||
overflow problems.
|
||||
|
||||
Options:
|
||||
-i, --info Show database information
|
||||
-l, --list List problematic tables
|
||||
-f, --fix Attempt to fix all tables (requires SUPER privilege)
|
||||
-s, --showsql Print SQL statements for fixing of tables
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/mysql_compressed_rows.php -l
|
||||
";
|
||||
|
||||
/** @var mysql_sql_generator $generator */
|
||||
$generator = $DB->get_manager()->generator;
|
||||
|
||||
$info = $DB->get_server_info();
|
||||
$filepertable = $DB->get_record_sql("SHOW VARIABLES LIKE 'innodb_file_per_table'");
|
||||
$filepertable = $filepertable ? $filepertable->value : '';
|
||||
$fileformat = $DB->get_record_sql("SHOW VARIABLES LIKE 'innodb_file_format'");
|
||||
$fileformat = $fileformat ? $fileformat->value : '';
|
||||
$prefix = $DB->get_prefix();
|
||||
$database = $CFG->dbname;
|
||||
|
||||
if (!empty($options['info'])) {
|
||||
echo "Database version: " . $info['description'] . "\n";
|
||||
echo "Database name: $database\n";
|
||||
echo "Database engine: " . $DB->get_dbengine() . "\n";
|
||||
echo "innodb_file_per_table: $filepertable\n";
|
||||
echo "innodb_file_format: $fileformat\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
$problem = false;
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antolope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT);
|
||||
echo str_pad($format, 11, ' ', STR_PAD_RIGHT);
|
||||
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$problem = true;
|
||||
echo " (needs fixing)\n";
|
||||
|
||||
} else if ($format !== 'Compressed' and $format !== 'Dynamic') {
|
||||
echo " (unknown)\n";
|
||||
|
||||
} else {
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($problem) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['fix'])) {
|
||||
$fixtables = array();
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antolope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$fixtables[$table] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fixtables) {
|
||||
echo "No changes necessary\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($filepertable !== 'ON') {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_per_table=1");
|
||||
} catch (dml_exception $e) {
|
||||
echo "Cannot enable GLOBAL innodb_file_per_table setting, use --showsql option and execute the statements manually.";
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
if ($fileformat !== 'Barracuda') {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_format=Barracuda");
|
||||
} catch (dml_exception $e) {
|
||||
echo "Cannot change GLOBAL innodb_file_format setting, use --showsql option and execute the statements manually.";
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$DB->is_compressed_row_format_supported(false)) {
|
||||
echo "MySQL server is not compatible with compressed row format.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($fixtables as $table) {
|
||||
$DB->change_database_structure("ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed");
|
||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT) . " ... Compressed\n";
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['showsql'])) {
|
||||
$fixtables = array();
|
||||
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antolope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$fixtables[$table] = $table;
|
||||
}
|
||||
}
|
||||
if (!$fixtables) {
|
||||
echo "No changes necessary\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
echo "Copy the following SQL statements and execute them using account with SUPER privilege:\n\n";
|
||||
echo "USE $database;\n";
|
||||
echo "SET SESSION sql_mode=STRICT_ALL_TABLES;\n";
|
||||
echo "SET GLOBAL innodb_file_per_table=1;\n";
|
||||
echo "SET GLOBAL innodb_file_format=Barracuda;\n";
|
||||
foreach ($fixtables as $table) {
|
||||
echo "ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed;\n";
|
||||
}
|
||||
echo "\n";
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
+3
-15
@@ -29,20 +29,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when detecting if upgrade necessary or when running upgrade.
|
||||
if (function_exists('opcache_reset') and !isset($_SERVER['REMOTE_ADDR'])) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
@@ -116,7 +110,7 @@ if (!$envstatus) {
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
@@ -156,12 +150,6 @@ if ($interactive) {
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) {
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
set_config('release', $release);
|
||||
@@ -171,7 +159,7 @@ set_config('branch', $branch);
|
||||
upgrade_noncore(true);
|
||||
|
||||
// log in as admin - we need doanything permission when applying defaults
|
||||
\core\session\manager::set_user(get_admin());
|
||||
session_set_user(get_admin());
|
||||
|
||||
// apply all default settings, just in case do it twice to fill all defaults
|
||||
admin_apply_default_settings(NULL, false);
|
||||
|
||||
+51
-3
@@ -24,9 +24,11 @@
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$formatname = required_param('format', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/courseformats.php');
|
||||
@@ -38,7 +40,8 @@ require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
|
||||
|
||||
$formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
$formatplugins = $allplugins['format'];
|
||||
$sortorder = array_flip(array_keys($formatplugins));
|
||||
|
||||
if (!isset($formatplugins[$formatname])) {
|
||||
@@ -52,13 +55,11 @@ switch ($action) {
|
||||
print_error('cannotdisableformat', 'error', $return);
|
||||
}
|
||||
set_config('disabled', 1, 'format_'. $formatname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$formatplugins[$formatname]->is_enabled()) {
|
||||
unset_config('disabled', 'format_'. $formatname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'up':
|
||||
@@ -79,5 +80,52 @@ switch ($action) {
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'uninstall':
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('courseformats', 'moodle'));
|
||||
|
||||
$coursecount = $DB->count_records('course', array('format' => $formatname));
|
||||
if ($coursecount) {
|
||||
// Check that default format is set. It will be used to convert courses
|
||||
// using this format
|
||||
$defaultformat = get_config('moodlecourse', 'format');
|
||||
$defaultformat = $formatplugins[get_config('moodlecourse', 'format')];
|
||||
if (!$defaultformat) {
|
||||
echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$format = $formatplugins[$formatname];
|
||||
$deleteurl = $format->get_uninstall_url();
|
||||
if (!$deleteurl) {
|
||||
// somebody was trying to cheat and type non-existing link
|
||||
echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
if ($coursecount) {
|
||||
$message = get_string('formatuninstallwithcourses', 'admin',
|
||||
(object)array('count' => $coursecount, 'format' => $format->displayname,
|
||||
'defaultformat' => $defaultformat->displayname));
|
||||
} else {
|
||||
$message = get_string('formatuninstallconfirm', 'admin', $format->displayname);
|
||||
}
|
||||
$deleteurl->param('confirm', 1);
|
||||
echo $OUTPUT->confirm($message, $deleteurl, $return);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->plugin = $format->displayname;
|
||||
$a->directory = $format->rootdir;
|
||||
uninstall_plugin('format', $formatname);
|
||||
echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($return);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
redirect($return);
|
||||
|
||||
+16
-2
@@ -53,7 +53,7 @@ require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// extra safety
|
||||
\core\session\manager::write_close();
|
||||
session_get_instance()->write_close();
|
||||
|
||||
// check if execution allowed
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
@@ -72,10 +72,24 @@ if (!empty($CFG->cronremotepassword)) {
|
||||
}
|
||||
|
||||
// send mime type and encoding
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
if (check_browser_version('MSIE')) {
|
||||
//ugly IE hack to work around downloading instead of viewing
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
// we do not want html markup in emulated CLI
|
||||
@ini_set('html_errors', 'off');
|
||||
|
||||
// execute the cron
|
||||
cron_run();
|
||||
|
||||
// finish the IE hack
|
||||
if (check_browser_version('MSIE')) {
|
||||
echo "</xmp>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+41
-1
@@ -83,6 +83,47 @@ switch ($action) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
if ($editor === 'textarea') {
|
||||
redirect($returnurl);
|
||||
}
|
||||
if (get_string_manager()->string_exists('pluginname', 'editor_'.$editor)) {
|
||||
$strplugin = get_string('pluginname', 'editor_'.$editor);
|
||||
} else {
|
||||
$strplugin = $editor;
|
||||
}
|
||||
|
||||
$PAGE->set_title($strplugin);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->heading(get_string('editors', 'core_editor'));
|
||||
|
||||
$deleteurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
|
||||
echo $OUTPUT->confirm(get_string('editordeleteconfirm', 'core_editor', $strplugin),
|
||||
$deleteurl, $returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Remove from enabled list.
|
||||
$key = array_search($editor, $active_editors);
|
||||
unset($active_editors[$key]);
|
||||
set_config('texteditors', implode(',', $active_editors));
|
||||
|
||||
// Delete everything!!
|
||||
uninstall_plugin('editor', $editor);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->name = $strplugin;
|
||||
$a->directory = "$CFG->dirroot/lib/editor/$editor";
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -93,7 +134,6 @@ if (empty($active_editors)) {
|
||||
}
|
||||
|
||||
set_config('texteditors', implode(',', $active_editors));
|
||||
core_plugin_manager::reset_caches();
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
|
||||
+48
-17
@@ -31,6 +31,7 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$enrol = required_param('enrol', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$migrate = optional_param('migrate', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/enrol.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
@@ -50,7 +51,6 @@ switch ($action) {
|
||||
case 'disable':
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
core_plugin_manager::reset_caches();
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
@@ -61,7 +61,6 @@ switch ($action) {
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled[] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
core_plugin_manager::reset_caches();
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
@@ -97,7 +96,7 @@ switch ($action) {
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
|
||||
case 'migrate':
|
||||
case 'uninstall':
|
||||
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
|
||||
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
|
||||
} else {
|
||||
@@ -107,26 +106,58 @@ switch ($action) {
|
||||
$PAGE->set_title($strplugin);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// This may take a long time.
|
||||
core_php_time_limit::raise();
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
|
||||
|
||||
// Disable plugin to prevent concurrent cron execution.
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
$deleteurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>0));
|
||||
$migrateurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>1));
|
||||
|
||||
echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol));
|
||||
$migrate = new single_button($migrateurl, get_string('uninstallmigrate', 'enrol'));
|
||||
$delete = new single_button($deleteurl, get_string('uninstalldelete', 'enrol'));
|
||||
$cancel = new single_button($return, get_string('cancel'), 'get');
|
||||
|
||||
require_once("$CFG->dirroot/enrol/manual/locallib.php");
|
||||
enrol_manual_migrate_plugin_enrolments($enrol);
|
||||
$buttons = $OUTPUT->render($delete) . $OUTPUT->render($cancel);
|
||||
if ($enrol !== 'manual') {
|
||||
$buttons = $OUTPUT->render($migrate) . $buttons;
|
||||
}
|
||||
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
echo html_writer::tag('p', markdown_to_html(get_string('uninstallconfirm', 'enrol', $strplugin)));
|
||||
echo html_writer::tag('div', $buttons, array('class' => 'buttons'));
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
if (!$return = core_plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol, 'manage')) {
|
||||
$return = new moodle_url('/admin/plugins.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// This may take a long time.
|
||||
set_time_limit(0);
|
||||
|
||||
// Disable plugin to prevent concurrent cron execution.
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
|
||||
if ($migrate) {
|
||||
echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol));
|
||||
|
||||
require_once("$CFG->dirroot/enrol/manual/locallib.php");
|
||||
enrol_manual_migrate_plugin_enrolments($enrol);
|
||||
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
}
|
||||
|
||||
// Delete everything!!
|
||||
uninstall_plugin('enrol', $enrol);
|
||||
$syscontext->mark_dirty(); // Resets all enrol caches.
|
||||
|
||||
$a = new stdClass();
|
||||
$a->plugin = $strplugin;
|
||||
$a->directory = "$CFG->dirroot/enrol/$enrol";
|
||||
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
echo $OUTPUT->continue_button($return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ admin_externalpage_setup('environment', '', $extraurlparams);
|
||||
// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
// Create component installer and execute it
|
||||
if ($cd = new component_installer('https://download.moodle.org',
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
@@ -53,7 +53,7 @@ if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'https://download.moodle.org/environment/environment.zip';
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest = $CFG->dataroot . '/';
|
||||
print_error($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
die();
|
||||
@@ -102,7 +102,7 @@ if ($contents = load_environment_xml()) {
|
||||
}
|
||||
|
||||
// Get the results of the environment check.
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version, ENV_SELECT_NEWER);
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version);
|
||||
|
||||
// Display the page.
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
@@ -899,7 +899,6 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.3.5" />
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
@@ -1006,557 +1005,6 @@
|
||||
<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>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.7" requires="2.2">
|
||||
<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.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</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="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="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="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" 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="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_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.8" requires="2.2">
|
||||
<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.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</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="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="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="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" 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="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_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.9" requires="2.2">
|
||||
<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.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</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="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="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="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" 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_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.0" requires="2.2">
|
||||
<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.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</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="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="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="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" 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_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+201
-167
@@ -1,225 +1,254 @@
|
||||
<?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/>.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Filter management page.
|
||||
* Processes actions from the admin_setting_managefilters object (defined in
|
||||
* adminlib.php).
|
||||
*
|
||||
* @package core
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package administration
|
||||
*//** */
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PLUGIN);
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('managefilters');
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
|
||||
admin_externalpage_setup('managefilters');
|
||||
|
||||
// Clean up bogus filter states first.
|
||||
$plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
|
||||
$filters = array();
|
||||
$states = filter_get_global_states();
|
||||
foreach ($states as $state) {
|
||||
if (!isset($plugininfos[$state->filter]) and !get_config('filter_'.$state->filter, 'version')) {
|
||||
// Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
|
||||
$DB->delete_records('filter_active', array('filter' => $state->filter));
|
||||
$DB->delete_records('filter_config', array('filter' => $state->filter));
|
||||
error_log('Deleted bogus "filter_'.$state->filter.'" states and config data.');
|
||||
} else {
|
||||
$filters[$state->filter] = $state;
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
$fitlernames = filter_get_all_installed();
|
||||
$newfilters = $fitlernames;
|
||||
foreach ($filters as $filter => $notused) {
|
||||
unset($newfilters[$filter]);
|
||||
}
|
||||
}
|
||||
|
||||
// Add properly installed and upgraded filters to the global states table.
|
||||
foreach ($plugininfos as $filter => $info) {
|
||||
if (isset($filters[$filter])) {
|
||||
continue;
|
||||
}
|
||||
/** @var \core\plugininfo\base $info */
|
||||
if ($info->is_installed_and_upgraded()) {
|
||||
filter_set_global_state($filter, TEXTFILTER_DISABLED);
|
||||
$states = filter_get_global_states();
|
||||
foreach ($states as $state) {
|
||||
if ($state->filter === $filter) {
|
||||
$filters[$filter] = $state;
|
||||
break;
|
||||
}
|
||||
/// Process actions ============================================================
|
||||
|
||||
if ($action) {
|
||||
if (!isset($filters[$filterpath]) && !isset($newfilters[$filterpath])) {
|
||||
throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath);
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
require_sesskey();
|
||||
}
|
||||
|
||||
// Process actions.
|
||||
switch ($action) {
|
||||
switch ($action) {
|
||||
|
||||
case 'setstate':
|
||||
if (isset($filters[$filterpath]) and $newstate = optional_param('newstate', '', PARAM_INT)) {
|
||||
if ($newstate = optional_param('newstate', '', PARAM_INT)) {
|
||||
filter_set_global_state($filterpath, $newstate);
|
||||
if ($newstate == TEXTFILTER_DISABLED) {
|
||||
filter_set_applies_to_strings($filterpath, false);
|
||||
}
|
||||
unset($newfilters[$filterpath]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'setapplyto':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
|
||||
filter_set_applies_to_strings($filterpath, $applytostrings);
|
||||
}
|
||||
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
|
||||
filter_set_applies_to_strings($filterpath, $applytostrings);
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
if (isset($filters[$filterpath])) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, 1);
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
if ($oldpos <= count($filters)) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
|
||||
if ($oldpos >= 1) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Reset caches and return.
|
||||
if ($action) {
|
||||
reset_text_filters_cache();
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect(new moodle_url('/admin/filters.php'));
|
||||
}
|
||||
case 'delete':
|
||||
if (!empty($filternames[$filterpath])) {
|
||||
$filtername = $filternames[$filterpath];
|
||||
} else {
|
||||
$filtername = $filterpath;
|
||||
}
|
||||
|
||||
// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
|
||||
if (substr($filterpath, 0, 4) == 'mod/') {
|
||||
$mod = basename($filterpath);
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->module = get_string('modulename', $mod);
|
||||
print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
|
||||
}
|
||||
|
||||
$states = filter_get_global_states();
|
||||
$stringfilters = filter_get_string_filters();
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$title = get_string('deletefilterareyousure', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
|
||||
$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->id = 'filterssetting';
|
||||
$table->data = array();
|
||||
$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
|
||||
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$lastactive = null;
|
||||
foreach ($states as $state) {
|
||||
if ($state->active != TEXTFILTER_DISABLED) {
|
||||
$lastactive = $state->filter;
|
||||
// Do the deletion.
|
||||
$title = get_string('deletingfilter', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
// Delete all data for this plugin.
|
||||
filter_delete_all_for_filter($filterpath);
|
||||
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->directory = $filterpath;
|
||||
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through filters adding to display table.
|
||||
$firstrow = true;
|
||||
foreach ($states as $state) {
|
||||
$filter = $state->filter;
|
||||
if (!isset($plugininfos[$filter])) {
|
||||
continue;
|
||||
// Add any missing filters to the DB table.
|
||||
foreach ($newfilters as $filter => $notused) {
|
||||
filter_set_global_state($filter, TEXTFILTER_DISABLED);
|
||||
}
|
||||
$plugininfo = $plugininfos[$filter];
|
||||
$applytostrings = isset($stringfilters[$filter]) && $state->active != TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($plugininfo, $state, $firstrow, $filter == $lastactive, $applytostrings);
|
||||
$table->data[] = $row;
|
||||
if ($state->active == TEXTFILTER_DISABLED) {
|
||||
|
||||
// Reset caches and return
|
||||
if ($action) {
|
||||
reset_text_filters_cache();
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
/// End of process actions =====================================================
|
||||
|
||||
/// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
|
||||
|
||||
$activechoices = array(
|
||||
TEXTFILTER_DISABLED => get_string('disabled', 'filters'),
|
||||
TEXTFILTER_OFF => get_string('offbutavailable', 'filters'),
|
||||
TEXTFILTER_ON => get_string('on', 'filters'),
|
||||
);
|
||||
$applytochoices = array(
|
||||
0 => get_string('content', 'filters'),
|
||||
1 => get_string('contentandheadings', 'filters'),
|
||||
);
|
||||
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
$filternames = filter_get_all_installed();
|
||||
$newfilters = $filternames;
|
||||
foreach ($filters as $filter => $notused) {
|
||||
unset($newfilters[$filter]);
|
||||
}
|
||||
$stringfilters = filter_get_string_filters();
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
|
||||
$table->align = array('left', 'left', 'center', 'left', 'left');
|
||||
$table->width = '100%';
|
||||
$table->data = array();
|
||||
|
||||
$lastactive = null;
|
||||
foreach ($filters as $filter => $filterinfo) {
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
$lastactive = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
// iterate through filters adding to display table
|
||||
$firstrow = true;
|
||||
foreach ($filters as $filter => $filterinfo) {
|
||||
$applytostrings = isset($stringfilters[$filter]) && $filterinfo->active != TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($filterinfo, $firstrow, $filter == $lastactive, $applytostrings);
|
||||
$table->data[] = $row;
|
||||
if ($filterinfo->active == TEXTFILTER_DISABLED) {
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
} else {
|
||||
$table->rowclasses[] = '';
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
foreach ($newfilters as $filter => $filtername) {
|
||||
$filterinfo = new stdClass;
|
||||
$filterinfo->filter = $filter;
|
||||
$filterinfo->active = TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($filterinfo, false, false, false);
|
||||
$table->data[] = $row;
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
} else {
|
||||
$table->rowclasses[] = '';
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
|
||||
echo html_writer::table($table);
|
||||
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
echo html_writer::table($table);
|
||||
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
/// Display helper functions ===================================================
|
||||
|
||||
/**
|
||||
* Return action URL.
|
||||
*
|
||||
* @param string $filterpath
|
||||
* @param string $action
|
||||
* @return moodle_url
|
||||
*/
|
||||
function filters_action_url($filterpath, $action) {
|
||||
if ($action === 'delete') {
|
||||
return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
|
||||
}
|
||||
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct table record.
|
||||
*
|
||||
* @param \core\plugininfo\filter $plugininfo
|
||||
* @param stdClass $state
|
||||
* @param bool $isfirstrow
|
||||
* @param bool $islastactive
|
||||
* @param bool $applytostrings
|
||||
* @return array data
|
||||
*/
|
||||
function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow, $islastactive, $applytostrings) {
|
||||
global $OUTPUT;
|
||||
function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) {
|
||||
global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!!
|
||||
$row = array();
|
||||
$filter = $state->filter;
|
||||
$active = $plugininfo->is_installed_and_upgraded();
|
||||
$filter = $filterinfo->filter;
|
||||
|
||||
static $activechoices;
|
||||
static $applytochoices;
|
||||
if (!isset($activechoices)) {
|
||||
$activechoices = array(
|
||||
TEXTFILTER_DISABLED => get_string('disabled', 'core_filters'),
|
||||
TEXTFILTER_OFF => get_string('offbutavailable', 'core_filters'),
|
||||
TEXTFILTER_ON => get_string('on', 'core_filters'),
|
||||
);
|
||||
$applytochoices = array(
|
||||
0 => get_string('content', 'core_filters'),
|
||||
1 => get_string('contentandheadings', 'core_filters'),
|
||||
);
|
||||
// Filter name
|
||||
if (!empty($filternames[$filter])) {
|
||||
$row[] = $filternames[$filter];
|
||||
} else {
|
||||
$row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>';
|
||||
}
|
||||
|
||||
// Filter name.
|
||||
$displayname = $plugininfo->displayname;
|
||||
if (!$plugininfo->rootdir) {
|
||||
$displayname = '<span class="error">' . $displayname . ' - ' . get_string('status_missing', 'core_plugin') . '</span>';
|
||||
} else if (!$active) {
|
||||
$displayname = '<span class="error">' . $displayname . ' - ' . get_string('error') . '</span>';
|
||||
}
|
||||
$row[] = $displayname;
|
||||
|
||||
// Disable/off/on.
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $state->active, null, 'active' . $filter);
|
||||
// Disable/off/on
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
|
||||
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Re-order.
|
||||
// Re-order
|
||||
$updown = '';
|
||||
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />';
|
||||
if ($state->active != TEXTFILTER_DISABLED) {
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
if (!$isfirstrow) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall')));
|
||||
} else {
|
||||
@@ -234,20 +263,25 @@ function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow,
|
||||
$row[] = $updown;
|
||||
|
||||
// Apply to strings.
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter);
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
|
||||
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
|
||||
$select->disabled = ($state->active == TEXTFILTER_DISABLED);
|
||||
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Settings link, if required.
|
||||
if ($active and filter_has_global_settings($filter)) {
|
||||
$row[] = html_writer::link(new moodle_url('/admin/settings.php', array('section'=>'filtersetting'.$filter)), get_string('settings'));
|
||||
// Settings link, if required
|
||||
if (filter_has_global_settings($filter)) {
|
||||
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' .
|
||||
str_replace('/', '',$filter) . '">' . get_string('settings') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Uninstall.
|
||||
$row[] = html_writer::link(filters_action_url($filter, 'delete'), get_string('uninstallplugin', 'core_admin'));
|
||||
// Delete
|
||||
if (substr($filter, 0, 4) != 'mod/') {
|
||||
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/** This expects the output from a command like
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
|
||||
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
|
||||
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
|
||||
*/
|
||||
|
||||
die('TODO: MDL-19380');
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->libdir.'/eventslib.php');
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
|
||||
|
||||
$site = get_site();
|
||||
|
||||
while(!feof($fd)) {
|
||||
$entry = fgets($fd);
|
||||
if (strlen(trim($entry)) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!$file = validate_line($entry)) {
|
||||
continue;
|
||||
}
|
||||
$bits = explode('/',$file);
|
||||
$a->filename = $bits[count($bits)-1];
|
||||
|
||||
if (!$log = $DB->get_record("log", array("module"=>"upload", "info"=>$file, "action"=>"upload"))) {
|
||||
$a->action = clam_handle_infected_file($file,0,false);
|
||||
clam_replace_infected_file($file);
|
||||
notify_admins_unknown($file,$a);
|
||||
continue;
|
||||
}
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid";
|
||||
$course = $DB->get_record_sql($sql, array('courseid' => $log->course));
|
||||
context_instance_preload($course);
|
||||
|
||||
$user = $DB->get_record("user", array("id"=>$log->userid));
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
$a->course = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
|
||||
$a->user = fullname($user);
|
||||
|
||||
notify_user($user,$subject,$a);
|
||||
notify_admins($user,$subject,$a);
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
|
||||
function notify_user($user,$subject,$a) {
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
$body = get_string('virusfoundlater','moodle',$a);
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userto = $user;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
}
|
||||
|
||||
|
||||
function notify_admins($user,$subject,$a) {
|
||||
|
||||
$admins = get_admins();
|
||||
|
||||
$body = get_string('virusfoundlateradmin','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
}
|
||||
}
|
||||
|
||||
function notify_admins_unknown($file,$a) {
|
||||
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_line($line) {
|
||||
global $CFG;
|
||||
if (strpos($line,"FOUND") === false) {
|
||||
return false;
|
||||
}
|
||||
$index = strpos($line,":");
|
||||
$file = substr($line,0,$index);
|
||||
if (!(strpos($file,$CFG->dataroot) === false)) {
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($file{0} == "/") {
|
||||
$file = $CFG->dataroot.$file;
|
||||
}
|
||||
else {
|
||||
$file = $CFG->dataroot."/".$file;
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// clean up
|
||||
$file = preg_replace('/\.\//','/',$file);
|
||||
$file = preg_replace('/\/\//','/',$file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
+98
-218
@@ -30,10 +30,10 @@ if (!file_exists('../config.php')) {
|
||||
}
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible
|
||||
if (version_compare(phpversion(), '5.4.4') < 0) {
|
||||
if (version_compare(phpversion(), '5.3.2') < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
|
||||
echo "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).<br />";
|
||||
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
|
||||
echo "Please upgrade your server software or install older Moodle version.";
|
||||
die();
|
||||
}
|
||||
@@ -45,48 +45,12 @@ if (!function_exists('iconv')) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Make sure php5-json is available.
|
||||
if (!function_exists('json_encode') || !function_exists('json_decode')) {
|
||||
// This also shouldn't happen.
|
||||
echo 'Moodle requires the json PHP extension. Please install or enable the json extension.';
|
||||
die();
|
||||
}
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
if ((isset($_GET['cache']) and $_GET['cache'] === '0')
|
||||
or (isset($_POST['cache']) and $_POST['cache'] === '0')
|
||||
or (!isset($_POST['cache']) and !isset($_GET['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey']))) {
|
||||
// Prevent caching at all cost when visiting this page directly,
|
||||
// we redirect to self once we known no upgrades are necessary.
|
||||
// Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
|
||||
// Note2: the sesskey is present in all block editing hacks, we can not redirect there, so enable caching.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when detecting if upgrade necessary or when running upgrade.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
$cache = 0;
|
||||
|
||||
} else {
|
||||
$cache = 1;
|
||||
}
|
||||
|
||||
require('../config.php');
|
||||
|
||||
// Invalidate the cache of version.php in any circumstances to help core_component
|
||||
// detecting if the version has changed and component cache should be reset.
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($CFG->dirroot . '/version.php', true);
|
||||
}
|
||||
// Make sure the component cache gets rebuilt if necessary, any method that
|
||||
// indirectly calls the protected init() method is good here.
|
||||
core_component::get_core_subsystems();
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/pluginlib.php'); // available updates notifications
|
||||
|
||||
$id = optional_param('id', '', PARAM_TEXT);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
@@ -95,37 +59,22 @@ $confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
||||
$showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
||||
$newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
|
||||
|
||||
// Set up PAGE.
|
||||
$url = new moodle_url('/admin/index.php');
|
||||
$url->param('cache', $cache);
|
||||
$PAGE->set_url($url);
|
||||
unset($url);
|
||||
|
||||
// Are we returning from an add-on installation request at moodle.org/plugins?
|
||||
if ($newaddonreq and !$cache and empty($CFG->disableonclickaddoninstall)) {
|
||||
$target = new moodle_url('/admin/tool/installaddon/index.php', array(
|
||||
'installaddonrequest' => $newaddonreq,
|
||||
'confirm' => 0));
|
||||
if (!isloggedin() or isguestuser()) {
|
||||
// Login and go the the add-on tool page.
|
||||
$SESSION->wantsurl = $target->out();
|
||||
redirect(get_login_url());
|
||||
}
|
||||
redirect($target);
|
||||
}
|
||||
// Check some PHP server settings
|
||||
|
||||
$PAGE->set_url('/admin/index.php');
|
||||
$PAGE->set_pagelayout('admin'); // Set a default pagelayout
|
||||
|
||||
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
||||
|
||||
// Check some PHP server settings
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
|
||||
}
|
||||
|
||||
if (ini_get_bool('magic_quotes_runtime')) {
|
||||
print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink));
|
||||
}
|
||||
|
||||
if (!ini_get_bool('file_uploads')) {
|
||||
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
|
||||
}
|
||||
@@ -165,7 +114,7 @@ if (!core_tables_exist()) {
|
||||
$strinstallation = get_string('installation', 'install');
|
||||
|
||||
// remove current session content completely
|
||||
\core\session\manager::terminate_current();
|
||||
session_get_instance()->terminate_current();
|
||||
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
@@ -175,7 +124,6 @@ if (!core_tables_exist()) {
|
||||
$PAGE->set_heading($strinstallation);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_licence_page();
|
||||
die();
|
||||
@@ -190,7 +138,6 @@ if (!core_tables_exist()) {
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
|
||||
die();
|
||||
@@ -198,7 +145,7 @@ if (!core_tables_exist()) {
|
||||
|
||||
// check plugin dependencies
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
|
||||
$PAGE->set_title($strinstallation);
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
@@ -237,13 +184,6 @@ if (!core_tables_exist()) {
|
||||
// Check version of Moodle code on disk compared with database
|
||||
// and upgrade if possible.
|
||||
|
||||
if (!$cache) {
|
||||
// Do not try to do anything fancy in non-cached mode,
|
||||
// this prevents themes from fetching data from non-existent tables.
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
}
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
@@ -251,51 +191,33 @@ if (empty($CFG->version)) {
|
||||
print_error('missingconfigversion', 'debug');
|
||||
}
|
||||
|
||||
// Detect config cache inconsistency, this happens when you switch branches on dev servers.
|
||||
if ($CFG->version != $DB->get_field('config', 'value', array('name'=>'version'))) {
|
||||
purge_all_caches();
|
||||
redirect(new moodle_url('/admin/index.php'), 'Config cache inconsistency detected, resetting caches...');
|
||||
}
|
||||
|
||||
if (!$cache and $version > $CFG->version) { // upgrade
|
||||
|
||||
// Warning about upgrading a test site.
|
||||
$testsite = false;
|
||||
if (defined('BEHAT_SITE_RUNNING')) {
|
||||
$testsite = 'behat';
|
||||
}
|
||||
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
// We then purge the regular caches.
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
purge_all_caches();
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
if (upgrade_stale_php_files_present()) {
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_stale_php_files_page();
|
||||
die();
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = "$CFG->release (".sprintf('%.2f', $CFG->version).")";
|
||||
$a->newversion = "$release (".sprintf('%.2f', $version).")";
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_heading($strdatabasechecking);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
@@ -308,6 +230,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
|
||||
@@ -319,45 +242,45 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
|
||||
|
||||
if ($fetchupdates) {
|
||||
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
}
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($reloadurl, $reloadurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
||||
$version, $showallplugins, $reloadurl,
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1, 'cache'=>0)));
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Always verify plugin dependencies!
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// Launch main upgrade.
|
||||
if ($fetchupdates) {
|
||||
// no sesskey support guaranteed here
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
available_update_checker::instance()->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($reloadurl, $reloadurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins, $reloadurl,
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Launch main upgrade
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
} else if ($version < $CFG->version) {
|
||||
@@ -366,70 +289,62 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
}
|
||||
|
||||
// Updated human-readable release version if necessary
|
||||
if (!$cache and $release <> $CFG->release) { // Update the release version
|
||||
if ($release <> $CFG->release) { // Update the release version
|
||||
set_config('release', $release);
|
||||
}
|
||||
|
||||
if (!$cache and $branch <> $CFG->branch) { // Update the branch
|
||||
if ($branch <> $CFG->branch) { // Update the branch
|
||||
set_config('branch', $branch);
|
||||
}
|
||||
|
||||
if (!$cache and moodle_needs_upgrading()) {
|
||||
if (moodle_needs_upgrading()) {
|
||||
if (!$PAGE->headerprinted) {
|
||||
// means core upgrade or installation was not already done
|
||||
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
$PAGE->set_title($strplugincheck);
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
// no sesskey support guaranteed here
|
||||
available_update_checker::instance()->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($PAGE->url, $PAGE->url);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
require_sesskey();
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Show plugins info.
|
||||
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// dependencies check passed, let's rock!
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins,
|
||||
new moodle_url($PAGE->url),
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1, 'cache'=>0)));
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
||||
die();
|
||||
}
|
||||
|
||||
// Make sure plugin dependencies are always checked.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('cache' => 0));
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
}
|
||||
|
||||
// install/upgrade all plugins and other parts
|
||||
upgrade_noncore(true);
|
||||
}
|
||||
@@ -489,30 +404,8 @@ if (during_initial_install()) {
|
||||
upgrade_finished('upgradesettings.php');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:config', context_system::instance())) {
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
redirect(new moodle_url('/admin/index.php', array('cache' => 0)));
|
||||
}
|
||||
}
|
||||
|
||||
// Now we can be sure everything was upgraded and caches work fine,
|
||||
// redirect if necessary to make sure caching is enabled.
|
||||
if (!$cache) {
|
||||
redirect(new moodle_url('/admin/index.php', array('cache' => 1)));
|
||||
}
|
||||
|
||||
// Check for valid admin user - no guest autologin
|
||||
require_login(0, false);
|
||||
if (isguestuser()) {
|
||||
// Login as real user!
|
||||
$SESSION->wantsurl = (string)new moodle_url('/admin/index.php');
|
||||
redirect(get_login_url());
|
||||
}
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
@@ -541,68 +434,55 @@ if (any_new_admin_settings($adminroot)){
|
||||
redirect('upgradesettings.php');
|
||||
}
|
||||
|
||||
// Return to original page that started the plugin uninstallation if necessary.
|
||||
if (isset($SESSION->pluginuninstallreturn)) {
|
||||
$return = $SESSION->pluginuninstallreturn;
|
||||
unset($SESSION->pluginuninstallreturn);
|
||||
if ($return) {
|
||||
redirect($return);
|
||||
}
|
||||
}
|
||||
|
||||
// Everything should now be set up, and the user is an admin
|
||||
|
||||
// Print default admin page with notifications.
|
||||
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
||||
|
||||
// We make the assumption that at least one schedule task should run once per day.
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastruntime) FROM {task_scheduled}');
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
|
||||
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
||||
$dbproblems = $DB->diagnose();
|
||||
$maintenancemode = !empty($CFG->maintenance_enabled);
|
||||
|
||||
// Available updates for Moodle core.
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
// Available updates for Moodle core
|
||||
$updateschecker = available_update_checker::instance();
|
||||
$availableupdates = array();
|
||||
$availableupdatesfetch = null;
|
||||
$availableupdates['core'] = $updateschecker->get_update_info('core',
|
||||
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
|
||||
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
// Only compute the update information when it is going to be displayed to the user.
|
||||
$availableupdates['core'] = $updateschecker->get_update_info('core',
|
||||
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
|
||||
|
||||
// Available updates for contributed plugins
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
|
||||
foreach ($plugintypeinstances as $pluginname => $plugininfo) {
|
||||
if (!empty($plugininfo->availableupdates)) {
|
||||
foreach ($plugininfo->availableupdates as $pluginavailableupdate) {
|
||||
if ($pluginavailableupdate->version > $plugininfo->versiondisk) {
|
||||
if (!isset($availableupdates[$plugintype.'_'.$pluginname])) {
|
||||
$availableupdates[$plugintype.'_'.$pluginname] = array();
|
||||
}
|
||||
$availableupdates[$plugintype.'_'.$pluginname][] = $pluginavailableupdate;
|
||||
// Available updates for contributed plugins
|
||||
$pluginman = plugin_manager::instance();
|
||||
foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
|
||||
foreach ($plugintypeinstances as $pluginname => $plugininfo) {
|
||||
if (!empty($plugininfo->availableupdates)) {
|
||||
foreach ($plugininfo->availableupdates as $pluginavailableupdate) {
|
||||
if ($pluginavailableupdate->version > $plugininfo->versiondisk) {
|
||||
if (!isset($availableupdates[$plugintype.'_'.$pluginname])) {
|
||||
$availableupdates[$plugintype.'_'.$pluginname] = array();
|
||||
}
|
||||
$availableupdates[$plugintype.'_'.$pluginname][] = $pluginavailableupdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The timestamp of the most recent check for available updates
|
||||
$availableupdatesfetch = $updateschecker->get_last_timefetched();
|
||||
}
|
||||
|
||||
// The timestamp of the most recent check for available updates
|
||||
$availableupdatesfetch = $updateschecker->get_last_timefetched();
|
||||
|
||||
$buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
|
||||
//check if the site is registered on Moodle.org
|
||||
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
|
||||
// Check if there are any cache warnings.
|
||||
$cachewarnings = cache_helper::warnings();
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
|
||||
/* @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
|
||||
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered, $cachewarnings);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered);
|
||||
|
||||
+12
-1
@@ -18,7 +18,7 @@
|
||||
/**
|
||||
* This file contains functions used by the admin pages
|
||||
*
|
||||
* @since Moodle 2.1
|
||||
* @since 2.1
|
||||
* @package admin
|
||||
* @copyright 2011 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -35,5 +35,16 @@ function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
'admin-*' => get_string('page-admin-x', 'pagetype'),
|
||||
$pagetype => get_string('page-admin-current', 'pagetype')
|
||||
);
|
||||
// Add the missing * (any page) option for them. MDL-30340
|
||||
// TODO: These pages are really 'pagetype-varying' - MDL-30564 -
|
||||
// and some day we should stop behaving that way, so proper pagetypes
|
||||
// can be specified for it (like course-category-* or so).
|
||||
// Luckly... the option we are introducing '*' is independent
|
||||
// of that varying behavior, so will work.
|
||||
if ($pagetype == 'admin-course-category') {
|
||||
$array += array(
|
||||
'*' => get_string('page-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
+42
-10
@@ -33,21 +33,55 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managelocalplugins');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('localplugindeleteconfirm', '', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('local', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['local'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
/// Print the table of all installed local plugins
|
||||
|
||||
$table = new flexible_table('localplugins_administration_table');
|
||||
$table->define_columns(array('name', 'version', 'uninstall'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('uninstallplugin', 'core_admin')));
|
||||
$table->define_columns(array('name', 'version', 'delete'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'localplugins');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('local') as $plugin => $plugindir) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $plugin);
|
||||
} else {
|
||||
@@ -55,13 +89,11 @@ foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
core_collator::asort($plugins);
|
||||
collatorlib::asort($plugins);
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('local_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
|
||||
}
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
|
||||
$version = get_config('local_' . $plugin);
|
||||
if (!empty($version->version)) {
|
||||
@@ -70,7 +102,7 @@ foreach ($plugins as $plugin => $name) {
|
||||
$version = '?';
|
||||
}
|
||||
|
||||
$table->add_data(array($name, $version, $uninstall));
|
||||
$table->add_data(array($name, $version, $delete));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
+28
-4
@@ -34,6 +34,8 @@ require_capability('moodle/site:config', context_system::instance());
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
$uninstall = optional_param('uninstall', 0, PARAM_INT);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
$headingtitle = get_string('managemessageoutputs', 'message');
|
||||
|
||||
@@ -42,7 +44,6 @@ if (!empty($disable) && confirm_sesskey()) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if (!empty($enable) && confirm_sesskey()) {
|
||||
@@ -50,10 +51,33 @@ if (!empty($enable) && confirm_sesskey()) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if ($disable || $enable) {
|
||||
if (!empty($uninstall) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
|
||||
$processorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
message_processor_uninstall($processor->name);
|
||||
$a = new stdClass();
|
||||
$a->processor = $processorname;
|
||||
$a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
|
||||
notice(get_string('processordeletefiles', 'message', $a), 'message.php');
|
||||
}
|
||||
}
|
||||
|
||||
if ($disable || $enable || $uninstall) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
@@ -71,4 +95,4 @@ $messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -16,6 +16,8 @@ require_login();
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
@@ -63,11 +65,9 @@ if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
if ($accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
} else if ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('uset'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
} elseif ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -103,7 +103,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
$usernames = explode(',', $form->username);
|
||||
|
||||
foreach ($usernames as $username) {
|
||||
$username = trim(core_text::strtolower($username));
|
||||
$username = trim(textlib::strtolower($username));
|
||||
if (!empty($username)) {
|
||||
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
|
||||
if ($form->accessctrl == 'allow') {
|
||||
@@ -118,8 +118,6 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Explain
|
||||
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
|
||||
// Are the needed bits enabled?
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
@@ -106,7 +106,7 @@
|
||||
</table>
|
||||
</form>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
|
||||
@@ -78,13 +78,9 @@ class mnet_review_host_form extends moodleform {
|
||||
$mnet_peer = $this->_customdata['peer'];
|
||||
|
||||
$mform->addElement('hidden', 'last_connect_time');
|
||||
$mform->setType('last_connect_time', PARAM_INT);
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('hidden', 'applicationid');
|
||||
$mform->setType('applicationid', PARAM_INT);
|
||||
$mform->addElement('hidden', 'oldpublickey');
|
||||
$mform->setType('oldpublickey', PARAM_PEM);
|
||||
|
||||
$mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
|
||||
$mform->setType('name', PARAM_NOTAGS);
|
||||
@@ -95,7 +91,7 @@ class mnet_review_host_form extends moodleform {
|
||||
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$themes = array('' => get_string('forceno'));
|
||||
foreach (array_keys(core_component::get_plugin_list('theme')) as $themename) {
|
||||
foreach (array_keys(get_plugin_list('theme')) as $themename) {
|
||||
$themes[$themename] = get_string('pluginname', 'theme_'.$themename);
|
||||
}
|
||||
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
|
||||
@@ -152,7 +148,6 @@ class mnet_review_host_form extends moodleform {
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
$mform->setType('deleted', PARAM_BOOL);
|
||||
}
|
||||
|
||||
// finished with static stuff, print save button
|
||||
|
||||
@@ -50,8 +50,6 @@ class mnet_profile_form extends moodleform {
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$fields = mnet_profile_field_options();
|
||||
|
||||
// Fields to import ----------------------------------------------------
|
||||
|
||||
@@ -39,7 +39,6 @@ class mnet_services_form extends moodleform {
|
||||
$myservices = mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$count = 0;
|
||||
foreach ($myservices as $name => $versions) {
|
||||
@@ -56,8 +55,6 @@ class mnet_services_form extends moodleform {
|
||||
$mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
|
||||
|
||||
$mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
|
||||
// Temporary fix until MDL-38885 gets integrated.
|
||||
$mform->setType('exists', PARAM_BOOL);
|
||||
|
||||
$pubstr = get_string('publish','mnet');
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
|
||||
+61
-30
@@ -13,12 +13,14 @@
|
||||
|
||||
$show = optional_param('show', '', PARAM_PLUGIN);
|
||||
$hide = optional_param('hide', '', PARAM_PLUGIN);
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stractivities = get_string("activities");
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
$strdelete = get_string("delete");
|
||||
$strversion = get_string("version");
|
||||
$strhide = get_string("hide");
|
||||
$strshow = get_string("show");
|
||||
@@ -40,14 +42,14 @@
|
||||
SET visibleold=visible, visible=0
|
||||
WHERE module=?";
|
||||
$DB->execute($sql, array($module->id));
|
||||
// Increment course.cacherev for courses where we just made something invisible.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just deleted something
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visibleold=1 AND module=?)",
|
||||
array($module->id));
|
||||
core_plugin_manager::reset_caches();
|
||||
WHERE visibleold=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -57,17 +59,49 @@
|
||||
}
|
||||
$DB->set_field("modules", "visible", "1", array("id"=>$module->id)); // Show main module
|
||||
$DB->set_field('course_modules', 'visible', '1', array('visibleold'=>1, 'module'=>$module->id)); // Get the previous saved visible state for the course module.
|
||||
// Increment course.cacherev for courses where we just made something visible.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just made something visible
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo = ''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visible=1 AND module=?)",
|
||||
array($module->id));
|
||||
core_plugin_manager::reset_caches();
|
||||
WHERE visible=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
|
||||
if (get_string_manager()->string_exists('modulename', $delete)) {
|
||||
$strmodulename = get_string('modulename', $delete);
|
||||
} else {
|
||||
$strmodulename = $delete;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "forum") {
|
||||
print_error("cannotdeleteforummodule", 'forum');
|
||||
}
|
||||
|
||||
uninstall_plugin('mod', $delete);
|
||||
$a = new stdClass();
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
|
||||
@@ -80,11 +114,11 @@
|
||||
/// Print the table of all modules
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(MODULE_TABLE);
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'uninstall', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strsettings, $struninstall));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
|
||||
$table->set_attribute('id', 'modules');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable');
|
||||
$table->setup();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
@@ -99,10 +133,7 @@
|
||||
$missing = false;
|
||||
}
|
||||
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('mod_'.$module->name, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=".sesskey()."\">$strdelete</a>";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") ||
|
||||
file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) {
|
||||
@@ -135,23 +166,23 @@
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=".sesskey()."\" title=\"$strshow\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"$strshow\" /></a>";
|
||||
$class = 'dimmed_text';
|
||||
$class = ' class="dimmed_text"';
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$uninstall = "";
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$version = get_config('mod_'.$module->name, 'version');
|
||||
|
||||
|
||||
$table->add_data(array(
|
||||
$strmodulename,
|
||||
'<span'.$class.'>'.$strmodulename.'</span>',
|
||||
$countlink,
|
||||
$version,
|
||||
'<span'.$class.'>'.$module->version.'</span>',
|
||||
$visible,
|
||||
$settings,
|
||||
$uninstall,
|
||||
), $class);
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
if (!isset($CFG)) {
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('oacleanup');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
online_assignment_cleanup(true);
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function online_assignment_cleanup($output=false) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
if ($output) {
|
||||
echo $OUTPUT->heading('Online Assignment Cleanup');
|
||||
echo '<center>';
|
||||
}
|
||||
|
||||
|
||||
/// We don't want to run this code if we are doing an upgrade from an assignment
|
||||
/// version earlier than 2005041400
|
||||
/// because the assignment type field will not exist
|
||||
$amv = $DB->get_field('modules', 'version', array('name'=>'assignment'));
|
||||
if ((int)$amv < 2005041400) {
|
||||
if ($output) {
|
||||
echo '</center>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/// get the module id for assignments from db
|
||||
$arecord = $DB->get_record('modules', array('name', 'assignment'));
|
||||
$aid = $arecord->id;
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.* $ctxselect FROM {course} c $ctxjoin";
|
||||
$courses = $DB->get_records_sql($sql);
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
context_instance_preload($course);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
if (empty($course->fullname)) {
|
||||
$fullname = get_string('course').': '.$course->id;
|
||||
} else {
|
||||
$fullname = format_string($course->fullname, true, array('context' => $context));
|
||||
}
|
||||
if ($output) echo $OUTPUT->heading($fullname);
|
||||
|
||||
/// retrieve a list of sections beyond what is currently being shown
|
||||
$courseformatoptions = course_get_format($course)->get_format_options();
|
||||
if (!isset($courseformatoptions['numsections'])) {
|
||||
// Course format does not use numsections
|
||||
if ($output) {
|
||||
echo 'No extra sections<br />';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$sql = "SELECT *
|
||||
FROM {course_sections}
|
||||
WHERE course=? AND section>?
|
||||
ORDER BY section ASC";
|
||||
$params = array($course->id, $courseformatoptions['numsections']);
|
||||
if (!($xsections = $DB->get_records_sql($sql, $params))) {
|
||||
if ($output) echo 'No extra sections<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// cycle through each of the xtra sections
|
||||
foreach ($xsections as $xsection) {
|
||||
|
||||
if ($output) echo 'Checking Section: '.$xsection->section.'<br />';
|
||||
|
||||
/// grab any module instances from the sequence field
|
||||
if (!empty($xsection->sequence)) {
|
||||
$instances = explode(',', $xsection->sequence);
|
||||
|
||||
/// cycle through the instances
|
||||
foreach ($instances as $instance) {
|
||||
/// is this an instance of an online assignment
|
||||
$sql = "SELECT a.id
|
||||
FROM {course_modules} cm, {assignment} a
|
||||
WHERE cm.id = ? AND cm.module = ? AND
|
||||
cm.instance = a.id AND a.assignmenttype = 'online'";
|
||||
$params = array($instance, $aid);
|
||||
|
||||
/// if record exists then we need to move instance to it's correct section
|
||||
if ($DB->record_exists_sql($sql, $params)) {
|
||||
|
||||
/// check the new section id
|
||||
/// the journal update erroneously stored it in course_sections->section
|
||||
$newsection = $xsection->section;
|
||||
/// double check the new section
|
||||
if ($newsection > $courseformatoptions['numsections']) {
|
||||
/// get the record for section 0 for this course
|
||||
if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
|
||||
continue;
|
||||
}
|
||||
$newsection = $zerosection->id;
|
||||
}
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
|
||||
if ($output) {
|
||||
echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. $fullname .'<br />';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// add instance to correct section
|
||||
array_push($sequence, $instance);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
|
||||
|
||||
/// now we need to remove the instance from the old sequence
|
||||
|
||||
/// grab the old section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// remove the old value from the array
|
||||
$key = array_search($instance, $sequence);
|
||||
unset($sequence[$key]);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
|
||||
|
||||
|
||||
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// if the summary and sequence are empty then remove this section
|
||||
if (empty($xsection->summary) and empty($xsection->sequence)) {
|
||||
$DB->delete_records('course_sections', array('id'=>$xsection->id));
|
||||
if ($output) echo 'Deleting empty section '.$xsection->section.'<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
|
||||
+40
-12
@@ -18,7 +18,7 @@
|
||||
* Provides an overview of installed plagiarism plugins
|
||||
*
|
||||
* Displays the list of found plagiarism plugins, their version (if found) and
|
||||
* a link to uninstall the plagiarism plugin.
|
||||
* a link to delete the plagiarism plugin.
|
||||
*
|
||||
* @see http://docs.moodle.org/dev/Plagiarism_API
|
||||
* @package admin
|
||||
@@ -30,17 +30,47 @@ require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
|
||||
admin_externalpage_setup('manageplagiarismplugins');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) { // If data submitted, then process and store.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('manageplagiarism', 'plagiarism'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'plagiarism_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'plagiarism_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('plagiarismplugindeleteconfirm', 'plagiarism', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('plagiarism', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['plagiarism'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print the table of all installed plagiarism plugins.
|
||||
|
||||
$txt = get_strings(array('settings', 'name', 'version'));
|
||||
$txt->uninstall = get_string('uninstallplugin', 'core_admin');
|
||||
$txt = get_strings(array('settings', 'name', 'version', 'delete'));
|
||||
|
||||
$plagiarismplugins = core_component::get_plugin_list('plagiarism');
|
||||
$plagiarismplugins = get_plugin_list('plagiarism');
|
||||
if (empty($plagiarismplugins)) {
|
||||
echo $OUTPUT->notification(get_string('nopluginsinstalled', 'plagiarism'));
|
||||
echo $OUTPUT->footer();
|
||||
@@ -51,7 +81,7 @@ echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
|
||||
echo $OUTPUT->box_start('generalbox authsui');
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array($txt->name, $txt->version, $txt->uninstall, $txt->settings);
|
||||
$table->head = array($txt->name, $txt->version, $txt->delete, $txt->settings);
|
||||
$table->colclasses = array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align');
|
||||
$table->data = array();
|
||||
$table->attributes['class'] = 'manageplagiarismtable generaltable';
|
||||
@@ -71,12 +101,10 @@ foreach ($plagiarismplugins as $plugin => $dir) {
|
||||
} else {
|
||||
$version = '?';
|
||||
}
|
||||
// uninstall link.
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $txt->uninstall);
|
||||
}
|
||||
$table->data[] = array($displayname, $version, $uninstall, $settings);
|
||||
// Delete link.
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
$table->data[] = array($displayname, $version, $delete, $settings);
|
||||
}
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
+10
-150
@@ -18,15 +18,6 @@
|
||||
/**
|
||||
* UI for general plugins management
|
||||
*
|
||||
* Supported HTTP parameters:
|
||||
*
|
||||
* ?fetchremote=1 - check for available updates
|
||||
* ?updatesonly=1 - display plugins with available update only
|
||||
* ?contribonly=1 - display non-standard add-ons only
|
||||
* ?uninstall=foo_bar - uninstall the given plugin
|
||||
* ?delete=foo_bar - delete the plugin folder (it must not be installed)
|
||||
* &confirm=1 - confirm the uninstall or delete action
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
@@ -35,150 +26,17 @@
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
|
||||
$updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
|
||||
$contribonly = optional_param('contribonly', false, PARAM_BOOL);
|
||||
$uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
|
||||
$delete = optional_param('delete', '', PARAM_COMPONENT);
|
||||
$confirmed = optional_param('confirm', false, PARAM_BOOL);
|
||||
$return = optional_param('return', 'overview', PARAM_ALPHA);
|
||||
|
||||
// NOTE: do not use admin_externalpage_setup() here because it loads
|
||||
// full admin tree which is not possible during uninstallation.
|
||||
|
||||
require_login();
|
||||
$syscontext = context_system::instance();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
|
||||
if ($uninstall) {
|
||||
require_sesskey();
|
||||
|
||||
if (!$confirmed) {
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
} else {
|
||||
$PAGE->set_url('/admin/plugins.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
}
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$pluginfo = $pluginman->get_plugin_info($uninstall);
|
||||
|
||||
// Make sure we know the plugin.
|
||||
if (is_null($pluginfo)) {
|
||||
throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $uninstall),
|
||||
'core_plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
|
||||
}
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
$PAGE->set_title($pluginname);
|
||||
$PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
|
||||
throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component),
|
||||
'core_plugin_manager::can_uninstall_plugin() returned false');
|
||||
}
|
||||
|
||||
if (!$confirmed) {
|
||||
$continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1, 'return'=>$return));
|
||||
$cancelurl = $pluginfo->get_return_url_after_uninstall($return);
|
||||
echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl, $cancelurl);
|
||||
exit();
|
||||
|
||||
} else {
|
||||
$SESSION->pluginuninstallreturn = $pluginfo->get_return_url_after_uninstall($return);
|
||||
$progress = new progress_trace_buffer(new text_progress_trace(), false);
|
||||
$pluginman->uninstall_plugin($pluginfo->component, $progress);
|
||||
$progress->finished();
|
||||
|
||||
if ($pluginman->is_plugin_folder_removable($pluginfo->component)) {
|
||||
$continueurl = new moodle_url($PAGE->url, array('delete' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
|
||||
echo $output->plugin_uninstall_results_removable_page($pluginman, $pluginfo, $progress, $continueurl);
|
||||
// Reset op code caches.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
exit();
|
||||
|
||||
} else {
|
||||
echo $output->plugin_uninstall_results_page($pluginman, $pluginfo, $progress);
|
||||
// Reset op code caches.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete and $confirmed) {
|
||||
require_sesskey();
|
||||
|
||||
$PAGE->set_url('/admin/plugins.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$pluginfo = $pluginman->get_plugin_info($delete);
|
||||
|
||||
// Make sure we know the plugin.
|
||||
if (is_null($pluginfo)) {
|
||||
throw new moodle_exception('err_removing_unknown_plugin', 'core_plugin', '', array('plugin' => $delete),
|
||||
'core_plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
|
||||
}
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
$PAGE->set_title($pluginname);
|
||||
$PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
// Make sure it is not installed.
|
||||
if (!is_null($pluginfo->versiondb)) {
|
||||
throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'versiondb' => $pluginfo->versiondb),
|
||||
'core_plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
|
||||
}
|
||||
|
||||
// Make sure the folder is removable.
|
||||
if (!$pluginman->is_plugin_folder_removable($pluginfo->component)) {
|
||||
throw new moodle_exception('err_removing_unremovable_folder', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir),
|
||||
'plugin root folder is not removable as expected');
|
||||
}
|
||||
|
||||
// Make sure the folder is within Moodle installation tree.
|
||||
if (strpos($pluginfo->rootdir, $CFG->dirroot) !== 0) {
|
||||
throw new moodle_exception('err_unexpected_plugin_rootdir', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir, 'dirroot' => $CFG->dirroot),
|
||||
'plugin root folder not in the moodle dirroot');
|
||||
}
|
||||
|
||||
// So long, and thanks for all the bugs.
|
||||
fulldelete($pluginfo->rootdir);
|
||||
// Reset op code caches.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
// We need to execute upgrade to make sure everything including caches is up to date.
|
||||
redirect(new moodle_url('/admin/index.php'));
|
||||
}
|
||||
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$checker = \core\update\checker::instance();
|
||||
$pluginman = plugin_manager::instance();
|
||||
$checker = available_update_checker::instance();
|
||||
|
||||
// Filtering options.
|
||||
$options = array(
|
||||
@@ -192,10 +50,12 @@ if ($fetchremote) {
|
||||
redirect(new moodle_url($PAGE->url, $options));
|
||||
}
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
|
||||
$deployer->initialize($myurl, new moodle_url('/admin'));
|
||||
$deployer->initialize($myurl, $myurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
|
||||
+1
-3
@@ -88,7 +88,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
} else {
|
||||
portfolio_static_function($plugin, 'create_instance', $plugin, $fromform->name, $fromform);
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
$savedstr = get_string('instancesaved', 'portfolio');
|
||||
redirect($baseurl, $savedstr, 1);
|
||||
exit;
|
||||
@@ -117,7 +116,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
$instance->set('visible', $visible);
|
||||
$instance->save();
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if ($action == 'delete') {
|
||||
$instance = portfolio_instance($portfolio);
|
||||
@@ -162,7 +160,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
$output = $OUTPUT->box_start('generalbox');
|
||||
|
||||
$plugins = core_component::get_plugin_list('portfolio');
|
||||
$plugins = get_plugin_list('portfolio');
|
||||
$plugins = array_keys($plugins);
|
||||
$instances = portfolio_instances(false, false);
|
||||
$usedplugins = array();
|
||||
|
||||
+72
-11
@@ -28,6 +28,7 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
// Check permissions.
|
||||
@@ -38,8 +39,8 @@ require_capability('moodle/question:config', $systemcontext);
|
||||
admin_externalpage_setup('manageqbehaviours');
|
||||
$thispageurl = new moodle_url('/admin/qbehaviours.php');
|
||||
|
||||
$behaviours = core_component::get_plugin_list('qbehaviour');
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
$behaviours = get_plugin_list('qbehaviour');
|
||||
$pluginmanager = plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql_menu("
|
||||
@@ -91,7 +92,6 @@ if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey(
|
||||
$disabledbehaviours[] = $disable;
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey())
|
||||
unset($disabledbehaviours[$key]);
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
@@ -137,6 +136,70 @@ if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missing') {
|
||||
print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
|
||||
}
|
||||
|
||||
if (!isset($behaviours[$delete])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $delete);
|
||||
}
|
||||
|
||||
$behaviourname = $sortedbehaviours[$delete];
|
||||
if ($counts[$delete] > 0) {
|
||||
print_error('cannotdeletebehaviourinuse', 'question', $thispageurl, $behaviourname);
|
||||
}
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
|
||||
echo $OUTPUT->confirm(
|
||||
get_string('deletebehaviourareyousuremessage', 'question', $behaviourname),
|
||||
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
|
||||
$thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete));
|
||||
}
|
||||
if (($key = array_search($delete, $disabledbehaviours)) !== false) {
|
||||
unset($disabledbehaviours[$key]);
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
$behaviourorder = array_keys($sortedbehaviours);
|
||||
if (($key = array_search($delete, $behaviourorder)) !== false) {
|
||||
unset($behaviourorder[$key]);
|
||||
set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qbehaviour_' . $delete);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->behaviour = $behaviourname;
|
||||
$a->directory = get_plugin_directory('qbehaviour', $delete);
|
||||
echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
// Print the page heading.
|
||||
@@ -147,12 +210,12 @@ echo $OUTPUT->heading(get_string('manageqbehaviours', 'admin'));
|
||||
$table = new flexible_table('qbehaviouradmintable');
|
||||
$table->define_baseurl($thispageurl);
|
||||
$table->define_columns(array('behaviour', 'numqas', 'version', 'requires',
|
||||
'available', 'uninstall'));
|
||||
'available', 'delete'));
|
||||
$table->define_headers(array(get_string('behaviour', 'question'), get_string('numqas', 'question'),
|
||||
get_string('version'), get_string('requires', 'admin'),
|
||||
get_string('availableq', 'question'), get_string('uninstallplugin', 'core_admin')));
|
||||
get_string('availableq', 'question'), get_string('delete')));
|
||||
$table->set_attribute('id', 'qbehaviours');
|
||||
$table->set_attribute('class', 'generaltable admintable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
@@ -207,11 +270,9 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
|
||||
if ($needed[$behaviour]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qbehaviour_'.$behaviour, 'manage');
|
||||
if ($uninstallurl) {
|
||||
$row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
|
||||
$row[] = html_writer::link(new moodle_url($thispageurl,
|
||||
array('delete' => $behaviour, 'sesskey' => sesskey())), get_string('delete'),
|
||||
array('title' => get_string('uninstallbehaviour', 'question')));
|
||||
}
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
|
||||
+72
-15
@@ -28,6 +28,7 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
// Check permissions.
|
||||
@@ -40,7 +41,7 @@ admin_externalpage_setup('manageqtypes');
|
||||
$thispageurl = new moodle_url('/admin/qtypes.php');
|
||||
|
||||
$qtypes = question_bank::get_all_qtypes();
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
$pluginmanager = plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql("
|
||||
@@ -121,6 +122,64 @@ if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missingtype') {
|
||||
print_error('cannotdeletemissingqtype', 'question', $thispageurl);
|
||||
}
|
||||
|
||||
if (!isset($qtypes[$delete])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $delete);
|
||||
}
|
||||
|
||||
$qtypename = $qtypes[$delete]->local_name();
|
||||
if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
|
||||
print_error('cannotdeleteqtypeinuse', 'question', $thispageurl, $qtypename);
|
||||
}
|
||||
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteqtypeneeded', 'question', $thispageurl, $qtypename);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$qtypename = $qtypes[$delete]->local_name();
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
|
||||
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename),
|
||||
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
|
||||
$thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
|
||||
}
|
||||
unset_config($delete . '_disabled', 'question');
|
||||
unset_config($delete . '_sortorder', 'question');
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qtype_' . $delete);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->qtype = $qtypename;
|
||||
$a->directory = $qtypes[$delete]->plugin_dir();
|
||||
echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
// Print the page heading.
|
||||
@@ -131,12 +190,12 @@ echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
|
||||
$table = new flexible_table('qtypeadmintable');
|
||||
$table->define_baseurl($thispageurl);
|
||||
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
|
||||
'availableto', 'uninstall', 'settings'));
|
||||
'availableto', 'delete', 'settings'));
|
||||
$table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'),
|
||||
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
|
||||
get_string('settings'), get_string('uninstallplugin', 'core_admin')));
|
||||
get_string('delete'), get_string('settings')));
|
||||
$table->set_attribute('id', 'qtypes');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
@@ -206,6 +265,15 @@ foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
|
||||
$row[] = $icons;
|
||||
|
||||
// Delete link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$row[] = html_writer::link(new moodle_url($thispageurl,
|
||||
array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'),
|
||||
array('title' => get_string('uninstallqtype', 'question')));
|
||||
}
|
||||
|
||||
// Settings link, if available.
|
||||
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
|
||||
if ($settings instanceof admin_externalpage) {
|
||||
@@ -217,17 +285,6 @@ foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Uninstall link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qtype_'.$qtypename, 'manage');
|
||||
if ($uninstallurl) {
|
||||
$row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
|
||||
array('title' => get_string('uninstallqtype', 'question')));
|
||||
}
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
$registeredhub->hubname = $hubname;
|
||||
$registrationmanager->update_registeredhub($registeredhub);
|
||||
|
||||
// Display notification message.
|
||||
//display notficiation message
|
||||
$notificationmessage = $OUTPUT->notification(
|
||||
get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
|
||||
echo $notificationmessage;
|
||||
|
||||
@@ -49,10 +49,8 @@ class site_unregistration_form extends moodleform {
|
||||
$unregisterlabel = get_string('unregister', 'hub');
|
||||
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
|
||||
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
|
||||
$mform->setType('unpublishalladvertisedcourses', PARAM_INT);
|
||||
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
|
||||
' ' . get_string('unpublishalluploadedcourses', 'hub'));
|
||||
$mform->setType('unpublishalluploadedcourses', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
@@ -84,6 +82,7 @@ class site_clean_registration_data_form extends moodleform {
|
||||
$unregisterlabel = get_string('forceunregister', 'hub');
|
||||
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
$mform->addElement('hidden', 'unregistration', 1);
|
||||
@@ -137,8 +136,8 @@ class hub_selector_form extends moodleform {
|
||||
$options = array();
|
||||
foreach ($hubs as $hub) {
|
||||
//to not display a name longer than 100 character (too big)
|
||||
if (core_text::strlen($hub['name']) > 100) {
|
||||
$hubname = core_text::substr($hub['name'], 0, 100);
|
||||
if (textlib::strlen($hub['name']) > 100) {
|
||||
$hubname = textlib::substr($hub['name'], 0, 100);
|
||||
$hubname = $hubname . "...";
|
||||
} else {
|
||||
$hubname = $hub['name'];
|
||||
@@ -150,7 +149,6 @@ class hub_selector_form extends moodleform {
|
||||
if (!empty($hubs)) {
|
||||
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
|
||||
$options, array("size" => 15));
|
||||
$mform->setType('publichub', PARAM_URL);
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
|
||||
@@ -158,10 +156,8 @@ class hub_selector_form extends moodleform {
|
||||
//Private hub
|
||||
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('unlistedurl', PARAM_URL);
|
||||
$mform->addElement('text', 'password', get_string('password'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
$this->add_action_buttons(false, get_string('selecthub', 'hub'));
|
||||
}
|
||||
@@ -175,8 +171,11 @@ class hub_selector_form extends moodleform {
|
||||
|
||||
$unlistedurl = $this->_form->_submitValues['unlistedurl'];
|
||||
|
||||
if (empty($unlistedurl)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
if (!empty($unlistedurl)) {
|
||||
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
|
||||
if (empty($unlistedurltotest)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
@@ -244,8 +243,6 @@ class site_registration_form extends moodleform {
|
||||
$postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
|
||||
$questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
|
||||
$resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
|
||||
$badgesnumber = get_config('hub', 'site_badges_' . $cleanhuburl);
|
||||
$issuedbadgesnumber = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
|
||||
$mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
|
||||
$participantnumberaveragecfg = get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl);
|
||||
$modulenumberaveragecfg = get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl);
|
||||
@@ -275,7 +272,6 @@ class site_registration_form extends moodleform {
|
||||
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
|
||||
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
|
||||
$mform->setDefault('privacy', $privacy);
|
||||
$mform->setType('privacy', PARAM_ALPHA);
|
||||
$mform->addHelpButton('privacy', 'privacy', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -287,7 +283,7 @@ class site_registration_form extends moodleform {
|
||||
$mform->addHelpButton('description', 'sitedesc', 'hub');
|
||||
|
||||
$languages = get_string_manager()->get_list_of_languages();
|
||||
core_collator::asort($languages);
|
||||
collatorlib::asort($languages);
|
||||
$mform->addElement('select', 'language', get_string('sitelang', 'hub'),
|
||||
$languages);
|
||||
$mform->setType('language', PARAM_ALPHANUMEXT);
|
||||
@@ -309,13 +305,11 @@ class site_registration_form extends moodleform {
|
||||
$countries = get_string_manager()->get_list_of_countries();
|
||||
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
|
||||
$mform->setDefault('countrycode', $country);
|
||||
$mform->setType('countrycode', PARAM_ALPHANUMEXT);
|
||||
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');
|
||||
|
||||
$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setDefault('geolocation', $geolocation);
|
||||
$mform->setType('geolocation', PARAM_RAW);
|
||||
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
|
||||
|
||||
$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
|
||||
@@ -333,7 +327,7 @@ class site_registration_form extends moodleform {
|
||||
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('contactemail', PARAM_EMAIL);
|
||||
$mform->setType('contactemail', PARAM_TEXT);
|
||||
$mform->setDefault('contactemail', $contactemail);
|
||||
$mform->addHelpButton('contactemail', 'siteemail', 'hub');
|
||||
|
||||
@@ -342,7 +336,6 @@ class site_registration_form extends moodleform {
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
|
||||
$mform->setDefault('contactable', $contactable);
|
||||
$mform->setType('contactable', PARAM_INT);
|
||||
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -351,7 +344,6 @@ class site_registration_form extends moodleform {
|
||||
$options[1] = get_string("registrationyes");
|
||||
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
|
||||
$mform->setDefault('emailalert', $emailalert);
|
||||
$mform->setType('emailalert', PARAM_INT);
|
||||
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -382,111 +374,80 @@ class site_registration_form extends moodleform {
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
$participantnumberaverage = number_format(average_number_of_participants(), 2);
|
||||
$modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
|
||||
$issuedbadges = $DB->count_records('badge_issued');
|
||||
|
||||
if (HUB_MOODLEORGHUBURL != $huburl) {
|
||||
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->setDefault('courses', $coursesnumber != -1);
|
||||
$mform->setType('courses', PARAM_INT);
|
||||
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('checkbox', 'users', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->setDefault('users', $usersnumber != -1);
|
||||
$mform->setType('users', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'roleassignments', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->setDefault('roleassignments', $roleassignmentsnumber != -1);
|
||||
$mform->setType('roleassignments', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'posts', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->setDefault('posts', $postsnumber != -1);
|
||||
$mform->setType('posts', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'questions', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->setDefault('questions', $questionsnumber != -1);
|
||||
$mform->setType('questions', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'resources', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->setDefault('resources', $resourcesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'badges', '',
|
||||
" " . get_string('badgesnumber', 'hub', $badges));
|
||||
$mform->setDefault('badges', $badgesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'issuedbadges', '',
|
||||
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
|
||||
$mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'participantnumberaverage', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->setDefault('participantnumberaverage', $participantnumberaveragecfg != -1);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('checkbox', 'modulenumberaverage', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
} else {
|
||||
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->addElement('hidden', 'courses', 1);
|
||||
$mform->setType('courses', PARAM_INT);
|
||||
$mform->addElement('hidden', 'courses', true);
|
||||
$mform->setType('courses', PARAM_FLOAT);
|
||||
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('static', 'userslabel', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->addElement('hidden', 'users', 1);
|
||||
$mform->setType('users', PARAM_INT);
|
||||
$mform->addElement('hidden', 'users', true);
|
||||
$mform->setType('users', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'roleassignmentslabel', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->addElement('hidden', 'roleassignments', 1);
|
||||
$mform->setType('roleassignments', PARAM_INT);
|
||||
$mform->addElement('hidden', 'roleassignments', true);
|
||||
$mform->setType('roleassignments', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'postslabel', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->addElement('hidden', 'posts', 1);
|
||||
$mform->setType('posts', PARAM_INT);
|
||||
$mform->addElement('hidden', 'posts', true);
|
||||
$mform->setType('posts', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'questionslabel', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->addElement('hidden', 'questions', 1);
|
||||
$mform->setType('questions', PARAM_INT);
|
||||
$mform->addElement('hidden', 'questions', true);
|
||||
$mform->setType('questions', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'resourceslabel', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->addElement('hidden', 'resources', 1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('static', 'badgeslabel', '',
|
||||
" " . get_string('badgesnumber', 'hub', $badges));
|
||||
$mform->addElement('hidden', 'badges', 1);
|
||||
$mform->setType('badges', PARAM_INT);
|
||||
|
||||
$mform->addElement('static', 'issuedbadgeslabel', '',
|
||||
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
|
||||
$mform->addElement('hidden', 'issuedbadges', true);
|
||||
$mform->setType('issuedbadges', PARAM_INT);
|
||||
$mform->addElement('hidden', 'resources', true);
|
||||
$mform->setType('resources', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'participantnumberaveragelabel', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->addElement('hidden', 'participantnumberaverage', 1);
|
||||
$mform->addElement('hidden', 'participantnumberaverage', true);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'modulenumberaveragelabel', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->addElement('hidden', 'modulenumberaverage', 1);
|
||||
$mform->addElement('hidden', 'modulenumberaverage', true);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* On this page the administrator selects which hub he wants to register (except for moodle.net)
|
||||
* Admins can register with moodle.net via the site admin menu "Registration" link.
|
||||
* On this page the administrator can also unregister from any hubs including moodle.net.
|
||||
* On this page the administrator selects which hub he wants to register,
|
||||
* except for MOOCH. Admins can register with MOOCH with the top admin menu "Registration" link.
|
||||
* On this page the administrator can also unregister from any hubs, including MOOCH.
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
+22
-40
@@ -53,36 +53,32 @@ class registration_manager {
|
||||
public function cron() {
|
||||
global $CFG;
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
//check if the last registration cron update was less than a week ago
|
||||
$lastcron = get_config('registration', 'crontime');
|
||||
if ($lastcron > strtotime("-7 day")) { // Prevent this happening more than once a week.
|
||||
return;
|
||||
}
|
||||
if ($lastcron === false or $lastcron < strtotime("-7 day")) { //set to a week, see MDL-23704
|
||||
$function = 'hub_update_site_info';
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
|
||||
$function = 'hub_update_site_info';
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
|
||||
// Update all hubs where the site is registered.
|
||||
$hubs = $this->get_registered_on_hubs();
|
||||
if (empty($hubs)) {
|
||||
mtrace(get_string('registrationwarning', 'admin'));
|
||||
}
|
||||
foreach ($hubs as $hub) {
|
||||
// Update the registration.
|
||||
$siteinfo = $this->get_site_info($hub->huburl);
|
||||
$params = array('siteinfo' => $siteinfo);
|
||||
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
|
||||
} catch (Exception $e) {
|
||||
$errorparam = new stdClass();
|
||||
$errorparam->errormessage = $e->getMessage();
|
||||
$errorparam->hubname = $hub->hubname;
|
||||
mtrace(get_string('errorcron', 'hub', $errorparam));
|
||||
//update all hub where the site is registered on
|
||||
$hubs = $this->get_registered_on_hubs();
|
||||
foreach ($hubs as $hub) {
|
||||
//update the registration
|
||||
$siteinfo = $this->get_site_info($hub->huburl);
|
||||
$params = array('siteinfo' => $siteinfo);
|
||||
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
|
||||
} catch (Exception $e) {
|
||||
$errorparam = new stdClass();
|
||||
$errorparam->errormessage = $e->getMessage();
|
||||
$errorparam->hubname = $hub->hubname;
|
||||
mtrace(get_string('errorcron', 'hub', $errorparam));
|
||||
}
|
||||
}
|
||||
set_config('crontime', time(), 'registration');
|
||||
}
|
||||
set_config('crontime', time(), 'registration');
|
||||
} else {
|
||||
mtrace(get_string('errorcronnoxmlrpc', 'hub'));
|
||||
}
|
||||
@@ -251,20 +247,6 @@ class registration_manager {
|
||||
$resourcecount = $DB->count_records('resource');
|
||||
}
|
||||
$siteinfo['resources'] = $resourcecount;
|
||||
// Badge statistics.
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
if (get_config('hub', 'site_badges_' . $cleanhuburl) == -1) {
|
||||
$badges = -1;
|
||||
} else {
|
||||
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
|
||||
}
|
||||
$siteinfo['badges'] = $badges;
|
||||
if (get_config('hub', 'site_issuedbadges_' . $cleanhuburl) == -1) {
|
||||
$issuedbadges = -1;
|
||||
} else {
|
||||
$issuedbadges = $DB->count_records('badge_issued');
|
||||
}
|
||||
$siteinfo['issuedbadges'] = $issuedbadges;
|
||||
//TODO
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
if (get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl) == -1) {
|
||||
|
||||
@@ -39,8 +39,6 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
|
||||
require_sesskey();
|
||||
|
||||
$huburl = required_param('huburl', PARAM_URL);
|
||||
$huburl = rtrim($huburl, "/");
|
||||
|
||||
@@ -68,7 +66,7 @@ if (!empty($fromform) and confirm_sesskey()) {
|
||||
// Set to -1 all optional data marked as "don't send" by the admin.
|
||||
// The function get_site_info() will not calculate the optional data if config is set to -1.
|
||||
$inputnames = array('courses', 'users', 'roleassignments', 'posts', 'questions', 'resources',
|
||||
'badges', 'issuedbadges', 'modulenumberaverage', 'participantnumberaverage');
|
||||
'modulenumberaverage', 'participantnumberaverage');
|
||||
foreach ($inputnames as $inputname) {
|
||||
if (empty($fromform->{$inputname})) {
|
||||
$fromform->{$inputname} = -1;
|
||||
@@ -97,8 +95,6 @@ if (!empty($fromform) and confirm_sesskey()) {
|
||||
set_config('site_postsnumber_' . $cleanhuburl, $fromform->posts, 'hub');
|
||||
set_config('site_questionsnumber_' . $cleanhuburl, $fromform->questions, 'hub');
|
||||
set_config('site_resourcesnumber_' . $cleanhuburl, $fromform->resources, 'hub');
|
||||
set_config('site_badges_' . $cleanhuburl, $fromform->badges, 'hub');
|
||||
set_config('site_issuedbadges_' . $cleanhuburl, $fromform->issuedbadges, 'hub');
|
||||
set_config('site_modulenumberaverage_' . $cleanhuburl, $fromform->modulenumberaverage, 'hub');
|
||||
set_config('site_participantnumberaverage_' . $cleanhuburl, $fromform->participantnumberaverage, 'hub');
|
||||
}
|
||||
@@ -137,8 +133,6 @@ if (!empty($fromform) and empty($update) and confirm_sesskey()) {
|
||||
$fromform->posts = $siteinfo['posts'];
|
||||
$fromform->questions = $siteinfo['questions'];
|
||||
$fromform->resources = $siteinfo['resources'];
|
||||
$fromform->badges = $siteinfo['badges'];
|
||||
$fromform->issuedbadges = $siteinfo['issuedbadges'];
|
||||
$fromform->modulenumberaverage = $siteinfo['modulenumberaverage'];
|
||||
$fromform->participantnumberaverage = $siteinfo['participantnumberaverage'];
|
||||
$fromform->street = $siteinfo['street'];
|
||||
@@ -179,13 +173,6 @@ if (!empty($error)) {
|
||||
|
||||
//some Moodle.org resitration explanation
|
||||
if ($huburl == HUB_MOODLEORGHUBURL) {
|
||||
if (!empty($registeredhub->token)) {
|
||||
$registrationmessage = get_string('pleaserefreshregistration', 'admin');
|
||||
} else {
|
||||
$registrationmessage = get_string('registrationwarning', 'admin');
|
||||
}
|
||||
echo $OUTPUT->notification($registrationmessage);
|
||||
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
|
||||
$renderer = $PAGE->get_renderer('core', 'register');
|
||||
echo $renderer->moodleorg_registration_message();
|
||||
|
||||
@@ -36,18 +36,13 @@ class core_register_renderer extends plugin_renderer_base {
|
||||
* @return string
|
||||
*/
|
||||
public function moodleorg_registration_message() {
|
||||
|
||||
$moodleorgstatslink = html_writer::link('http://moodle.net/stats',
|
||||
get_string('statsmoodleorg', 'admin'),
|
||||
array('target' => '_blank'));
|
||||
|
||||
$hublink = html_writer::link('https://moodle.net/mod/page/view.php?id=1',
|
||||
get_string('moodleorghubname', 'admin'),
|
||||
array('target' => '_blank'));
|
||||
|
||||
$moodleorgregmsg = get_string('registermoodleorg', 'admin', $hublink);
|
||||
$moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
|
||||
$moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
|
||||
$moochurl = html_writer::link(HUB_MOODLEORGHUBURL, 'Moodle.net');
|
||||
$moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
|
||||
$items = array(get_string('registermoodleorgli1', 'admin'),
|
||||
get_string('registermoodleorgli2', 'admin', $moodleorgstatslink));
|
||||
get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
|
||||
get_string('registermoodleorgli3', 'admin', $moochurl));
|
||||
$moodleorgregmsg .= html_writer::alist($items);
|
||||
return $moodleorgregmsg;
|
||||
}
|
||||
|
||||
+95
-258
@@ -25,6 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
|
||||
/**
|
||||
* Standard HTML output renderer for core_admin subsystem
|
||||
@@ -120,7 +121,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading(get_string('pluginscheck', 'admin'));
|
||||
$output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
$output .= $this->plugins_check_table(core_plugin_manager::instance(), $version, array('xdep' => true));
|
||||
$output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
|
||||
$output .= $this->warning(get_string('pluginschecktodo', 'admin'));
|
||||
$output .= $this->continue_button($reloadurl);
|
||||
|
||||
@@ -134,20 +135,17 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* during upgrade.
|
||||
* @param string $strnewversion
|
||||
* @param int $maturity
|
||||
* @param string $testsite
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
|
||||
public function upgrade_confirm_page($strnewversion, $maturity) {
|
||||
$output = '';
|
||||
|
||||
$continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'cache' => 0));
|
||||
$continue = new single_button($continueurl, get_string('continue'), 'get');
|
||||
$cancelurl = new moodle_url('/admin/index.php');
|
||||
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
|
||||
$cancelurl = new moodle_url('index.php');
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->maturity_warning($maturity);
|
||||
$output .= $this->test_site_warning($testsite);
|
||||
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
|
||||
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
@@ -170,7 +168,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||
|
||||
if (!$envstatus) {
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1, 'cache' => 0));
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
|
||||
|
||||
} else {
|
||||
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
@@ -179,7 +177,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
|
||||
}
|
||||
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
|
||||
}
|
||||
|
||||
$output .= $this->footer();
|
||||
@@ -189,15 +187,15 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display the upgrade page that lists all the plugins that require attention.
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins.
|
||||
* @param \core\update\checker $checker provides information about available updates.
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @param available_update_checker $checker provides information about available updates.
|
||||
* @param int $version the version of the Moodle code from version.php.
|
||||
* @param bool $showallplugins
|
||||
* @param moodle_url $reloadurl
|
||||
* @param moodle_url $continueurl
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_plugin_check_page(core_plugin_manager $pluginman, \core\update\checker $checker,
|
||||
public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
|
||||
$version, $showallplugins, $reloadurl, $continueurl) {
|
||||
global $CFG;
|
||||
|
||||
@@ -239,11 +237,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Prints a page with a summary of plugin deployment to be confirmed.
|
||||
*
|
||||
* @param \core\update\deployer $deployer
|
||||
* @param array $data deployer's data package as returned by {@link \core\update\deployer::submitted_data()}
|
||||
* @param available_update_deployer $deployer
|
||||
* @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
|
||||
* @return string
|
||||
*/
|
||||
public function upgrade_plugin_confirm_deploy_page(\core\update\deployer $deployer, array $data) {
|
||||
public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {
|
||||
|
||||
if (!$deployer->initialized()) {
|
||||
throw new coding_exception('Unable to render a page for non-initialized deployer.');
|
||||
@@ -281,10 +279,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
|
||||
}
|
||||
|
||||
$widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
|
||||
$widget = $deployer->make_execution_widget($data['updateinfo']);
|
||||
$output .= $this->output->render($widget);
|
||||
|
||||
$output .= $this->output->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
|
||||
$output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');
|
||||
|
||||
$output .= $this->container_end();
|
||||
$output .= $this->footer();
|
||||
@@ -301,15 +299,14 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @param bool $dbproblems warn db has problems
|
||||
* @param bool $maintenancemode warn in maintenance mode
|
||||
* @param bool $buggyiconvnomb warn iconv problems
|
||||
* @param array|null $availableupdates array of \core\update\info objects or null
|
||||
* @param array|null $availableupdates array of available_update_info objects or null
|
||||
* @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
|
||||
* @param string[] $cachewarnings An array containing warnings from the Cache API.
|
||||
*
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
|
||||
$buggyiconvnomb, $registered, array $cachewarnings = array()) {
|
||||
$buggyiconvnomb, $registered) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
@@ -322,7 +319,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->cron_overdue_warning($cronoverdue);
|
||||
$output .= $this->db_problems($dbproblems);
|
||||
$output .= $this->maintenance_mode_warning($maintenancemode);
|
||||
$output .= $this->cache_warnings($cachewarnings);
|
||||
$output .= $this->registration_warning($registered);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -342,12 +338,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* bool contribonly - show only contributed extensions
|
||||
* bool updatesonly - show only plugins with an available update
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\update\checker $checker
|
||||
* @param plugin_manager $pluginman
|
||||
* @param available_update_checker $checker
|
||||
* @param array $options filtering options
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function plugin_management_page(core_plugin_manager $pluginman, \core\update\checker $checker, array $options = array()) {
|
||||
public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
$output = '';
|
||||
@@ -375,98 +371,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page to confirm the plugin uninstallation.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\plugininfo\base $pluginfo
|
||||
* @param moodle_url $continueurl URL to continue after confirmation
|
||||
* @param moodle_url $cancelurl URL to to go if cancelled
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_confirm_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, moodle_url $continueurl, moodle_url $cancelurl) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
$confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
|
||||
if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
|
||||
$confirm .= $extraconfirm;
|
||||
}
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
$output .= $this->output->confirm($confirm, $continueurl, $cancelurl);
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with results of plugin uninstallation and offer removal of plugin files.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\plugininfo\base $pluginfo
|
||||
* @param progress_trace_buffer $progress
|
||||
* @param moodle_url $continueurl URL to continue to remove the plugin folder
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_results_removable_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo,
|
||||
progress_trace_buffer $progress, moodle_url $continueurl) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
// Do not show navigation here, they must click one of the buttons.
|
||||
$this->page->set_pagelayout('maintenance');
|
||||
$this->page->set_cacheable(false);
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
$output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
|
||||
|
||||
$confirm = $this->output->container(get_string('uninstalldeleteconfirm', 'core_plugin',
|
||||
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'uninstalldeleteconfirm');
|
||||
|
||||
if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
|
||||
$confirm .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
|
||||
'uninstalldeleteconfirmexternal');
|
||||
}
|
||||
|
||||
// After any uninstall we must execute full upgrade to finish the cleanup!
|
||||
$output .= $this->output->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\plugininfo\base $pluginfo
|
||||
* @param progress_trace_buffer $progress
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_results_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, progress_trace_buffer $progress) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginfo->component;
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
$output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
|
||||
|
||||
$output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
|
||||
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
|
||||
$output .= $this->output->continue_button(new moodle_url('/admin/index.php'));
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugin management page (admin/environment.php).
|
||||
* @param array $versions
|
||||
@@ -564,23 +468,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function cron_overdue_warning($cronoverdue) {
|
||||
global $CFG;
|
||||
if (!$cronoverdue) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($CFG->cronclionly)) {
|
||||
$url = new moodle_url('/admin/cron.php');
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$url = new moodle_url('/admin/cron.php', array('password' => $CFG->cronremotepassword));
|
||||
}
|
||||
|
||||
return $this->warning(get_string('cronwarning', 'admin', $url->out()) . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
// $CFG->cronclionly is not empty: cron can run only from CLI.
|
||||
return $this->warning(get_string('cronwarningcli', 'admin') . ' ' .
|
||||
return $this->warning(get_string('cronwarning', 'admin') . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
@@ -597,19 +489,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $this->warning($dbproblems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders cache warnings if there are any.
|
||||
*
|
||||
* @param string[] $cachewarnings
|
||||
* @return string
|
||||
*/
|
||||
public function cache_warnings(array $cachewarnings) {
|
||||
if (!count($cachewarnings)) {
|
||||
return '';
|
||||
}
|
||||
return join("\n", array_map(array($this, 'warning'), $cachewarnings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if the site in in maintenance mode.
|
||||
* @param bool $maintenancemode
|
||||
@@ -637,26 +516,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
return $this->warning(
|
||||
return $this->box(
|
||||
$this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$this->container($this->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'error');
|
||||
}
|
||||
|
||||
/*
|
||||
* If necessary, displays a warning about upgrading a test site.
|
||||
*
|
||||
* @param string $testsite
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function test_site_warning($testsite) {
|
||||
|
||||
if (!$testsite) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$warning = (get_string('testsiteupgradewarning', 'admin', $testsite));
|
||||
return $this->warning($warning, 'error');
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -688,16 +551,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return ''; // No worries.
|
||||
}
|
||||
|
||||
$level = 'warning';
|
||||
|
||||
if ($maturity == MATURITY_ALPHA) {
|
||||
$level = 'error';
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
$warningtext = get_string('maturitycoreinfo', 'admin', $maturitylevel);
|
||||
$warningtext .= ' ' . $this->doc_link('admin/versions', get_string('morehelp'));
|
||||
return $this->warning($warningtext, $level);
|
||||
return $this->box(
|
||||
get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
|
||||
$this->doc_link('admin/versions', get_string('morehelp')),
|
||||
'generalbox adminwarning maturityinfo maturity'.$maturity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -706,13 +564,13 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* The structure of the $updates param has changed since 2.4. It contains not only updates
|
||||
* for the core itself, but also for all other installed plugins.
|
||||
*
|
||||
* @param array|null $updates array of (string)component => array of \core\update\info objects or null
|
||||
* @param array|null $updates array of (string)component => array of available_update_info objects or null
|
||||
* @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
|
||||
* @return string
|
||||
*/
|
||||
protected function available_updates($updates, $fetch) {
|
||||
|
||||
$updateinfo = '';
|
||||
$updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
|
||||
$someupdateavailable = false;
|
||||
if (is_array($updates)) {
|
||||
if (is_array($updates['core'])) {
|
||||
@@ -741,15 +599,16 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$updateinfo .= $this->container_start('checkforupdates');
|
||||
$fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
|
||||
$updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
|
||||
$updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
|
||||
if ($fetch) {
|
||||
$updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
|
||||
userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
|
||||
}
|
||||
$updateinfo .= $this->container_end();
|
||||
|
||||
return $this->warning($updateinfo);
|
||||
$updateinfo .= $this->box_end();
|
||||
|
||||
return $updateinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -762,7 +621,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
if (!$registered) {
|
||||
|
||||
$registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
|
||||
$registerbutton = $this->single_button(new moodle_url('registration/register.php',
|
||||
array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
|
||||
get_string('register', 'admin'));
|
||||
|
||||
@@ -776,9 +635,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Helper method to render the information about the available Moodle update
|
||||
*
|
||||
* @param \core\update\info $updateinfo information about the available Moodle core update
|
||||
* @param available_update_info $updateinfo information about the available Moodle core update
|
||||
*/
|
||||
protected function moodle_available_update_info(\core\update\info $updateinfo) {
|
||||
protected function moodle_available_update_info(available_update_info $updateinfo) {
|
||||
|
||||
$boxclasses = 'moodleupdateinfo';
|
||||
$info = array();
|
||||
@@ -845,12 +704,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* (bool)full = false: whether to display up-to-date plugins, too
|
||||
* (bool)xdep = false: display the plugins with unsatisified dependecies only
|
||||
*
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins.
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @param int $version the version of the Moodle code from version.php.
|
||||
* @param array $options rendering options
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_check_table(core_plugin_manager $pluginman, $version, array $options = array()) {
|
||||
public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
@@ -943,7 +802,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
|
||||
|
||||
$statusisboring = in_array($statuscode, array(
|
||||
core_plugin_manager::PLUGIN_STATUS_NODB, core_plugin_manager::PLUGIN_STATUS_UPTODATE));
|
||||
plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
|
||||
|
||||
$coredependency = $plugin->is_core_dependency_satisfied($version);
|
||||
$otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
|
||||
@@ -955,7 +814,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
|
||||
} else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
|
||||
// no change is going to happen to the plugin - display it only
|
||||
// if the user wants to see the full list
|
||||
if (empty($options['full'])) {
|
||||
@@ -990,7 +849,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
|
||||
if (empty($options['full'])) {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
||||
get_string('nonehighlightedinfo', 'core_plugin'));
|
||||
}
|
||||
$out .= $this->output->container_end();
|
||||
@@ -1000,11 +859,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
|
||||
if (empty($options['full'])) {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
||||
get_string('somehighlightedinfo', 'core_plugin'));
|
||||
} else {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
|
||||
get_string('somehighlightedonly', 'core_plugin'));
|
||||
}
|
||||
$out .= $this->output->container_end();
|
||||
@@ -1019,12 +878,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Formats the information that needs to go in the 'Requires' column.
|
||||
* @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
|
||||
* @param core_plugin_manager $pluginman provides data on all the plugins.
|
||||
* @param plugininfo_base $plugin the plugin we are rendering the row for.
|
||||
* @param plugin_manager $pluginman provides data on all the plugins.
|
||||
* @param string $version
|
||||
* @return string HTML code
|
||||
*/
|
||||
protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) {
|
||||
protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
|
||||
$requires = array();
|
||||
|
||||
if (!empty($plugin->versionrequires)) {
|
||||
@@ -1039,28 +898,19 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
|
||||
$ok = true;
|
||||
$otherplugin = $pluginman->get_plugin_info($component);
|
||||
$actions = array();
|
||||
|
||||
if (is_null($otherplugin)) {
|
||||
// The required plugin is not installed.
|
||||
$class = 'requires-failed requires-missing';
|
||||
$installurl = new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $component));
|
||||
$uploadurl = new moodle_url('/admin/tool/installaddon/');
|
||||
$actions[] = html_writer::link($installurl, get_string('dependencyinstall', 'core_plugin'));
|
||||
$actions[] = html_writer::link($uploadurl, get_string('dependencyupload', 'core_plugin'));
|
||||
|
||||
$ok = false;
|
||||
} else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
|
||||
// The required plugin is installed but needs to be updated.
|
||||
$class = 'requires-failed requires-outdated';
|
||||
if (!$otherplugin->is_standard()) {
|
||||
$updateurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1));
|
||||
$actions[] = html_writer::link($updateurl, get_string('checkforupdates', 'core_plugin'));
|
||||
}
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Already installed plugin with sufficient version.
|
||||
if ($ok) {
|
||||
$class = 'requires-ok';
|
||||
} else {
|
||||
$class = 'requires-failed';
|
||||
}
|
||||
|
||||
if ($requiredversion != ANY_VERSION) {
|
||||
@@ -1068,11 +918,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$str = 'otherplugin';
|
||||
}
|
||||
|
||||
$componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin='.$component);
|
||||
$componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out()));
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::div(get_string($str, 'core_plugin',
|
||||
array('component' => $component, 'version' => $requiredversion)), 'component').
|
||||
html_writer::div(implode(' | ', $actions), 'actions'),
|
||||
get_string($str, 'core_plugin',
|
||||
array('component' => $componenturl, 'version' => $requiredversion)),
|
||||
array('class' => $class));
|
||||
}
|
||||
|
||||
@@ -1085,11 +935,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Prints an overview about the plugins - number of installed, number of extensions etc.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins
|
||||
* @param plugin_manager $pluginman provides information about the plugins
|
||||
* @param array $options filtering options
|
||||
* @return string as usually
|
||||
*/
|
||||
public function plugins_overview_panel(core_plugin_manager $pluginman, array $options = array()) {
|
||||
public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
@@ -1098,7 +948,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
continue;
|
||||
}
|
||||
$numtotal++;
|
||||
@@ -1165,11 +1015,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
*
|
||||
* This default implementation renders all plugins into one big table.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins.
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @param array $options filtering options
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_control_panel(core_plugin_manager $pluginman, array $options = array()) {
|
||||
public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
@@ -1213,32 +1063,26 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('displayname', 'core_plugin'),
|
||||
get_string('source', 'core_plugin'),
|
||||
get_string('version', 'core_plugin'),
|
||||
get_string('release', 'core_plugin'),
|
||||
get_string('availability', 'core_plugin'),
|
||||
get_string('actions', 'core_plugin'),
|
||||
get_string('notes','core_plugin'),
|
||||
);
|
||||
$table->headspan = array(1, 1, 1, 1, 1, 2, 1);
|
||||
$table->colclasses = array(
|
||||
'pluginname', 'source', 'version', 'release', 'availability', 'settings', 'uninstall', 'notes'
|
||||
'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
|
||||
);
|
||||
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
$heading = $pluginman->plugintype_name_plural($type);
|
||||
$pluginclass = core_plugin_manager::resolve_plugininfo_class($type);
|
||||
if ($manageurl = $pluginclass::get_manage_url()) {
|
||||
$heading = html_writer::link($manageurl, $heading);
|
||||
}
|
||||
$header = new html_table_cell(html_writer::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
|
||||
|
||||
$header = new html_table_cell($pluginman->plugintype_name_plural($type));
|
||||
$header->header = true;
|
||||
$header->colspan = array_sum($table->headspan);
|
||||
$header->colspan = count($table->head);
|
||||
$header = new html_table_row(array($header));
|
||||
$header->attributes['class'] = 'plugintypeheader type-' . $type;
|
||||
$table->data[] = $header;
|
||||
|
||||
if (empty($plugins)) {
|
||||
$msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
|
||||
$msg->colspan = array_sum($table->headspan);
|
||||
$msg->colspan = count($table->head);
|
||||
$row = new html_table_row(array($msg));
|
||||
$row->attributes['class'] .= 'msg msg-noneinstalled';
|
||||
$table->data[] = $row;
|
||||
@@ -1254,12 +1098,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
|
||||
}
|
||||
$status = $plugin->get_status();
|
||||
$row->attributes['class'] .= ' status-'.$status;
|
||||
if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
|
||||
} else if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
|
||||
$msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
|
||||
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
|
||||
$row->attributes['class'] .= ' missingfromdisk';
|
||||
} else {
|
||||
$msg = '';
|
||||
}
|
||||
@@ -1276,7 +1117,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$version = new html_table_cell($plugin->versiondb);
|
||||
$release = new html_table_cell($plugin->release);
|
||||
|
||||
$isenabled = $plugin->is_enabled();
|
||||
if (is_null($isenabled)) {
|
||||
@@ -1289,20 +1129,19 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
|
||||
}
|
||||
|
||||
$actions = array();
|
||||
|
||||
$settingsurl = $plugin->get_settings_url();
|
||||
if (!is_null($settingsurl)) {
|
||||
$settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
|
||||
} else {
|
||||
$settings = '';
|
||||
$actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
|
||||
}
|
||||
$settings = new html_table_cell($settings);
|
||||
|
||||
if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component, 'overview')) {
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
|
||||
} else {
|
||||
$uninstall = '';
|
||||
$uninstallurl = $plugin->get_uninstall_url();
|
||||
if (!is_null($uninstallurl)) {
|
||||
$actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
|
||||
}
|
||||
$uninstall = new html_table_cell($uninstall);
|
||||
|
||||
$actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
|
||||
|
||||
$requriedby = $pluginman->other_plugins_that_require($plugin->component);
|
||||
if ($requriedby) {
|
||||
@@ -1322,7 +1161,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$notes = new html_table_cell($requiredby.$updateinfo);
|
||||
|
||||
$row->cells = array(
|
||||
$pluginname, $source, $version, $release, $availability, $settings, $uninstall, $notes
|
||||
$pluginname, $source, $version, $availability, $actions, $notes
|
||||
);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
@@ -1337,9 +1176,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* The passed objects always provides at least the 'version' property containing
|
||||
* the (higher) version of the plugin available.
|
||||
*
|
||||
* @param \core\update\info $updateinfo information about the available update for the plugin
|
||||
* @param available_update_info $updateinfo information about the available update for the plugin
|
||||
*/
|
||||
protected function plugin_available_update_info(\core\update\info $updateinfo) {
|
||||
protected function plugin_available_update_info(available_update_info $updateinfo) {
|
||||
|
||||
$boxclasses = 'pluginupdateinfo';
|
||||
$info = array();
|
||||
@@ -1368,7 +1207,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
|
||||
$box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->initialized()) {
|
||||
$impediments = $deployer->deployment_impediments($updateinfo);
|
||||
if (empty($impediments)) {
|
||||
@@ -1394,7 +1233,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* configuration and how it suits Moodle needs.
|
||||
*
|
||||
* @param boolean $result final result of the check (true/false)
|
||||
* @param environment_results[] $environment_results array of results gathered
|
||||
* @param array $environment_results array of results gathered
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function environment_check_table($result, $environment_results) {
|
||||
@@ -1406,12 +1245,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('name'),
|
||||
get_string('info'),
|
||||
get_string('report'),
|
||||
get_string('plugin'),
|
||||
get_string('status'),
|
||||
);
|
||||
$servertable->colclasses = array('centeralign name', 'centeralign info', 'leftalign report', 'leftalign plugin', 'centeralign status');
|
||||
$servertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$servertable->id = 'serverstatus';
|
||||
$servertable->align = array('center', 'center', 'left', 'center');
|
||||
$servertable->wrap = array('nowrap', '', '', 'nowrap');
|
||||
$servertable->size = array('10', 10, '100%', '10');
|
||||
$servertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
@@ -1419,12 +1258,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$othertable->head = array(
|
||||
get_string('info'),
|
||||
get_string('report'),
|
||||
get_string('plugin'),
|
||||
get_string('status'),
|
||||
);
|
||||
$othertable->colclasses = array('aligncenter info', 'alignleft report', 'alignleft plugin', 'aligncenter status');
|
||||
$othertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$othertable->id = 'otherserverstatus';
|
||||
$othertable->align = array('center', 'left', 'center');
|
||||
$othertable->wrap = array('', '', 'nowrap');
|
||||
$othertable->size = array(10, '100%', '10');
|
||||
$othertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
@@ -1438,7 +1277,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$type = $environment_result->getPart();
|
||||
$info = $environment_result->getInfo();
|
||||
$status = $environment_result->getStatus();
|
||||
$plugin = $environment_result->getPluginName();
|
||||
$error_code = $environment_result->getErrorCode();
|
||||
// Process Report field
|
||||
$rec = new stdClass();
|
||||
@@ -1515,8 +1353,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
if (!empty($info)){
|
||||
$linkparts[] = $info;
|
||||
}
|
||||
// Plugin environments do not have docs pages yet.
|
||||
if (empty($CFG->docroot) or $environment_result->plugin) {
|
||||
if (empty($CFG->docroot)) {
|
||||
$report = get_string($stringtouse, 'admin', $rec);
|
||||
} else {
|
||||
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
|
||||
@@ -1542,9 +1379,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
// Add the row to the table
|
||||
if ($environment_result->getPart() == 'custom_check'){
|
||||
$otherdata[$messagetype][] = array ($info, $report, $plugin, $status);
|
||||
$otherdata[$messagetype][] = array ($info, $report, $status);
|
||||
} else {
|
||||
$serverdata[$messagetype][] = array ($type, $info, $report, $plugin, $status);
|
||||
$serverdata[$messagetype][] = array ($type, $info, $report, $status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+43
-25
@@ -18,7 +18,7 @@
|
||||
* Provides an overview of installed reports
|
||||
*
|
||||
* Displays the list of found reports, their version (if found) and
|
||||
* a link to uninstall the report.
|
||||
* a link to delete the report.
|
||||
*
|
||||
* The code is based on admin/localplugins.php by David Mudrak.
|
||||
*
|
||||
@@ -33,24 +33,55 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managereports');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('reports'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'report_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'report_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('reportsdeleteconfirm', 'admin', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('report', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['report'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('reports'));
|
||||
|
||||
/// Print the table of all installed report plugins
|
||||
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
|
||||
$table = new flexible_table('reportplugins_administration_table');
|
||||
$table->define_columns(array('name', 'logstoressupported', 'version', 'uninstall'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('logstoressupported', 'admin'), get_string('version'),
|
||||
$struninstall));
|
||||
$table->define_columns(array('name', 'version', 'delete'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'reportplugins');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
foreach (core_component::get_plugin_list('report') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('report') as $plugin => $plugindir) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'report_' . $plugin)) {
|
||||
$strpluginname = get_string('pluginname', 'report_' . $plugin);
|
||||
} else {
|
||||
@@ -58,7 +89,7 @@ foreach (core_component::get_plugin_list('report') as $plugin => $plugindir) {
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
core_collator::asort($plugins);
|
||||
collatorlib::asort($plugins);
|
||||
|
||||
$like = $DB->sql_like('plugin', '?', true, true, false, '|');
|
||||
$params = array('report|_%');
|
||||
@@ -72,22 +103,9 @@ foreach ($installed as $config) {
|
||||
}
|
||||
}
|
||||
|
||||
$logmanager = get_log_manager();
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('report_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
|
||||
$stores = $logmanager->get_supported_logstores('report_' . $plugin);
|
||||
if ($stores === false) {
|
||||
$supportedstores = get_string('logstorenotrequired', 'admin');
|
||||
} else if (!empty($stores)) {
|
||||
$supportedstores = implode(', ', $stores);
|
||||
} else {
|
||||
$supportedstores = get_string('nosupportedlogstore', 'admin');;
|
||||
}
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
|
||||
if (!isset($versions[$plugin])) {
|
||||
if (file_exists("$CFG->dirroot/report/$plugin/version.php")) {
|
||||
@@ -108,7 +126,7 @@ foreach ($plugins as $plugin => $name) {
|
||||
}
|
||||
}
|
||||
|
||||
$table->add_data(array($name, $supportedstores, $version, $uninstall));
|
||||
$table->add_data(array($name, $version, $delete));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
+14
-32
@@ -148,7 +148,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
if ($success) {
|
||||
// configs saved
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($baseurl);
|
||||
} else {
|
||||
print_error('instancenotsaved', 'repository', $baseurl);
|
||||
@@ -189,7 +188,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
print_error('invalidplugin', 'repository', '', $repository);
|
||||
}
|
||||
$repositorytype->update_visibility(true);
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if ($action == 'hide') {
|
||||
if (!confirm_sesskey()) {
|
||||
@@ -200,7 +198,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
print_error('invalidplugin', 'repository', '', $repository);
|
||||
}
|
||||
$repositorytype->update_visibility(false);
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if ($action == 'delete') {
|
||||
$repositorytype = repository::get_type_by_typename($repository);
|
||||
@@ -211,7 +208,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
|
||||
if ($repositorytype->delete($downloadcontents)) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($baseurl);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'repository', $baseurl);
|
||||
@@ -264,7 +260,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$strshow = get_string('on', 'repository');
|
||||
$strhide = get_string('off', 'repository');
|
||||
$strdelete = get_string('disabled', 'repository');
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
|
||||
$actionchoicesforexisting = array(
|
||||
'show' => $strshow,
|
||||
@@ -287,21 +282,18 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
// Table to list plug-ins
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr, $struninstall);
|
||||
|
||||
$table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
|
||||
$table->id = 'repositoriessetting';
|
||||
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
|
||||
$table->align = array('left', 'center', 'center', 'center', 'center');
|
||||
$table->data = array();
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
|
||||
// Get list of used plug-ins
|
||||
$repositorytypes = repository::get_types();
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
if (!empty($repositorytypes)) {
|
||||
$totalrepositorytypes = count($repositorytypes);
|
||||
$instances = repository::get_types();
|
||||
if (!empty($instances)) {
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
$totalinstances = count($instances);
|
||||
$updowncount = 1;
|
||||
foreach ($repositorytypes as $i) {
|
||||
foreach ($instances as $i) {
|
||||
$settings = '';
|
||||
$typename = $i->get_typename();
|
||||
// Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
|
||||
@@ -324,10 +316,9 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$userinstances = array();
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
$repocontext = context::instance_by_id($instance->instance->contextid);
|
||||
if ($repocontext->contextlevel == CONTEXT_COURSE) {
|
||||
if ($instance->context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseinstances[] = $instance;
|
||||
} else if ($repocontext->contextlevel == CONTEXT_USER) {
|
||||
} else if ($instance->context->contextlevel == CONTEXT_USER) {
|
||||
$userinstances[] = $instance;
|
||||
}
|
||||
}
|
||||
@@ -375,7 +366,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
if ($updowncount < $totalrepositorytypes) {
|
||||
if ($updowncount < $totalinstances) {
|
||||
$updown .= "<a href=\"$sesskeyurl&action=movedown&repos=".$typename."\">";
|
||||
$updown .= "<img src=\"" . $OUTPUT->pix_url('t/down') . "\" alt=\"down\" /></a>";
|
||||
}
|
||||
@@ -385,12 +376,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
$updowncount++;
|
||||
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $typename, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
|
||||
$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings, $uninstall);
|
||||
$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings);
|
||||
|
||||
if (!in_array($typename, $alreadyplugins)) {
|
||||
$alreadyplugins[] = $typename;
|
||||
@@ -399,18 +385,14 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
|
||||
// Get all the plugins that exist on disk
|
||||
$plugins = core_component::get_plugin_list('repository');
|
||||
$plugins = get_plugin_list('repository');
|
||||
if (!empty($plugins)) {
|
||||
foreach ($plugins as $plugin => $dir) {
|
||||
// Check that it has not already been listed
|
||||
if (!in_array($plugin, $alreadyplugins)) {
|
||||
$select = new single_select(repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '', $uninstall);
|
||||
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ $return = true;
|
||||
if (!empty($edit) || !empty($new)) {
|
||||
if (!empty($edit)) {
|
||||
$instance = repository::get_instance($edit);
|
||||
if (!$instance->can_be_edited_by_user()) {
|
||||
if ($instance->instance->contextid != $context->id) {
|
||||
throw new repository_exception('nopermissiontoaccess', 'repository');
|
||||
}
|
||||
$instancetype = repository::get_type_by_id($instance->options['typeid']);
|
||||
@@ -102,7 +102,6 @@ if (!empty($edit) || !empty($new)) {
|
||||
$data = data_submitted();
|
||||
}
|
||||
if ($success) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($parenturl);
|
||||
} else {
|
||||
print_error('instancenotsaved', 'repository', $parenturl);
|
||||
@@ -119,20 +118,18 @@ if (!empty($edit) || !empty($new)) {
|
||||
} else if (!empty($hide)) {
|
||||
$instance = repository::get_type_by_typename($hide);
|
||||
$instance->hide();
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if (!empty($delete)) {
|
||||
$instance = repository::get_instance($delete);
|
||||
if ($instance->readonly) {
|
||||
// If you try to delete an instance set as readonly, display an error message.
|
||||
throw new repository_exception('readonlyinstance', 'repository');
|
||||
} else if (!$instance->can_be_edited_by_user()) {
|
||||
} else if ($instance->instance->contextid != $context->id) {
|
||||
throw new repository_exception('nopermissiontoaccess', 'repository');
|
||||
}
|
||||
if ($sure) {
|
||||
if ($instance->delete($downloadcontents)) {
|
||||
$deletedstr = get_string('instancedeleted', 'repository');
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($parenturl, $deletedstr, 3);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'repository', $parenturl);
|
||||
|
||||
+24
-21
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,15 +16,16 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Select site administrators.
|
||||
* Lets you site administrators
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 2010 Petr Skoda (skodak) http://skodak.org
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$confirmadd = optional_param('confirmadd', 0, PARAM_INT);
|
||||
$confirmdel = optional_param('confirmdel', 0, PARAM_INT);
|
||||
@@ -35,10 +37,10 @@ if (!is_siteadmin()) {
|
||||
die;
|
||||
}
|
||||
|
||||
$admisselector = new core_role_admins_existing_selector();
|
||||
$admisselector = new admins_existing_selector();
|
||||
$admisselector->set_extra_fields(array('username', 'email'));
|
||||
|
||||
$potentialadmisselector = new core_role_admins_potential_selector();
|
||||
$potentialadmisselector = new admins_potential_selector();
|
||||
$potentialadmisselector->set_extra_fields(array('username', 'email'));
|
||||
|
||||
if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
@@ -46,8 +48,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
$user = reset($userstoadd);
|
||||
$username = fullname($user) . " ($user->username, $user->email)";
|
||||
echo $OUTPUT->header();
|
||||
$yesurl = new moodle_url('/admin/roles/admins.php', array('confirmadd'=>$user->id, 'sesskey'=>sesskey()));
|
||||
echo $OUTPUT->confirm(get_string('confirmaddadmin', 'core_role', $username), $yesurl, $PAGE->url);
|
||||
echo $OUTPUT->confirm(get_string('confirmaddadmin', 'role', $username), new moodle_url('/admin/roles/admins.php', array('confirmadd'=>$user->id, 'sesskey'=>sesskey())), $PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
@@ -56,12 +57,11 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
if ($userstoremove = $admisselector->get_selected_users()) {
|
||||
$user = reset($userstoremove);
|
||||
if ($USER->id == $user->id) {
|
||||
// Can not remove self.
|
||||
//can not remove self
|
||||
} else {
|
||||
$username = fullname($user) . " ($user->username, $user->email)";
|
||||
echo $OUTPUT->header();
|
||||
$yesurl = new moodle_url('/admin/roles/admins.php', array('confirmdel'=>$user->id, 'sesskey'=>sesskey()));
|
||||
echo $OUTPUT->confirm(get_string('confirmdeladmin', 'core_role', $username), $yesurl, $PAGE->url);
|
||||
echo $OUTPUT->confirm(get_string('confirmdeladmin', 'role', $username), new moodle_url('/admin/roles/admins.php', array('confirmdel'=>$user->id, 'sesskey'=>sesskey())), $PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
$newmain = reset($newmain);
|
||||
$newmain = $newmain->id;
|
||||
$admins = array();
|
||||
foreach (explode(',', $CFG->siteadmins) as $admin) {
|
||||
foreach(explode(',', $CFG->siteadmins) as $admin) {
|
||||
$admin = (int)$admin;
|
||||
if ($admin) {
|
||||
$admins[$admin] = $admin;
|
||||
@@ -89,7 +89,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
|
||||
} else if ($confirmadd and confirm_sesskey()) {
|
||||
$admins = array();
|
||||
foreach (explode(',', $CFG->siteadmins) as $admin) {
|
||||
foreach(explode(',', $CFG->siteadmins) as $admin) {
|
||||
$admin = (int)$admin;
|
||||
if ($admin) {
|
||||
$admins[$admin] = $admin;
|
||||
@@ -101,7 +101,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
|
||||
} else if ($confirmdel and confirm_sesskey() and $confirmdel != $USER->id) {
|
||||
$admins = array();
|
||||
foreach (explode(',', $CFG->siteadmins) as $admin) {
|
||||
foreach(explode(',', $CFG->siteadmins) as $admin) {
|
||||
$admin = (int)$admin;
|
||||
if ($admin) {
|
||||
$admins[$admin] = $admin;
|
||||
@@ -112,12 +112,12 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
// Print header.
|
||||
/// Print header
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
|
||||
<div id="addadmisform">
|
||||
<h3 class="main"><?php print_string('manageadmins', 'core_role'); ?></h3>
|
||||
<h3 class="main"><?php print_string('manageadmins', 'role'); ?></h3>
|
||||
|
||||
<form id="assignform" method="post" action="<?php echo $PAGE->url ?>">
|
||||
<div>
|
||||
@@ -127,18 +127,18 @@ echo $OUTPUT->header();
|
||||
<tr>
|
||||
<td id='existingcell'>
|
||||
<p>
|
||||
<label for="removeselect"><?php print_string('existingadmins', 'core_role'); ?></label>
|
||||
<label for="removeselect"><?php print_string('existingadmins', 'role'); ?></label>
|
||||
</p>
|
||||
<?php $admisselector->display(); ?>
|
||||
</td>
|
||||
<td id="buttonscell">
|
||||
<td id='buttonscell'>
|
||||
<p class="arrow_button">
|
||||
<input name="add" id="add" type="submit" value="<?php echo $OUTPUT->larrow().' '.get_string('add'); ?>" title="<?php print_string('add'); ?>" /><br />
|
||||
<input name="remove" id="remove" type="submit" value="<?php echo get_string('remove').' '.$OUTPUT->rarrow(); ?>" title="<?php print_string('remove'); ?>" />
|
||||
<input name="main" id="main" type="submit" value="<?php echo get_string('mainadminset', 'core_role'); ?>" title="<?php print_string('mainadminset', 'core_role'); ?>" />
|
||||
<input name="main" id="main" type="submit" value="<?php echo get_string('mainadminset', 'role'); ?>" title="<?php print_string('mainadminset', 'role'); ?>" />
|
||||
</p>
|
||||
</td>
|
||||
<td id="potentialcell">
|
||||
<td id='potentialcell'>
|
||||
<p>
|
||||
<label for="addselect"><?php print_string('users'); ?></label>
|
||||
</p>
|
||||
@@ -152,4 +152,7 @@ echo $OUTPUT->header();
|
||||
|
||||
<?php
|
||||
|
||||
//this must be after calling display() on the selectors so their setup JS executes first
|
||||
//////$PAGE->requires->js_function_call('init_add_remove_admis_page');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+10
-22
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,21 +16,23 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allow overriding of roles by other roles.
|
||||
* Allow overriding of roles by other roles
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$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'
|
||||
'assign' => 'role_allow_assign_page',
|
||||
'override' => 'role_allow_override_page',
|
||||
'switch' => 'role_allow_switch_page'
|
||||
);
|
||||
if (!isset($classformode[$mode])) {
|
||||
print_error('invalidmode', '', '', $mode);
|
||||
@@ -45,23 +48,8 @@ $controller = new $classformode[$mode]();
|
||||
|
||||
if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
|
||||
$controller->process_submission();
|
||||
$syscontext->mark_dirty();
|
||||
$event = null;
|
||||
// Create event depending on mode.
|
||||
switch ($mode) {
|
||||
case 'assign':
|
||||
$event = \core\event\role_allow_assign_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
case 'override':
|
||||
$event = \core\event\role_allow_override_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
case 'switch':
|
||||
$event = \core\event\role_allow_switch_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
}
|
||||
if ($event) {
|
||||
$event->trigger();
|
||||
}
|
||||
mark_context_dirty($syscontext->path);
|
||||
add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
|
||||
+50
-68
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,21 +16,21 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Assign roles to users.
|
||||
* Lets you assign roles to users in a particular context.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
define("MAX_USERS_TO_LIST_PER_ROLE", 10);
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT);
|
||||
$returnto = optional_param('return', null, PARAM_ALPHANUMEXT);
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT);
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -50,25 +51,25 @@ if ($course) {
|
||||
}
|
||||
|
||||
|
||||
// Security.
|
||||
// security
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/role:assign', $context);
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$contextname = $context->get_context_name();
|
||||
$contextname = print_context_name($context);
|
||||
$courseid = $course->id;
|
||||
|
||||
// These are needed early because of tabs.php.
|
||||
// These are needed early because of tabs.php
|
||||
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
|
||||
$overridableroles = get_overridable_roles($context, ROLENAME_BOTH);
|
||||
|
||||
// Make sure this user can assign this role.
|
||||
// Make sure this user can assign this role
|
||||
if ($roleid && !isset($assignableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotassignrolehere', '', $context->get_url(), $a);
|
||||
print_error('cannotassignrolehere', '', get_context_url($context), $a);
|
||||
}
|
||||
|
||||
// Work out an appropriate page title.
|
||||
@@ -76,12 +77,12 @@ if ($roleid) {
|
||||
$a = new stdClass;
|
||||
$a->role = $assignableroles[$roleid];
|
||||
$a->context = $contextname;
|
||||
$title = get_string('assignrolenameincontext', 'core_role', $a);
|
||||
$title = get_string('assignrolenameincontext', 'role', $a);
|
||||
} else {
|
||||
if ($isfrontpage) {
|
||||
$title = get_string('frontpageroles', 'admin');
|
||||
} else {
|
||||
$title = get_string('assignrolesin', 'core_role', $contextname);
|
||||
$title = get_string('assignrolesin', 'role', $contextname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,10 +92,10 @@ if ($roleid) {
|
||||
// Create the user selector objects.
|
||||
$options = array('context' => $context, 'roleid' => $roleid);
|
||||
|
||||
$potentialuserselector = core_role_get_potential_user_selector($context, 'addselect', $options);
|
||||
$currentuserselector = new core_role_existing_role_holders('removeselect', $options);
|
||||
$potentialuserselector = roles_get_potential_user_selector($context, 'addselect', $options);
|
||||
$currentuserselector = new existing_role_holders('removeselect', $options);
|
||||
|
||||
// Process incoming role assignments.
|
||||
// Process incoming role assignments
|
||||
$errors = array();
|
||||
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$userstoassign = $potentialuserselector->get_selected_users();
|
||||
@@ -111,24 +112,28 @@ if ($roleid) {
|
||||
$potentialuserselector->invalidate_selected_users();
|
||||
$currentuserselector->invalidate_selected_users();
|
||||
|
||||
$rolename = $assignableroles[$roleid];
|
||||
add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
// Counts have changed, so reload.
|
||||
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Process incoming role unassignments.
|
||||
// Process incoming role unassignments
|
||||
if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$userstounassign = $currentuserselector->get_selected_users();
|
||||
if (!empty($userstounassign)) {
|
||||
|
||||
foreach ($userstounassign as $removeuser) {
|
||||
// Unassign only roles that are added manually, no messing with other components!!!
|
||||
//unassign only roles that are added manually, no messing with other components!!!
|
||||
role_unassign($roleid, $removeuser->id, $context->id, '');
|
||||
}
|
||||
|
||||
$potentialuserselector->invalidate_selected_users();
|
||||
$currentuserselector->invalidate_selected_users();
|
||||
|
||||
$rolename = $assignableroles[$roleid];
|
||||
add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
// Counts have changed, so reload.
|
||||
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
|
||||
}
|
||||
@@ -140,7 +145,6 @@ $PAGE->set_title($title);
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
@@ -149,17 +153,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -170,28 +174,25 @@ switch ($context->contextlevel) {
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print heading.
|
||||
echo $OUTPUT->heading_with_help($title, 'assignroles', 'core_role');
|
||||
echo $OUTPUT->heading_with_help($title, 'assignroles', 'role');
|
||||
|
||||
if ($roleid) {
|
||||
// Show UI for assigning a particular role to users.
|
||||
// Print a warning if we are assigning system roles.
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
echo $OUTPUT->notification(get_string('globalroleswarning', 'core_role'));
|
||||
echo $OUTPUT->box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
// Print the form.
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
if ($returnto !== null) {
|
||||
$assignurl->param('return', $returnto);
|
||||
}
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
?>
|
||||
<form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
|
||||
<table id="assigningrole" summary="" class="admintable roleassigntable generaltable" cellspacing="0">
|
||||
<table summary="" class="roleassigntable generaltable generalbox boxaligncenter" cellspacing="0">
|
||||
<tr>
|
||||
<td id="existingcell">
|
||||
<p><label for="removeselect"><?php print_string('extusers', 'core_role'); ?></label></p>
|
||||
<p><label for="removeselect"><?php print_string('extusers', 'role'); ?></label></p>
|
||||
<?php $currentuserselector->display() ?>
|
||||
</td>
|
||||
<td id="buttonscell">
|
||||
@@ -204,7 +205,7 @@ if ($roleid) {
|
||||
</div>
|
||||
</td>
|
||||
<td id="potentialcell">
|
||||
<p><label for="addselect"><?php print_string('potusers', 'core_role'); ?></label></p>
|
||||
<p><label for="addselect"><?php print_string('potusers', 'role'); ?></label></p>
|
||||
<?php $potentialuserselector->display() ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -228,45 +229,37 @@ if ($roleid) {
|
||||
// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
|
||||
$newroleurl = new moodle_url($PAGE->url);
|
||||
if ($returnto !== null) {
|
||||
$newroleurl->param('return', $returnto);
|
||||
}
|
||||
$select = new single_select($newroleurl, 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('assignanotherrole', 'core_role');
|
||||
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('assignanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
$backurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
|
||||
if ($returnto !== null) {
|
||||
$backurl->param('return', $returnto);
|
||||
}
|
||||
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
|
||||
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'role') . '</a></p>';
|
||||
echo '</div>';
|
||||
|
||||
} else if (empty($assignableroles)) {
|
||||
// Print a message that there are no roles that can me assigned here.
|
||||
echo $OUTPUT->heading(get_string('notabletoassignroleshere', 'core_role'), 3);
|
||||
echo $OUTPUT->heading(get_string('notabletoassignroleshere', 'role'), 3);
|
||||
|
||||
} else {
|
||||
// Show UI for choosing a role to assign.
|
||||
|
||||
// Print a warning if we are assigning system roles.
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
echo $OUTPUT->notification(get_string('globalroleswarning', 'core_role'));
|
||||
echo $OUTPUT->box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
// Print instruction.
|
||||
echo $OUTPUT->heading(get_string('chooseroletoassign', 'core_role'), 3);
|
||||
// Print instruction
|
||||
echo $OUTPUT->heading(get_string('chooseroletoassign', 'role'), 3);
|
||||
|
||||
// Get the names of role holders for roles with between 1 and MAX_USERS_TO_LIST_PER_ROLE users,
|
||||
// and so determine whether to show the extra column.
|
||||
$roleholdernames = array();
|
||||
$strmorethanmax = get_string('morethan', 'core_role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
$strmorethanmax = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
$showroleholders = false;
|
||||
foreach ($assignableroles as $roleid => $notused) {
|
||||
$roleusers = '';
|
||||
if (0 < $assigncounts[$roleid] && $assigncounts[$roleid] <= MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
|
||||
$roleusers = get_role_users($roleid, $context, false, $userfields);
|
||||
$roleusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname');
|
||||
if (!empty($roleusers)) {
|
||||
$strroleusers = array();
|
||||
foreach ($roleusers as $user) {
|
||||
@@ -277,32 +270,28 @@ if ($roleid) {
|
||||
}
|
||||
} else if ($assigncounts[$roleid] > MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
if ($returnto !== null) {
|
||||
$assignurl->param('return', $returnto);
|
||||
}
|
||||
$roleholdernames[$roleid] = '<a href="'.$assignurl.'">'.$strmorethanmax.'</a>';
|
||||
} else {
|
||||
$roleholdernames[$roleid] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Print overview table.
|
||||
// Print overview table
|
||||
$table = new html_table();
|
||||
$table->id = 'assignrole';
|
||||
$table->head = array(get_string('role'), get_string('description'), get_string('userswiththisrole', 'core_role'));
|
||||
$table->colclasses = array('leftalign role', 'leftalign', 'centeralign userrole');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->tablealign = 'center';
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('role'), get_string('description'), get_string('userswiththisrole', 'role'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('left', 'left', 'center');
|
||||
if ($showroleholders) {
|
||||
$table->headspan = array(1, 1, 2);
|
||||
$table->colclasses[] = 'leftalign roleholder';
|
||||
$table->wrap[] = 'nowrap';
|
||||
$table->align[] = 'left';
|
||||
}
|
||||
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
if ($returnto !== null) {
|
||||
$assignurl->param('return', $returnto);
|
||||
}
|
||||
$row = array('<a href="'.$assignurl.'">'.$rolename.'</a>',
|
||||
$description, $assigncounts[$roleid]);
|
||||
if ($showroleholders) {
|
||||
@@ -314,15 +303,8 @@ if ($roleid) {
|
||||
echo html_writer::table($table);
|
||||
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
|
||||
if ($context->contextlevel === CONTEXT_COURSECAT && $returnto === 'management') {
|
||||
$url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
|
||||
} else {
|
||||
$url = $context->get_url();
|
||||
}
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
}
|
||||
|
||||
+21
-27
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,14 +18,16 @@
|
||||
/**
|
||||
* Shows the result of has_capability for every capability for a user in a context.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -44,41 +47,32 @@ if ($course) {
|
||||
}
|
||||
}
|
||||
|
||||
// Security first.
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $context)) {
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
} else {
|
||||
$PAGE->set_context($context);
|
||||
}
|
||||
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$courseid = $course->id;
|
||||
$contextname = $context->get_context_name();
|
||||
$contextname = print_context_name($context);
|
||||
|
||||
// Get the user_selector we will need.
|
||||
// Teachers within a course just get to see the same list of enrolled users.
|
||||
// Admins (people with moodle/role:manage) can run this report for any user.
|
||||
$options = array('accesscontext' => $context);
|
||||
$userselector = new core_role_check_users_selector('reportuser', $options);
|
||||
$userselector = new role_check_users_selector('reportuser', $options);
|
||||
$userselector->set_rows(20);
|
||||
|
||||
// Work out an appropriate page title.
|
||||
$title = get_string('checkpermissionsin', 'core_role', $contextname);
|
||||
$title = get_string('checkpermissionsin', 'role', $contextname);
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->set_title($title);
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('checkpermissions', '', array('contextid' => $contextid));
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
@@ -87,17 +81,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid), $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php');
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -123,7 +117,7 @@ if (!is_null($reportuser)) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
if (!empty($roleassignments)) {
|
||||
echo $OUTPUT->heading(get_string('rolesforuser', 'core_role', fullname($reportuser)), 3);
|
||||
echo $OUTPUT->heading(get_string('rolesforuser', 'role', fullname($reportuser)), 3);
|
||||
echo html_writer::start_tag('ul');
|
||||
|
||||
$systemcontext = context_system::instance();
|
||||
@@ -137,20 +131,20 @@ if (!is_null($reportuser)) {
|
||||
array('action' => 'view', 'roleid' => $ra->roleid)), $rolename);
|
||||
}
|
||||
|
||||
echo html_writer::tag('li', get_string('roleincontext', 'core_role',
|
||||
echo html_writer::tag('li', get_string('roleincontext', 'role',
|
||||
array('role' => $rolename, 'context' => $link)));
|
||||
}
|
||||
echo html_writer::end_tag('ul');
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('permissionsforuser', 'core_role', fullname($reportuser)), 3);
|
||||
$table = new core_role_check_capability_table($context, $reportuser, $contextname);
|
||||
echo $OUTPUT->heading(get_string('permissionsforuser', 'role', fullname($reportuser)), 3);
|
||||
$table = new check_capability_table($context, $reportuser, $contextname);
|
||||
$table->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$selectheading = get_string('selectanotheruser', 'core_role');
|
||||
$selectheading = get_string('selectanotheruser', 'role');
|
||||
} else {
|
||||
$selectheading = get_string('selectauser', 'core_role');
|
||||
$selectheading = get_string('selectauser', 'role');
|
||||
}
|
||||
|
||||
// Show UI for choosing a user to report on.
|
||||
@@ -171,14 +165,14 @@ echo $OUTPUT->heading('<label for="reportuser">' . $selectheading . '</label>',
|
||||
$userselector->display();
|
||||
|
||||
// Submit button and the end of the form.
|
||||
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'core_role') . '" /></p>';
|
||||
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'role') . '" /></p>';
|
||||
echo '</form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// Appropriate back link.
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Existing admin user selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
class core_role_admins_existing_selector extends user_selector_base {
|
||||
/**
|
||||
* Create instance.
|
||||
*
|
||||
* @param string $name control name
|
||||
* @param array $options should have two elements with keys groupid and courseid.
|
||||
*/
|
||||
public function __construct($name = null, $options = array()) {
|
||||
if (is_null($name)) {
|
||||
$name = 'removeselect';
|
||||
}
|
||||
$options['multiselect'] = false;
|
||||
parent::__construct($name, $options);
|
||||
}
|
||||
|
||||
public function find_users($search) {
|
||||
global $DB, $CFG;
|
||||
list($wherecondition, $params) = $this->search_sql($search, '');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('');
|
||||
|
||||
if ($wherecondition) {
|
||||
$wherecondition = "$wherecondition AND id IN ($CFG->siteadmins)";
|
||||
} else {
|
||||
$wherecondition = "id IN ($CFG->siteadmins)";
|
||||
}
|
||||
$sql = " FROM {user}
|
||||
WHERE $wherecondition";
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext);
|
||||
$params = array_merge($params, $sortparams);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, $params);
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$mainadmin = array();
|
||||
$mainadminuser = get_admin();
|
||||
if ($mainadminuser && isset($availableusers[$mainadminuser->id])) {
|
||||
$mainadmin = array($mainadminuser->id => $availableusers[$mainadminuser->id]);
|
||||
unset($availableusers[$mainadminuser->id]);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($mainadmin) {
|
||||
$result[get_string('mainadmin', 'core_role')] = $mainadmin;
|
||||
}
|
||||
|
||||
if ($availableusers) {
|
||||
if ($search) {
|
||||
$groupname = get_string('extusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('extusers', 'core_role');
|
||||
}
|
||||
$result[$groupname] = $availableusers;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +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/>.
|
||||
|
||||
/**
|
||||
* Potential admin user selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
class core_role_admins_potential_selector extends user_selector_base {
|
||||
/**
|
||||
* Create instance.
|
||||
*
|
||||
* @param string $name control name
|
||||
* @param array $options should have two elements with keys groupid and courseid.
|
||||
*/
|
||||
public function __construct($name = null, $options = array()) {
|
||||
global $CFG;
|
||||
if (is_null($name)) {
|
||||
$name = 'addselect';
|
||||
}
|
||||
$options['multiselect'] = false;
|
||||
$options['exclude'] = explode(',', $CFG->siteadmins);
|
||||
parent::__construct($name, $options);
|
||||
}
|
||||
|
||||
public function find_users($search) {
|
||||
global $CFG, $DB;
|
||||
list($wherecondition, $params) = $this->search_sql($search, '');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('');
|
||||
$countfields = 'SELECT COUNT(1)';
|
||||
|
||||
$sql = " FROM {user}
|
||||
WHERE $wherecondition AND mnethostid = :localmnet";
|
||||
|
||||
// It could be dangerous to make remote users admins and also this could lead to other problems.
|
||||
$params['localmnet'] = $CFG->mnet_localhost_id;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialcount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialcount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialcount);
|
||||
}
|
||||
}
|
||||
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$groupname = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
return array($groupname => $availableusers);
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +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/>.
|
||||
|
||||
/**
|
||||
* Role assign matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.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 assigns tab.
|
||||
*/
|
||||
class core_role_allow_assign_page extends core_role_allow_role_page {
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_assign', 'allowassign');
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_assign($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletoassign', 'core_role', $a);
|
||||
}
|
||||
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowassign', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -1,49 +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/>.
|
||||
|
||||
/**
|
||||
* Role override matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.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 overrides tab.
|
||||
*/
|
||||
class core_role_allow_override_page extends core_role_allow_role_page {
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_override', 'allowoverride');
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_override($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletooverride', 'core_role', $a);
|
||||
}
|
||||
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowoverride2', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -1,164 +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/>.
|
||||
|
||||
/**
|
||||
* Base class for allow matrices.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Base class for managing the data in the grid of checkboxes on the role allow
|
||||
* allow/overrides/switch editing pages (allow.php).
|
||||
*/
|
||||
abstract class core_role_allow_role_page {
|
||||
protected $tablename;
|
||||
protected $targetcolname;
|
||||
protected $roles;
|
||||
protected $allowed = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $tablename the table where our data is stored.
|
||||
* @param string $targetcolname the name of the target role id column.
|
||||
*/
|
||||
public function __construct($tablename, $targetcolname) {
|
||||
$this->tablename = $tablename;
|
||||
$this->targetcolname = $targetcolname;
|
||||
$this->load_required_roles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load information about all the roles we will need information about.
|
||||
*/
|
||||
protected function load_required_roles() {
|
||||
// Get all roles.
|
||||
$this->roles = role_fix_names(get_all_roles(), context_system::instance(), ROLENAME_ORIGINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the data with the new settings submitted by the user.
|
||||
*/
|
||||
public function process_submission() {
|
||||
global $DB;
|
||||
// Delete all records, then add back the ones that should be allowed.
|
||||
$DB->delete_records($this->tablename);
|
||||
foreach ($this->roles as $fromroleid => $notused) {
|
||||
foreach ($this->roles as $targetroleid => $alsonotused) {
|
||||
if (optional_param('s_' . $fromroleid . '_' . $targetroleid, false, PARAM_BOOL)) {
|
||||
$this->set_allow($fromroleid, $targetroleid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set one allow in the database.
|
||||
* @param int $fromroleid
|
||||
* @param int $targetroleid
|
||||
*/
|
||||
protected abstract function set_allow($fromroleid, $targetroleid);
|
||||
|
||||
/**
|
||||
* Load the current allows from the database.
|
||||
*/
|
||||
public function load_current_settings() {
|
||||
global $DB;
|
||||
// Load the current settings.
|
||||
$this->allowed = array();
|
||||
foreach ($this->roles as $role) {
|
||||
// Make an array $role->id => false. This is probably too clever for its own good.
|
||||
$this->allowed[$role->id] = array_combine(array_keys($this->roles), array_fill(0, count($this->roles), false));
|
||||
}
|
||||
$rs = $DB->get_recordset($this->tablename);
|
||||
foreach ($rs as $allow) {
|
||||
$this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true;
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is target allowed?
|
||||
*
|
||||
* @param integer $targetroleid a role id.
|
||||
* @return boolean whether the user should be allowed to select this role as a target role.
|
||||
*/
|
||||
protected function is_allowed_target($targetroleid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns structure that can be passed to print_table,
|
||||
* containing one cell for each checkbox.
|
||||
* @return html_table a table
|
||||
*/
|
||||
public function get_table() {
|
||||
$table = new html_table();
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->align = array('left');
|
||||
$table->rotateheaders = true;
|
||||
$table->head = array(' ');
|
||||
$table->colclasses = array('');
|
||||
|
||||
// Add role name headers.
|
||||
foreach ($this->roles as $targetrole) {
|
||||
$table->head[] = $targetrole->localname;
|
||||
$table->align[] = 'left';
|
||||
if ($this->is_allowed_target($targetrole->id)) {
|
||||
$table->colclasses[] = '';
|
||||
} else {
|
||||
$table->colclasses[] = 'dimmed_text';
|
||||
}
|
||||
}
|
||||
|
||||
// Now the rest of the table.
|
||||
foreach ($this->roles as $fromrole) {
|
||||
$row = array($fromrole->localname);
|
||||
foreach ($this->roles as $targetrole) {
|
||||
$checked = '';
|
||||
$disabled = '';
|
||||
if ($this->allowed[$fromrole->id][$targetrole->id]) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
if (!$this->is_allowed_target($targetrole->id)) {
|
||||
$disabled = 'disabled="disabled" ';
|
||||
}
|
||||
$name = 's_' . $fromrole->id . '_' . $targetrole->id;
|
||||
$tooltip = $this->get_cell_tooltip($fromrole, $targetrole);
|
||||
$row[] = '<input type="checkbox" name="' . $name . '" id="' . $name .
|
||||
'" title="' . $tooltip . '" value="1" ' . $checked . $disabled . '/>' .
|
||||
'<label for="' . $name . '" class="accesshide">' . $tooltip . '</label>';
|
||||
}
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snippet of text displayed above the table, telling the admin what to do.
|
||||
* @return string
|
||||
*/
|
||||
public abstract function get_intro_text();
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Role witch matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.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 switches tab.
|
||||
*/
|
||||
class core_role_allow_switch_page extends core_role_allow_role_page {
|
||||
protected $allowedtargetroles;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_switch', 'allowswitch');
|
||||
}
|
||||
|
||||
protected function load_required_roles() {
|
||||
global $DB;
|
||||
parent::load_required_roles();
|
||||
$this->allowedtargetroles = $DB->get_records_menu('role', null, 'id');
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_switch($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function is_allowed_target($targetroleid) {
|
||||
return isset($this->allowedtargetroles[$targetroleid]);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletoswitch', 'core_role', $a);
|
||||
}
|
||||
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowswitch', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
/**
|
||||
* Base class to avoid duplicating code.
|
||||
*/
|
||||
abstract class core_role_assign_user_selector_base extends user_selector_base {
|
||||
protected $roleid;
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @param string $name control name
|
||||
* @param array $options should have two elements with keys groupid and courseid.
|
||||
*/
|
||||
public function __construct($name, $options) {
|
||||
global $CFG;
|
||||
if (isset($options['context'])) {
|
||||
$this->context = $options['context'];
|
||||
} else {
|
||||
$this->context = context::instance_by_id($options['contextid']);
|
||||
}
|
||||
$options['accesscontext'] = $this->context;
|
||||
parent::__construct($name, $options);
|
||||
$this->roleid = $options['roleid'];
|
||||
require_once($CFG->dirroot . '/group/lib.php');
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
$options['roleid'] = $this->roleid;
|
||||
$options['contextid'] = $this->context->id;
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,179 +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/>.
|
||||
|
||||
/**
|
||||
* Base capability table.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This class represents a table with one row for each of a list of capabilities
|
||||
* where the first cell in the row contains the capability name, and there is
|
||||
* arbitrary stuff in the rest of the row. This class is used by
|
||||
* admin/roles/manage.php, override.php and check.php.
|
||||
*
|
||||
* An ajaxy search UI shown at the top, if JavaScript is on.
|
||||
*/
|
||||
abstract class core_role_capability_table_base {
|
||||
/** The context this table relates to. */
|
||||
protected $context;
|
||||
|
||||
/** The capabilities to display. Initialised as $context->get_capabilities(). */
|
||||
protected $capabilities = array();
|
||||
|
||||
/** Added as an id="" attribute to the table on output. */
|
||||
protected $id;
|
||||
|
||||
/** Added to the class="" attribute on output. */
|
||||
protected $classes = array('rolecap');
|
||||
|
||||
/** Default number of capabilities in the table for the search UI to be shown. */
|
||||
const NUM_CAPS_FOR_SEARCH = 12;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param context $context the context this table relates to.
|
||||
* @param string $id what to put in the id="" attribute.
|
||||
*/
|
||||
public function __construct(context $context, $id) {
|
||||
$this->context = $context;
|
||||
$this->capabilities = $context->get_capabilities();
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to add class="" attributes to the table. You get the rolecap by
|
||||
* default.
|
||||
* @param array $classnames of class names.
|
||||
*/
|
||||
public function add_classes($classnames) {
|
||||
$this->classes = array_unique(array_merge($this->classes, $classnames));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the table.
|
||||
*/
|
||||
public function display() {
|
||||
if (count($this->capabilities) > self::NUM_CAPS_FOR_SEARCH) {
|
||||
global $PAGE;
|
||||
$jsmodule = array(
|
||||
'name' => 'rolescapfilter',
|
||||
'fullpath' => '/admin/roles/module.js',
|
||||
'strings' => array(
|
||||
array('filter', 'moodle'),
|
||||
array('clear', 'moodle'), ),
|
||||
'requires' => array('node', 'cookie', 'escape')
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.core_role.init_cap_table_filter', array($this->id, $this->context->id), false,
|
||||
$jsmodule);
|
||||
}
|
||||
echo '<table class="' . implode(' ', $this->classes) . '" id="' . $this->id . '">' . "\n<thead>\n";
|
||||
echo '<tr><th class="name" align="left" scope="col">' . get_string('capability', 'core_role') . '</th>';
|
||||
$this->add_header_cells();
|
||||
echo "</tr>\n</thead>\n<tbody>\n";
|
||||
|
||||
// Loop over capabilities.
|
||||
$contextlevel = 0;
|
||||
$component = '';
|
||||
foreach ($this->capabilities as $capability) {
|
||||
if ($this->skip_row($capability)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prints a breaker if component or name or context level has changed.
|
||||
if (component_level_changed($capability, $component, $contextlevel)) {
|
||||
$this->print_heading_row($capability);
|
||||
}
|
||||
$contextlevel = $capability->contextlevel;
|
||||
$component = $capability->component;
|
||||
|
||||
// Start the row.
|
||||
echo '<tr class="' . implode(' ', array_unique(array_merge(array('rolecap'),
|
||||
$this->get_row_classes($capability)))) . '">';
|
||||
|
||||
// Table cell for the capability name.
|
||||
echo '<th scope="row" class="name"><span class="cap-desc">' . get_capability_docs_link($capability) .
|
||||
'<span class="cap-name">' . $capability->name . '</span></span></th>';
|
||||
|
||||
// Add the cells specific to this table.
|
||||
$this->add_row_cells($capability);
|
||||
|
||||
// End the row.
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
// End of the table.
|
||||
echo "</tbody>\n</table>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to output a heading rows when the context level or component changes.
|
||||
* @param stdClass $capability gives the new component and contextlevel.
|
||||
*/
|
||||
protected function print_heading_row($capability) {
|
||||
echo '<tr class="rolecapheading header"><td colspan="' . (1 + $this->num_extra_columns()) . '" class="header"><strong>' .
|
||||
get_component_string($capability->component, $capability->contextlevel) .
|
||||
'</strong></td></tr>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses to override, output header cells, after the initial capability one.
|
||||
*/
|
||||
protected abstract function add_header_cells();
|
||||
|
||||
/**
|
||||
* For subclasses to override, return the number of cells that add_header_cells/add_row_cells output.
|
||||
*/
|
||||
protected abstract function num_extra_columns();
|
||||
|
||||
/**
|
||||
* For subclasses to override. Allows certain capabilties
|
||||
* to be left out of the table.
|
||||
*
|
||||
* @param object $capability the capability this row relates to.
|
||||
* @return boolean. If true, this row is omitted from the table.
|
||||
*/
|
||||
protected function skip_row($capability) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses to override. A change to reaturn class names that are added
|
||||
* to the class="" attribute on the <tr> for this capability.
|
||||
*
|
||||
* @param stdClass $capability the capability this row relates to.
|
||||
* @return array of class name strings.
|
||||
*/
|
||||
protected function get_row_classes($capability) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses to override. Output the data cells for this capability. The
|
||||
* capability name cell will already have been output.
|
||||
*
|
||||
* You can rely on get_row_classes always being called before add_row_cells.
|
||||
*
|
||||
* @param stdClass $capability the capability this row relates to.
|
||||
*/
|
||||
protected abstract function add_row_cells($capability);
|
||||
}
|
||||
@@ -1,193 +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/>.
|
||||
|
||||
/**
|
||||
* Capabilities table with risks.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This subclass is the bases for both the define roles and override roles
|
||||
* pages. As well as adding the risks columns, this also provides generic
|
||||
* facilities for showing a certain number of permissions columns, and
|
||||
* recording the current and submitted permissions for each capability.
|
||||
*/
|
||||
abstract class core_role_capability_table_with_risks extends core_role_capability_table_base {
|
||||
protected $allrisks;
|
||||
protected $allpermissions; // We don't need perms ourselves, but all our subclasses do.
|
||||
protected $strperms; // Language string cache.
|
||||
protected $risksurl; // URL in moodledocs about risks.
|
||||
protected $riskicons = array(); // Cache to avoid regenerating the HTML for each risk icon.
|
||||
/** @var array The capabilities to highlight as default/inherited. */
|
||||
protected $parentpermissions;
|
||||
protected $displaypermissions;
|
||||
protected $permissions;
|
||||
protected $changed;
|
||||
protected $roleid;
|
||||
|
||||
public function __construct($context, $id, $roleid) {
|
||||
parent::__construct($context, $id);
|
||||
|
||||
$this->allrisks = get_all_risks();
|
||||
$this->risksurl = get_docs_url(s(get_string('risks', 'core_role')));
|
||||
|
||||
$this->allpermissions = array(
|
||||
CAP_INHERIT => 'inherit',
|
||||
CAP_ALLOW => 'allow',
|
||||
CAP_PREVENT => 'prevent' ,
|
||||
CAP_PROHIBIT => 'prohibit',
|
||||
);
|
||||
|
||||
$this->strperms = array();
|
||||
foreach ($this->allpermissions as $permname) {
|
||||
$this->strperms[$permname] = get_string($permname, 'core_role');
|
||||
}
|
||||
|
||||
$this->roleid = $roleid;
|
||||
$this->load_current_permissions();
|
||||
|
||||
// Fill in any blank permissions with an explicit CAP_INHERIT, and init a locked field.
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
if (!isset($this->permissions[$cap->name])) {
|
||||
$this->permissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
$this->capabilities[$capid]->locked = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function load_current_permissions() {
|
||||
global $DB;
|
||||
|
||||
// Load the overrides/definition in this context.
|
||||
if ($this->roleid) {
|
||||
$this->permissions = $DB->get_records_menu('role_capabilities', array('roleid' => $this->roleid,
|
||||
'contextid' => $this->context->id), '', 'capability,permission');
|
||||
} else {
|
||||
$this->permissions = array();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract function load_parent_permissions();
|
||||
|
||||
/**
|
||||
* Update $this->permissions based on submitted data, while making a list of
|
||||
* changed capabilities in $this->changed.
|
||||
*/
|
||||
public function read_submitted_permissions() {
|
||||
$this->changed = array();
|
||||
|
||||
foreach ($this->capabilities as $cap) {
|
||||
if ($cap->locked || $this->skip_row($cap)) {
|
||||
// The user is not allowed to change the permission for this capability.
|
||||
continue;
|
||||
}
|
||||
|
||||
$permission = optional_param($cap->name, null, PARAM_PERMISSION);
|
||||
if (is_null($permission)) {
|
||||
// A permission was not specified in submitted data.
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the permission has changed, update $this->permissions and
|
||||
// Record the fact there is data to save.
|
||||
if ($this->permissions[$cap->name] != $permission) {
|
||||
$this->permissions[$cap->name] = $permission;
|
||||
$this->changed[] = $cap->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the new values of any permissions that have been changed.
|
||||
*/
|
||||
public function save_changes() {
|
||||
// Set the permissions.
|
||||
foreach ($this->changed as $changedcap) {
|
||||
assign_capability($changedcap, $this->permissions[$changedcap],
|
||||
$this->roleid, $this->context->id, true);
|
||||
}
|
||||
|
||||
// Force accessinfo refresh for users visiting this context.
|
||||
$this->context->mark_dirty();
|
||||
}
|
||||
|
||||
public function display() {
|
||||
$this->load_parent_permissions();
|
||||
foreach ($this->capabilities as $cap) {
|
||||
if (!isset($this->parentpermissions[$cap->name])) {
|
||||
$this->parentpermissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
parent::display();
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
global $OUTPUT;
|
||||
echo '<th colspan="' . count($this->displaypermissions) . '" scope="col">' .
|
||||
get_string('permission', 'core_role') . ' ' . $OUTPUT->help_icon('permission', 'core_role') . '</th>';
|
||||
echo '<th class="risk" colspan="' . count($this->allrisks) . '" scope="col">' . get_string('risks', 'core_role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return count($this->displaypermissions) + count($this->allrisks);
|
||||
}
|
||||
|
||||
protected function get_row_classes($capability) {
|
||||
$rowclasses = array();
|
||||
foreach ($this->allrisks as $riskname => $risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
$rowclasses[] = $riskname;
|
||||
}
|
||||
}
|
||||
return $rowclasses;
|
||||
}
|
||||
|
||||
protected abstract function add_permission_cells($capability);
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
$this->add_permission_cells($capability);
|
||||
// One cell for each possible risk.
|
||||
foreach ($this->allrisks as $riskname => $risk) {
|
||||
echo '<td class="risk ' . str_replace('risk', '', $riskname) . '">';
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
echo $this->get_risk_icon($riskname);
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a risk icon, as a link to the Risks page on Moodle Docs.
|
||||
*
|
||||
* @param string $type the type of risk, will be one of the keys from the
|
||||
* get_all_risks array. Must start with 'risk'.
|
||||
*/
|
||||
public function get_risk_icon($type) {
|
||||
global $OUTPUT;
|
||||
if (!isset($this->riskicons[$type])) {
|
||||
$iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type));
|
||||
$text = '<img src="' . $iconurl . '" alt="' . get_string($type . 'short', 'admin') . '" />';
|
||||
$action = new popup_action('click', $this->risksurl, 'docspopup');
|
||||
$this->riskicons[$type] = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin')));
|
||||
}
|
||||
return $this->riskicons[$type];
|
||||
}
|
||||
}
|
||||
@@ -1,84 +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/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of core_role_capability_table_base for use on the Check permissions page.
|
||||
*
|
||||
* We have one additional column, Allowed, which contains yes/no.
|
||||
*/
|
||||
class core_role_check_capability_table extends core_role_capability_table_base {
|
||||
protected $user;
|
||||
protected $fullname;
|
||||
protected $contextname;
|
||||
protected $stryes;
|
||||
protected $strno;
|
||||
private $hascap;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param object $context the context this table relates to.
|
||||
* @param object $user the user we are generating the results for.
|
||||
* @param string $contextname $context->get_context_name() - to save recomputing.
|
||||
*/
|
||||
public function __construct($context, $user, $contextname) {
|
||||
parent::__construct($context, 'explaincaps');
|
||||
$this->user = $user;
|
||||
$this->fullname = fullname($user);
|
||||
$this->contextname = $contextname;
|
||||
$this->stryes = get_string('yes');
|
||||
$this->strno = get_string('no');
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
echo '<th>' . get_string('allowed', 'core_role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function get_row_classes($capability) {
|
||||
$this->hascap = has_capability($capability->name, $this->context, $this->user->id);
|
||||
if ($this->hascap) {
|
||||
return array('yes');
|
||||
} else {
|
||||
return array('no');
|
||||
}
|
||||
}
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
if ($this->hascap) {
|
||||
$result = $this->stryes;
|
||||
} else {
|
||||
$result = $this->strno;
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->fullname = $this->fullname;
|
||||
$a->capability = $capability->name;
|
||||
$a->context = $this->contextname;
|
||||
echo '<td>' . $result . '</td>';
|
||||
}
|
||||
}
|
||||
@@ -1,153 +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/>.
|
||||
|
||||
/**
|
||||
* User selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
/**
|
||||
* User selector subclass for the selection of users in the check permissions page.
|
||||
*
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
*/
|
||||
class core_role_check_users_selector extends user_selector_base {
|
||||
/** @var bool limit listing of users to enrolled only */
|
||||
protected $onlyenrolled;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name the control name/id for use in the HTML.
|
||||
* @param array $options other options needed to construct this selector.
|
||||
* You must be able to clone a userselector by doing new get_class($us)($us->get_name(), $us->get_options());
|
||||
*/
|
||||
public function __construct($name, $options) {
|
||||
if (!isset($options['multiselect'])) {
|
||||
$options['multiselect'] = false;
|
||||
}
|
||||
parent::__construct($name, $options);
|
||||
|
||||
$coursecontext = $this->accesscontext->get_course_context(false);
|
||||
if ($coursecontext and $coursecontext->id != SITEID and !has_capability('moodle/role:manage', $coursecontext)) {
|
||||
// Prevent normal teachers from looking up all users.
|
||||
$this->onlyenrolled = true;
|
||||
} else {
|
||||
$this->onlyenrolled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('u');
|
||||
$countfields = 'SELECT COUNT(1)';
|
||||
|
||||
$coursecontext = $this->accesscontext->get_course_context(false);
|
||||
|
||||
if ($coursecontext and $coursecontext != SITEID) {
|
||||
$sql1 = " FROM {user} u
|
||||
JOIN {user_enrolments} ue ON (ue.userid = u.id)
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
|
||||
WHERE $wherecondition";
|
||||
$params['courseid1'] = $coursecontext->instanceid;
|
||||
|
||||
if ($this->onlyenrolled) {
|
||||
$sql2 = null;
|
||||
} else {
|
||||
$sql2 = " FROM {user} u
|
||||
LEFT JOIN ({user_enrolments} ue
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid2)) ON (ue.userid = u.id)
|
||||
WHERE $wherecondition
|
||||
AND ue.id IS NULL";
|
||||
$params['courseid2'] = $coursecontext->instanceid;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($this->onlyenrolled) {
|
||||
// Bad luck, current user may not view only enrolled users.
|
||||
return array();
|
||||
}
|
||||
$sql1 = null;
|
||||
$sql2 = " FROM {user} u
|
||||
WHERE $wherecondition";
|
||||
}
|
||||
|
||||
$params['contextid'] = $this->accesscontext->id;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
$result = array();
|
||||
|
||||
if ($search) {
|
||||
$groupname1 = get_string('enrolledusersmatching', 'enrol', $search);
|
||||
$groupname2 = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname1 = get_string('enrolledusers', 'enrol');
|
||||
$groupname2 = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
if ($sql1) {
|
||||
$enrolleduserscount = $DB->count_records_sql($countfields . $sql1, $params);
|
||||
if (!$this->is_validating() and $enrolleduserscount > $this->maxusersperpage) {
|
||||
$result[$groupname1] = array();
|
||||
$toomany = $this->too_many_results($search, $enrolleduserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
|
||||
} else {
|
||||
$enrolledusers = $DB->get_records_sql($fields . $sql1 . $order, array_merge($params, $sortparams));
|
||||
if ($enrolledusers) {
|
||||
$result[$groupname1] = $enrolledusers;
|
||||
}
|
||||
}
|
||||
if ($sql2) {
|
||||
$result[''] = array();
|
||||
}
|
||||
}
|
||||
if ($sql2) {
|
||||
$otheruserscount = $DB->count_records_sql($countfields . $sql2, $params);
|
||||
if (!$this->is_validating() and $otheruserscount > $this->maxusersperpage) {
|
||||
$result[$groupname2] = array();
|
||||
$toomany = $this->too_many_results($search, $otheruserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
} else {
|
||||
$otherusers = $DB->get_records_sql($fields . $sql2 . $order, array_merge($params, $sortparams));
|
||||
if ($otherusers) {
|
||||
$result[$groupname2] = $otherusers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,646 +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/>.
|
||||
|
||||
/**
|
||||
* Advanced role definition form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* As well as tracking the permissions information about the role we are creating
|
||||
* or editing, we also track the other information about the role. (This class is
|
||||
* starting to be more and more like a formslib form in some respects.)
|
||||
*/
|
||||
class core_role_define_role_table_advanced extends core_role_capability_table_with_risks {
|
||||
/** @var stdClass Used to store other information (besides permissions) about the role we are creating/editing. */
|
||||
protected $role;
|
||||
/** @var array Used to store errors found when validating the data. */
|
||||
protected $errors;
|
||||
protected $contextlevels;
|
||||
protected $allcontextlevels;
|
||||
protected $disabled = '';
|
||||
|
||||
protected $allowassign;
|
||||
protected $allowoverride;
|
||||
protected $allowswitch;
|
||||
|
||||
public function __construct($context, $roleid) {
|
||||
$this->roleid = $roleid;
|
||||
parent::__construct($context, 'defineroletable', $roleid);
|
||||
$this->displaypermissions = $this->allpermissions;
|
||||
$this->strperms[$this->allpermissions[CAP_INHERIT]] = get_string('notset', 'core_role');
|
||||
|
||||
$this->allcontextlevels = array();
|
||||
$levels = context_helper::get_all_levels();
|
||||
foreach ($levels as $level => $classname) {
|
||||
$this->allcontextlevels[$level] = context_helper::get_level_name($level);
|
||||
}
|
||||
}
|
||||
|
||||
protected function load_current_permissions() {
|
||||
global $DB;
|
||||
if ($this->roleid) {
|
||||
if (!$this->role = $DB->get_record('role', array('id' => $this->roleid))) {
|
||||
throw new moodle_exception('invalidroleid');
|
||||
}
|
||||
$contextlevels = get_role_contextlevels($this->roleid);
|
||||
// Put the contextlevels in the array keys, as well as the values.
|
||||
if (!empty($contextlevels)) {
|
||||
$this->contextlevels = array_combine($contextlevels, $contextlevels);
|
||||
} else {
|
||||
$this->contextlevels = array();
|
||||
}
|
||||
$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'));
|
||||
|
||||
} else {
|
||||
$this->role = new stdClass;
|
||||
$this->role->name = '';
|
||||
$this->role->shortname = '';
|
||||
$this->role->description = '';
|
||||
$this->role->archetype = '';
|
||||
$this->contextlevels = array();
|
||||
$this->allowassign = array();
|
||||
$this->allowoverride = array();
|
||||
$this->allowswitch = array();
|
||||
}
|
||||
parent::load_current_permissions();
|
||||
}
|
||||
|
||||
public function read_submitted_permissions() {
|
||||
global $DB;
|
||||
$this->errors = array();
|
||||
|
||||
// Role short name. We clean this in a special way. We want to end up
|
||||
// with only lowercase safe ASCII characters.
|
||||
$shortname = optional_param('shortname', null, PARAM_RAW);
|
||||
if (!is_null($shortname)) {
|
||||
$this->role->shortname = $shortname;
|
||||
$this->role->shortname = core_text::specialtoascii($this->role->shortname);
|
||||
$this->role->shortname = core_text::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
|
||||
if (empty($this->role->shortname)) {
|
||||
$this->errors['shortname'] = get_string('errorbadroleshortname', 'core_role');
|
||||
}
|
||||
}
|
||||
if ($DB->record_exists_select('role', 'shortname = ? and id <> ?', array($this->role->shortname, $this->roleid))) {
|
||||
$this->errors['shortname'] = get_string('errorexistsroleshortname', 'core_role');
|
||||
}
|
||||
|
||||
// Role name.
|
||||
$name = optional_param('name', null, PARAM_TEXT);
|
||||
if (!is_null($name)) {
|
||||
$this->role->name = $name;
|
||||
// Hack: short names of standard roles are equal to archetypes, empty name means localised via lang packs.
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$shortname]) and html_is_blank($this->role->name)) {
|
||||
$this->errors['name'] = get_string('errorbadrolename', 'core_role');
|
||||
}
|
||||
}
|
||||
if ($this->role->name !== '' and $DB->record_exists_select('role', 'name = ? and id <> ?', array($this->role->name, $this->roleid))) {
|
||||
$this->errors['name'] = get_string('errorexistsrolename', 'core_role');
|
||||
}
|
||||
|
||||
// Description.
|
||||
$description = optional_param('description', null, PARAM_RAW);
|
||||
if (!is_null($description)) {
|
||||
$this->role->description = $description;
|
||||
}
|
||||
|
||||
// Legacy type.
|
||||
$archetype = optional_param('archetype', null, PARAM_RAW);
|
||||
if (isset($archetype)) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (isset($archetypes[$archetype])) {
|
||||
$this->role->archetype = $archetype;
|
||||
} else {
|
||||
$this->role->archetype = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Assignable context levels.
|
||||
foreach ($this->allcontextlevels as $cl => $notused) {
|
||||
$assignable = optional_param('contextlevel' . $cl, null, PARAM_BOOL);
|
||||
if (!is_null($assignable)) {
|
||||
if ($assignable) {
|
||||
$this->contextlevels[$cl] = $cl;
|
||||
} else {
|
||||
unset($this->contextlevels[$cl]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allowed roles.
|
||||
$allow = optional_param_array('allowassign', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowassign = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowoverride', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowoverride = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowswitch', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowswitch = $allow;
|
||||
}
|
||||
|
||||
// Now read the permissions for each capability.
|
||||
parent::read_submitted_permissions();
|
||||
}
|
||||
|
||||
public function is_submission_valid() {
|
||||
return empty($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this after the table has been initialised,
|
||||
* this resets everything to that role.
|
||||
*
|
||||
* @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'
|
||||
*/
|
||||
public function force_duplicate($roleid, array $options) {
|
||||
global $DB;
|
||||
|
||||
if ($roleid == 0) {
|
||||
// This means reset to nothing == remove everything.
|
||||
|
||||
if ($options['shortname']) {
|
||||
$this->role->shortname = '';
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
$this->role->name = '';
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
$this->role->description = '';
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
$this->role->archetype = '';
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
$this->contextlevels = array();
|
||||
}
|
||||
|
||||
if ($options['allowassign']) {
|
||||
$this->allowassign = array();
|
||||
}
|
||||
if ($options['allowoverride']) {
|
||||
$this->allowoverride = array();
|
||||
}
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = array();
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
$this->permissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
if ($options['shortname']) {
|
||||
$this->role->shortname = $role->shortname;
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
$this->role->name = $role->name;
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
$this->role->description = $role->description;
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
$this->role->archetype = $role->archetype;
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
$this->contextlevels = array();
|
||||
$levels = get_role_contextlevels($roleid);
|
||||
foreach ($levels as $cl) {
|
||||
$this->contextlevels[$cl] = $cl;
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['allowassign']) {
|
||||
$this->allowassign = array_keys($this->get_allow_roles_list('assign', $roleid));
|
||||
}
|
||||
if ($options['allowoverride']) {
|
||||
$this->allowoverride = array_keys($this->get_allow_roles_list('override', $roleid));
|
||||
}
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = array_keys($this->get_allow_roles_list('switch', $roleid));
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
$this->permissions = $DB->get_records_menu('role_capabilities',
|
||||
array('roleid' => $roleid, 'contextid' => context_system::instance()->id),
|
||||
'', 'capability,permission');
|
||||
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
if (!isset($this->permissions[$cap->name])) {
|
||||
$this->permissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the role definition to match given archetype.
|
||||
*
|
||||
* @param string $archetype
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
*/
|
||||
public function force_archetype($archetype, array $options) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$archetype])) {
|
||||
throw new coding_exception('Unknown archetype: '.$archetype);
|
||||
}
|
||||
|
||||
if ($options['shortname']) {
|
||||
$this->role->shortname = '';
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
$this->role->name = '';
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
$this->role->description = '';
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
$this->role->archetype = $archetype;
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
$this->contextlevels = array();
|
||||
$defaults = get_default_contextlevels($archetype);
|
||||
foreach ($defaults as $cl) {
|
||||
$this->contextlevels[$cl] = $cl;
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['allowassign']) {
|
||||
$this->allowassign = get_default_role_archetype_allows('assign', $archetype);
|
||||
}
|
||||
if ($options['allowoverride']) {
|
||||
$this->allowoverride = get_default_role_archetype_allows('override', $archetype);
|
||||
}
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = get_default_role_archetype_allows('switch', $archetype);
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
$defaultpermissions = get_default_capabilities($archetype);
|
||||
foreach ($this->permissions as $k => $v) {
|
||||
if (isset($defaultpermissions[$k])) {
|
||||
$this->permissions[$k] = $defaultpermissions[$k];
|
||||
continue;
|
||||
}
|
||||
$this->permissions[$k] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the role definition to match given preset.
|
||||
*
|
||||
* @param string $xml
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
*/
|
||||
public function force_preset($xml, array $options) {
|
||||
if (!$info = core_role_preset::parse_preset($xml)) {
|
||||
throw new coding_exception('Invalid role preset');
|
||||
}
|
||||
|
||||
if ($options['shortname']) {
|
||||
if (isset($info['shortname'])) {
|
||||
$this->role->shortname = $info['shortname'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
if (isset($info['name'])) {
|
||||
$this->role->name = $info['name'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
if (isset($info['description'])) {
|
||||
$this->role->description = $info['description'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
if (isset($info['archetype'])) {
|
||||
$this->role->archetype = $info['archetype'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
if (isset($info['contextlevels'])) {
|
||||
$this->contextlevels = $info['contextlevels'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
if ($options['allow'.$type]) {
|
||||
if (isset($info['allow'.$type])) {
|
||||
$this->{'allow'.$type} = $info['allow'.$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
foreach ($this->permissions as $k => $v) {
|
||||
// Note: do not set everything else to CAP_INHERIT here
|
||||
// because the xml file might not contain all capabilities.
|
||||
if (isset($info['permissions'][$k])) {
|
||||
$this->permissions[$k] = $info['permissions'][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get_role_name() {
|
||||
return $this->role->name;
|
||||
}
|
||||
|
||||
public function get_role_id() {
|
||||
return $this->role->id;
|
||||
}
|
||||
|
||||
public function get_archetype() {
|
||||
return $this->role->archetype;
|
||||
}
|
||||
|
||||
protected function load_parent_permissions() {
|
||||
$this->parentpermissions = get_default_capabilities($this->role->archetype);
|
||||
}
|
||||
|
||||
public function save_changes() {
|
||||
global $DB;
|
||||
|
||||
if (!$this->roleid) {
|
||||
// Creating role.
|
||||
$this->role->id = create_role($this->role->name, $this->role->shortname, $this->role->description, $this->role->archetype);
|
||||
$this->roleid = $this->role->id; // Needed to make the parent::save_changes(); call work.
|
||||
} else {
|
||||
// Updating role.
|
||||
$DB->update_record('role', $this->role);
|
||||
}
|
||||
|
||||
// Assignable contexts.
|
||||
set_role_contextlevels($this->role->id, $this->contextlevels);
|
||||
|
||||
// Set allowed roles.
|
||||
$this->save_allow('assign');
|
||||
$this->save_allow('override');
|
||||
$this->save_allow('switch');
|
||||
|
||||
// Permissions.
|
||||
parent::save_changes();
|
||||
}
|
||||
|
||||
protected function save_allow($type) {
|
||||
global $DB;
|
||||
|
||||
$current = array_keys($this->get_allow_roles_list($type));
|
||||
$wanted = $this->{'allow'.$type};
|
||||
|
||||
$addfunction = 'allow_'.$type;
|
||||
$deltable = 'role_allow_'.$type;
|
||||
$field = 'allow'.$type;
|
||||
|
||||
foreach ($current as $roleid) {
|
||||
if (!in_array($roleid, $wanted)) {
|
||||
$DB->delete_records($deltable, array('roleid'=>$this->roleid, $field=>$roleid));
|
||||
continue;
|
||||
}
|
||||
$key = array_search($roleid, $wanted);
|
||||
unset($wanted[$key]);
|
||||
}
|
||||
|
||||
foreach ($wanted as $roleid) {
|
||||
if ($roleid == -1) {
|
||||
$roleid = $this->roleid;
|
||||
}
|
||||
$addfunction($this->roleid, $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_name_field($id) {
|
||||
return '<input type="text" id="' . $id . '" name="' . $id . '" maxlength="254" value="' . s($this->role->name) . '" />';
|
||||
}
|
||||
|
||||
protected function get_shortname_field($id) {
|
||||
return '<input type="text" id="' . $id . '" name="' . $id . '" maxlength="254" value="' . s($this->role->shortname) . '" />';
|
||||
}
|
||||
|
||||
protected function get_description_field($id) {
|
||||
return print_textarea(true, 10, 50, 50, 10, 'description', $this->role->description, 0, true);
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
foreach (get_role_archetypes() as $type) {
|
||||
$options[$type] = get_string('archetype'.$type, 'role');
|
||||
}
|
||||
return html_writer::select($options, 'archetype', $this->role->archetype, false);
|
||||
}
|
||||
|
||||
protected function get_assignable_levels_control() {
|
||||
$output = '';
|
||||
foreach ($this->allcontextlevels as $cl => $clname) {
|
||||
$extraarguments = $this->disabled;
|
||||
if (in_array($cl, $this->contextlevels)) {
|
||||
$extraarguments .= 'checked="checked" ';
|
||||
}
|
||||
if (!$this->disabled) {
|
||||
$output .= '<input type="hidden" name="contextlevel' . $cl . '" value="0" />';
|
||||
}
|
||||
$output .= '<input type="checkbox" id="cl' . $cl . '" name="contextlevel' . $cl .
|
||||
'" value="1" ' . $extraarguments . '/> ';
|
||||
$output .= '<label for="cl' . $cl . '">' . $clname . "</label><br />\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of roles of the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @param int $roleid (null means current role)
|
||||
* @return array
|
||||
*/
|
||||
protected function get_allow_roles_list($type, $roleid = null) {
|
||||
global $DB;
|
||||
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($roleid === null) {
|
||||
$roleid = $this->roleid;
|
||||
}
|
||||
|
||||
if (empty($roleid)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT r.*
|
||||
FROM {role} r
|
||||
JOIN {role_allow_{$type}} a ON a.allow{$type} = r.id
|
||||
WHERE a.roleid = :roleid
|
||||
ORDER BY r.sortorder ASC";
|
||||
return $DB->get_records_sql($sql, array('roleid'=>$roleid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of roles with the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @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') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return '';
|
||||
}
|
||||
|
||||
$property = 'allow'.$type;
|
||||
$selected = $this->$property;
|
||||
|
||||
$options = array();
|
||||
foreach (role_get_names(null, ROLENAME_ALIAS) as $role) {
|
||||
$options[$role->id] = $role->localname;
|
||||
}
|
||||
if ($this->roleid == 0) {
|
||||
$options[-1] = get_string('thisnewrole', 'core_role');
|
||||
}
|
||||
return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple'=>'multiple', 'size'=>10));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the risks associated with a role.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_role_risks_info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function print_field($name, $caption, $field) {
|
||||
global $OUTPUT;
|
||||
// Attempt to generate HTML like formslib.
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle">';
|
||||
if ($name) {
|
||||
echo '<label for="' . $name . '">';
|
||||
}
|
||||
echo $caption;
|
||||
if ($name) {
|
||||
echo "</label>\n";
|
||||
}
|
||||
echo '</div>';
|
||||
if (isset($this->errors[$name])) {
|
||||
$extraclass = ' error';
|
||||
} else {
|
||||
$extraclass = '';
|
||||
}
|
||||
echo '<div class="felement' . $extraclass . '">';
|
||||
echo $field;
|
||||
if (isset($this->errors[$name])) {
|
||||
echo $OUTPUT->error_text($this->errors[$name]);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
protected function print_show_hide_advanced_button() {
|
||||
echo '<p class="definenotice">' . get_string('highlightedcellsshowdefault', 'core_role') . ' </p>';
|
||||
echo '<div class="advancedbutton">';
|
||||
echo '<input type="submit" name="toggleadvanced" value="' . get_string('hideadvanced', 'form') . '" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function display() {
|
||||
global $OUTPUT;
|
||||
// Extra fields at the top of the page.
|
||||
echo '<div class="topfields clearfix">';
|
||||
$this->print_field('shortname', get_string('roleshortname', 'core_role').' '.$OUTPUT->help_icon('roleshortname', 'core_role'), $this->get_shortname_field('shortname'));
|
||||
$this->print_field('name', get_string('customrolename', 'core_role').' '.$OUTPUT->help_icon('customrolename', 'core_role'), $this->get_name_field('name'));
|
||||
$this->print_field('edit-description', get_string('customroledescription', 'core_role').' '.$OUTPUT->help_icon('customroledescription', 'core_role'),
|
||||
$this->get_description_field('description'));
|
||||
$this->print_field('menuarchetype', get_string('archetype', 'core_role').' '.$OUTPUT->help_icon('archetype', 'core_role'), $this->get_archetype_field('archetype'));
|
||||
$this->print_field('', get_string('maybeassignedin', 'core_role'), $this->get_assignable_levels_control());
|
||||
$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'));
|
||||
if ($risks = $this->get_role_risks_info()) {
|
||||
$this->print_field('', get_string('rolerisks', 'core_role'), $risks);
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
$this->print_show_hide_advanced_button();
|
||||
|
||||
// Now the permissions table.
|
||||
parent::display();
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
// One cell for each possible permission.
|
||||
foreach ($this->displaypermissions as $perm => $permname) {
|
||||
$strperm = $this->strperms[$permname];
|
||||
$extraclass = '';
|
||||
if ($perm == $this->parentpermissions[$capability->name]) {
|
||||
$extraclass = ' capdefault';
|
||||
}
|
||||
$checked = '';
|
||||
if ($this->permissions[$capability->name] == $perm) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
echo '<td class="' . $permname . $extraclass . '">';
|
||||
echo '<label><input type="radio" name="' . $capability->name .
|
||||
'" value="' . $perm . '" ' . $checked . '/> ';
|
||||
echo '<span class="note">' . $strperm . '</span>';
|
||||
echo '</label></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class core_role_define_role_table_basic extends core_role_define_role_table_advanced {
|
||||
protected $stradvmessage;
|
||||
protected $strallow;
|
||||
|
||||
public function __construct($context, $roleid) {
|
||||
parent::__construct($context, $roleid);
|
||||
$this->displaypermissions = array(CAP_ALLOW => $this->allpermissions[CAP_ALLOW]);
|
||||
$this->stradvmessage = get_string('useshowadvancedtochange', 'core_role');
|
||||
$this->strallow = $this->strperms[$this->allpermissions[CAP_ALLOW]];
|
||||
}
|
||||
|
||||
protected function print_show_hide_advanced_button() {
|
||||
echo '<div class="advancedbutton">';
|
||||
echo '<input type="submit" name="toggleadvanced" value="' . get_string('showadvanced', 'form') . '" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
$permname = $this->allpermissions[$perm];
|
||||
$defaultperm = $this->allpermissions[$this->parentpermissions[$capability->name]];
|
||||
echo '<td class="' . $permname . '">';
|
||||
if ($perm == CAP_ALLOW || $perm == CAP_INHERIT) {
|
||||
$checked = '';
|
||||
if ($perm == CAP_ALLOW) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
echo '<input type="hidden" name="' . $capability->name . '" value="' . CAP_INHERIT . '" />';
|
||||
echo '<label><input type="checkbox" name="' . $capability->name .
|
||||
'" value="' . CAP_ALLOW . '" ' . $checked . '/> ' . $this->strallow . '</label>';
|
||||
} else {
|
||||
echo '<input type="hidden" name="' . $capability->name . '" value="' . $perm . '" />';
|
||||
echo $this->strperms[$permname] . '<span class="note">' . $this->stradvmessage . '</span>';
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
@@ -1,153 +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/>.
|
||||
|
||||
/**
|
||||
* Existing user selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User selector subclass for the list of users who already have the role in
|
||||
* question on the assign roles page.
|
||||
*/
|
||||
class core_role_existing_role_holders extends core_role_assign_user_selector_base {
|
||||
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params = array_merge($params, $ctxparams);
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$params = array_merge($params, $sortparams);
|
||||
|
||||
$fields = "SELECT ra.id AS raid," . $this->required_fields_sql('u') . ",ra.contextid,ra.component ";
|
||||
$countfields = "SELECT COUNT(1) ";
|
||||
$sql = "FROM {role_assignments} ra
|
||||
JOIN {user} u ON u.id = ra.userid
|
||||
JOIN {context} ctx ON ra.contextid = ctx.id
|
||||
WHERE $wherecondition
|
||||
AND ctx.id $ctxcondition
|
||||
AND ra.roleid = :roleid";
|
||||
$order = " ORDER BY ctx.depth DESC, ra.component, $sort";
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$existinguserscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($existinguserscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $existinguserscount);
|
||||
}
|
||||
}
|
||||
|
||||
$contextusers = $DB->get_records_sql($fields . $sql . $order, $params);
|
||||
|
||||
// No users at all.
|
||||
if (empty($contextusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// We have users. Out put them in groups by context depth.
|
||||
// To help the loop below, tack a dummy user on the end of the results
|
||||
// array, to trigger output of the last group.
|
||||
$dummyuser = new stdClass;
|
||||
$dummyuser->contextid = 0;
|
||||
$dummyuser->id = 0;
|
||||
$dummyuser->component = '';
|
||||
$contextusers[] = $dummyuser;
|
||||
$results = array(); // The results array we are building up.
|
||||
$doneusers = array(); // Ensures we only list each user at most once.
|
||||
$currentcontextid = $this->context->id;
|
||||
$currentgroup = array();
|
||||
foreach ($contextusers as $user) {
|
||||
if (isset($doneusers[$user->id])) {
|
||||
continue;
|
||||
}
|
||||
$doneusers[$user->id] = 1;
|
||||
if ($user->contextid != $currentcontextid) {
|
||||
// We have got to the end of the previous group. Add it to the results array.
|
||||
if ($currentcontextid == $this->context->id) {
|
||||
$groupname = $this->this_con_group_name($search, count($currentgroup));
|
||||
} else {
|
||||
$groupname = $this->parent_con_group_name($search, $currentcontextid);
|
||||
}
|
||||
$results[$groupname] = $currentgroup;
|
||||
// Get ready for the next group.
|
||||
$currentcontextid = $user->contextid;
|
||||
$currentgroup = array();
|
||||
}
|
||||
// Add this user to the group we are building up.
|
||||
unset($user->contextid);
|
||||
if ($currentcontextid != $this->context->id) {
|
||||
$user->disabled = true;
|
||||
}
|
||||
if ($user->component !== '') {
|
||||
// Bad luck, you can tweak only manual role assignments.
|
||||
$user->disabled = true;
|
||||
}
|
||||
unset($user->component);
|
||||
$currentgroup[$user->id] = $user;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function this_con_group_name($search, $numusers) {
|
||||
if ($this->context->contextlevel == CONTEXT_SYSTEM) {
|
||||
// Special case in the System context.
|
||||
if ($search) {
|
||||
return get_string('extusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
return get_string('extusers', 'core_role');
|
||||
}
|
||||
}
|
||||
$contexttype = context_helper::get_level_name($this->context->contextlevel);
|
||||
if ($search) {
|
||||
$a = new stdClass;
|
||||
$a->search = $search;
|
||||
$a->contexttype = $contexttype;
|
||||
if ($numusers) {
|
||||
return get_string('usersinthisxmatching', 'core_role', $a);
|
||||
} else {
|
||||
return get_string('noneinthisxmatching', 'core_role', $a);
|
||||
}
|
||||
} else {
|
||||
if ($numusers) {
|
||||
return get_string('usersinthisx', 'core_role', $contexttype);
|
||||
} else {
|
||||
return get_string('noneinthisx', 'core_role', $contexttype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function parent_con_group_name($search, $contextid) {
|
||||
$context = context::instance_by_id($contextid);
|
||||
$contextname = $context->get_context_name(true, true);
|
||||
if ($search) {
|
||||
$a = new stdClass;
|
||||
$a->contextname = $contextname;
|
||||
$a->search = $search;
|
||||
return get_string('usersfrommatching', 'core_role', $a);
|
||||
} else {
|
||||
return get_string('usersfrom', 'core_role', $contextname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +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/>.
|
||||
|
||||
/**
|
||||
* override permissions table.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class core_role_override_permissions_table_advanced extends core_role_capability_table_with_risks {
|
||||
protected $strnotset;
|
||||
protected $haslockedcapabilities = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This method loads loads all the information about the current state of
|
||||
* the overrides, then updates that based on any submitted data. It also
|
||||
* works out which capabilities should be locked for this user.
|
||||
*
|
||||
* @param object $context the context this table relates to.
|
||||
* @param integer $roleid the role being overridden.
|
||||
* @param boolean $safeoverridesonly If true, the user is only allowed to override
|
||||
* capabilities with no risks.
|
||||
*/
|
||||
public function __construct($context, $roleid, $safeoverridesonly) {
|
||||
parent::__construct($context, 'overriderolestable', $roleid);
|
||||
$this->displaypermissions = $this->allpermissions;
|
||||
$this->strnotset = get_string('notset', 'core_role');
|
||||
|
||||
// Determine which capabilities should be locked.
|
||||
if ($safeoverridesonly) {
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
if (!is_safe_capability($cap)) {
|
||||
$this->capabilities[$capid]->locked = true;
|
||||
$this->haslockedcapabilities = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function load_parent_permissions() {
|
||||
// Get the capabilities from the parent context, so that can be shown in the interface.
|
||||
$parentcontext = $this->context->get_parent_context();
|
||||
$this->parentpermissions = role_context_capabilities($this->roleid, $parentcontext);
|
||||
}
|
||||
|
||||
public function has_locked_capabilities() {
|
||||
return $this->haslockedcapabilities;
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$disabled = '';
|
||||
if ($capability->locked || $this->parentpermissions[$capability->name] == CAP_PROHIBIT) {
|
||||
$disabled = ' disabled="disabled"';
|
||||
}
|
||||
|
||||
// One cell for each possible permission.
|
||||
foreach ($this->displaypermissions as $perm => $permname) {
|
||||
$strperm = $this->strperms[$permname];
|
||||
$extraclass = '';
|
||||
if ($perm != CAP_INHERIT && $perm == $this->parentpermissions[$capability->name]) {
|
||||
$extraclass = ' capcurrent';
|
||||
}
|
||||
$checked = '';
|
||||
if ($this->permissions[$capability->name] == $perm) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
echo '<td class="' . $permname . $extraclass . '">';
|
||||
echo '<label><input type="radio" name="' . $capability->name .
|
||||
'" value="' . $perm . '" ' . $checked . $disabled . '/> ';
|
||||
if ($perm == CAP_INHERIT) {
|
||||
$inherited = $this->parentpermissions[$capability->name];
|
||||
if ($inherited == CAP_INHERIT) {
|
||||
$inherited = $this->strnotset;
|
||||
} else {
|
||||
$inherited = $this->strperms[$this->allpermissions[$inherited]];
|
||||
}
|
||||
$strperm .= ' (' . $inherited . ')';
|
||||
}
|
||||
echo '<span class="note">' . $strperm . '</span>';
|
||||
echo '</label></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +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/>.
|
||||
|
||||
/**
|
||||
* Allow something form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
class core_role_permission_allow_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form.
|
||||
*/
|
||||
protected function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach ($needed as $id => $unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
foreach ($forbidden as $id => $unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'allowheader', get_string('roleallowheader', 'core_role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'core_role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden', 'capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden', 'contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden', 'allow');
|
||||
$mform->setType('allow', PARAM_INT);
|
||||
$mform->setDefault('allow', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('allow', 'core_role'));
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Prohibit something form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
|
||||
class core_role_permission_prohibit_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form.
|
||||
*/
|
||||
protected function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach ($forbidden as $id => $unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'core_role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'core_role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden', 'capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden', 'contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden', 'prohibit');
|
||||
$mform->setType('prohibit', PARAM_INT);
|
||||
$mform->setDefault('prohibit', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('prohibit', 'core_role'));
|
||||
}
|
||||
}
|
||||
@@ -1,150 +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/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of core_role_capability_table_base for use on the Permissions page.
|
||||
*/
|
||||
class core_role_permissions_table extends core_role_capability_table_base {
|
||||
protected $contextname;
|
||||
protected $allowoverrides;
|
||||
protected $allowsafeoverrides;
|
||||
protected $overridableroles;
|
||||
protected $roles;
|
||||
protected $icons = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param context $context the context this table relates to.
|
||||
* @param string $contextname $context->get_context_name() - to save recomputing.
|
||||
* @param array $allowoverrides
|
||||
* @param array $allowsafeoverrides
|
||||
* @param array $overridableroles
|
||||
*/
|
||||
public function __construct($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles) {
|
||||
parent::__construct($context, 'permissions');
|
||||
$this->contextname = $contextname;
|
||||
$this->allowoverrides = $allowoverrides;
|
||||
$this->allowsafeoverrides = $allowsafeoverrides;
|
||||
$this->overridableroles = $overridableroles;
|
||||
|
||||
$roles = get_all_roles($context);
|
||||
$this->roles = role_fix_names(array_reverse($roles, true), $context, ROLENAME_ALIAS, true);
|
||||
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
echo '<th>' . get_string('risks', 'core_role') . '</th>';
|
||||
echo '<th>' . get_string('neededroles', 'core_role') . '</th>';
|
||||
echo '<th>' . get_string('prohibitedroles', 'core_role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
global $OUTPUT, $PAGE;
|
||||
|
||||
$context = $this->context;
|
||||
$contextid = $this->context->id;
|
||||
$allowoverrides = $this->allowoverrides;
|
||||
$allowsafeoverrides = $this->allowsafeoverrides;
|
||||
$overridableroles = $this->overridableroles;
|
||||
$roles = $this->roles;
|
||||
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
$neededroles = array();
|
||||
$forbiddenroles = array();
|
||||
$allowable = $overridableroles;
|
||||
$forbitable = $overridableroles;
|
||||
foreach ($neededroles as $id => $unused) {
|
||||
unset($allowable[$id]);
|
||||
}
|
||||
foreach ($forbidden as $id => $unused) {
|
||||
unset($allowable[$id]);
|
||||
unset($forbitable[$id]);
|
||||
}
|
||||
|
||||
foreach ($roles as $id => $name) {
|
||||
if (isset($needed[$id])) {
|
||||
$neededroles[$id] = $roles[$id];
|
||||
if (isset($overridableroles[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$preventurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'prevent'=>1));
|
||||
$neededroles[$id] .= $OUTPUT->action_icon($preventurl, new pix_icon('t/delete', get_string('prevent', 'core_role')));
|
||||
}
|
||||
}
|
||||
}
|
||||
$neededroles = implode(', ', $neededroles);
|
||||
foreach ($roles as $id => $name) {
|
||||
if (isset($forbidden[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$forbiddenroles[$id] = $roles[$id];
|
||||
if (isset($overridableroles[$id]) and prohibit_is_removable($id, $context, $capability->name)) {
|
||||
$unprohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'unprohibit'=>1));
|
||||
$forbiddenroles[$id] .= $OUTPUT->action_icon($unprohibiturl, new pix_icon('t/delete', get_string('delete')));
|
||||
}
|
||||
}
|
||||
}
|
||||
$forbiddenroles = implode(', ', $forbiddenroles);
|
||||
|
||||
if ($allowable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$allowurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'allow'=>1));
|
||||
$neededroles .= '<div class="allowmore">'.$OUTPUT->action_icon($allowurl, new pix_icon('t/add', get_string('allow', 'core_role'))).'</div>';
|
||||
}
|
||||
|
||||
if ($forbitable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$prohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'prohibit'=>1));
|
||||
$forbiddenroles .= '<div class="prohibitmore">'.$OUTPUT->action_icon($prohibiturl, new pix_icon('t/add', get_string('prohibit', 'core_role'))).'</div>';
|
||||
}
|
||||
|
||||
$risks = $this->get_risks($capability);
|
||||
|
||||
echo '<td>' . $risks . '</td>';
|
||||
echo '<td>' . $neededroles . '</td>';
|
||||
echo '<td>' . $forbiddenroles . '</td>';
|
||||
}
|
||||
|
||||
protected function get_risks($capability) {
|
||||
global $OUTPUT;
|
||||
|
||||
$allrisks = get_all_risks();
|
||||
$risksurl = new moodle_url(get_docs_url(s(get_string('risks', 'core_role'))));
|
||||
|
||||
$return = '';
|
||||
|
||||
foreach ($allrisks as $type => $risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
if (!isset($this->icons[$type])) {
|
||||
$pixicon = new pix_icon('/i/' . str_replace('risk', 'risk_', $type), get_string($type . 'short', 'admin'));
|
||||
$this->icons[$type] = $OUTPUT->action_icon($risksurl, $pixicon, new popup_action('click', $risksurl));
|
||||
}
|
||||
$return .= $this->icons[$type];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +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/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User selector subclass for the list of potential users on the assign roles page,
|
||||
* when we are assigning in a context below the course level. (CONTEXT_MODULE and
|
||||
* some CONTEXT_BLOCK).
|
||||
*
|
||||
* This returns only enrolled users in this context.
|
||||
*/
|
||||
class core_role_potential_assignees_below_course extends core_role_assign_user_selector_base {
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($enrolsql, $eparams) = get_enrolled_sql($this->context);
|
||||
|
||||
// Now we have to go to the database.
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
$params = array_merge($params, $eparams);
|
||||
|
||||
if ($wherecondition) {
|
||||
$wherecondition = ' AND ' . $wherecondition;
|
||||
}
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('u');
|
||||
$countfields = 'SELECT COUNT(u.id)';
|
||||
|
||||
$sql = " FROM ($enrolsql) enrolled_users_view
|
||||
JOIN {user} u ON u.id = enrolled_users_view.id
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = enrolled_users_view.id AND
|
||||
ra.roleid = :roleid AND ra.contextid = :contextid)
|
||||
WHERE ra.id IS NULL
|
||||
$wherecondition";
|
||||
$params['contextid'] = $this->context->id;
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
||||
// If not, show them.
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$groupname = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
return array($groupname => $availableusers);
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User selector subclass for the list of potential users on the assign roles page,
|
||||
* when we are assigning in a context at or above the course level. In this case we
|
||||
* show all the users in the system who do not already have the role.
|
||||
*/
|
||||
class core_role_potential_assignees_course_and_above extends core_role_assign_user_selector_base {
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, '');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('');
|
||||
$countfields = 'SELECT COUNT(1)';
|
||||
|
||||
$sql = " FROM {user}
|
||||
WHERE $wherecondition
|
||||
AND id NOT IN (
|
||||
SELECT r.userid
|
||||
FROM {role_assignments} r
|
||||
WHERE r.contextid = :contextid
|
||||
AND r.roleid = :roleid)";
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
$params['contextid'] = $this->context->id;
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$groupname = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
return array($groupname => $availableusers);
|
||||
}
|
||||
}
|
||||
@@ -1,314 +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/>.
|
||||
|
||||
/**
|
||||
* New role XML processing.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* XML role file manipulation class.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_role_preset {
|
||||
|
||||
/**
|
||||
* Send role export xml file to browser.
|
||||
*
|
||||
* @param int $roleid
|
||||
* @return void does not return, send the file to output
|
||||
*/
|
||||
public static function send_export_xml($roleid) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
if ($role->shortname) {
|
||||
$filename = $role->shortname.'.xml';
|
||||
} else {
|
||||
$filename = 'role.xml';
|
||||
}
|
||||
$xml = self::get_export_xml($roleid);
|
||||
send_file($xml, $filename, 0, false, true, true);
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate role export xml file.
|
||||
*
|
||||
* @param $roleid
|
||||
* @return string
|
||||
*/
|
||||
public static function get_export_xml($roleid) {
|
||||
global $DB;
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$top = $dom->createElement('role');
|
||||
$dom->appendChild($top);
|
||||
|
||||
$top->appendChild($dom->createElement('shortname', $role->shortname));
|
||||
$top->appendChild($dom->createElement('name', $role->name));
|
||||
$top->appendChild($dom->createElement('description', $role->description));
|
||||
$top->appendChild($dom->createElement('archetype', $role->archetype));
|
||||
|
||||
$contextlevels = $dom->createElement('contextlevels');
|
||||
$top->appendChild($contextlevels);
|
||||
foreach (get_role_contextlevels($roleid) as $level) {
|
||||
$name = context_helper::get_class_for_level($level);
|
||||
$name = preg_replace('/^context_/', '', $name);
|
||||
$contextlevels->appendChild($dom->createElement('level', $name));
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
$allows = $dom->createElement('allow'.$type);
|
||||
$top->appendChild($allows);
|
||||
$records = $DB->get_records('role_allow_'.$type, array('roleid'=>$roleid), "allow$type ASC");
|
||||
foreach ($records as $record) {
|
||||
if (!$ar = $DB->get_record('role', array('id'=>$record->{'allow'.$type}))) {
|
||||
continue;
|
||||
}
|
||||
$allows->appendChild($dom->createElement('shortname', $ar->shortname));
|
||||
}
|
||||
}
|
||||
|
||||
$permissions = $dom->createElement('permissions');
|
||||
$top->appendChild($permissions);
|
||||
|
||||
$capabilities = $DB->get_records_sql_menu(
|
||||
"SELECT capability, permission
|
||||
FROM {role_capabilities}
|
||||
WHERE contextid = :syscontext AND roleid = :roleid
|
||||
ORDER BY capability ASC",
|
||||
array('syscontext'=>context_system::instance()->id, 'roleid'=>$roleid));
|
||||
|
||||
$allcapabilities = $DB->get_records('capabilities', array(), 'name ASC');
|
||||
foreach ($allcapabilities as $cap) {
|
||||
if (!isset($capabilities[$cap->name])) {
|
||||
$permissions->appendChild($dom->createElement('inherit', $cap->name));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($capabilities as $capability => $permission) {
|
||||
if ($permission == CAP_ALLOW) {
|
||||
$permissions->appendChild($dom->createElement('allow', $capability));
|
||||
}
|
||||
}
|
||||
foreach ($capabilities as $capability => $permission) {
|
||||
if ($permission == CAP_PREVENT) {
|
||||
$permissions->appendChild($dom->createElement('prevent', $capability));
|
||||
}
|
||||
}
|
||||
foreach ($capabilities as $capability => $permission) {
|
||||
if ($permission == CAP_PROHIBIT) {
|
||||
$permissions->appendChild($dom->createElement('prohibit', $capability));
|
||||
}
|
||||
}
|
||||
|
||||
return $dom->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this XML valid role preset?
|
||||
*
|
||||
* @param string $xml
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_valid_preset($xml) {
|
||||
$dom = new DOMDocument();
|
||||
if (!$dom->loadXML($xml)) {
|
||||
return false;
|
||||
} else {
|
||||
$val = @$dom->schemaValidate(__DIR__.'/../role_schema.xml');
|
||||
if (!$val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse role preset xml file.
|
||||
*
|
||||
* @param string $xml
|
||||
* @return array role info, null on error
|
||||
*/
|
||||
public static function parse_preset($xml) {
|
||||
global $DB;
|
||||
|
||||
$info = array();
|
||||
|
||||
if (!self::is_valid_preset($xml)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$info['shortname'] = self::get_node_value($dom, '/role/shortname');
|
||||
if (isset($info['shortname'])) {
|
||||
$info['shortname'] = strtolower(clean_param($info['shortname'], PARAM_ALPHANUMEXT));
|
||||
}
|
||||
|
||||
$info['name'] = self::get_node_value($dom, '/role/name');
|
||||
if (isset($value)) {
|
||||
$info['name'] = clean_param($info['name'], PARAM_TEXT);
|
||||
}
|
||||
|
||||
$info['description'] = self::get_node_value($dom, '/role/description');
|
||||
if (isset($value)) {
|
||||
$info['description'] = clean_param($info['description'], PARAM_CLEANHTML);
|
||||
}
|
||||
|
||||
$info['archetype'] = self::get_node_value($dom, '/role/archetype');
|
||||
if (isset($value)) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$info['archetype']])) {
|
||||
$info['archetype'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$values = self::get_node_children_values($dom, '/role/contextlevels', 'level');
|
||||
if (isset($values)) {
|
||||
$info['contextlevels'] = array();
|
||||
$levelmap = array_flip(context_helper::get_all_levels());
|
||||
foreach ($values as $value) {
|
||||
$level = 'context_'.$value;
|
||||
if (isset($levelmap[$level])) {
|
||||
$cl = $levelmap[$level];
|
||||
$info['contextlevels'][$cl] = $cl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
$values = self::get_node_children_values($dom, '/role/allow'.$type, 'shortname');
|
||||
if (!isset($values)) {
|
||||
$info['allow'.$type] = null;
|
||||
continue;
|
||||
}
|
||||
$info['allow'.$type] = array();
|
||||
foreach ($values as $value) {
|
||||
if ($value === $info['shortname']) {
|
||||
array_unshift($info['allow'.$type], -1); // Means self.
|
||||
}
|
||||
if ($role = $DB->get_record('role', array('shortname'=>$value))) {
|
||||
$info['allow'.$type][] = $role->id;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$info['permissions'] = array();
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'inherit');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'allow');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_ALLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'prevent');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_PREVENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'prohibit');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_PROHIBIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
protected static function get_node(DOMDocument $dom, $path) {
|
||||
$parts = explode('/', $path);
|
||||
$elname = end($parts);
|
||||
|
||||
$nodes = $dom->getElementsByTagName($elname);
|
||||
|
||||
if ($nodes->length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->getNodePath() === $path) {
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static function get_node_value(DOMDocument $dom, $path) {
|
||||
if (!$node = self::get_node($dom, $path)) {
|
||||
return null;
|
||||
}
|
||||
return $node->nodeValue;
|
||||
}
|
||||
|
||||
protected static function get_node_children(DOMDocument $dom, $path, $tagname) {
|
||||
if (!$node = self::get_node($dom, $path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach ($node->childNodes as $child) {
|
||||
if ($child->nodeName === $tagname) {
|
||||
$return[] = $child;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected static function get_node_children_values(DOMDocument $dom, $path, $tagname) {
|
||||
$children = self::get_node_children($dom, $path, $tagname);
|
||||
|
||||
if ($children === null) {
|
||||
return null;
|
||||
}
|
||||
$return = array();
|
||||
foreach ($children as $child) {
|
||||
$return[] = $child->nodeValue;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,120 +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/>.
|
||||
|
||||
/**
|
||||
* Role add/reset selection form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
|
||||
/**
|
||||
* Role add/reset selection form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_role_preset_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Definition of this form.
|
||||
*/
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$data = $this->_customdata;
|
||||
$options = array();
|
||||
|
||||
$group = get_string('other');
|
||||
$options[$group] = array();
|
||||
$options[$group][0] = get_string('norole', 'core_role');
|
||||
|
||||
$group = get_string('role', 'core');
|
||||
$options[$group] = array();
|
||||
foreach (role_get_names(null, ROLENAME_BOTH) as $role) {
|
||||
// Allow reset to self too, it may be useful when importing incomplete XML preset.
|
||||
$options[$group][$role->id] = $role->localname;
|
||||
}
|
||||
|
||||
$group = get_string('archetype', 'core_role');
|
||||
$options[$group] = array();
|
||||
foreach (get_role_archetypes() as $type) {
|
||||
$options[$group][$type] = get_string('archetype'.$type, 'core_role');
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'presetheader', get_string('roleresetdefaults', 'core_role'));
|
||||
|
||||
$mform->addElement('selectgroups', 'resettype', get_string('roleresetrole', 'core_role'), $options);
|
||||
|
||||
$mform->addElement('filepicker', 'rolepreset', get_string('rolerepreset', 'core_role'));
|
||||
|
||||
if ($data['roleid']) {
|
||||
$mform->addElement('header', 'resetheader', get_string('resetrole', 'core_role'));
|
||||
|
||||
$mform->addElement('advcheckbox', 'shortname', get_string('roleshortname', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'name', get_string('customrolename', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'description', get_string('customroledescription', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'archetype', get_string('archetype', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'contextlevels', get_string('maybeassignedin', 'core_role'));
|
||||
$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', 'permissions', get_string('permissions', 'core_role'));
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'roleid');
|
||||
$mform->setType('roleid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'action');
|
||||
$mform->setType('action', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'return');
|
||||
$mform->setType('return', PARAM_ALPHA);
|
||||
|
||||
$this->add_action_buttons(true, get_string('continue', 'core'));
|
||||
|
||||
$this->set_data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate this form.
|
||||
*
|
||||
* @param array $data submitted data
|
||||
* @param array $files not used
|
||||
* @return array errors
|
||||
*/
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
if ($files = $this->get_draft_files('rolepreset')) {
|
||||
/** @var stored_file $file */
|
||||
$file = reset($files);
|
||||
$xml = $file->get_content();
|
||||
if (!core_role_preset::is_valid_preset($xml)) {
|
||||
$errors['rolepreset'] = get_string('invalidpresetfile', 'core_role');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
@@ -1,136 +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/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class core_role_view_role_definition_table extends core_role_define_role_table_advanced {
|
||||
public function __construct($context, $roleid) {
|
||||
parent::__construct($context, $roleid);
|
||||
$this->displaypermissions = array(CAP_ALLOW => $this->allpermissions[CAP_ALLOW]);
|
||||
$this->disabled = 'disabled="disabled" ';
|
||||
}
|
||||
|
||||
public function save_changes() {
|
||||
throw new moodle_exception('invalidaccess');
|
||||
}
|
||||
|
||||
protected function get_name_field($id) {
|
||||
return role_get_name($this->role);
|
||||
}
|
||||
|
||||
protected function get_shortname_field($id) {
|
||||
return $this->role->shortname;
|
||||
}
|
||||
|
||||
protected function get_description_field($id) {
|
||||
return role_get_description($this->role);
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
if (empty($this->role->archetype)) {
|
||||
return get_string('none');
|
||||
} else {
|
||||
return get_string('archetype'.$this->role->archetype, 'core_role');
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_allow_role_control($type) {
|
||||
if ($roles = $this->get_allow_roles_list($type)) {
|
||||
$roles = role_fix_names($roles, null, ROLENAME_ORIGINAL, true);
|
||||
return implode(', ', $roles);
|
||||
} else {
|
||||
return get_string('none');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function print_show_hide_advanced_button() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML risk icons.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_role_risks_info() {
|
||||
global $OUTPUT;
|
||||
|
||||
if (empty($this->roleid)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$risks = array();
|
||||
$allrisks = get_all_risks();
|
||||
foreach ($this->capabilities as $capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
if ($perm != CAP_ALLOW) {
|
||||
continue;
|
||||
}
|
||||
foreach ($allrisks as $type => $risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
$risks[$type] = $risk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$risksurl = new moodle_url(get_docs_url(s(get_string('risks', 'core_role'))));
|
||||
foreach ($risks as $type => $risk) {
|
||||
$pixicon = new pix_icon('/i/' . str_replace('risk', 'risk_', $type), get_string($type . 'short', 'admin'));
|
||||
$risks[$type] = $OUTPUT->action_icon($risksurl, $pixicon, new popup_action('click', $risksurl));
|
||||
}
|
||||
|
||||
return implode(' ', $risks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the row should be skipped.
|
||||
*
|
||||
* @param string $capability
|
||||
* @return bool
|
||||
*/
|
||||
protected function skip_row($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
if ($perm == CAP_INHERIT) {
|
||||
// Do not print empty rows in role overview, admins need to know quickly what is allowed and prohibited,
|
||||
// if they want to see the list of all capabilities they can go to edit role page.
|
||||
return true;
|
||||
}
|
||||
parent::skip_row($capability);
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
$permname = $this->allpermissions[$perm];
|
||||
$defaultperm = $this->allpermissions[$this->parentpermissions[$capability->name]];
|
||||
if ($permname != $defaultperm) {
|
||||
$default = get_string('defaultx', 'core_role', $this->strperms[$defaultperm]);
|
||||
} else {
|
||||
$default = " ";
|
||||
}
|
||||
echo '<td class="' . $permname . '">' . $this->strperms[$permname] . '<span class="note">' .
|
||||
$default . '</span></td>';
|
||||
|
||||
}
|
||||
}
|
||||
+122
-228
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,271 +19,164 @@
|
||||
* Lets the user edit role definitions.
|
||||
*
|
||||
* Responds to actions:
|
||||
* add - add a new role (allows import, duplicate, archetype)
|
||||
* export - save xml role definition
|
||||
* add - add a new role
|
||||
* duplicate - like add, only initialise the new role by using an existing one.
|
||||
* edit - edit the definition of a role
|
||||
* view - view the definition of a role
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHA);
|
||||
if (!in_array($action, array('add', 'export', 'edit', 'reset', 'view'))) {
|
||||
throw new moodle_exception('invalidaccess');
|
||||
}
|
||||
if ($action != 'add') {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
} else {
|
||||
$roleid = 0;
|
||||
}
|
||||
$resettype = optional_param('resettype', '', PARAM_RAW);
|
||||
$return = optional_param('return', 'manage', PARAM_ALPHA);
|
||||
|
||||
// Get the base URL for this and related pages into a convenient variable.
|
||||
$baseurl = new moodle_url('/admin/roles/define.php', array('action'=>$action, 'roleid'=>$roleid));
|
||||
$manageurl = new moodle_url('/admin/roles/manage.php');
|
||||
if ($return === 'manage') {
|
||||
$returnurl = $manageurl;
|
||||
} else {
|
||||
$returnurl = new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$roleid));;
|
||||
}
|
||||
|
||||
// Check access permissions.
|
||||
$systemcontext = context_system::instance();
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), new moodle_url('/admin/roles/define.php'));
|
||||
|
||||
// Export role.
|
||||
if ($action === 'export') {
|
||||
core_role_preset::send_export_xml($roleid);
|
||||
die;
|
||||
}
|
||||
|
||||
// Handle the toggle advanced mode button.
|
||||
$showadvanced = get_user_preferences('definerole_showadvanced', false);
|
||||
if (optional_param('toggleadvanced', false, PARAM_BOOL)) {
|
||||
$showadvanced = !$showadvanced;
|
||||
set_user_preference('definerole_showadvanced', $showadvanced);
|
||||
}
|
||||
|
||||
// Get some basic data we are going to need.
|
||||
$roles = get_all_roles();
|
||||
$rolenames = role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
|
||||
$rolescount = count($roles);
|
||||
|
||||
if ($action === 'add') {
|
||||
$title = get_string('addinganewrole', 'core_role');
|
||||
} else if ($action == 'view') {
|
||||
$title = get_string('viewingdefinitionofrolex', 'core_role', $rolenames[$roleid]->localname);
|
||||
} else if ($action == 'reset') {
|
||||
$title = get_string('resettingrole', 'core_role', $rolenames[$roleid]->localname);
|
||||
} else {
|
||||
$title = get_string('editingrolex', 'core_role', $rolenames[$roleid]->localname);
|
||||
}
|
||||
|
||||
// Decide how to create new role.
|
||||
if ($action === 'add' and $resettype !== 'none') {
|
||||
$mform = new core_role_preset_form(null, array('action'=>'add', 'roleid'=>0, 'resettype'=>'0', 'return'=>'manage'));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($manageurl);
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
$resettype = $data->resettype;
|
||||
$options = array(
|
||||
'shortname' => 1,
|
||||
'name' => 1,
|
||||
'description' => 1,
|
||||
'permissions' => 1,
|
||||
'archetype' => 1,
|
||||
'contextlevels' => 1,
|
||||
'allowassign' => 1,
|
||||
'allowoverride' => 1,
|
||||
'allowswitch' => 1);
|
||||
if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, 0);
|
||||
} else {
|
||||
$definitiontable = new core_role_define_role_table_basic($systemcontext, 0);
|
||||
}
|
||||
if (is_number($resettype)) {
|
||||
// Duplicate the role.
|
||||
$definitiontable->force_duplicate($resettype, $options);
|
||||
} else {
|
||||
// Must be an archetype.
|
||||
$definitiontable->force_archetype($resettype, $options);
|
||||
}
|
||||
|
||||
if ($xml = $mform->get_file_content('rolepreset')) {
|
||||
$definitiontable->force_preset($xml, $options);
|
||||
}
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHA);
|
||||
if (!in_array($action, array('add', 'duplicate', 'edit', 'view'))) {
|
||||
throw new moodle_exception('invalidaccess');
|
||||
}
|
||||
if ($action != 'add') {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'core_role');
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
$roleid = 0;
|
||||
}
|
||||
|
||||
} else if ($action === 'reset' and $resettype !== 'none') {
|
||||
if (!$role = $DB->get_record('role', array('id'=>$roleid))) {
|
||||
/// Get the base URL for this and related pages into a convenient variable.
|
||||
$manageurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
|
||||
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
|
||||
if ($action == 'duplicate') {
|
||||
$baseurl = $defineurl . '?action=add';
|
||||
} else {
|
||||
$baseurl = $defineurl . '?action=' . $action;
|
||||
if ($roleid) {
|
||||
$baseurl .= '&roleid=' . $roleid;
|
||||
}
|
||||
}
|
||||
|
||||
/// Check access permissions.
|
||||
$systemcontext = context_system::instance();
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), $defineurl);
|
||||
|
||||
/// Handle the cancel button.
|
||||
if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
redirect($manageurl);
|
||||
}
|
||||
$resettype = empty($role->archetype) ? '0' : $role->archetype;
|
||||
$mform = new core_role_preset_form(null,
|
||||
array('action'=>'reset', 'roleid'=>$roleid, 'resettype'=>$resettype , 'permissions'=>1, 'archetype'=>1, 'contextlevels'=>1, 'return'=>$return));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
$resettype = $data->resettype;
|
||||
$options = array(
|
||||
'shortname' => $data->shortname,
|
||||
'name' => $data->name,
|
||||
'description' => $data->description,
|
||||
'permissions' => $data->permissions,
|
||||
'archetype' => $data->archetype,
|
||||
'contextlevels' => $data->contextlevels,
|
||||
'allowassign' => $data->allowassign,
|
||||
'allowoverride' => $data->allowoverride,
|
||||
'allowswitch' => $data->allowswitch);
|
||||
if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, $roleid);
|
||||
} else {
|
||||
$definitiontable = new core_role_define_role_table_basic($systemcontext, $roleid);
|
||||
}
|
||||
if (is_number($resettype)) {
|
||||
// Duplicate the role.
|
||||
$definitiontable->force_duplicate($resettype, $options);
|
||||
} else {
|
||||
// Must be an archetype.
|
||||
$definitiontable->force_archetype($resettype, $options);
|
||||
}
|
||||
|
||||
if ($xml = $mform->get_file_content('rolepreset')) {
|
||||
$definitiontable->force_preset($xml, $options);
|
||||
}
|
||||
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'core_role');
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
/// Handle the toggle advanced mode button.
|
||||
$showadvanced = get_user_preferences('definerole_showadvanced', false);
|
||||
if (optional_param('toggleadvanced', false, PARAM_BOOL)) {
|
||||
$showadvanced = !$showadvanced;
|
||||
set_user_preference('definerole_showadvanced', $showadvanced);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Create the table object.
|
||||
if ($action === 'view') {
|
||||
$definitiontable = new core_role_view_role_definition_table($systemcontext, $roleid);
|
||||
/// Get some basic data we are going to need.
|
||||
$roles = get_all_roles();
|
||||
$rolenames = role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
|
||||
$rolescount = count($roles);
|
||||
|
||||
/// Create the table object.
|
||||
if ($action == 'view') {
|
||||
$definitiontable = new view_role_definition_table($systemcontext, $roleid);
|
||||
} else if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, $roleid);
|
||||
$definitiontable = new define_role_table_advanced($systemcontext, $roleid);
|
||||
} else {
|
||||
$definitiontable = new core_role_define_role_table_basic($systemcontext, $roleid);
|
||||
$definitiontable = new define_role_table_basic($systemcontext, $roleid);
|
||||
}
|
||||
$definitiontable->read_submitted_permissions();
|
||||
}
|
||||
|
||||
// Handle the cancel button.
|
||||
if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Process submission in necessary.
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
|
||||
$definitiontable->save_changes();
|
||||
$tableroleid = $definitiontable->get_role_id();
|
||||
// Trigger event.
|
||||
$event = \core\event\role_capabilities_updated::create(
|
||||
array(
|
||||
'context' => $systemcontext,
|
||||
'objectid' => $roleid
|
||||
)
|
||||
);
|
||||
$event->set_legacy_logdata(array(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' . $tableroleid,
|
||||
$definitiontable->get_role_name(), '', $USER->id));
|
||||
if (!empty($role)) {
|
||||
$event->add_record_snapshot('role', $role);
|
||||
if ($action == 'duplicate') {
|
||||
$definitiontable->make_copy();
|
||||
}
|
||||
$event->trigger();
|
||||
|
||||
if ($action === 'add') {
|
||||
redirect(new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$definitiontable->get_role_id())));
|
||||
/// Process submission in necessary.
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
|
||||
$definitiontable->save_changes();
|
||||
add_to_log(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' .
|
||||
$definitiontable->get_role_id(), $definitiontable->get_role_name(), '', $USER->id);
|
||||
redirect($manageurl);
|
||||
}
|
||||
|
||||
/// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
include('managetabs.php');
|
||||
|
||||
if ($action == 'add') {
|
||||
$title = get_string('addinganewrole', 'role');
|
||||
} else if ($action == 'duplicate') {
|
||||
$title = get_string('addingrolebycopying', 'role', $rolenames[$roleid]->localname);
|
||||
} else if ($action == 'view') {
|
||||
$title = get_string('viewingdefinitionofrolex', 'role', $rolenames[$roleid]->localname);
|
||||
} else if ($action == 'edit') {
|
||||
$title = get_string('editingrolex', 'role', $rolenames[$roleid]->localname);
|
||||
}
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'role');
|
||||
|
||||
/// Work out some button labels.
|
||||
if ($action == 'add' || $action == 'duplicate') {
|
||||
$submitlabel = get_string('createthisrole', 'role');
|
||||
} else {
|
||||
redirect($returnurl);
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
}
|
||||
|
||||
// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
/// On the view page, show some extra controls at the top.
|
||||
if ($action == 'view') {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
$options = array();
|
||||
$options['roleid'] = $roleid;
|
||||
$options['action'] = 'edit';
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('edit'));
|
||||
$options['action'] = 'reset';
|
||||
if ($definitiontable->get_archetype()) {
|
||||
echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrole', 'role'));
|
||||
} else {
|
||||
echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrolenolegacy', 'role'));
|
||||
}
|
||||
$options['action'] = 'duplicate';
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('duplicaterole', 'role'));
|
||||
echo $OUTPUT->single_button(new moodle_url($manageurl), get_string('listallroles', 'role'));
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
|
||||
$currenttab = 'manage';
|
||||
require('managetabs.php');
|
||||
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'core_role');
|
||||
|
||||
// Work out some button labels.
|
||||
if ($action === 'add') {
|
||||
$submitlabel = get_string('createthisrole', 'core_role');
|
||||
} else {
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
|
||||
// On the view page, show some extra controls at the top.
|
||||
if ($action === 'view') {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
$url = new moodle_url('/admin/roles/define.php', array('action'=>'edit', 'roleid'=>$roleid, 'return'=>'define'));
|
||||
echo $OUTPUT->single_button(new moodle_url($url), get_string('edit'));
|
||||
$url = new moodle_url('/admin/roles/define.php', array('action'=>'reset', 'roleid'=>$roleid, 'return'=>'define'));
|
||||
echo $OUTPUT->single_button(new moodle_url($url), get_string('resetrole', 'core_role'));
|
||||
$url = new moodle_url('/admin/roles/define.php', array('action'=>'export', 'roleid'=>$roleid));
|
||||
echo $OUTPUT->single_button(new moodle_url($url), get_string('export', 'core_role'));
|
||||
echo $OUTPUT->single_button($manageurl, get_string('listallroles', 'core_role'));
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
|
||||
// Start the form.
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
if ($action === 'view') {
|
||||
echo '<div class="mform">';
|
||||
} else {
|
||||
// Start the form.
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
if ($action == 'view') {
|
||||
echo '<div class="mform">';
|
||||
} else {
|
||||
?>
|
||||
<form id="rolesform" class="mform" action="<?php p($baseurl->out(false)); ?>" method="post"><div>
|
||||
<form id="rolesform" class="mform" action="<?php echo $baseurl; ?>" method="post"><div>
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="return" value="<?php p($return); ?>" />
|
||||
<input type="hidden" name="resettype" value="none" />
|
||||
<div class="submit buttons">
|
||||
<input type="submit" name="savechanges" value="<?php p($submitlabel); ?>" />
|
||||
<input type="submit" name="savechanges" value="<?php echo $submitlabel; ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel'); ?>" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
// Print the form controls.
|
||||
$definitiontable->display();
|
||||
// Print the form controls.
|
||||
$definitiontable->display();
|
||||
|
||||
// Close the stuff we left open above.
|
||||
if ($action === 'view') {
|
||||
echo '</div>';
|
||||
} else {
|
||||
?>
|
||||
/// Close the stuff we left open above.
|
||||
if ($action == 'view') {
|
||||
echo '</div>';
|
||||
} else {
|
||||
?>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" name="savechanges" value="<?php p($submitlabel); ?>" />
|
||||
<input type="submit" name="savechanges" value="<?php echo $submitlabel; ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel'); ?>" />
|
||||
</div>
|
||||
</div></form>
|
||||
<?php
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
<?php
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// Print a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
echo '<p><a href="' . s($manageurl->out(false)) . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
|
||||
echo '</div>';
|
||||
/// Print a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
echo '<p><a href="' . $manageurl . '">' . get_string('backtoallroles', 'role') . '</a></p>';
|
||||
echo '</div>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+1721
-18
File diff suppressed because it is too large
Load Diff
+203
-160
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -22,196 +23,238 @@
|
||||
* delete - delete a role (with are-you-sure)
|
||||
* moveup - change the sort order
|
||||
* movedown - change the sort order
|
||||
* reset - set a role's permissions back to the default for that legacy role type.
|
||||
*
|
||||
* For all but the first two of those, you also need a roleid parameter, and
|
||||
* possibly some other data.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
if ($action) {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
} else {
|
||||
$roleid = 0;
|
||||
}
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
if ($action) {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
}
|
||||
|
||||
// Get the base URL for this and related pages into a convenient variable.
|
||||
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
|
||||
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
|
||||
/// Get the base URL for this and related pages into a convenient variable.
|
||||
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
|
||||
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
|
||||
|
||||
// Check access permissions.
|
||||
$systemcontext = context_system::instance();
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles');
|
||||
/// Check access permissions.
|
||||
$systemcontext = context_system::instance();
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
// Get some basic data we are going to need.
|
||||
$roles = role_fix_names(get_all_roles(), $systemcontext, ROLENAME_ORIGINAL);
|
||||
/// Get some basic data we are going to need.
|
||||
$roles = role_fix_names(get_all_roles(), $systemcontext, ROLENAME_ORIGINAL);
|
||||
|
||||
$undeletableroles = array();
|
||||
$undeletableroles[$CFG->notloggedinroleid] = 1;
|
||||
$undeletableroles[$CFG->guestroleid] = 1;
|
||||
$undeletableroles[$CFG->defaultuserroleid] = 1;
|
||||
$undeletableroles = array();
|
||||
$undeletableroles[$CFG->notloggedinroleid] = 1;
|
||||
$undeletableroles[$CFG->guestroleid] = 1;
|
||||
$undeletableroles[$CFG->defaultuserroleid] = 1;
|
||||
|
||||
// Process submitted data.
|
||||
$confirmed = (optional_param('confirm', false, PARAM_BOOL) && data_submitted() && confirm_sesskey());
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (isset($undeletableroles[$roleid])) {
|
||||
print_error('cannotdeletethisrole', '', $baseurl);
|
||||
}
|
||||
if (!$confirmed) {
|
||||
// Show confirmation.
|
||||
echo $OUTPUT->header();
|
||||
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$a = new stdClass();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = $DB->count_records_select('role_assignments',
|
||||
'roleid = ?', array($roleid), 'COUNT(DISTINCT userid)');
|
||||
///.Process submitted data.
|
||||
$confirmed = optional_param('confirm', false, PARAM_BOOL) && data_submitted() && confirm_sesskey();
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (isset($undeletableroles[$roleid])) {
|
||||
print_error('cannotdeletethisrole', '', $baseurl);
|
||||
}
|
||||
if (!$confirmed) {
|
||||
// show confirmation
|
||||
echo $OUTPUT->header();
|
||||
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$a = new stdClass();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = $DB->count_records('role_assignments', array('roleid'=>$roleid));
|
||||
|
||||
$formcontinue = new single_button(new moodle_url($baseurl, $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url($baseurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deleterolesure', 'core_role', $a), $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (!delete_role($roleid)) {
|
||||
// The delete failed, but mark the context dirty in case.
|
||||
$systemcontext->mark_dirty();
|
||||
print_error('cannotdeleterolewithid', 'error', $baseurl, $roleid);
|
||||
}
|
||||
// Deleted a role sitewide...
|
||||
$systemcontext->mark_dirty();
|
||||
redirect($baseurl);
|
||||
break;
|
||||
$formcontinue = new single_button(new moodle_url($baseurl, $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url($baseurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deleterolesure', 'role', $a), $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (!delete_role($roleid)) {
|
||||
// The delete failed, but mark the context dirty in case.
|
||||
mark_context_dirty($systemcontext->path);
|
||||
print_error('cannotdeleterolewithid', 'error', $baseurl, $roleid);
|
||||
}
|
||||
// Deleted a role sitewide...
|
||||
mark_context_dirty($systemcontext->path);
|
||||
add_to_log(SITEID, 'role', 'delete', 'admin/roles/manage.php', $roles[$roleid]->localname, '', $USER->id);
|
||||
redirect($baseurl);
|
||||
break;
|
||||
|
||||
case 'moveup':
|
||||
if (confirm_sesskey()) {
|
||||
$prevrole = null;
|
||||
$thisrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
break;
|
||||
case 'moveup':
|
||||
if (confirm_sesskey()) {
|
||||
$prevrole = null;
|
||||
$thisrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
break;
|
||||
} else {
|
||||
$prevrole = $role;
|
||||
}
|
||||
}
|
||||
if (is_null($thisrole) || is_null($prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
|
||||
case 'movedown':
|
||||
if (confirm_sesskey()) {
|
||||
$thisrole = null;
|
||||
$nextrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
} else if (!is_null($thisrole)) {
|
||||
$nextrole = $role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_null($nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
|
||||
case 'reset':
|
||||
if (!$confirmed) {
|
||||
// show confirmation
|
||||
echo $OUTPUT->header();
|
||||
$optionsyes = array('action'=>'reset', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new stdClass();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->legacytype = $roles[$roleid]->archetype;
|
||||
if (empty($a->legacytype)) {
|
||||
$warning = get_string('resetrolesurenolegacy', 'role', $a);
|
||||
} else {
|
||||
$prevrole = $role;
|
||||
$warning = get_string('resetrolesure', 'role', $a);
|
||||
}
|
||||
$formcontinue = new single_button(new moodle_url('manage.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url('manage.php', $optionsno), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm($warning, $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (is_null($thisrole) || is_null($prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
|
||||
// Reset context levels for standard archetypes
|
||||
if ($roles[$roleid]->archetype) {
|
||||
set_role_contextlevels($roleid, get_default_contextlevels($roles[$roleid]->archetype));
|
||||
}
|
||||
if (!switch_roles($thisrole, $prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
//reset or delete the capabilities
|
||||
reset_role_capabilities($roleid);
|
||||
|
||||
case 'movedown':
|
||||
if (confirm_sesskey()) {
|
||||
$thisrole = null;
|
||||
$nextrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
} else if (!is_null($thisrole)) {
|
||||
$nextrole = $role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_null($nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
// Mark context dirty, log and redirect.
|
||||
mark_context_dirty($systemcontext->path);
|
||||
add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?action=reset&roleid=' . $roleid, $roles[$roleid]->localname, '', $USER->id);
|
||||
redirect($defineurl . '?action=view&roleid=' . $roleid);
|
||||
break;
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
/// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
}
|
||||
$currenttab = 'manage';
|
||||
include_once('managetabs.php');
|
||||
|
||||
// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
require('managetabs.php');
|
||||
|
||||
// Initialise table.
|
||||
$table = new html_table();
|
||||
$table->colclasses = array('leftalign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->id = 'roles';
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->head = array(
|
||||
get_string('role') . ' ' . $OUTPUT->help_icon('roles', 'core_role'),
|
||||
get_string('description'),
|
||||
get_string('roleshortname', 'core_role'),
|
||||
get_string('edit')
|
||||
);
|
||||
|
||||
// Get some strings outside the loop.
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
|
||||
// Print a list of roles with edit/copy/delete/reorder icons.
|
||||
$table->data = array();
|
||||
$firstrole = reset($roles);
|
||||
$lastrole = end($roles);
|
||||
foreach ($roles as $role) {
|
||||
// Basic data.
|
||||
$row = array(
|
||||
'<a href="' . $defineurl . '?action=view&roleid=' . $role->id . '">' . $role->localname . '</a>',
|
||||
role_get_description($role),
|
||||
s($role->shortname),
|
||||
'',
|
||||
/// Initialise table.
|
||||
$table = new html_table();
|
||||
$table->tablealign = 'center';
|
||||
$table->align = array('left', 'left', 'left', 'left');
|
||||
$table->wrap = array('nowrap', '', 'nowrap','nowrap');
|
||||
$table->width = '90%';
|
||||
$table->head = array(
|
||||
get_string('role') . ' ' . $OUTPUT->help_icon('roles', 'role'),
|
||||
get_string('description'),
|
||||
get_string('roleshortname', 'role'),
|
||||
get_string('edit')
|
||||
);
|
||||
|
||||
// Move up.
|
||||
if ($role->sortorder != $firstrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=moveup&roleid=' . $role->id . '&sesskey=' . sesskey(), 'up', $strmoveup, $strmoveup);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// Move down.
|
||||
if ($role->sortorder != $lastrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=movedown&roleid=' . $role->id . '&sesskey=' . sesskey(), 'down', $strmovedown, $strmovedown);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// Edit.
|
||||
$row[3] .= get_action_icon($defineurl . '?action=edit&roleid=' . $role->id,
|
||||
'edit', $stredit, get_string('editxrole', 'core_role', $role->localname));
|
||||
// Delete.
|
||||
if (isset($undeletableroles[$role->id])) {
|
||||
$row[3] .= get_spacer();
|
||||
} else {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=delete&roleid=' . $role->id,
|
||||
'delete', $strdelete, get_string('deletexrole', 'core_role', $role->localname));
|
||||
}
|
||||
/// Get some strings outside the loop.
|
||||
$stredit = get_string('edit');
|
||||
$strduplicate = get_string('duplicate');
|
||||
$strdelete = get_string('delete');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
/// Print a list of roles with edit/copy/delete/reorder icons.
|
||||
$table->data = array();
|
||||
$firstrole = reset($roles);
|
||||
$lastrole = end($roles);
|
||||
foreach ($roles as $role) {
|
||||
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'core_role'), 'get');
|
||||
echo $OUTPUT->container_end();
|
||||
/// Basic data.
|
||||
$row = array(
|
||||
'<a href="' . $defineurl . '?action=view&roleid=' . $role->id . '">' . $role->localname . '</a>',
|
||||
role_get_description($role),
|
||||
s($role->shortname),
|
||||
'',
|
||||
);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
/// Icons:
|
||||
// move up
|
||||
if ($role->sortorder != $firstrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=moveup&roleid=' . $role->id . '&sesskey=' . sesskey(), 'up', $strmoveup, $strmoveup);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// move down
|
||||
if ($role->sortorder != $lastrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=movedown&roleid=' . $role->id . '&sesskey=' . sesskey(), 'down', $strmovedown, $strmovedown);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// edit
|
||||
$row[3] .= get_action_icon($defineurl . '?action=edit&roleid=' . $role->id,
|
||||
'edit', $stredit, get_string('editxrole', 'role', $role->localname));
|
||||
// duplicate
|
||||
$row[3] .= get_action_icon($defineurl . '?action=duplicate&roleid=' . $role->id,
|
||||
'copy', $strduplicate, get_string('createrolebycopying', 'role', $role->localname));
|
||||
// delete
|
||||
if (isset($undeletableroles[$role->id])) {
|
||||
$row[3] .= get_spacer();
|
||||
} else {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=delete&roleid=' . $role->id,
|
||||
'delete', $strdelete, get_string('deletexrole', 'role', $role->localname));
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'role'), 'get');
|
||||
echo $OUTPUT->container_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
function get_action_icon($url, $icon, $alt, $tooltip) {
|
||||
global $OUTPUT;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,18 +18,22 @@
|
||||
/**
|
||||
* Defines the tab bar used on the manage/allow assign/allow overrides pages.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$toprow = array();
|
||||
$toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), get_string('manageroles', 'core_role'));
|
||||
$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('manage', new moodle_url('/admin/roles/manage.php'), get_string('manageroles', 'role'));
|
||||
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'role'));
|
||||
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'role'));
|
||||
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'role'));
|
||||
$tabs = array($toprow);
|
||||
|
||||
echo $OUTPUT->tabtree($toprow, $currenttab);
|
||||
print_tabs($tabs, $currenttab);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ M.core_role.init_cap_table_filter = function(Y, tableid, contextid) {
|
||||
marginRight : 'auto'
|
||||
});
|
||||
// Create the capability search input.
|
||||
this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+Y.Escape.html(filtervalue)+'" />');
|
||||
this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+filtervalue+'" />');
|
||||
// Create a label for the search input.
|
||||
this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.str.moodle.filter+' </label>');
|
||||
// Create a clear button to clear the input.
|
||||
|
||||
+27
-50
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,15 +18,17 @@
|
||||
/**
|
||||
* Lets you override role definitions in contexts.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = required_param('roleid', PARAM_INT); // requested role id
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -45,7 +48,7 @@ if ($course) {
|
||||
}
|
||||
}
|
||||
|
||||
// Security first.
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
$safeoverridesonly = false;
|
||||
if (!has_capability('moodle/role:override', $context)) {
|
||||
@@ -53,19 +56,9 @@ if (!has_capability('moodle/role:override', $context)) {
|
||||
$safeoverridesonly = true;
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
navigation_node::override_active_url(new moodle_url('/admin/roles/permissions.php',
|
||||
array('contextid'=>$context->id, 'userid'=>$context->instanceid, 'courseid'=>$course->id)));
|
||||
|
||||
} else {
|
||||
$PAGE->set_context($context);
|
||||
navigation_node::override_active_url(new moodle_url('/admin/roles/permissions.php', array('contextid'=>$context->id)));
|
||||
}
|
||||
|
||||
$courseid = $course->id;
|
||||
|
||||
$returnurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $context->id));
|
||||
@@ -77,15 +70,15 @@ if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
// These are needed early.
|
||||
// These are needed early
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
|
||||
|
||||
// Work out an appropriate page title.
|
||||
$contextname = $context->get_context_name();
|
||||
$straction = get_string('overrideroles', 'core_role'); // Used by tabs.php.
|
||||
$contextname = print_context_name($context);
|
||||
$straction = get_string('overrideroles', 'role'); // Used by tabs.php
|
||||
$a = (object)array('context' => $contextname, 'role' => $overridableroles[$roleid]);
|
||||
$title = get_string('overridepermissionsforrole', 'core_role', $a);
|
||||
$title = get_string('overridepermissionsforrole', 'role', $a);
|
||||
|
||||
$currenttab = 'permissions';
|
||||
|
||||
@@ -101,17 +94,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -119,61 +112,45 @@ switch ($context->contextlevel) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure this user can override that role.
|
||||
// Make sure this user can override that role
|
||||
if (empty($overridableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotoverriderolehere', '', $context->get_url(), $a);
|
||||
print_error('cannotoverriderolehere', '', get_context_url($context), $a);
|
||||
}
|
||||
|
||||
// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
$overridestable = new core_role_override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable->read_submitted_permissions();
|
||||
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$overridestable->save_changes();
|
||||
$rolename = $overridableroles[$roleid];
|
||||
// Trigger event.
|
||||
$event = \core\event\role_capabilities_updated::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $roleid,
|
||||
)
|
||||
);
|
||||
|
||||
$event->set_legacy_logdata(
|
||||
array(
|
||||
$course->id, 'role', 'override', 'admin/roles/override.php?contextid=' . $context->id . '&roleid=' . $roleid,
|
||||
$rolename, '', $USER->id
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('role', $role);
|
||||
$event->trigger();
|
||||
|
||||
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Finally start page output.
|
||||
// Finally start page output
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading_with_help($title, 'overridepermissions', 'core_role');
|
||||
echo $OUTPUT->heading_with_help($title, 'overridepermissions', 'role');
|
||||
|
||||
// Show UI for overriding roles.
|
||||
if (!empty($capabilities)) {
|
||||
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'core_role'), 'generalbox boxaligncenter');
|
||||
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'role'), 'generalbox boxaligncenter');
|
||||
|
||||
} else {
|
||||
// Print the capabilities overrideable in this context.
|
||||
// Print the capabilities overrideable in this context
|
||||
echo $OUTPUT->box_start('generalbox capbox');
|
||||
echo html_writer::start_tag('form', array('id'=>'overrideform', 'action'=>$PAGE->url->out(), 'method'=>'post'));
|
||||
echo html_writer::start_tag('div');
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'roleid', 'value'=>$roleid));
|
||||
echo html_writer::tag('p', get_string('highlightedcellsshowinherit', 'core_role'), array('class'=>'overridenotice'));
|
||||
echo html_writer::tag('p', get_string('highlightedcellsshowinherit', 'role'), array('class'=>'overridenotice'));
|
||||
|
||||
$overridestable->display();
|
||||
if ($overridestable->has_locked_capabilities()) {
|
||||
echo '<p class="overridenotice">' . get_string('safeoverridenotice', 'core_role') . "</p>\n";
|
||||
echo '<p class="overridenotice">' . get_string('safeoverridenotice', 'role') . "</p>\n";
|
||||
}
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'submit_buttons'));
|
||||
@@ -188,9 +165,9 @@ if (!empty($capabilities)) {
|
||||
// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('overrideanotherrole', 'core_role');
|
||||
$select->label = get_string('overrideanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
echo html_writer::tag('p', html_writer::tag('a', get_string('backtoallroles', 'core_role'), array('href'=>$returnurl)));
|
||||
echo html_writer::tag('p', html_writer::tag('a', get_string('backtoallroles', 'role'), array('href'=>$returnurl)));
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+36
-48
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,16 +16,19 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Change permissions.
|
||||
* This script serves draft files of current user
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 2009 Petr Skoda (skodak) info@skodak.org
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
|
||||
require_once("permissions_forms.php");
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT);
|
||||
$capability = optional_param('capability', false, PARAM_CAPABILITY);
|
||||
@@ -33,7 +37,6 @@ $prevent = optional_param('prevent', 0, PARAM_BOOL);
|
||||
$allow = optional_param('allow', 0, PARAM_BOOL);
|
||||
$unprohibit = optional_param('unprohibit', 0, PARAM_BOOL);
|
||||
$prohibit = optional_param('prohibit', 0, PARAM_BOOL);
|
||||
$return = optional_param('return', null, PARAM_ALPHANUMEXT);
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -53,22 +56,15 @@ if ($course) {
|
||||
}
|
||||
}
|
||||
|
||||
// Security first.
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/role:review', $context);
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
} else {
|
||||
$PAGE->set_context($context);
|
||||
}
|
||||
|
||||
$PAGE->set_context($context);
|
||||
$courseid = $course->id;
|
||||
|
||||
|
||||
// These are needed early because of tabs.php.
|
||||
// These are needed early because of tabs.php
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
|
||||
if ($capability) {
|
||||
@@ -78,9 +74,9 @@ if ($capability) {
|
||||
$allowoverrides = has_capability('moodle/role:override', $context);
|
||||
$allowsafeoverrides = has_capability('moodle/role:safeoverride', $context);
|
||||
|
||||
$contextname = $context->get_context_name();
|
||||
$title = get_string('permissionsincontext', 'core_role', $contextname);
|
||||
$straction = get_string('permissions', 'core_role'); // Used by tabs.php.
|
||||
$contextname = print_context_name($context);
|
||||
$title = get_string('permissionsincontext', 'role', $contextname);
|
||||
$straction = get_string('permissions', 'role'); // Used by tabs.php
|
||||
$currenttab = 'permissions';
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
@@ -95,17 +91,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -113,12 +109,12 @@ switch ($context->contextlevel) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle confirmations and actions.
|
||||
// We have a capability and overrides are allowed or safe overrides are allowed and this is safe.
|
||||
// handle confirmations and actions
|
||||
// We have a capability and overrides are allowed or safe overrides are allowed and this is safe
|
||||
if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capability($capability)))) {
|
||||
// If we already know the the role ID, it is overrideable, and we are setting prevent or unprohibit.
|
||||
// If we already know the the role ID, it is overrideable, and we are setting prevent or unprohibit
|
||||
if (isset($overridableroles[$roleid]) && ($prevent || $unprohibit)) {
|
||||
// We are preventing.
|
||||
// We are preventing
|
||||
if ($prevent) {
|
||||
if ($confirm && data_submitted() && confirm_sesskey()) {
|
||||
role_change_permission($roleid, $context, $capability->name, CAP_PREVENT);
|
||||
@@ -126,24 +122,22 @@ if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capabilit
|
||||
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'role'=>$overridableroles[$roleid], 'context'=>$contextname);
|
||||
$message = get_string('confirmroleprevent', 'core_role', $a);
|
||||
$continueurl = new moodle_url($PAGE->url,
|
||||
array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'prevent'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
$message = get_string('confirmroleprevent', 'role', $a);
|
||||
$continueurl = new moodle_url($PAGE->url, array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'prevent'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
}
|
||||
}
|
||||
// We are unprohibiting.
|
||||
// We are unprohibiting
|
||||
if ($unprohibit) {
|
||||
if ($confirm && data_submitted() && confirm_sesskey()) {
|
||||
role_change_permission($roleid, $context, $capability->name, CAP_INHERIT);
|
||||
redirect($PAGE->url);
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'role'=>$overridableroles[$roleid], 'context'=>$contextname);
|
||||
$message = get_string('confirmroleunprohibit', 'core_role', $a);
|
||||
$continueurl = new moodle_url($PAGE->url,
|
||||
array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'unprohibit'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
$message = get_string('confirmroleunprohibit', 'role', $a);
|
||||
$continueurl = new moodle_url($PAGE->url, array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'unprohibit'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
}
|
||||
}
|
||||
// Display and print.
|
||||
// Display and print
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
echo $OUTPUT->confirm($message, $continueurl, $PAGE->url);
|
||||
@@ -153,7 +147,7 @@ if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capabilit
|
||||
|
||||
if ($allow || $prohibit) {
|
||||
if ($allow) {
|
||||
$mform = new core_role_permission_allow_form(null, array($context, $capability, $overridableroles));
|
||||
$mform = new role_allow_form(null, array($context, $capability, $overridableroles));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($PAGE->url);
|
||||
} else if ($data = $mform->get_data() and !empty($data->roleid)) {
|
||||
@@ -164,11 +158,11 @@ if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capabilit
|
||||
redirect($PAGE->url);
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'context'=>$contextname);
|
||||
$message = get_string('roleallowinfo', 'core_role', $a);
|
||||
$message = get_string('roleallowinfo', 'role', $a);
|
||||
}
|
||||
}
|
||||
if ($prohibit) {
|
||||
$mform = new core_role_permission_prohibit_form(null, array($context, $capability, $overridableroles));
|
||||
$mform = new role_prohibit_form(null, array($context, $capability, $overridableroles));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($PAGE->url);
|
||||
} else if ($data = $mform->get_data() and !empty($data->roleid)) {
|
||||
@@ -179,7 +173,7 @@ if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capabilit
|
||||
redirect($PAGE->url);
|
||||
} else {
|
||||
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'context'=>$contextname);
|
||||
$message = get_string('roleprohibitinfo', 'core_role', $a);
|
||||
$message = get_string('roleprohibitinfo', 'role', $a);
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
@@ -194,13 +188,13 @@ if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capabilit
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$table = new core_role_permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
|
||||
$table = new permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
|
||||
echo $OUTPUT->box_start('generalbox capbox');
|
||||
// Print link to advanced override page.
|
||||
// print link to advanced override page
|
||||
if ($overridableroles) {
|
||||
$overrideurl = new moodle_url('/admin/roles/override.php', array('contextid' => $context->id));
|
||||
$select = new single_select($overrideurl, 'roleid', $nameswithcounts);
|
||||
$select->label = get_string('advancedoverride', 'core_role');
|
||||
$select->label = get_string('advancedoverride', 'role');
|
||||
echo html_writer::tag('div', $OUTPUT->render($select), array('class'=>'advancedoverride'));
|
||||
}
|
||||
$table->display();
|
||||
@@ -208,16 +202,10 @@ echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
|
||||
if ($context->contextlevel === CONTEXT_COURSECAT && $return === 'management') {
|
||||
$url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
|
||||
} else {
|
||||
$url = $context->get_url();
|
||||
}
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer($course);
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script serves draft files of current user
|
||||
*
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 2009 Petr Skoda (skodak) info@skodak.org
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
|
||||
class role_allow_form extends moodleform {
|
||||
|
||||
// Define the form
|
||||
function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach($needed as $id=>$unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
foreach($forbidden as $id=>$unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'allowheader', get_string('roleallowheader', 'role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden','capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden','contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden','allow');
|
||||
$mform->setType('allow', PARAM_INT);
|
||||
$mform->setDefault('allow', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('allow', 'role'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class role_prohibit_form extends moodleform {
|
||||
|
||||
// Define the form
|
||||
function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach($forbidden as $id=>$unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden','capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden','contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden','prohibit');
|
||||
$mform->setType('prohibit', PARAM_INT);
|
||||
$mform->setDefault('prohibit', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('prohibit', 'role'));
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
||||
<xs:element name="role">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="shortname" minOccurs="0"/>
|
||||
<xs:element ref="name" minOccurs="0"/>
|
||||
<xs:element ref="description" minOccurs="0"/>
|
||||
<xs:element ref="archetype" minOccurs="0"/>
|
||||
<xs:element ref="contextlevels" minOccurs="0"/>
|
||||
<xs:element ref="allowassign" minOccurs="0"/>
|
||||
<xs:element ref="allowoverride" minOccurs="0"/>
|
||||
<xs:element ref="allowswitch" minOccurs="0"/>
|
||||
<xs:element ref="permissions" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="archetype" type="xs:string"/>
|
||||
<xs:element name="contextlevels">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" ref="level"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="level" type="xs:string"/>
|
||||
<xs:element name="allowassign">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" ref="shortname"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="allowoverride">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" ref="shortname"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="allowswitch">
|
||||
<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>
|
||||
<xs:element ref="inherit" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="allow" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="prevent" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="prohibit" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="shortname" type="xs:string"/>
|
||||
<xs:element name="name" type="xs:string"/>
|
||||
<xs:element name="description" type="xs:string"/>
|
||||
<xs:element name="inherit" type="xs:string"/>
|
||||
<xs:element name="allow" type="xs:string"/>
|
||||
<xs:element name="prevent" type="xs:string"/>
|
||||
<xs:element name="prohibit" type="xs:string"/>
|
||||
</xs:schema>
|
||||
@@ -1,79 +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/>.
|
||||
|
||||
/**
|
||||
* Role XML presets test case.
|
||||
*
|
||||
* @package core_role
|
||||
* @category phpunit
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
class core_role_preset_testcase extends advanced_testcase {
|
||||
public function test_xml() {
|
||||
global $DB;
|
||||
|
||||
$roles = $DB->get_records('role');
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$xml = core_role_preset::get_export_xml($role->id);
|
||||
$this->assertTrue(core_role_preset::is_valid_preset($xml));
|
||||
$info = core_role_preset::parse_preset($xml);
|
||||
$this->assertSame($role->shortname, $info['shortname']);
|
||||
$this->assertSame($role->name, $info['name']);
|
||||
$this->assertSame($role->description, $info['description']);
|
||||
$this->assertSame($role->archetype, $info['archetype']);
|
||||
|
||||
$contextlevels = get_role_contextlevels($role->id);
|
||||
$this->assertEquals(array_values($contextlevels), array_values($info['contextlevels']));
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
$records = $DB->get_records('role_allow_'.$type, array('roleid'=>$role->id), "allow$type ASC");
|
||||
$allows = array();
|
||||
foreach ($records as $record) {
|
||||
if ($record->{'allow'.$type} == $role->id) {
|
||||
array_unshift($allows, -1);
|
||||
}
|
||||
$allows[] = $record->{'allow'.$type};
|
||||
}
|
||||
$this->assertEquals($allows, $info['allow'.$type], "$type $role->shortname does not match");
|
||||
}
|
||||
|
||||
$capabilities = $DB->get_records_sql(
|
||||
"SELECT *
|
||||
FROM {role_capabilities}
|
||||
WHERE contextid = :syscontext AND roleid = :roleid
|
||||
ORDER BY capability ASC",
|
||||
array('syscontext'=>context_system::instance()->id, 'roleid'=>$role->id));
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
$this->assertEquals($cap->permission, $info['permissions'][$cap->capability]);
|
||||
unset($info['permissions'][$cap->capability]);
|
||||
}
|
||||
// The remainders should be only inherits.
|
||||
foreach ($info['permissions'] as $capability => $permission) {
|
||||
if ($permission == CAP_INHERIT) {
|
||||
continue;
|
||||
}
|
||||
$this->fail('only CAP_INHERIT expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
-43
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,13 +19,14 @@
|
||||
* User roles report list all the users who have been assigned a particular
|
||||
* role in all contexts.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright © 2007 The Open University and others
|
||||
* @author t.j.hunt@open.ac.uk and others
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
|
||||
// Get params.
|
||||
$userid = required_param('userid', PARAM_INT);
|
||||
@@ -41,21 +43,15 @@ $systemcontext = context_system::instance();
|
||||
$baseurl = new moodle_url('/admin/roles/usersroles.php', array('userid'=>$userid, 'courseid'=>$courseid));
|
||||
|
||||
$PAGE->set_url($baseurl);
|
||||
$PAGE->set_context($coursecontext);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
// Check login and permissions.
|
||||
if ($course->id == SITEID) {
|
||||
require_login();
|
||||
$PAGE->set_context($usercontext);
|
||||
} else {
|
||||
require_login($course);
|
||||
$PAGE->set_context($coursecontext);
|
||||
}
|
||||
|
||||
/// Check login and permissions.
|
||||
require_login($course);
|
||||
$canview = has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
|
||||
'moodle/role:override', 'moodle/role:manage'), $usercontext);
|
||||
if (!$canview) {
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
|
||||
}
|
||||
|
||||
if ($userid != $USER->id) {
|
||||
@@ -69,26 +65,32 @@ if ($course->id != $SITE->id || $userid != $USER->id) {
|
||||
$PAGE->navbar->includesettingsbase = true;
|
||||
}
|
||||
|
||||
// Now get the role assignments for this user.
|
||||
$sql = "SELECT ra.id, ra.userid, ra.contextid, ra.roleid, ra.component, ra.itemid, c.path
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} c ON ra.contextid = c.id
|
||||
JOIN {role} r ON ra.roleid = r.id
|
||||
WHERE ra.userid = ?
|
||||
ORDER BY contextlevel DESC, contextid ASC, r.sortorder ASC";
|
||||
/// Now get the role assignments for this user.
|
||||
$sql = "SELECT
|
||||
ra.id, ra.userid, ra.contextid, ra.roleid, ra.component, ra.itemid,
|
||||
c.path
|
||||
FROM
|
||||
{role_assignments} ra
|
||||
JOIN {context} c ON ra.contextid = c.id
|
||||
JOIN {role} r ON ra.roleid = r.id
|
||||
WHERE
|
||||
ra.userid = ?
|
||||
"./*AND ra.active = 1*/"
|
||||
ORDER BY
|
||||
contextlevel DESC, contextid ASC, r.sortorder ASC";
|
||||
$roleassignments = $DB->get_records_sql($sql, array($user->id));
|
||||
|
||||
$allroles = role_fix_names(get_all_roles());
|
||||
|
||||
// In order to display a nice tree of contexts, we need to get all the
|
||||
// ancestors of all the contexts in the query we just did.
|
||||
/// In order to display a nice tree of contexts, we need to get all the
|
||||
/// ancestors of all the contexts in the query we just did.
|
||||
$requiredcontexts = array();
|
||||
foreach ($roleassignments as $ra) {
|
||||
$requiredcontexts = array_merge($requiredcontexts, explode('/', trim($ra->path, '/')));
|
||||
}
|
||||
$requiredcontexts = array_unique($requiredcontexts);
|
||||
|
||||
// Now load those contexts.
|
||||
/// Now load those contexts.
|
||||
if ($requiredcontexts) {
|
||||
list($sqlcontexttest, $contextparams) = $DB->get_in_or_equal($requiredcontexts);
|
||||
$contexts = get_sorted_contexts('ctx.id ' . $sqlcontexttest, $contextparams);
|
||||
@@ -96,22 +98,22 @@ if ($requiredcontexts) {
|
||||
$contexts = array();
|
||||
}
|
||||
|
||||
// Prepare some empty arrays to hold the data we are about to compute.
|
||||
/// Prepare some empty arrays to hold the data we are about to compute.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$contexts[$conid]->children = array();
|
||||
$contexts[$conid]->roleassignments = array();
|
||||
}
|
||||
|
||||
// Put the contexts into a tree structure.
|
||||
/// Put the contexts into a tree structure.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$context = context::instance_by_id($conid);
|
||||
$parentcontext = $context->get_parent_context();
|
||||
if ($parentcontext) {
|
||||
$contexts[$parentcontext->id]->children[] = $conid;
|
||||
$parentcontextid = get_parent_contextid($context);
|
||||
if ($parentcontextid) {
|
||||
$contexts[$parentcontextid]->children[] = $conid;
|
||||
}
|
||||
}
|
||||
|
||||
// Put the role capabilities into the context tree.
|
||||
/// Put the role capabilities into the context tree.
|
||||
foreach ($roleassignments as $ra) {
|
||||
$contexts[$ra->contextid]->roleassignments[$ra->roleid] = $ra;
|
||||
}
|
||||
@@ -119,30 +121,30 @@ foreach ($roleassignments as $ra) {
|
||||
$assignableroles = get_assignable_roles($usercontext, ROLENAME_BOTH);
|
||||
$overridableroles = get_overridable_roles($usercontext, ROLENAME_BOTH);
|
||||
|
||||
// Print the header.
|
||||
/// Print the header
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $coursecontext));
|
||||
$straction = get_string('thisusersroles', 'core_role');
|
||||
$title = get_string('xroleassignments', 'core_role', $fullname);
|
||||
$straction = get_string('thisusersroles', 'role');
|
||||
$title = get_string('xroleassignments', 'role', $fullname);
|
||||
|
||||
// Course header.
|
||||
/// Course header
|
||||
$PAGE->set_title($title);
|
||||
if ($courseid == SITEID) {
|
||||
if ($courseid != SITEID) {
|
||||
$PAGE->set_heading($fullname);
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname.': '.$fullname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
echo $OUTPUT->heading($title, 3);
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
|
||||
// Display them.
|
||||
if (!$roleassignments) {
|
||||
echo '<p>', get_string('noroleassignments', 'core_role'), '</p>';
|
||||
echo '<p>', get_string('noroleassignments', 'role'), '</p>';
|
||||
} else {
|
||||
print_report_tree($systemcontext->id, $contexts, $systemcontext, $fullname, $allroles);
|
||||
}
|
||||
|
||||
// End of page.
|
||||
/// End of page.
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -153,13 +155,13 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname, $al
|
||||
static $stredit = null, $strcheckpermissions, $globalroleassigner, $assignurl, $checkurl;
|
||||
if (is_null($stredit)) {
|
||||
$stredit = get_string('edit');
|
||||
$strcheckpermissions = get_string('checkpermissions', 'core_role');
|
||||
$strcheckpermissions = get_string('checkpermissions', 'role');
|
||||
$globalroleassigner = has_capability('moodle/role:assign', $systemcontext);
|
||||
$assignurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php';
|
||||
$checkurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php';
|
||||
}
|
||||
|
||||
// Pull the current context into an array for convenience.
|
||||
// Pull the current context into an array for convinience.
|
||||
$context = context::instance_by_id($contextid);
|
||||
|
||||
// Print the context name.
|
||||
@@ -187,11 +189,11 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname, $al
|
||||
$a->fullname = $fullname;
|
||||
$a->contextlevel = $context->get_level_name();
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
$strgoto = get_string('gotoassignsystemroles', 'core_role');
|
||||
$strcheck = get_string('checksystempermissionsfor', 'core_role', $a);
|
||||
$strgoto = get_string('gotoassignsystemroles', 'role');
|
||||
$strcheck = get_string('checksystempermissionsfor', 'role', $a);
|
||||
} else {
|
||||
$strgoto = get_string('gotoassignroles', 'core_role', $a);
|
||||
$strcheck = get_string('checkuserspermissionshere', 'core_role', $a);
|
||||
$strgoto = get_string('gotoassignroles', 'role', $a);
|
||||
$strcheck = get_string('checkuserspermissionshere', 'role', $a);
|
||||
}
|
||||
echo ' <a title="' . $strgoto . '" href="' . $raurl . '"><img class="iconsmall" src="' .
|
||||
$OUTPUT->pix_url('t/edit') . '" alt="' . $stredit . '" /></a> ';
|
||||
|
||||
+3
-3
@@ -22,6 +22,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
|
||||
if (admin_write_settings($data)) {
|
||||
$statusmsg = get_string('changessaved');
|
||||
}
|
||||
$adminroot = admin_get_root(true); //reload tree
|
||||
|
||||
if (!empty($adminroot->errors)) {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
@@ -43,11 +44,10 @@ if ($errormsg !== '') {
|
||||
|
||||
$resultshtml = admin_search_settings_html($query); // case insensitive search only
|
||||
|
||||
echo '<form action="' . $PAGE->url->out(true) . '" method="post" id="adminsettings">';
|
||||
echo '<form action="search.php" method="post" id="adminsettings">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
// HACK to prevent browsers from automatically inserting the user's password into the wrong fields.
|
||||
echo prevent_form_autofill_password();
|
||||
echo '<input type="hidden" name="query" value="'.s($query).'" />';
|
||||
echo '</div>';
|
||||
echo '<fieldset>';
|
||||
echo '<div class="clearer"><!-- --></div>';
|
||||
|
||||
+1
-5
@@ -14,7 +14,6 @@ $PAGE->set_url('/admin/settings.php', array('section' => $section));
|
||||
$PAGE->set_pagetype('admin-setting-' . $section);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->navigation->clear_cache();
|
||||
navigation_node::require_admin_tree();
|
||||
|
||||
$adminroot = admin_get_root(); // need all settings
|
||||
$settingspage = $adminroot->locate($section, true);
|
||||
@@ -48,6 +47,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
}
|
||||
$adminroot = admin_get_root(true); //reload tree
|
||||
$settingspage = $adminroot->locate($section, true);
|
||||
}
|
||||
|
||||
@@ -77,8 +77,6 @@ if (empty($SITE->fullname)) {
|
||||
echo html_writer::input_hidden_params($PAGE->url);
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
// HACK to prevent browsers from automatically inserting the user's password into the wrong fields.
|
||||
echo prevent_form_autofill_password();
|
||||
|
||||
echo $settingspage->output_html();
|
||||
|
||||
@@ -121,8 +119,6 @@ if (empty($SITE->fullname)) {
|
||||
echo html_writer::input_hidden_params($PAGE->url);
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
// HACK to prevent browsers from automatically inserting the user's password into the wrong fields.
|
||||
echo prevent_form_autofill_password();
|
||||
echo $OUTPUT->heading($settingspage->visiblename);
|
||||
|
||||
echo $settingspage->output_html();
|
||||
|
||||
@@ -2,12 +2,7 @@
|
||||
|
||||
// This file defines settingpages and externalpages under the "appearance" category
|
||||
|
||||
$capabilities = array(
|
||||
'moodle/my:configsyspages',
|
||||
'moodle/tag:manage'
|
||||
);
|
||||
|
||||
if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$ADMIN->add('appearance', new admin_category('themes', new lang_string('themes')));
|
||||
// "themesettings" settingpage
|
||||
@@ -29,7 +24,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
$ADMIN->add('themes', new admin_externalpage('themeselector', new lang_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php'));
|
||||
|
||||
// settings for each theme
|
||||
foreach (core_component::get_plugin_list('theme') as $theme => $themedir) {
|
||||
foreach (get_plugin_list('theme') as $theme => $themedir) {
|
||||
$settings_path = "$themedir/settings.php";
|
||||
if (file_exists($settings_path)) {
|
||||
$settings = new admin_settingpage('themesetting'.$theme, new lang_string('pluginname', 'theme_'.$theme));
|
||||
@@ -41,11 +36,8 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
}
|
||||
|
||||
|
||||
// Calendar settings.
|
||||
// calendar
|
||||
$temp = new admin_settingpage('calendar', new lang_string('calendarsettings','admin'));
|
||||
|
||||
$temp->add(new admin_setting_configselect('calendartype', new lang_string('calendartype', 'admin'),
|
||||
new lang_string('calendartype_desc', 'admin'), 'gregorian', \core_calendar\type_factory::get_list_of_calendar_types()));
|
||||
$temp->add(new admin_setting_special_adminseesall());
|
||||
//this is hacky because we do not want to include the stuff from calendar/lib.php
|
||||
$temp->add(new admin_setting_configselect('calendar_site_timeformat', new lang_string('pref_timeformat', 'calendar'),
|
||||
@@ -75,21 +67,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('calendar_maxevents',new lang_string('configmaxevents','admin'),new lang_string('helpupcomingmaxevents', 'admin'),10,$options));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecalendarexport', new lang_string('enablecalendarexport', 'admin'), new lang_string('configenablecalendarexport','admin'), 1));
|
||||
|
||||
// Calendar custom export settings.
|
||||
$days = array(365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
150 => new lang_string('numdays', '', 150),
|
||||
120 => new lang_string('numdays', '', 120),
|
||||
90 => new lang_string('numdays', '', 90),
|
||||
60 => new lang_string('numdays', '', 60),
|
||||
30 => new lang_string('numdays', '', 30),
|
||||
5 => new lang_string('numdays', '', 5));
|
||||
$temp->add(new admin_setting_configcheckbox('calendar_customexport', new lang_string('configcalendarcustomexport', 'admin'), new lang_string('helpcalendarcustomexport','admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('calendar_exportlookahead', new lang_string('configexportlookahead','admin'), new lang_string('helpexportlookahead', 'admin'), 365, $days));
|
||||
$temp->add(new admin_setting_configselect('calendar_exportlookback', new lang_string('configexportlookback','admin'), new lang_string('helpexportlookback', 'admin'), 5, $days));
|
||||
$temp->add(new admin_setting_configtext('calendar_exportsalt', new lang_string('calendarexportsalt','admin'), new lang_string('configcalendarexportsalt', 'admin'), random_string(60)));
|
||||
$temp->add(new admin_setting_configcheckbox('calendar_showicalsource', new lang_string('configshowicalsource', 'admin'), new lang_string('helpshowicalsource','admin'), 1));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// blog
|
||||
@@ -118,7 +96,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
);
|
||||
$temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices));
|
||||
$temp->add(new admin_setting_configcheckbox('allowguestmymoodle', new lang_string('allowguestmymoodle', 'admin'), new lang_string('configallowguestmymoodle', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowfullcoursenames', new lang_string('navshowfullcoursenames', 'admin'), new lang_string('navshowfullcoursenames_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0));
|
||||
@@ -191,18 +168,13 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
// "documentation" settingpage
|
||||
$temp = new admin_settingpage('documentation', new lang_string('moodledocs'));
|
||||
$temp->add(new admin_setting_configtext('docroot', new lang_string('docroot', 'admin'), new lang_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL));
|
||||
$ltemp = array('' => get_string('forceno'));
|
||||
$ltemp += get_string_manager()->get_list_of_translations(true);
|
||||
$temp->add(new admin_setting_configselect('doclang', get_string('doclang', 'admin'), get_string('configdoclang', 'admin'), '', $ltemp));
|
||||
$temp->add(new admin_setting_configcheckbox('doctonewwindow', new lang_string('doctonewwindow', 'admin'), new lang_string('configdoctonewwindow', 'admin'), 0));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$temp = new admin_externalpage('mypage', new lang_string('mypage', 'admin'), $CFG->wwwroot . '/my/indexsys.php',
|
||||
'moodle/my:configsyspages');
|
||||
$temp = new admin_externalpage('mypage', new lang_string('mypage', 'admin'), $CFG->wwwroot . '/my/indexsys.php');
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$temp = new admin_externalpage('profilepage', new lang_string('myprofile', 'admin'), $CFG->wwwroot . '/user/profilesys.php',
|
||||
'moodle/my:configsyspages');
|
||||
$temp = new admin_externalpage('profilepage', new lang_string('myprofile', 'admin'), $CFG->wwwroot . '/user/profilesys.php');
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// coursecontact is the person responsible for course - usually manages enrolments, receives notification, etc.
|
||||
@@ -213,25 +185,20 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
new lang_string('courselistshortnames_desc', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('coursesperpage', new lang_string('coursesperpage', 'admin'), new lang_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('courseswithsummarieslimit', new lang_string('courseswithsummarieslimit', 'admin'), new lang_string('configcourseswithsummarieslimit', 'admin'), 10, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('courseoverviewfileslimit', new lang_string('courseoverviewfileslimit'),
|
||||
new lang_string('configcourseoverviewfileslimit', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('courseoverviewfilesext', new lang_string('courseoverviewfilesext'),
|
||||
new lang_string('configcourseoverviewfilesext', 'admin'), '.jpg,.gif,.png'));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$temp = new admin_settingpage('ajax', new lang_string('ajaxuse'));
|
||||
$temp->add(new admin_setting_configcheckbox('enableajax', new lang_string('enableajax', 'admin'), new lang_string('configenableajax', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('useexternalyui', new lang_string('useexternalyui', 'admin'), new lang_string('configuseexternalyui', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('yuicomboloading', new lang_string('yuicomboloading', 'admin'), new lang_string('configyuicomboloading', 'admin'), 1));
|
||||
$setting = new admin_setting_configcheckbox('cachejs', new lang_string('cachejs', 'admin'), new lang_string('cachejs_help', 'admin'), 1);
|
||||
$setting->set_updatedcallback('js_reset_all_caches');
|
||||
$temp->add($setting);
|
||||
$temp->add(new admin_setting_configcheckbox('modchooserdefault', new lang_string('modchooserdefault', 'admin'), new lang_string('configmodchooserdefault', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('modeditingmenu', new lang_string('modeditingmenu', 'admin'), new lang_string('modeditingmenu_desc', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('blockeditingmenu', new lang_string('blockeditingmenu', 'admin'), new lang_string('blockeditingmenu_desc', 'admin'), 1));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// link to tag management interface
|
||||
$ADMIN->add('appearance', new admin_externalpage('managetags', new lang_string('managetags', 'tag'), $CFG->wwwroot.'/tag/manage.php', 'moodle/tag:manage'));
|
||||
$ADMIN->add('appearance', new admin_externalpage('managetags', new lang_string('managetags', 'tag'), "$CFG->wwwroot/tag/manage.php"));
|
||||
|
||||
$temp = new admin_settingpage('additionalhtml', new lang_string('additionalhtml', 'admin'));
|
||||
$temp->add(new admin_setting_heading('additionalhtml_heading', new lang_string('additionalhtml_heading', 'admin'), new lang_string('additionalhtml_desc', 'admin')));
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file defines settingpages and externalpages under the "badges" section
|
||||
*
|
||||
* @package core
|
||||
* @subpackage badges
|
||||
* @copyright 2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
|
||||
*/
|
||||
|
||||
global $SITE;
|
||||
|
||||
if (($hassiteconfig || has_any_capability(array(
|
||||
'moodle/badges:viewawarded',
|
||||
'moodle/badges:createbadge',
|
||||
'moodle/badges:manageglobalsettings',
|
||||
'moodle/badges:awardbadge',
|
||||
'moodle/badges:configurecriteria',
|
||||
'moodle/badges:configuremessages',
|
||||
'moodle/badges:configuredetails',
|
||||
'moodle/badges:deletebadge'), $systemcontext))) {
|
||||
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
$globalsettings = new admin_settingpage('badgesettings', new lang_string('badgesettings', 'badges'),
|
||||
array('moodle/badges:manageglobalsettings'), empty($CFG->enablebadges));
|
||||
|
||||
$globalsettings->add(new admin_setting_configtext('badges_defaultissuername',
|
||||
new lang_string('defaultissuername', 'badges'),
|
||||
new lang_string('defaultissuername_desc', 'badges'),
|
||||
$SITE->fullname ? $SITE->fullname : $SITE->shortname, PARAM_TEXT));
|
||||
|
||||
$globalsettings->add(new admin_setting_configtext('badges_defaultissuercontact',
|
||||
new lang_string('defaultissuercontact', 'badges'),
|
||||
new lang_string('defaultissuercontact_desc', 'badges'),
|
||||
get_config('moodle','supportemail'), PARAM_EMAIL));
|
||||
|
||||
$globalsettings->add(new admin_setting_configtext('badges_badgesalt',
|
||||
new lang_string('badgesalt', 'badges'),
|
||||
new lang_string('badgesalt_desc', 'badges'),
|
||||
'badges' . $SITE->timecreated, PARAM_ALPHANUM));
|
||||
|
||||
$globalsettings->add(new admin_setting_configcheckbox('badges_allowexternalbackpack',
|
||||
new lang_string('allowexternalbackpack', 'badges'),
|
||||
new lang_string('allowexternalbackpack_desc', 'badges'), 1));
|
||||
|
||||
$globalsettings->add(new admin_setting_configcheckbox('badges_allowcoursebadges',
|
||||
new lang_string('allowcoursebadges', 'badges'),
|
||||
new lang_string('allowcoursebadges_desc', 'badges'), 1));
|
||||
|
||||
$ADMIN->add('badges', $globalsettings);
|
||||
|
||||
$ADMIN->add('badges',
|
||||
new admin_externalpage('managebadges',
|
||||
new lang_string('managebadges', 'badges'),
|
||||
new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)),
|
||||
array(
|
||||
'moodle/badges:viewawarded',
|
||||
'moodle/badges:createbadge',
|
||||
'moodle/badges:awardbadge',
|
||||
'moodle/badges:configurecriteria',
|
||||
'moodle/badges:configuremessages',
|
||||
'moodle/badges:configuredetails',
|
||||
'moodle/badges:deletebadge'
|
||||
),
|
||||
empty($CFG->enablebadges)
|
||||
)
|
||||
);
|
||||
|
||||
$ADMIN->add('badges',
|
||||
new admin_externalpage('newbadge',
|
||||
new lang_string('newbadge', 'badges'),
|
||||
new moodle_url('/badges/newbadge.php', array('type' => BADGE_TYPE_SITE)),
|
||||
array('moodle/badges:createbadge'), empty($CFG->enablebadges)
|
||||
)
|
||||
);
|
||||
}
|
||||
+53
-121
@@ -1,122 +1,40 @@
|
||||
<?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 defines settingpages and externalpages under the "courses" category
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
// This file defines settingpages and externalpages under the "courses" category
|
||||
|
||||
$capabilities = array(
|
||||
'moodle/backup:backupcourse',
|
||||
'moodle/category:manage',
|
||||
'moodle/course:create',
|
||||
'moodle/site:approvecourse',
|
||||
'moodle/restore:restorecourse'
|
||||
);
|
||||
if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
// Speedup for non-admins, add all caps used on this page.
|
||||
$ADMIN->add('courses',
|
||||
new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
|
||||
$CFG->wwwroot . '/course/management.php',
|
||||
array('moodle/category:manage', 'moodle/course:create')
|
||||
)
|
||||
);
|
||||
$ADMIN->add('courses',
|
||||
new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
|
||||
new moodle_url('/course/editcategory.php', array('parent' => 0)),
|
||||
array('moodle/category:manage')
|
||||
)
|
||||
);
|
||||
$ADMIN->add('courses',
|
||||
new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'),
|
||||
new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)),
|
||||
array('moodle/course:create')
|
||||
)
|
||||
);
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/backup:backupcourse', $systemcontext)
|
||||
or has_capability('moodle/category:manage', $systemcontext)
|
||||
or has_capability('moodle/course:create', $systemcontext)
|
||||
or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// Course Default Settings Page.
|
||||
// NOTE: these settings must be applied after all other settings because they depend on them.
|
||||
$ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on',
|
||||
array('moodle/category:manage', 'moodle/course:create')));
|
||||
|
||||
// Main course settings.
|
||||
/// Course Default Settings Page
|
||||
/// NOTE: these settings must be applied after all other settings because they depend on them
|
||||
///main course settings
|
||||
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('hide');
|
||||
$choices['1'] = new lang_string('show');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
|
||||
1, $choices));
|
||||
|
||||
// Course format.
|
||||
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
|
||||
|
||||
$courseformats = get_sorted_course_formats(true);
|
||||
$formcourseformats = array();
|
||||
foreach ($courseformats as $courseformat) {
|
||||
$formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'),
|
||||
'weeks',$formcourseformats));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks',$formcourseformats));
|
||||
|
||||
$temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'),
|
||||
new lang_string('maxnumberweeks_desc'), 52));
|
||||
$temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'), new lang_string('maxnumberweeks_desc'), 52));
|
||||
|
||||
$temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'),
|
||||
new lang_string('coursehelpnumberweeks'), 10));
|
||||
$temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'), new lang_string('coursehelpnumberweeks'), 10));
|
||||
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('hiddensectionscollapsed');
|
||||
$choices['1'] = new lang_string('hiddensectionsinvisible');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'),
|
||||
new lang_string('coursehelphiddensections'), 0, $choices));
|
||||
|
||||
$choices = array();
|
||||
$choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
|
||||
$choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
|
||||
new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
|
||||
|
||||
// Appearance.
|
||||
$temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
|
||||
|
||||
$languages = array();
|
||||
$languages[''] = new lang_string('forceno');
|
||||
$languages += get_string_manager()->get_list_of_translations();
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages),
|
||||
$languages));
|
||||
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'), new lang_string('coursehelphiddensections'), 0,$choices));
|
||||
$options = range(0, 10);
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'),
|
||||
new lang_string('coursehelpnewsitemsnumber'), 5, $options));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'),
|
||||
new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
|
||||
array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
// Files and uploads.
|
||||
$temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
|
||||
|
||||
if (!empty($CFG->legacyfilesinnewcourses)) {
|
||||
$choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'),
|
||||
new lang_string('courselegacyfiles_help'), key($choices), $choices));
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'), new lang_string('coursehelpnewsitemsnumber'), 5,$options));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'), new lang_string('coursehelpshowgrades'), 1,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
$currentmaxbytes = get_config('moodlecourse', 'maxbytes');
|
||||
if (isset($CFG->maxbytes)) {
|
||||
@@ -124,15 +42,18 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
} else {
|
||||
$choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
|
||||
new lang_string('coursehelpmaximumupload'), key($choices), $choices));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'), new lang_string('coursehelpmaximumupload'), key($choices), $choices));
|
||||
|
||||
// Completion tracking.
|
||||
$temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
|
||||
new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
if (!empty($CFG->legacyfilesinnewcourses)) {
|
||||
$choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'), new lang_string('courselegacyfiles_help'), key($choices), $choices));
|
||||
}
|
||||
|
||||
$choices = array();
|
||||
$choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
|
||||
$choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
|
||||
|
||||
// Groups.
|
||||
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
|
||||
$choices = array();
|
||||
$choices[NOGROUPS] = new lang_string('groupsnone', 'group');
|
||||
@@ -141,10 +62,28 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', new lang_string('force'), new lang_string('coursehelpforce'), 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
|
||||
$temp->add(new admin_setting_heading('availability', new lang_string('availability'), ''));
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('courseavailablenot');
|
||||
$choices['1'] = new lang_string('courseavailable');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), '', 1,$choices));
|
||||
|
||||
|
||||
$temp->add(new admin_setting_heading('language', new lang_string('language'), ''));
|
||||
$languages=array();
|
||||
$languages[''] = new lang_string('forceno');
|
||||
$languages += get_string_manager()->get_list_of_translations();
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '',key($languages),$languages));
|
||||
|
||||
$temp->add(new admin_setting_heading('progress', new lang_string('progress','completion'), ''));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion','completion'), '',
|
||||
0, array(0 => new lang_string('completiondisabled','completion'), 1 => new lang_string('completionenabled','completion'))));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('moodlecourse/completionstartonenrol', new lang_string('completionstartonenrol','completion'), new lang_string('completionstartonenrolhelp', 'completion'), 0));
|
||||
$ADMIN->add('courses', $temp);
|
||||
|
||||
|
||||
// "courserequests" settingpage.
|
||||
/// "courserequests" settingpage
|
||||
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
|
||||
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory', new lang_string('defaultrequestcategory', 'admin'), new lang_string('configdefaultrequestcategory', 'admin'), 1));
|
||||
@@ -152,13 +91,13 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
|
||||
$ADMIN->add('courses', $temp);
|
||||
|
||||
// Pending course requests.
|
||||
/// Pending course requests.
|
||||
if (!empty($CFG->enablecourserequests)) {
|
||||
$ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
|
||||
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
|
||||
}
|
||||
|
||||
// Add a category for backups.
|
||||
// Add a category for backups
|
||||
$ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
|
||||
|
||||
// Create a page for general backups configuration and defaults.
|
||||
@@ -191,16 +130,9 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), array('value'=>1,'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', new lang_string('generallogs','backup'), new lang_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for general import configuration and defaults.
|
||||
$temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse');
|
||||
$temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10));
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for automated backups configuration and defaults.
|
||||
@@ -266,14 +198,14 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
|
||||
|
||||
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
}
|
||||
|
||||
} // end of speedup
|
||||
|
||||
@@ -19,15 +19,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$enablecssoptimiser->set_updatedcallback('theme_reset_all_caches');
|
||||
$temp->add($enablecssoptimiser);
|
||||
|
||||
// Backup archive .mbz format: switching to .tar.gz enables larger files, better
|
||||
// progress reporting and possibly better performance. This is an experimental
|
||||
// setting but if successful, should be removed and enabled by default in a future
|
||||
// version. Note: this setting controls newly-created backups only; restore always
|
||||
// supports both formats.
|
||||
$temp->add(new admin_setting_configcheckbox('enabletgzbackups',
|
||||
new lang_string('enabletgzbackups', 'admin'),
|
||||
new lang_string('enabletgzbackups_desc', 'admin'), 0));
|
||||
|
||||
$ADMIN->add('experimental', $temp);
|
||||
|
||||
// "debugging" settingpage
|
||||
@@ -41,46 +32,44 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configcheckbox('debugpageinfo', new lang_string('debugpageinfo', 'admin'), new lang_string('configdebugpageinfo', 'admin'), 0));
|
||||
$ADMIN->add('development', $temp);
|
||||
|
||||
// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
|
||||
$xhprofenabled = extension_loaded('xhprof') && function_exists('xhprof_enable');
|
||||
$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));
|
||||
// List of URLs that will be automatically profiled.
|
||||
$temp->add(new admin_setting_configtextarea('profilingincluded', new lang_string('profilingincluded', 'admin'), new lang_string('profilingincluded_help', 'admin'), ''));
|
||||
// List of URLs that won't be profiled ever.
|
||||
$temp->add(new admin_setting_configtextarea('profilingexcluded', new lang_string('profilingexcluded', 'admin'), new lang_string('profilingexcluded_help', 'admin'), ''));
|
||||
// Allow random profiling each XX requests.
|
||||
$temp->add(new admin_setting_configtext('profilingautofrec', new lang_string('profilingautofrec', 'admin'), new lang_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
|
||||
// Allow PROFILEME/DONTPROFILEME GPC.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
|
||||
// Allow PROFILEALL/PROFILEALLSTOP GPC.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
|
||||
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
|
||||
// TODO: Allow to skip call_user functions (ignored_functions array)
|
||||
// Specify the life time (in minutes) of profiling runs.
|
||||
$temp->add(new admin_setting_configselect('profilinglifetime', new lang_string('profilinglifetime', 'admin'), new lang_string('profilinglifetime_help', 'admin'), 24*60, array(
|
||||
0 => new lang_string('neverdeleteruns', 'admin'),
|
||||
30*24*60 => new lang_string('numdays', '', 30),
|
||||
15*24*60 => new lang_string('numdays', '', 15),
|
||||
7*24*60 => new lang_string('numdays', '', 7),
|
||||
4*24*60 => new lang_string('numdays', '', 4),
|
||||
2*24*60 => new lang_string('numdays', '', 2),
|
||||
24*60 => new lang_string('numhours', '', 24),
|
||||
16*80 => new lang_string('numhours', '', 16),
|
||||
8*60 => new lang_string('numhours', '', 8),
|
||||
4*60 => new lang_string('numhours', '', 4),
|
||||
2*60 => new lang_string('numhours', '', 2),
|
||||
60 => new lang_string('numminutes', '', 60),
|
||||
30 => new lang_string('numminutes', '', 30),
|
||||
15 => new lang_string('numminutes', '', 15))));
|
||||
// Define the prefix to be added to imported profiling runs.
|
||||
$temp->add(new admin_setting_configtext('profilingimportprefix',
|
||||
new lang_string('profilingimportprefix', 'admin'),
|
||||
new lang_string('profilingimportprefix_desc', 'admin'), '(I)', PARAM_TAG, 10));
|
||||
// "profiling" settingpage (conditionally if the 'xhprof' extension is available only)
|
||||
if (extension_loaded('xhprof') && function_exists('xhprof_enable')) {
|
||||
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'));
|
||||
// Main profiling switch
|
||||
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
||||
// List of URLs that will be automatically profiled
|
||||
$temp->add(new admin_setting_configtextarea('profilingincluded', new lang_string('profilingincluded', 'admin'), new lang_string('profilingincluded_help', 'admin'), ''));
|
||||
// List of URLs that won't be profiled ever
|
||||
$temp->add(new admin_setting_configtextarea('profilingexcluded', new lang_string('profilingexcluded', 'admin'), new lang_string('profilingexcluded_help', 'admin'), ''));
|
||||
// Allow random profiling each XX requests
|
||||
$temp->add(new admin_setting_configtext('profilingautofrec', new lang_string('profilingautofrec', 'admin'), new lang_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
|
||||
// Allow PROFILEME/DONTPROFILEME GPC
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
|
||||
// Allow PROFILEALL/PROFILEALLSTOP GPC
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
|
||||
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
|
||||
// TODO: Allow to skip call_user functions (ignored_functions array)
|
||||
// Specify the life time (in minutes) of profiling runs
|
||||
$temp->add(new admin_setting_configselect('profilinglifetime', new lang_string('profilinglifetime', 'admin'), new lang_string('profilinglifetime_help', 'admin'), 24*60, array(
|
||||
0 => new lang_string('neverdeleteruns', 'admin'),
|
||||
30*24*60 => new lang_string('numdays', '', 30),
|
||||
15*24*60 => new lang_string('numdays', '', 15),
|
||||
7*24*60 => new lang_string('numdays', '', 7),
|
||||
4*24*60 => new lang_string('numdays', '', 4),
|
||||
2*24*60 => new lang_string('numdays', '', 2),
|
||||
24*60 => new lang_string('numhours', '', 24),
|
||||
16*80 => new lang_string('numhours', '', 16),
|
||||
8*60 => new lang_string('numhours', '', 8),
|
||||
4*60 => new lang_string('numhours', '', 4),
|
||||
2*60 => new lang_string('numhours', '', 2),
|
||||
60 => new lang_string('numminutes', '', 60),
|
||||
30 => new lang_string('numminutes', '', 30),
|
||||
15 => new lang_string('numminutes', '', 15))));
|
||||
|
||||
// Add the 'profiling' page to admin block
|
||||
$ADMIN->add('development', $temp);
|
||||
}
|
||||
|
||||
// Add the 'profiling' page to admin block.
|
||||
$ADMIN->add('development', $temp);
|
||||
|
||||
// Web service test clients DO NOT COMMIT : THE EXTERNAL WEB PAGE IS NOT AN ADMIN PAGE !!!!!
|
||||
$ADMIN->add('development', new admin_externalpage('testclient', new lang_string('testclient', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/testclient.php"));
|
||||
@@ -91,6 +80,4 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
}
|
||||
|
||||
$ADMIN->add('development', new admin_externalpage('purgecaches', new lang_string('purgecaches','admin'), "$CFG->wwwroot/$CFG->admin/purgecaches.php"));
|
||||
|
||||
$ADMIN->add('development', new admin_externalpage('thirdpartylibs', new lang_string('thirdpartylibs','admin'), "$CFG->wwwroot/$CFG->admin/thirdpartylibs.php"));
|
||||
} // end of speedup
|
||||
|
||||
@@ -32,9 +32,7 @@ if (!during_initial_install()) { //do not use during installation
|
||||
for ($i=1; $i<100; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('maxcategorydepth', new lang_string('configsitemaxcategorydepth','admin'), new lang_string('configsitemaxcategorydepthhelp','admin'), 2, $options));
|
||||
|
||||
$temp->add(new admin_setting_configtext('frontpagecourselimit', new lang_string('configfrontpagecourselimit','admin'), new lang_string('configfrontpagecourselimithelp','admin'), 200, PARAM_INT));
|
||||
$temp->add(new admin_setting_configselect('maxcategorydepth', new lang_string('configsitemaxcategorydepth','admin'), new lang_string('configsitemaxcategorydepthhelp','admin'), 0, $options));
|
||||
|
||||
$temp->add(new admin_setting_sitesetcheckbox('numsections', new lang_string('sitesection'), new lang_string('sitesectionhelp','admin'), 1));
|
||||
$temp->add(new admin_setting_sitesetselect('newsitems', new lang_string('newsitemsnumber'), '', 3,
|
||||
@@ -69,6 +67,29 @@ if (!during_initial_install()) { //do not use during installation
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', new lang_string('frontpagedefaultrole', 'admin'), '', $defaultfrontpageroleid, $options));
|
||||
|
||||
|
||||
$ADMIN->add('frontpage', $temp);
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpageroles', new lang_string('frontpageroles', 'admin'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $frontpagecontext->id, 'moodle/role:assign', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagefilters', new lang_string('frontpagefilters', 'admin'), "$CFG->wwwroot/filter/manage.php?contextid=" . $frontpagecontext->id, 'moodle/filter:manage', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagebackup', new lang_string('frontpagebackup', 'admin'), $CFG->wwwroot.'/backup/backup.php?id='.SITEID, 'moodle/backup:backupcourse', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', new lang_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/backup/restorefile.php?contextid='.$frontpagecontext->id, 'moodle/restore:restorecourse', false, $frontpagecontext));
|
||||
|
||||
$questioncapabilities = array(
|
||||
'moodle/question:add',
|
||||
'moodle/question:editmine',
|
||||
'moodle/question:editall',
|
||||
'moodle/question:viewmine',
|
||||
'moodle/question:viewall',
|
||||
'moodle/question:movemine',
|
||||
'moodle/question:moveall');
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagequestions', new lang_string('frontpagequestions', 'admin'), $CFG->wwwroot.'/question/edit.php?courseid='.SITEID, $questioncapabilities, false, $frontpagecontext));
|
||||
|
||||
if (!empty($SITE->legacyfiles) and $SITE->legacyfiles === 2) {
|
||||
$ADMIN->add('frontpage', new admin_externalpage('sitefiles', new lang_string('sitelegacyfiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID, 'moodle/course:managefiles', false, $frontpagecontext));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,6 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
$temp->add(new admin_setting_special_gradeexport());
|
||||
|
||||
$temp->add(new admin_setting_special_gradelimiting());
|
||||
|
||||
$temp->add(new admin_setting_special_gradepointmax());
|
||||
|
||||
$temp->add(new admin_setting_special_gradepointdefault());
|
||||
}
|
||||
$ADMIN->add('grades', $temp);
|
||||
|
||||
@@ -182,7 +178,7 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
// Reports
|
||||
$ADMIN->add('grades', new admin_category('gradereports', new lang_string('reportsettings', 'grades')));
|
||||
foreach (core_component::get_plugin_list('gradereport') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('gradereport') as $plugin => $plugindir) {
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($plugindir.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradereport'.$plugin, new lang_string('pluginname', 'gradereport_'.$plugin), 'moodle/grade:manage');
|
||||
@@ -195,7 +191,7 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
// Imports
|
||||
$ADMIN->add('grades', new admin_category('gradeimports', new lang_string('importsettings', 'grades')));
|
||||
foreach (core_component::get_plugin_list('gradeimport') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('gradeimport') as $plugin => $plugindir) {
|
||||
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($plugindir.'/settings.php')) {
|
||||
@@ -210,7 +206,7 @@ if (has_capability('moodle/grade:manage', $systemcontext)
|
||||
|
||||
// Exports
|
||||
$ADMIN->add('grades', new admin_category('gradeexports', new lang_string('exportsettings', 'grades')));
|
||||
foreach (core_component::get_plugin_list('gradeexport') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('gradeexport') as $plugin => $plugindir) {
|
||||
// Include all the settings commands for this plugin if there are any
|
||||
if (file_exists($plugindir.'/settings.php')) {
|
||||
$settings = new admin_settingpage('gradeexport'.$plugin, new lang_string('pluginname', 'gradeexport_'.$plugin), 'moodle/grade:manage');
|
||||
|
||||
+96
-153
@@ -1,68 +1,47 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Load all plugins into the admin tree.
|
||||
*
|
||||
* Please note that is file is always loaded last - it means that you can inject entries into other categories too.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2007 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
/*
|
||||
* Please note that is file is always loaded last - it means that you can inject entries into other categories too.
|
||||
*/
|
||||
|
||||
if ($hassiteconfig) {
|
||||
/* @var admin_root $ADMIN */
|
||||
$ADMIN->locate('modules')->set_sorting(true);
|
||||
require_once("$CFG->libdir/pluginlib.php");
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
|
||||
$ADMIN->add('modules', new admin_page_pluginsoverview());
|
||||
|
||||
// activity modules
|
||||
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
|
||||
$ADMIN->add('modsettings', new admin_page_managemods());
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('mod') as $plugin) {
|
||||
/** @var \core\plugininfo\mod $plugin */
|
||||
$plugin->load_settings($ADMIN, 'modsettings', $hassiteconfig);
|
||||
foreach ($allplugins['mod'] as $module) {
|
||||
$module->load_settings($ADMIN, 'modsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// hidden script for converting journals to online assignments (or something like that) linked from elsewhere
|
||||
$ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
|
||||
|
||||
// course formats
|
||||
$ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
|
||||
$temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
|
||||
$temp->add(new admin_setting_manageformats());
|
||||
$ADMIN->add('formatsettings', $temp);
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('format') as $plugin) {
|
||||
/** @var \core\plugininfo\format $plugin */
|
||||
$plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
|
||||
foreach ($allplugins['format'] as $format) {
|
||||
$format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// blocks
|
||||
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
|
||||
$ADMIN->add('blocksettings', new admin_page_manageblocks());
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('block') as $plugin) {
|
||||
/** @var \core\plugininfo\block $plugin */
|
||||
$plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
|
||||
foreach ($allplugins['block'] as $block) {
|
||||
$block->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// message outputs
|
||||
$ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
|
||||
$ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
|
||||
$ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('message') as $plugin) {
|
||||
/** @var \core\plugininfo\message $plugin */
|
||||
$plugin->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
|
||||
foreach ($allplugins['message'] as $processor) {
|
||||
$processor->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
|
||||
}
|
||||
|
||||
// authentication plugins
|
||||
@@ -72,7 +51,6 @@ if ($hassiteconfig) {
|
||||
$temp->add(new admin_setting_manageauths());
|
||||
$temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
|
||||
$temp->add(new admin_setting_special_registerauth());
|
||||
$temp->add(new admin_setting_configcheckbox('authloginviaemail', new lang_string('authloginviaemail', 'core_auth'), new lang_string('authloginviaemail_desc', 'core_auth'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configselect('guestloginbutton', new lang_string('guestloginbutton', 'auth'),
|
||||
@@ -91,12 +69,8 @@ if ($hassiteconfig) {
|
||||
$temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
|
||||
$ADMIN->add('authsettings', $temp);
|
||||
|
||||
$temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
|
||||
$ADMIN->add('authsettings', $temp);
|
||||
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('auth') as $plugin) {
|
||||
/** @var \core\plugininfo\auth $plugin */
|
||||
$plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
|
||||
foreach ($allplugins['auth'] as $auth) {
|
||||
$auth->load_settings($ADMIN, 'authsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// Enrolment plugins
|
||||
@@ -104,13 +78,8 @@ if ($hassiteconfig) {
|
||||
$temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
|
||||
$temp->add(new admin_setting_manageenrols());
|
||||
$ADMIN->add('enrolments', $temp);
|
||||
|
||||
$temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
|
||||
$ADMIN->add('enrolments', $temp);
|
||||
|
||||
foreach(core_plugin_manager::instance()->get_plugins_of_type('enrol') as $plugin) {
|
||||
/** @var \core\plugininfo\enrol $plugin */
|
||||
$plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
|
||||
foreach($allplugins['enrol'] as $enrol) {
|
||||
$enrol->load_settings($ADMIN, 'enrolments', $hassiteconfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,9 +88,8 @@ if ($hassiteconfig) {
|
||||
$temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
|
||||
$temp->add(new admin_setting_manageeditors());
|
||||
$ADMIN->add('editorsettings', $temp);
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('editor') as $plugin) {
|
||||
/** @var \core\plugininfo\editor $plugin */
|
||||
$plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
|
||||
foreach ($allplugins['editor'] as $editor) {
|
||||
$editor->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
/// License types
|
||||
@@ -146,7 +114,31 @@ if ($hassiteconfig) {
|
||||
// "filtersettings" settingpage
|
||||
$temp = new admin_settingpage('commonfiltersettings', new lang_string('commonfiltersettings', 'admin'));
|
||||
if ($ADMIN->fulltree) {
|
||||
$cachetimes = array(
|
||||
604800 => new lang_string('numdays','',7),
|
||||
86400 => new lang_string('numdays','',1),
|
||||
43200 => new lang_string('numhours','',12),
|
||||
10800 => new lang_string('numhours','',3),
|
||||
7200 => new lang_string('numhours','',2),
|
||||
3600 => new lang_string('numhours','',1),
|
||||
2700 => new lang_string('numminutes','',45),
|
||||
1800 => new lang_string('numminutes','',30),
|
||||
900 => new lang_string('numminutes','',15),
|
||||
600 => new lang_string('numminutes','',10),
|
||||
540 => new lang_string('numminutes','',9),
|
||||
480 => new lang_string('numminutes','',8),
|
||||
420 => new lang_string('numminutes','',7),
|
||||
360 => new lang_string('numminutes','',6),
|
||||
300 => new lang_string('numminutes','',5),
|
||||
240 => new lang_string('numminutes','',4),
|
||||
180 => new lang_string('numminutes','',3),
|
||||
120 => new lang_string('numminutes','',2),
|
||||
60 => new lang_string('numminutes','',1),
|
||||
30 => new lang_string('numseconds','',30),
|
||||
0 => new lang_string('no')
|
||||
);
|
||||
$items = array();
|
||||
$items[] = new admin_setting_configselect('cachetext', new lang_string('cachetext', 'admin'), new lang_string('configcachetext', 'admin'), 60, $cachetimes);
|
||||
$items[] = new admin_setting_configselect('filteruploadedfiles', new lang_string('filteruploadedfiles', 'admin'), new lang_string('configfilteruploadedfiles', 'admin'), 0,
|
||||
array('0' => new lang_string('none'), '1' => new lang_string('allfiles'), '2' => new lang_string('htmlfilesonly')));
|
||||
$items[] = new admin_setting_configcheckbox('filtermatchoneperpage', new lang_string('filtermatchoneperpage', 'admin'), new lang_string('configfiltermatchoneperpage', 'admin'), 0);
|
||||
@@ -158,9 +150,8 @@ if ($hassiteconfig) {
|
||||
}
|
||||
$ADMIN->add('filtersettings', $temp);
|
||||
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('filter') as $plugin) {
|
||||
/** @var \core\plugininfo\filter $plugin */
|
||||
$plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
|
||||
foreach ($allplugins['filter'] as $filter) {
|
||||
$filter->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,9 +196,9 @@ if ($hassiteconfig) {
|
||||
50, PARAM_INT, 3));
|
||||
|
||||
$ADMIN->add('portfoliosettings', $temp);
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true));
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true));
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true));
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
|
||||
|
||||
foreach (portfolio_instances(false, false) as $portfolio) {
|
||||
require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
|
||||
@@ -219,7 +210,9 @@ if ($hassiteconfig) {
|
||||
$portfolio->get('name'),
|
||||
$url . '?action=edit&pf=' . $portfolio->get('id'),
|
||||
'moodle/site:config'
|
||||
)
|
||||
),
|
||||
$portfolio->get('name'),
|
||||
$url . '?action=edit&pf=' . $portfolio->get('id')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -236,27 +229,27 @@ if ($hassiteconfig) {
|
||||
|
||||
// Add common settings page
|
||||
$temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
|
||||
$temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('repositorygetfiletimeout', new lang_string('getfiletimeout', 'repository'), new lang_string('configgetfiletimeout', 'repository'), 30, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('repositorysyncfiletimeout', new lang_string('syncfiletimeout', 'repository'), new lang_string('configsyncfiletimeout', 'repository'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('repositorysyncimagetimeout', new lang_string('syncimagetimeout', 'repository'), new lang_string('configsyncimagetimeout', 'repository'), 3, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
|
||||
$temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
|
||||
$ADMIN->add('repositorysettings', $temp);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
|
||||
new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
|
||||
new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
|
||||
new lang_string('manage', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('manage', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
|
||||
new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
|
||||
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('repository') as $plugin) {
|
||||
/** @var \core\plugininfo\repository $plugin */
|
||||
$plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
|
||||
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
foreach ($allplugins['repository'] as $repositorytype) {
|
||||
$repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
/// Web services
|
||||
@@ -278,6 +271,9 @@ if ($hassiteconfig) {
|
||||
$ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
|
||||
/// manage service
|
||||
$temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
|
||||
$temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
|
||||
new lang_string('enablemobilewebservice', 'admin'),
|
||||
new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
|
||||
$temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
|
||||
$temp->add(new admin_setting_manageexternalservices());
|
||||
$ADMIN->add('webservicesettings', $temp);
|
||||
@@ -301,9 +297,8 @@ if ($hassiteconfig) {
|
||||
'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
|
||||
$ADMIN->add('webservicesettings', $temp);
|
||||
/// links to protocol pages
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('webservice') as $plugin) {
|
||||
/** @var \core\plugininfo\webservice $plugin */
|
||||
$plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
|
||||
foreach ($allplugins['webservice'] as $webservice) {
|
||||
$webservice->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
|
||||
}
|
||||
/// manage token page link
|
||||
$ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
|
||||
@@ -317,7 +312,10 @@ if ($hassiteconfig) {
|
||||
|
||||
// Question type settings
|
||||
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
|
||||
|
||||
if (!$hassiteconfig) {
|
||||
require_once("$CFG->libdir/pluginlib.php");
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
}
|
||||
// Question behaviour settings.
|
||||
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
|
||||
$ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
|
||||
@@ -325,57 +323,8 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
// Question type settings.
|
||||
$ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
|
||||
$ADMIN->add('qtypesettings', new admin_page_manageqtypes());
|
||||
|
||||
// Question preview defaults.
|
||||
$settings = new admin_settingpage('qdefaultsetting',
|
||||
get_string('questionpreviewdefaults', 'question'),
|
||||
'moodle/question:config');
|
||||
$ADMIN->add('qtypesettings', $settings);
|
||||
|
||||
$settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
|
||||
'', get_string('questionpreviewdefaults_desc', 'question')));
|
||||
|
||||
// These keys are question_display_options::HIDDEN and VISIBLE.
|
||||
$hiddenofvisible = array(
|
||||
0 => get_string('notshown', 'question'),
|
||||
1 => get_string('shown', 'question'),
|
||||
);
|
||||
|
||||
$settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
|
||||
get_string('howquestionsbehave', 'question'), '',
|
||||
'deferredfeedback'));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/correctness',
|
||||
get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
// These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
|
||||
$marksoptions = array(
|
||||
0 => get_string('notshown', 'question'),
|
||||
1 => get_string('showmaxmarkonly', 'question'),
|
||||
2 => get_string('showmarkandmax', 'question'),
|
||||
);
|
||||
$settings->add(new admin_setting_configselect('question_preview/marks',
|
||||
get_string('marks', 'question'), '', 2, $marksoptions));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/markdp',
|
||||
get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/feedback',
|
||||
get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/generalfeedback',
|
||||
get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/rightanswer',
|
||||
get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/history',
|
||||
get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
|
||||
|
||||
// Settings for particular question types.
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('qtype') as $plugin) {
|
||||
/** @var \core\plugininfo\qtype $plugin */
|
||||
$plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
|
||||
foreach ($allplugins['qtype'] as $qtype) {
|
||||
$qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,8 +334,7 @@ if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
|
||||
$ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
|
||||
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('plagiarism') as $plugin) {
|
||||
/** @var \core\plugininfo\plagiarism $plugin */
|
||||
foreach ($allplugins['plagiarism'] as $plugin) {
|
||||
$plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
|
||||
}
|
||||
}
|
||||
@@ -395,7 +343,7 @@ $ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comme
|
||||
// Course reports settings
|
||||
if ($hassiteconfig) {
|
||||
$pages = array();
|
||||
foreach (core_component::get_plugin_list('coursereport') as $report => $path) {
|
||||
foreach (get_plugin_list('coursereport') as $report => $path) {
|
||||
$file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
|
||||
if (file_exists($file)) {
|
||||
$settings = new admin_settingpage('coursereport' . $report,
|
||||
@@ -418,7 +366,7 @@ if ($hassiteconfig) {
|
||||
|
||||
// Now add reports
|
||||
$pages = array();
|
||||
foreach (core_component::get_plugin_list('report') as $report => $plugindir) {
|
||||
foreach (get_plugin_list('report') as $report => $plugindir) {
|
||||
$settings_path = "$plugindir/settings.php";
|
||||
if (file_exists($settings_path)) {
|
||||
$settings = new admin_settingpage('report' . $report,
|
||||
@@ -443,10 +391,12 @@ if ($hassiteconfig) {
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
|
||||
}
|
||||
|
||||
// Now add various admin tools.
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('tool') as $plugin) {
|
||||
/** @var \core\plugininfo\tool $plugin */
|
||||
$plugin->load_settings($ADMIN, null, $hassiteconfig);
|
||||
// Now add various admin tools
|
||||
foreach (get_plugin_list('tool') as $plugin => $plugindir) {
|
||||
$settings_path = "$plugindir/settings.php";
|
||||
if (file_exists($settings_path)) {
|
||||
include($settings_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Now add the Cache plugins
|
||||
@@ -455,7 +405,7 @@ if ($hassiteconfig) {
|
||||
$ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
|
||||
$ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
|
||||
$ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
|
||||
foreach (core_component::get_plugin_list('cachestore') as $plugin => $path) {
|
||||
foreach (get_plugin_list('cachestore') as $plugin => $path) {
|
||||
$settingspath = $path.'/settings.php';
|
||||
if (file_exists($settingspath)) {
|
||||
$settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
|
||||
@@ -465,16 +415,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add Calendar type settings.
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
|
||||
foreach (core_component::get_plugin_list_with_file('calendartype', 'settings.php') as $plugin => $settingspath) {
|
||||
$settings = new admin_settingpage('calendartype_' . $plugin . '_settings', new lang_string('pluginname', 'calendartype_' . $plugin), 'moodle/site:config');
|
||||
include($settingspath);
|
||||
$ADMIN->add('calendartype', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
/// Add all local plugins - must be always last!
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
|
||||
@@ -482,9 +422,12 @@ if ($hassiteconfig) {
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
|
||||
}
|
||||
|
||||
// Extend settings for each local plugin. Note that their settings may be in any part of the
|
||||
// settings tree and may be visible not only for administrators.
|
||||
foreach (core_plugin_manager::instance()->get_plugins_of_type('local') as $plugin) {
|
||||
/** @var \core\plugininfo\local $plugin */
|
||||
$plugin->load_settings($ADMIN, null, $hassiteconfig);
|
||||
// extend settings for each local plugin. Note that their settings may be in any part of the
|
||||
// settings tree and may be visible not only for administrators. We can not use $allplugins here
|
||||
foreach (get_plugin_list('local') as $plugin => $plugindir) {
|
||||
$settings_path = "$plugindir/settings.php";
|
||||
if (file_exists($settings_path)) {
|
||||
include($settings_path);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-29
@@ -23,12 +23,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
new lang_string('configprofileroles', 'admin'),
|
||||
array('student', 'teacher', 'editingteacher')));
|
||||
|
||||
$maxbytes = 0;
|
||||
if (!empty($CFG->maxbytes)) {
|
||||
$maxbytes = $CFG->maxbytes;
|
||||
}
|
||||
$max_upload_choices = get_max_upload_sizes(0, 0, 0, $maxbytes);
|
||||
$max_upload_choices = get_max_upload_sizes();
|
||||
// maxbytes set to 0 will allow the maximum server limit for uploads
|
||||
$max_upload_choices[0] = new lang_string('serverlimit', 'admin');
|
||||
$temp->add(new admin_setting_configselect('maxbytes', new lang_string('maxbytes', 'admin'), new lang_string('configmaxbytes', 'admin'), 0, $max_upload_choices));
|
||||
// 100MB
|
||||
$defaultuserquota = 104857600;
|
||||
@@ -46,7 +43,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
1800 => new lang_string('numminutes', '', 30),
|
||||
2700 => new lang_string('numminutes', '', 45),
|
||||
3600 => new lang_string('numminutes', '', 60))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), new lang_string('configfullnamedisplay', 'admin'),
|
||||
'language', array('language' => new lang_string('language'),
|
||||
'firstname lastname' => new lang_string('firstname').' + '.new lang_string('lastname'),
|
||||
'lastname firstname' => new lang_string('lastname').' + '.new lang_string('firstname'),
|
||||
'firstname' => new lang_string('firstname'))));
|
||||
$temp->add(new admin_setting_configcheckbox('extendedusernamechars', new lang_string('extendedusernamechars', 'admin'), new lang_string('configextendedusernamechars', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('sitepolicy', new lang_string('sitepolicy', 'admin'), new lang_string('sitepolicy_help', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sitepolicyguest', new lang_string('sitepolicyguest', 'admin'), new lang_string('sitepolicyguest_help', 'admin'), (isset($CFG->sitepolicy) ? $CFG->sitepolicy : ''), PARAM_RAW));
|
||||
@@ -58,11 +59,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configcheckbox('cronclionly', new lang_string('cronclionly', 'admin'), new lang_string('configcronclionly', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configpasswordunmask('cronremotepassword', new lang_string('cronremotepassword', 'admin'), new lang_string('configcronremotepassword', 'admin'), ''));
|
||||
|
||||
$options = array(0=>get_string('no'), 3=>3, 5=>5, 7=>7, 10=>10, 20=>20, 30=>30, 50=>50, 100=>100);
|
||||
$temp->add(new admin_setting_configselect('lockoutthreshold', new lang_string('lockoutthreshold', 'admin'), new lang_string('lockoutthreshold_desc', 'admin'), 0, $options));
|
||||
$temp->add(new admin_setting_configduration('lockoutwindow', new lang_string('lockoutwindow', 'admin'), new lang_string('lockoutwindow_desc', 'admin'), 60*30));
|
||||
$temp->add(new admin_setting_configduration('lockoutduration', new lang_string('lockoutduration', 'admin'), new lang_string('lockoutduration_desc', 'admin'), 60*30));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('passwordpolicy', new lang_string('passwordpolicy', 'admin'), new lang_string('configpasswordpolicy', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('minpasswordlength', new lang_string('minpasswordlength', 'admin'), new lang_string('configminpasswordlength', 'admin'), 8, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('minpassworddigits', new lang_string('minpassworddigits', 'admin'), new lang_string('configminpassworddigits', 'admin'), 1, PARAM_INT));
|
||||
@@ -70,22 +66,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configtext('minpasswordupper', new lang_string('minpasswordupper', 'admin'), new lang_string('configminpasswordupper', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('minpasswordnonalphanum', new lang_string('minpasswordnonalphanum', 'admin'), new lang_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('maxconsecutiveidentchars', new lang_string('maxconsecutiveidentchars', 'admin'), new lang_string('configmaxconsecutiveidentchars', 'admin'), 0, PARAM_INT));
|
||||
$pwresetoptions = array(
|
||||
300 => new lang_string('numminutes', '', 5),
|
||||
900 => new lang_string('numminutes', '', 15),
|
||||
1800 => new lang_string('numminutes', '', 30),
|
||||
2700 => new lang_string('numminutes', '', 45),
|
||||
3600 => new lang_string('numminutes', '', 60),
|
||||
7200 => new lang_string('numminutes', '', 120),
|
||||
14400 => new lang_string('numminutes', '', 240)
|
||||
);
|
||||
$adminsetting = new admin_setting_configselect(
|
||||
'pwresettime',
|
||||
new lang_string('passwordresettime','admin'),
|
||||
new lang_string('configpasswordresettime','admin'),
|
||||
1800,
|
||||
$pwresetoptions);
|
||||
$temp->add($adminsetting);
|
||||
$temp->add(new admin_setting_configcheckbox('groupenrolmentkeypolicy', new lang_string('groupenrolmentkeypolicy', 'admin'), new lang_string('groupenrolmentkeypolicy_desc', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('disableuserimages', new lang_string('disableuserimages', 'admin'), new lang_string('configdisableuserimages', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', new lang_string('emailchangeconfirmation', 'admin'), new lang_string('configemailchangeconfirmation', 'admin'), 1));
|
||||
@@ -108,8 +88,10 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// "notifications" settingpage
|
||||
$temp = new admin_settingpage('notifications', new lang_string('notifications', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('displayloginfailures', new lang_string('displayloginfailures', 'admin'),
|
||||
new lang_string('configdisplayloginfailures', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configselect('displayloginfailures', new lang_string('displayloginfailures', 'admin'), new lang_string('configdisplayloginfailures', 'admin'), '', array('' => new lang_string('nobody'),
|
||||
'admin' => new lang_string('administrators'),
|
||||
'teacher' => new lang_string('administratorsandteachers'),
|
||||
'everybody' => new lang_string('everybody'))));
|
||||
$temp->add(new admin_setting_users_with_capability('notifyloginfailures', new lang_string('notifyloginfailures', 'admin'), new lang_string('confignotifyloginfailures', 'admin'), array(), 'moodle/site:config'));
|
||||
$options = array();
|
||||
for ($i = 1; $i <= 100; $i++) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user