Revision 86b65fa0
Added by Andreas Kohlbecker almost 11 years ago
7.x/modules/cdm_dataportal/cdm_dataportal.install | ||
---|---|---|
127 | 127 |
* update for RELEASE 3.2.2: |
128 | 128 |
* - migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image['show'] |
129 | 129 |
* - enabling required module file |
130 |
* - enable new debug block for all dataportals |
|
130 | 131 |
*/ |
131 | 132 |
function cdm_dataportal_update_7304() { |
132 | 133 |
|
133 | 134 |
module_enable(array('file'), TRUE); |
134 | 135 |
$tasks_performed[] = 'module file enabled'; |
135 | 136 |
|
136 |
$cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT); |
|
137 |
$cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0); |
|
138 |
variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings); |
|
139 |
variable_del('cdm_dataportal_show_default_image'); |
|
140 |
$tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']'; |
|
137 |
if(!variable_get(CDM_TAXON_PROFILE_IMAGE, FALSE)){ |
|
138 |
$cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT); |
|
139 |
$cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0); |
|
140 |
variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings); |
|
141 |
variable_del('cdm_dataportal_show_default_image'); |
|
142 |
$tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']'; |
|
143 |
} |
|
144 |
|
|
145 |
$cdm_admin_role = user_role_load_by_name('CDM admin'); |
|
146 |
$admin_role = user_role_load_by_name("admin"); |
|
147 |
if(!$admin_role){ |
|
148 |
$admin_role = user_role_load_by_name("administrator"); |
|
149 |
} |
|
150 |
user_multiple_role_edit(array(1), 'add_role', $admin_role->rid); |
|
151 |
$tasks_performed[] = 'admin user (uid=1) added to role ' . $admin_role->name; |
|
152 |
|
|
153 |
// CDM web service debug block |
|
154 |
$cdm_ws_debug_block = array( |
|
155 |
'block' => array( |
|
156 |
'module' => 'cdm_api', |
|
157 |
'delta' => 'cdm_ws_debug', |
|
158 |
'theme' => NULL, |
|
159 |
'status' => 1, |
|
160 |
'weight' => -50, |
|
161 |
'region' => 'sidebar_first', |
|
162 |
'pages' => '', |
|
163 |
'cache' => -1, |
|
164 |
), |
|
165 |
'block_role' => |
|
166 |
array( |
|
167 |
array( |
|
168 |
'module' => 'cdm_api', |
|
169 |
'delta' => 'cdm_ws_debug', |
|
170 |
'rid' => $cdm_admin_role->rid |
|
171 |
), |
|
172 |
array( |
|
173 |
'module' => 'cdm_api', |
|
174 |
'delta' => 'cdm_ws_debug', |
|
175 |
'rid' => $admin_role->rid |
|
176 |
) |
|
177 |
) |
|
178 |
); |
|
179 |
// clean up existing block configuration which might be set by drupal automatically, we need to override this |
|
180 |
db_delete('block')->condition('module', 'cdm_api')->execute(); |
|
181 |
db_delete('block_role')->condition('module', 'cdm_api')->execute(); |
|
182 |
// insert |
|
183 |
$block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache')); |
|
184 |
$block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid')); |
|
185 |
|
|
186 |
$themes = system_list('theme'); |
|
187 |
foreach ($themes as $theme) { |
|
188 |
if($theme->status == "1"){ // only for enabled themes |
|
189 |
$cdm_ws_debug_block['block']['theme'] = $theme->name; |
|
190 |
$block_insert->values($cdm_ws_debug_block['block']); |
|
191 |
} |
|
192 |
} |
|
193 |
foreach($cdm_ws_debug_block['block_role'] as $block_role){ |
|
194 |
$block_role_insert->values($block_role); |
|
195 |
} |
|
196 |
$block_insert->execute(); |
|
197 |
$block_role_insert->execute(); |
|
198 |
$tasks_performed[] = 'CDM web service debug block enabled for \'CDM admin\' users in all themes'; |
|
199 |
$tasks_performed[] = _remove_variable('cdm_webservice_debug'); |
|
200 |
$tasks_performed[] = _remove_variable('cdm_webservice_isStub'); |
|
141 | 201 |
|
142 | 202 |
return join(', ',$tasks_performed); |
143 | 203 |
} |
... | ... | |
161 | 221 |
$success = TRUE; |
162 | 222 |
} |
163 | 223 |
|
164 |
return "Variable \'$old_name\' to \'$new_name\' renamed. ";
|
|
224 |
return "Variable '$old_name' to '$new_name' renamed. ";
|
|
165 | 225 |
} |
166 | 226 |
|
167 | 227 |
/** |
... | ... | |
174 | 234 |
*/ |
175 | 235 |
function _remove_variable($name) { |
176 | 236 |
variable_del($name); |
177 |
return "Variable \'$name\' removed. ";
|
|
237 |
return "Variable '$name' removed. ";
|
|
178 | 238 |
} |
179 | 239 |
|
180 | 240 |
/** |
... | ... | |
187 | 247 |
*/ |
188 | 248 |
function _create_variable($name, $value) { |
189 | 249 |
variable_set($name, $value); |
190 |
return "Variable \'$name\' created with value: \'$value\'. ";
|
|
250 |
return "Variable '$name' created with value: '$value'. ";
|
|
191 | 251 |
} |
192 | 252 |
|
193 | 253 |
/** |
Also available in: Unified diff
module update and some bugfixes for #3316 (dataportal debug box as table and as block)