Commit 2fb15a92 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-4980: updating update hook to convert to using brand api for site footer logos

parent e70c57b9
...@@ -299,15 +299,128 @@ function uw_virtual_site_homepage_update_7104() { ...@@ -299,15 +299,128 @@ function uw_virtual_site_homepage_update_7104() {
variable_set('uw_site_footer_api_site', 'brand'); variable_set('uw_site_footer_api_site', 'brand');
variable_set('uw_site_footer_ignore_certificates', 0); variable_set('uw_site_footer_ignore_certificates', 0);
// Get the faculty list logo field. // Update the facilty logo list field to not used previous keys
$field = field_info_field('field_uw_faculty_list_logo'); // and allowed values function.
$field_name = 'field_uw_faculty_list_logo';
$field_definition = db_query("SELECT id, data FROM field_config WHERE field_name = :field_name LIMIT 1", array(':field_name' => $field_name))->fetchAll();
$data = unserialize($field_definition[0]->data);
$data['settings']['allowed_values'] = [];
$data['settings']['allowed_values_function'] = '_uw_virtual_site_homepage_site_footer_allowed_values';
db_update('field_config')
->condition('field_name', $field_name)
->fields(['data' => serialize($data)])
->execute();
// Get the nodes that are site footers.
$nodes = node_load_multiple(array(), array('type' => 'uw_virtual_site_homepage'));
foreach ($nodes as $node) {
if (isset($node->field_uw_faculty_list_logo) && !empty($node->field_uw_faculty_list_logo)) {
$node->field_uw_faculty_list_logo = [
'und' => [
'0' => [
'value' => _uw_virtual_site_homepage_get_logo_name($node->field_uw_faculty_list_logo['und'][0]['value']),
],
],
];
node_save($node);
}
}
// Update the settings. /**
$field['settings']['allowed_values_function'] = '_uw_virtual_site_homepage_site_footer_allowed_values'; * Helper function.
$field['settings']['allowed_values'] = array(); *
* Return the name of the site footer logo, given the key.
*/
function _uw_virtual_site_homepage_get_logo_name($logo_key = NULL, $with_nids = FALSE) {
// If there is no key, return.
if (!$logo_key) {
return;
}
// The array that stores all the old information about the logos.
$logos = array(
'UWaterloo_logo' => $with_nids ? 356 : 'University of Waterloo',
'UWaterloo_Applied_Health_Sciences' => $with_nids ? 366 : 'Applied Health Sciences',
'UWaterloo_Applied_Health_Sciences_Kinesiology' => $with_nids ? 320 : 'Applied Health Sciences - Kinesiology',
'UWaterloo_Applied_Health_Sciences_PublicHealth' => $with_nids ? 319 : 'Applied Health Sciences - Public Health',
'UWaterloo_Applied_Health_Sciences_Recreation_Lesiure' => $with_nids ? 321 : 'Applied Health Sciences - Recreation and Leisure Studies',
'UWaterloo_Arts' => $with_nids ? 365 : 'Arts',
'UWaterloo_Arts_Anthropology' => $with_nids ? 322 : 'Arts - Anthropology',
'UWaterloo_Arts_Classical_Studies' => $with_nids ? 323 : 'Arts - Classical Studies',
'UWaterloo_Arts_Communication_Arts' => $with_nids ? 324 : 'Arts - Communication_Arts',
'UWaterloo_Arts_Economics' => $with_nids ? 325 : 'Arts - Economics',
'UWaterloo_Arts_English_Language_Literature' => $with_nids ? 326 : 'Arts - English Language Literature',
'UWaterloo_Arts_FineArts' => $with_nids ? 327 : 'Arts - Fine Arts',
'UWaterloo_Arts_French' => $with_nids ? 328 : 'Arts - French',
'UWaterloo_Arts_Germanic_Slavic_Studies' => $with_nids ? 330 : 'Arts - Germanic Slavic Studies',
'UWaterloo_Arts_History' => $with_nids ? 331 : 'Arts - History',
'UWaterloo_Arts_Philosophy' => $with_nids ? 344 : 'Arts - Philosophy',
'UWaterloo_Arts_Political_Science' => $with_nids ? 345 : 'Arts - Political Science',
'UWaterloo_Arts_Psychology' => $with_nids ? 346 : 'Arts - Psychology',
'UWaterloo_Arts_Religious_Studies' => $with_nids ? 348 : 'Arts - Religious Studies',
'UWaterloo_Arts_School_of_Accounting_and_Finance' => $with_nids ? 378 : 'Arts - School of Accounting and Finance',
'UWaterloo_Arts_Sociology_and_Legal_Studies' => $with_nids ? 354 : 'Arts - Sociology and Legal Studies',
'UWaterloo_Arts_Spanish_and_Latin_American_Studies' => $with_nids ? 355 : 'Arts - Spanish and Latin American Studies',
'UWaterloo_Engineering' => $with_nids ? 368 : 'Engineering',
'UWaterloo_Engineering_wordmark' => $with_nids ? 360 : 'Engineering wordmark',
'UWaterloo_Engineering_Architecture' => $with_nids ? 377 : 'Engineering - Architecture',
'UWaterloo_Engineering_Chemical_Engineering' => $with_nids ? 334 : 'Engineering - Chemical Engineering',
'UWaterloo_Engineering_Civil_Environmental_Engineering' => $with_nids ? 336 : 'Engineering - Civil Environmental Engineering',
'UWaterloo_Engineering_Electrical_Computer_Engineering' => $with_nids ? 340 : 'Engineering - Electrical Computer Engineering',
'UWaterloo_Engineering_Management_Sciences' => $with_nids ? 342 : 'Engineering - Management Sciences',
'UWaterloo_Engineering_Mechanical_Engineering' => $with_nids ? 343 : 'Engineering - Mechanical Engineering',
'UWaterloo_Engineering_Systems_Design_Engineering' => $with_nids ? 358 : 'Engineering - Systems Design Engineering',
'UWaterloo_Environment' => $with_nids ? 367 : 'Environment',
'UWaterloo_Environment_50th_Anniversary' => $with_nids ? 403 : 'Environment - 50th Anniversary',
'UWaterloo_Environment_Environment_Enterprise_Development' => $with_nids ? 376 : 'Environment - Environment Enterprise Development',
'UWaterloo_Environment_Enviromental_Resources_and_Sustainability' => $with_nids ? 375 : 'Environment - Enviromental Resources and Sustainability',
'UWaterloo_Environment_Geography_Environmental_and_Management' => $with_nids ? 329 : 'Environment - Geography Environmental and Management',
'UWaterloo_Environment_Knowledge_Intergration' => $with_nids ? 341 : 'Environment - Knowledge Intergration',
'UWaterloo_Environment_Planning' => $with_nids ? 372 : 'Environment - Planning',
'UWaterloo_Mathematics' => $with_nids ? 369 : 'Mathematics',
'UWaterloo_Math_Applied_Math' => $with_nids ? 332 : 'Mathematics - Applied Math',
'UWaterloo_Math_Combinatorics_and_Optimization' => $with_nids ? 338 : 'Mathematics - Combinatorics and Optimization',
'UWaterloo_Math_Computer_Science' => $with_nids ? 379 : 'Mathematics - Computer Science',
'UWaterloo_Math_Pure_Math' => $with_nids ? 347 : 'Mathematics - Pure Math',
'UWaterloo_Math_Statistics_Actuarial_Science' => $with_nids ? 357 : 'Mathematics - Statistics Actuarial Science',
'UWaterloo_Science' => $with_nids ? 370 : 'Science',
'UWaterloo_Science_Biology' => $with_nids ? 333 : 'Science - Biology',
'UWaterloo_Science_Chemistry' => $with_nids ? 335 : 'Science - Chemistry',
'UWaterloo_Science_Earth_and_Environmental_Science' => $with_nids ? 339 : 'Science - Earth and Environmental Science',
'UWaterloo_Science_Optometry_and_Vision_Science' => $with_nids ? 374 : 'Science - Optometry and Vision Science',
'UWaterloo_Sciecne_Pharmacy' => $with_nids ? 373 : 'Science - Pharmacy',
'UWaterloo_Science_Physics_and_Astronomy' => $with_nids ? 402 : 'Science - Physics and Astronomy',
'conrad_grebel' => $with_nids ? 389 : 'Conrad Grebel',
'renison_university_college' => $with_nids ? 391 : 'Renison University College',
'st_jeromes_university' => $with_nids ? 392 : 'St. Jerome\'s University',
'st_pauls' => $with_nids ? 393 : 'St. Paul\'s University College',
'McMaster_University' => $with_nids ? 390 : 'McMaster University',
'Print_and_Retail_Solutions' => $with_nids ? 364 : 'Print and Retail Solutions',
'Survey_Research_Centre' => $with_nids ? 394 : 'Survey Research Centre',
'Sustainable_Development_Solutions_Network_(SDSN)_Canada' => $with_nids ? 395 : 'Sustainable Development Solutions Network (SDSN) Canada',
'University_of_Guelph' => $with_nids ? 396 : 'University of Guelph',
'Waterloo_Centre_for_Microbial_Research' => $with_nids ? 398 : 'Waterloo Centre for Microbial Research',
'Waterloo_Institute_for_Complexity_and_Innovation' => $with_nids ? 399 : 'Waterloo Institute for Complexity and Innovation',
'Water_Institute' => $with_nids ? 397 : 'Water Institute',
'Western_University' => $with_nids ? 400 : 'Western University',
'Wilfrid_Laurier_University' => $with_nids ? 401 : 'Wilfrid Laurier University',
'UWaterloo_Arts_Stratford_School_Interaction_Design_Business' => $with_nids ? 371 : 'Arts - Stratford School of Interaction Design and Business',
'UWaterloo_Engineering_Conrad_School_of_Entrepreneurship_and_Business' => $with_nids ? 380 : 'Conrad School of Entrepreneurship and Business',
);
// Save the field. // If there is a logo with the key return it,
field_update_field($field); // if there is not logo simply return.
if (isset($logos[$logo_key])) {
return $logos[$logo_key];
}
else {
return;
}
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment