-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathverify.provision.inc
136 lines (114 loc) · 3.77 KB
/
verify.provision.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* @file
*
* CiviCRM support module for the Aegir backend.
*
* This file contains the verify operations.
*/
/**
* Implements hook_pre_provision_verify().
*
* Keep old values of paths/url so that we can later search and replace
* in the civicrm_domain table
*/
function drush_provision_civicrm_pre_provision_verify($url = NULL) {
if (_provision_civicrm_is_site_context()) {
$drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT');
drush_set_option('civicrm_old_path', $drupalRoot);
$baseUrl = 'http://' . drush_get_option('uri', false);
drush_set_option('civicrm_old_baseurl', $baseUrl);
}
}
/**
* Implements hook_provision_verify().
*/
function drush_provision_civicrm_provision_verify($url = NULL) {
if (! _provision_civicrm_is_site_context()) {
return;
}
drush_log(dt("CiviCRM: Running drush_civicrm_provision_verify"));
// This needs to be done before we initialize CiviCRM,
// otherwise we will load with an old include path (civicrm_root).
_provision_civicrm_regenerate_settings();
// Most importantly, get rid of the Config.IDS.ini
_provision_civicrm_fixpermissions();
// Enabling the upgrade mode (if necessary) will avoid pesky issues
// during the Drupal upgrade.
_provision_civicrm_check_upgrade_mode();
drush_log(dt("CiviCRM: Finished drush_civicrm_provision_verify"));
}
/**
* Implements hook_post_provision_verify().
*
* Persist civicrm settings in the drushrc.php
*/
function drush_provision_civicrm_post_provision_verify($url = NULL) {
if (! _provision_civicrm_is_site_context(TRUE)) {
return;
}
drush_include_engine('drupal', 'environment');
$modules = drush_get_modules();
if (! $modules['civicrm']->status) {
drush_log(dt("CiviCRM: not enabled. Skipping verify operations for CiviCRM. You will need to re-verify the site if you enable CiviCRM in the future."));
return;
}
_civicrm_init();
_provision_civicrm_check_upgrade_mode();
// verify might return fail if, for example, this is a very old version of CiviCRM
// in which case, no point continuing with the upgrade and cache clear.
if (provision_civicrm_verify_common()) {
// Run the CiviCRM upgrade procedure
_provision_civicrm_upgradedb();
drush_log(dt("CiviCRM: calling cache clear"));
if (function_exists('drush_civicrm_cacheclear')) {
// CiviCRM >= 4.2
drush_civicrm_cacheclear();
}
elseif (function_exists('civicrm_cache_clear')) {
// CiviCRM < 4.2
civicrm_cache_clear();
}
else {
drush_log(dt("CiviCRM: Could not find the function to flush the cache. What version of CiviCRM are you using?"), 'warning');
}
drush_log(dt("CiviCRM: cache clear finished"));
}
}
/**
* Implements hook_provision_apache_vhost_config().
*
* Inject a "deny" statement in the Apache vhost on the files/civicrm
* directory, in order to restrict access to uploaded files, templates,
* logs, etc.
*
* If you have custom CSS or JS to include, you should do that
* from a Drupal module.
*/
function provision_civicrm_provision_apache_vhost_config($data = null) {
if (! _provision_civicrm_is_site_context()) {
return;
}
$cividir = d()->site_path . '/files/civicrm';
$contribdir = $cividir . '/persist/contribute';
$customdir = $cividir . '/custom';
$dynamicdir = $cividir . '/dynamic';
$htaccess =
"<Directory \"$cividir\">\n"
. " Order allow,deny\n"
. " Deny from all\n"
. "</Directory>\n"
. "<Directory \"$contribdir\">\n"
. " Order allow,deny\n"
. " Allow from all\n"
. "</Directory>\n"
. "<Directory \"$customdir\">\n"
. " Order allow,deny\n"
. " Allow from all\n"
. "</Directory>\n"
. "<Directory \"$dynamicdir\">\n"
. " Order allow,deny\n"
. " Allow from all\n"
. "</Directory>\n";
return $htaccess;
}