field_multiple_limit.install in Field multiple limit 7
Field multiple limit install file.
File
field_multiple_limit.installView source
<?php
/**
* @file
* Field multiple limit install file.
*/
/**
* Implements hook_uninstall().
*/
function field_multiple_limit_uninstall() {
$field_info = field_info_fields();
foreach ($field_info as $field) {
foreach ($field['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
// get the instance settings from the database
$instance = db_select('field_config_instance', 'fci')
->fields('fci', array(
'data',
))
->condition('field_name', $field['field_name'])
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->execute()
->fetchField();
$instance = unserialize($instance);
// remove the display settings provided by this module
foreach ($instance['display'] as &$display) {
if (isset($display['settings']['field_multiple_limit'])) {
unset($display['settings']['field_multiple_limit']);
}
if (isset($display['settings']['field_multiple_limit_offset'])) {
unset($display['settings']['field_multiple_limit_offset']);
}
}
// re-serialize the instance, then save back to the database
$instance = serialize($instance);
db_update('field_config_instance')
->fields(array(
'data' => $instance,
))
->condition('field_name', $field['field_name'])
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->execute();
}
}
}
field_cache_clear();
// views displays
if (db_table_exists('views_display')) {
// Getting all view displays from database.
$view_displays = db_select('views_display', 'vd')
->fields('vd')
->execute();
// Iterate all view displays and modify them.
foreach ($view_displays as $view_display) {
$vid = $view_display->vid;
$id = $view_display->id;
$display_options = unserialize($view_display->display_options);
// remove the display settings provided by this module
if (isset($display_options['fields'])) {
foreach ($display_options['fields'] as &$field) {
$settings =& $field['settings'];
if (isset($settings['field_multiple_limit'])) {
unset($settings['field_multiple_limit']);
}
if (isset($settings['field_multiple_limit_offset'])) {
unset($settings['field_multiple_limit_offset']);
}
}
}
$display_options = serialize($display_options);
// Finally we update the current view display.
db_update('views_display')
->fields(array(
'display_options' => $display_options,
))
->condition('vid', $vid)
->condition('id', $id)
->execute();
}
}
}
Functions
Name | Description |
---|---|
field_multiple_limit_uninstall | Implements hook_uninstall(). |