Commit 38122561 authored by Eric Bremner's avatar Eric Bremner
Browse files

FDSU-1805: Merging in Faculty/Department.

parents db02317f 2cee7e9b
......@@ -39,13 +39,13 @@ function uw_virtual_site_homepage_field_default_field_bases() {
'type' => 'text',
);
// Exported field_base: 'field_uw_email_homepage'
$field_bases['field_uw_email_homepage'] = array(
// Exported field_base: 'field_uw_department'
$field_bases['field_uw_department'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_email_homepage',
'field_name' => 'field_uw_department',
'foreign keys' => array(
'format' => array(
'columns' => array(
......@@ -68,13 +68,13 @@ function uw_virtual_site_homepage_field_default_field_bases() {
'type' => 'text',
);
// Exported field_base: 'field_uw_extension'
$field_bases['field_uw_extension'] = array(
// Exported field_base: 'field_uw_email_homepage'
$field_bases['field_uw_email_homepage'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_extension',
'field_name' => 'field_uw_email_homepage',
'foreign keys' => array(
'format' => array(
'columns' => array(
......@@ -97,13 +97,13 @@ function uw_virtual_site_homepage_field_default_field_bases() {
'type' => 'text',
);
// Exported field_base: 'field_uw_faculty'
$field_bases['field_uw_faculty'] = array(
// Exported field_base: 'field_uw_extension'
$field_bases['field_uw_extension'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_faculty',
'field_name' => 'field_uw_extension',
'foreign keys' => array(
'format' => array(
'columns' => array(
......@@ -154,6 +154,40 @@ function uw_virtual_site_homepage_field_default_field_bases() {
),
'translatable' => 0,
'type' => 'image',
// Exported field_base: 'field_uw_faculty_list'
$field_bases['field_uw_faculty_list'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_uw_faculty_list',
'foreign keys' => array(),
'indexes' => array(
'value' => array(
0 => 'value',
),
),
'locked' => 0,
'module' => 'list',
'settings' => array(
'allowed_values' => array(
'default' => 'University of Waterloo',
'ahs' => 'Faculty of Applied Health Sciences',
'arts' => 'Faculty of Arts',
'engineering' => 'Faculty of Engineering',
'environment' => 'Faculty of Environment',
'math' => 'Faculty of Mathematics',
'science' => 'Faculty of Science',
'cgc' => 'Conrad Grebel University College',
'ren' => 'Renison University College',
'stj' => 'St. Jerome\'s University',
'stp' => 'St. Paul\'s University College',
),
'allowed_values_function' => '',
),
'translatable' => 0,
'type' => 'list_text',
);
// Exported field_base: 'field_uw_office_hours'
......
......@@ -80,6 +80,76 @@ function uw_virtual_site_homepage_field_default_field_instances() {
),
);
// Exported field_instance: 'node-uw_virtual_site_homepage-field_uw_department'
$field_instances['node-uw_virtual_site_homepage-field_uw_department'] = array(
'bundle' => 'uw_virtual_site_homepage',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => 4,
),
'links' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'no_image_teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'sidebar_teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'slide_teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'title' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_uw_department',
'label' => 'Department/school',
'required' => 0,
'settings' => array(
'text_processing' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 6,
),
);
// Exported field_instance: 'node-uw_virtual_site_homepage-field_uw_email_homepage'
$field_instances['node-uw_virtual_site_homepage-field_uw_email_homepage'] = array(
'bundle' => 'uw_virtual_site_homepage',
......@@ -146,7 +216,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 8,
'weight' => 10,
),
);
......@@ -216,23 +286,27 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 7,
'weight' => 9,
),
);
// Exported field_instance: 'node-uw_virtual_site_homepage-field_uw_faculty'
$field_instances['node-uw_virtual_site_homepage-field_uw_faculty'] = array(
// Exported field_instance: 'node-uw_virtual_site_homepage-field_uw_faculty_list'
$field_instances['node-uw_virtual_site_homepage-field_uw_faculty_list'] = array(
'bundle' => 'uw_virtual_site_homepage',
'default_value' => NULL,
'default_value' => array(
0 => array(
'value' => 'default',
),
),
'deleted' => 0,
'description' => 'Enter your faculty or department (for example: Faculty of Environment).',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'text',
'module' => 'list',
'settings' => array(),
'type' => 'text_default',
'weight' => 2,
'type' => 'list_default',
'weight' => 3,
),
'links' => array(
'label' => 'above',
......@@ -272,21 +346,18 @@ function uw_virtual_site_homepage_field_default_field_instances() {
),
),
'entity_type' => 'node',
'field_name' => 'field_uw_faculty',
'field_name' => 'field_uw_faculty_list',
'label' => 'Faculty',
'required' => 0,
'settings' => array(
'text_processing' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 4,
'module' => 'options',
'settings' => array(),
'type' => 'options_select',
'weight' => 5,
),
);
......@@ -456,7 +527,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'rows' => 5,
),
'type' => 'text_textarea',
'weight' => 9,
'weight' => 11,
),
);
......@@ -526,7 +597,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 5,
'weight' => 7,
),
);
......@@ -596,7 +667,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 6,
'weight' => 8,
),
);
......@@ -857,7 +928,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 3,
'weight' => 12,
),
'links' => array(
'label' => 'above',
......@@ -930,6 +1001,7 @@ function uw_virtual_site_homepage_field_default_field_instances() {
'module' => 'og',
'settings' => array(),
'type' => 'og_complex',
<<<<<<< HEAD
'weight' => 10,
),
);
......@@ -1008,11 +1080,11 @@ function uw_virtual_site_homepage_field_default_field_instances() {
// Translatables
// Included for use with string extractors like potx.
t('Credentials');
t('Department/school');
t('Email');
t('Enter the location of your office (for example: NH 101).');
t('Enter your credentials. This will appear under the site title at the top of every page (for example: PhD Computer Science). Leave blank if not to be displayed.');
t('Enter your email address (for example: john.doe@uwaterloo.ca).');
t('Enter your faculty or department (for example: Faculty of Environment).');
t('Enter your office hours (for example: Mondays, Wednesday and Fridays 10:30 am to 11:45 am).');
t('Enter your phone extension (for example: 45555).');
t('Enter your phone number (for example: 519-888-4567).');
......@@ -1021,7 +1093,6 @@ function uw_virtual_site_homepage_field_default_field_instances() {
t('Groups audience');
t('Homepage banners');
t('Images should be 360 pixels by 480 pixels.');
t('OG vocabulary');
t('Office hours');
t('Office location');
t('Phone number');
......
......@@ -12,6 +12,7 @@ dependencies[] = menu
dependencies[] = node
dependencies[] = og
dependencies[] = og_vocab
dependencies[] = options
dependencies[] = os_app_base
dependencies[] = spaces
dependencies[] = strongarm
......@@ -22,10 +23,11 @@ features[ctools][] = strongarm:strongarm:1
features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[field_base][] = field_uw_credentials
features[field_base][] = field_uw_department
features[field_base][] = field_uw_email_homepage
features[field_base][] = field_uw_extension
features[field_base][] = field_uw_faculty
features[field_base][] = field_uw_home_page_banners
features[field_base][] = field_uw_faculty_list
features[field_base][] = field_uw_office_hours
features[field_base][] = field_uw_office_location
features[field_base][] = field_uw_phone_number
......@@ -37,6 +39,10 @@ features[field_instance][] = node-uw_virtual_site_homepage-field_uw_email_homepa
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_extension
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_faculty
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_home_page_banners
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_department
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_email_homepage
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_extension
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_faculty_list
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_office_hours
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_office_location
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_phone_number
......@@ -44,7 +50,6 @@ features[field_instance][] = node-uw_virtual_site_homepage-field_uw_profile_imag
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_site_description
features[field_instance][] = node-uw_virtual_site_homepage-field_uw_theme_settings
features[field_instance][] = node-uw_virtual_site_homepage-og_group_ref
features[field_instance][] = node-uw_virtual_site_homepage-og_vocabulary
features[node][] = uw_virtual_site_homepage
features[user_permission][] = create uw_virtual_site_homepage content
features[user_permission][] = delete any uw_virtual_site_homepage content
......
......@@ -46,11 +46,11 @@ function uw_virtual_site_homepage_update_7100() {
$old_names = array(
'field_faculty',
'field_office_location',
'field_phone_number',
'field_extension',
'field_email_homepage',
'field_office_hours',
'field_office_location',
'field_phone_number',
'field_extension',
'field_email_homepage',
'field_office_hours',
'field_profile_image',
'body',
);
......@@ -194,6 +194,126 @@ function uw_virtual_site_homepage_update_7100() {
features_revert_module('uw_virtual_site_homepage');
}
/**
* Implements hook_update_N().
* Convert the value from field_uw_faculty to field_uw_faculty_list.
* Remove field_uw_faculty field.
*/
function uw_virtual_site_homepage_update_7101() {
// Revert fields
features_revert(array('uw_virtual_site_homepage' => array('field_base', 'field_instance')));
// Convert the value from field_data_field_uw_faculty table to field_data_field_uw_faculty_list table.
if (db_table_exists('field_data_field_uw_faculty') && db_table_exists('field_data_field_uw_faculty_list')) {
$result = db_select('field_data_field_uw_faculty', 'f')
->fields('f')
->condition('bundle', 'uw_virtual_site_homepage', '=')
->execute()
->fetchAll();
foreach ($result as $item) {
$faculty_value = _get_faculty_list_value($item->field_uw_faculty_value);
$data = array(
'entity_type' => 'node',
'bundle' => 'uw_virtual_site_homepage',
'deleted' => 0,
'entity_id' => $item->entity_id,
'revision_id' => $item->revision_id,
'language' => 'und',
'delta' => 0,
'field_uw_faculty_list_value' => $faculty_value,
);
drupal_write_record('field_data_field_uw_faculty_list', $data);
}
}
// Convert the value from field_revision_field_uw_faculty to field_revision_field_uw_faculty_list.
if (db_table_exists('field_revision_field_uw_faculty') && db_table_exists('field_revision_field_uw_faculty_list')) {
$result2 = db_select('field_revision_field_uw_faculty', 'f')
->fields('f')
->condition('bundle', 'uw_virtual_site_homepage', '=')
->execute()
->fetchAll();
foreach ($result2 as $item2) {
$faculty_value2 = _get_faculty_list_value($item2->field_uw_faculty_value);
$data2 = array(
'entity_type' => 'node',
'bundle' => 'uw_virtual_site_homepage',
'deleted' => 0,
'entity_id' => $item2->entity_id,
'revision_id' => $item2->revision_id,
'language' => 'und',
'delta' => 0,
'field_uw_faculty_list_value' => $faculty_value2,
);
drupal_write_record('field_revision_field_uw_faculty_list', $data2);
}
}
drupal_set_message(t("Converted the value from the old faculty field to the new faculty field for the existing hompage setting node."));
// Delete or remove field_uw_faculty field from uw_virtual_site_homepage content type.
$field_uw_faculty = field_info_instance('node', 'field_uw_faculty', 'uw_virtual_site_homepage');
if (!empty($field_uw_faculty)) {
field_delete_field('field_uw_faculty');
drupal_set_message(t('field_uw_faculty field has been successfully removed.'), 'status');
}
}
/**
* Helper function to get the value from field_uw_faculty
*/
function _get_faculty_list_value($field_uw_faculty) {
$faculty_name = strtolower($field_uw_faculty);
if (strpos($faculty_name, 'university of waterloo') !== FALSE) {
$faculty_list_value = 'default';
}
if (strpos($faculty_name, 'faculty of applied health sciences') !== FALSE) {
$faculty_list_value = 'ahs';
}
if (strpos($faculty_name, 'faculty of arts') !== FALSE || strpos($faculty_name, 'arts') !== FALSE) {
$faculty_list_value = 'arts';
}
if (strpos($faculty_name, 'faculty of engineering') !== FALSE || strpos($faculty_name, 'engineering') !== FALSE) {
$faculty_list_value = 'engineering';
}
if (strpos($faculty_name, 'faculty of environment') !== FALSE) {
$faculty_list_value = 'environment';
}
if (strpos($faculty_name, 'faculty of mathematics') !== FALSE || strpos($faculty_name, 'mathematics') !== FALSE) {
$faculty_list_value = 'math';
}
if (strpos($faculty_name, 'faculty of science') !== FALSE) {
$faculty_list_value = 'science';
}
if (strpos($faculty_name, 'conrad grebel university college') !== FALSE) {
$faculty_list_value = 'cgc';
}
if (strpos($faculty_name, 'renison university college') !== FALSE) {
$faculty_list_value = 'ren';
}
if (strpos($faculty_name, 'st. jerome') !== FALSE) {
$faculty_list_value = 'stj';
}
if (strpos($faculty_name, 'st. paul') !== FALSE) {
$faculty_list_value = 'stp';
}
return $faculty_list_value;
}
/**
* Helper function to get the new field information
*/
......
Supports Markdown
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