-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathcivicrm.install
177 lines (156 loc) · 4.64 KB
/
civicrm.install
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/
/**
* Enable CiviCRM.
*/
function civicrm_enable() {
db_query("UPDATE {system} SET weight = 100 WHERE name = 'civicrm'");
menu_rebuild();
menu_link_maintain('civicrm', 'delete', 'civicrm', 'CiviCRM');
$options = array(
'link_title' => 'CiviCRM',
'link_path' => 'civicrm/dashboard',
'module' => 'civicrm',
'options' => array('alter' => TRUE),
);
menu_link_save($options);
if (!civicrm_initialize()) {
$installLink = url('civicrm/setup');
$message = t('<p class="error"><strong>CiviCRM is almost ready.</strong> You must <a href="@url">configure CiviCRM</a> for it to work.</p>', [
'@url' => $installLink,
]);
backdrop_set_message($message, 'status', FALSE);
return;
}
// also invoke civicrm menu rebuild
CRM_Core_Menu::store();
}
/**
* Implements hook_install().
*/
function civicrm_install() {
$t = get_t();
$link = l($t('Administer > Appearance > Administration theme'), 'admin/appearance');
backdrop_set_message($t("CiviCRM theme configuration setting is available under !link", array('!link' => $link)));
}
/**
* Implements hook_uninstall().
*/
function civicrm_uninstall() {
require_once 'civicrm.module';
if (!civicrm_initialize()) {
return;
}
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
require_once 'CRM/Core/DAO.php';
CRM_Core_DAO::dropAllTables();
$config = config('layout.layout.civicrm_admin_default');
$config->delete();
}
function civicrm_requirements($phase) {
$requirements = array();
$t = get_t();
switch ($phase) {
case 'runtime':
if (!civicrm_initialize()) {
$installLink = url('civicrm/setup');
$requirements['civicrm'] = array(
'title' => $t("CiviCRM"),
'severity' => REQUIREMENT_ERROR,
'value' => $t('<p class="error"><strong>CiviCRM is almost ready.</strong> You must <a href="@url">configure CiviCRM</a> for it to work.</p>', [
'@url' => $installLink,
]),
);
return $requirements;
}
$vc = new CRM_Utils_VersionCheck();
$vc->initialize();
if (isset($vc->versionInfo['patch'])) {
if ($vc->versionInfo['patch']['severity'] == 'critical') {
$severity = REQUIREMENT_ERROR;
}
else {
$severity = REQUIREMENT_WARNING;
}
$value = $vc->localVersion . ': ' . $vc->versionInfo['patch']['title'];
$description = $vc->versionInfo['patch']['message'];
}
else {
$severity = REQUIREMENT_OK;
$value = $vc->localVersion;
$description = NULL;
}
$requirements['civicrm'] = array(
'title' => $t("CiviCRM"),
'severity' => $severity,
'value' => $value,
'description' => $description,
);
break;
}
return $requirements;
}
/**
* Implements hook_update_last_removed().
*/
function civicrm_update_last_removed() {
return 7401;
}
/**
* Move civicrmtheme settings from variables to config.
*/
function civicrm_update_1000() {
// Migrate variables to config.
$config = config('civicrm.settings');
$config->set('theme_admin', update_variable_get('civicrmtheme_theme_admin', 'seven'));
$config->set('theme_public', update_variable_get('civicrmtheme_theme_public', 0));
$config->save();
// Delete variables.
update_variable_del('theme_admin');
update_variable_del('theme_public');
}
/**
* Move civicrmtheme config.
*/
function civicrm_update_1001() {
// Migrate civicrmtheme config.
$config_new = config('civicrm.settings');
$config_old = config('civicrmtheme.settings');
if ($config_old->isNew()) {
return;
}
$config_new->setData($config_old->getData());
$config_new->save();
$config_old->delete();
}
/**
* Disable civicrmtheme sub-module
*/
function civicrm_update_1002() {
module_disable(array('civicrmtheme'));
}
/**
* Update the Default CiviCRM Layout.
*/
function civicrm_update_1003() {
// Should now belong to civicrm, not civicrmtheme.
$config = config('layout.layout.civicrm_admin_default');
$config->set('module', 'civicrm');
$config->save();
}