Commit | Line | Data |
---|---|---|
4bcd4c62 TO |
1 | <?php |
2 | /** | |
3 | * @file | |
4 | * | |
5 | * Configure settings on the newly populated database. | |
6 | */ | |
7 | ||
8 | if (!defined('CIVI_SETUP')) { | |
9 | exit("Installation plugins must only be loaded by the installer.\n"); | |
10 | } | |
11 | ||
12 | \Civi\Setup::dispatcher() | |
13 | ->addListener('civi.setup.installDatabase', function (\Civi\Setup\Event\InstallDatabaseEvent $e) { | |
14 | if ($e->getModel()->cms !== 'Backdrop') { | |
15 | return; | |
16 | } | |
17 | \Civi\Setup::log()->info(sprintf('[%s] Flush CMS metadata', basename(__FILE__))); | |
18 | ||
19 | system_rebuild_module_data(); | |
20 | module_enable(array('civicrm', 'civicrmtheme')); | |
21 | backdrop_flush_all_caches(); | |
22 | civicrm_install_set_backdrop_perms(); | |
23 | }, \Civi\Setup::PRIORITY_LATE + 50); | |
24 | ||
25 | function civicrm_install_set_backdrop_perms() { | |
26 | $perms = array( | |
27 | 'access all custom data', | |
28 | 'access uploaded files', | |
29 | 'make online contributions', | |
30 | 'profile create', | |
31 | 'profile edit', | |
32 | 'profile view', | |
33 | 'register for events', | |
34 | 'view event info', | |
35 | 'view event participants', | |
36 | 'access CiviMail subscribe/unsubscribe pages', | |
37 | ); | |
38 | ||
39 | // Adding a permission that has not yet been assigned to a module by | |
40 | // a hook_permission implementation results in a database error. | |
41 | // CRM-9042 | |
42 | $allPerms = array_keys(module_invoke_all('permission')); | |
43 | foreach (array_diff($perms, $allPerms) as $perm) { | |
44 | watchdog('civicrm', | |
45 | 'Cannot grant the %perm permission because it does not yet exist.', | |
46 | array('%perm' => $perm), | |
47 | WATCHDOG_ERROR | |
48 | ); | |
49 | } | |
50 | $perms = array_intersect($perms, $allPerms); | |
51 | user_role_grant_permissions(BACKDROP_AUTHENTICATED_ROLE, $perms); | |
52 | user_role_grant_permissions(BACKDROP_ANONYMOUS_ROLE, $perms); | |
53 | } |