You are here

function imagecache_profiles_update_6000 in ImageCache Profiles 7

Same name and namespace in other branches
  1. 6 imagecache_profiles.install \imagecache_profiles_update_6000()

Implements hook_update_N().

Views support patch includes changes stored variables from the name of the imagecache preset to its numerical value. This function converts variables from preset names to their preset id.

File

./imagecache_profiles.install, line 9

Code

function imagecache_profiles_update_6000() {
  $ret = array();
  $variables = array(
    'user_picture_imagecache_profiles',
    'user_picture_imagecache_comments',
    'user_picture_imagecache_profiles_default',
  );
  foreach ($variables as $var) {
    $value = variable_get($var, '');
    if ($value && !is_numeric($value)) {
      $preset = imagecache_preset_by_name($value);
      if ($preset['presetid']) {
        variable_set($var, $preset['presetid']);
        $ret[] = array(
          'success' => TRUE,
          'query' => t('%var updated from %value to %presetid', array(
            '%var' => $var,
            '%value' => $value,
            '%presetid' => $preset['presetid'],
          )),
        );
      }
      else {
        $ret[] = array(
          'success' => FALSE,
          'query' => t('%var not updated: no imagecache preset could be found for %value. <a href="@settings_page"> Update your profile picture presets manually </a>', array(
            '%var' => $var,
            '%value' => $value,
            '@settings_page' => url('admin/user/settings'),
          )),
        );
      }
    }
  }
  return $ret;
}