You are here

function linkit_update_7303 in Linkit 7.3

Fixed 7302. Set URL type to "Entity view page" to preserve current behavior.

File

./linkit.install, line 231
Install, update and uninstall functions for the Linkit module.

Code

function linkit_update_7303() {
  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'linkit') . '/plugins/linkit_search/file.class.php';
  $profiles = linkit_profile_load_all();
  $show_notice = FALSE;
  foreach ($profiles as $profile) {

    // If the broken 7302 has been applied, and no other changes has been made, there is not way to get the data back.
    // Lets add the default settings instead.
    if (isset($profile->data['entity:file']) && $profile->data['entity:file'] == LINKIT_FILE_URL_TYPE_ENTITY) {
      $profile->data['entity:file'] = array(
        'result_description' => '',
        'bundles' => array(
          'image' => 0,
          'video' => 0,
          'audio' => 0,
          'document' => 0,
        ),
        'group_by_bundle' => 0,
        'show_scheme' => 0,
        'group_by_scheme' => 0,
        'url_type' => 'entity',
        'image_extra_info' => array(
          'thumbnail' => 'thumbnail',
          'dimensions' => 'dimensions',
        ),
      );
      ctools_export_crud_save('linkit_profiles', $profile);
      $show_notice = TRUE;
    }
    else {
      if (isset($profile->data['entity:file']) && !isset($profile->data['entity:file']['url_type'])) {
        $profile->data['entity:file']['url_type'] = LINKIT_FILE_URL_TYPE_ENTITY;
        ctools_export_crud_save('linkit_profiles', $profile);
      }
    }
    if ($show_notice) {
      return t('A previous update may have changed the settings for the "managed file" search plugin in all your linkit profiles.');
    }
  }
}