Index: imagecache.api.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.api.php,v retrieving revision 1.2 diff -u -p -r1.2 imagecache.api.php --- imagecache.api.php 17 Feb 2009 21:36:18 -0000 1.2 +++ imagecache.api.php 2 Oct 2009 21:13:13 -0000 @@ -40,15 +40,17 @@ function hook_imagecache_actions() { * @return array * An array of imagecache preset definitions. Each definition can be * generated by exporting a preset from the database. Each preset - * definition should be keyed on its presetname (for easier interaction + * definition should be keyed on its presetnamespace (for easier interaction * with drupal_alter) and have the following attributes: - * "presetname": the imagecache preset name. Required. + * "presetnamespace": the imagecache preset name. Required. + * "presetname": the human readable name. * "actions": an array of action defintions for this preset. Required. */ function hook_imagecache_default_presets() { $presets = array(); $presets['thumbnail'] = array ( - 'presetname' => 'thumbnail', + 'presetnamespace' => 'thumbnail', + 'presetname' => 'Thumbnail (60x60 px)', 'actions' => array ( 0 => array ( 'weight' => '0', Index: imagecache.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.install,v retrieving revision 1.27 diff -u -p -r1.27 imagecache.install --- imagecache.install 1 May 2009 15:02:29 -0000 1.27 +++ imagecache.install 2 Oct 2009 21:13:16 -0000 @@ -55,7 +55,13 @@ function imagecache_schema() { 'not null' => TRUE, ), 'presetname' => array( - 'description' => t('The primary identifier for a node.'), + 'description' => t('The human readable name for an imagecache_preset.'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + ), + 'presetnamespace' => array( + 'description' => t('The namespace for an imagecache_preset.'), 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, @@ -321,3 +327,24 @@ function imagecache_update_6001() { db_change_field($ret, 'imagecache_action', 'weight', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); return $ret; } + + +/** + * Renamen column 'presetname' to 'presetnamespace' and add new column 'presetname'. + */ +function imagecache_update_6002() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {imagecache_preset} CHANGE presetname presetnamespace VARCHAR(255) NOT NULL DEFAULT ''"); + $ret[] = update_sql("ALTER TABLE {imagecache_preset} ADD COLUMN presetname varchar(255) NOT NULL DEFAULT '' AFTER presetid"); + break; + + case 'pgsql': + $ret[] = update_sql('ALTER TABLE {imagecache_preset} RENAME COLUMN presetname TO presetnamespace'); + $ret[] = update_sql("ALTER TABLE {imagecache_preset} ADD COLUMN presetname varchar(255) NOT NULL DEFAULT ''"); + break; + } + return $ret; +} Index: imagecache.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.module,v retrieving revision 1.112 diff -u -p -r1.112 imagecache.module --- imagecache.module 7 May 2009 15:15:04 -0000 1.112 +++ imagecache.module 2 Oct 2009 21:13:19 -0000 @@ -56,7 +56,7 @@ define('IMAGECACHE_STORAGE_OVERRIDE', 2) function imagecache_perm() { $perms = array('administer imagecache', 'flush imagecache'); foreach (imagecache_presets() as $preset) { - $perms[] = 'view imagecache '. $preset['presetname']; + $perms[] = 'view imagecache '. $preset['presetnamespace']; } return $perms; } @@ -145,23 +145,23 @@ function imagecache_theme() { ); foreach (imagecache_presets() as $preset) { - $theme['imagecache_formatter_'. $preset['presetname'] .'_default'] = array( + $theme['imagecache_formatter_'. $preset['presetnamespace'] .'_default'] = array( 'arguments' => array('element' => NULL), 'function' => 'theme_imagecache_formatter_default', ); - $theme['imagecache_formatter_'. $preset['presetname'] .'_linked'] = array( + $theme['imagecache_formatter_'. $preset['presetnamespace'] .'_linked'] = array( 'arguments' => array('element' => NULL), 'function' => 'theme_imagecache_formatter_linked', ); - $theme['imagecache_formatter_'. $preset['presetname'] .'_imagelink'] = array( + $theme['imagecache_formatter_'. $preset['presetnamespace'] .'_imagelink'] = array( 'arguments' => array('element' => NULL), 'function' => 'theme_imagecache_formatter_imagelink', ); - $theme['imagecache_formatter_'. $preset['presetname'] .'_path'] = array( + $theme['imagecache_formatter_'. $preset['presetnamespace'] .'_path'] = array( 'arguments' => array('element' => NULL), 'function' => 'theme_imagecache_formatter_path', ); - $theme['imagecache_formatter_'. $preset['presetname'] .'_url'] = array( + $theme['imagecache_formatter_'. $preset['presetnamespace'] .'_url'] = array( 'arguments' => array('element' => NULL), 'function' => 'theme_imagecache_formatter_url', ); @@ -301,7 +301,7 @@ function imagecache_action_definition($a * This code is very similar to the Drupal core function file_create_url(), but * handles the case of Clean URLs and public downloads differently however. * - * @param $presetname + * @param $presetnamespace * @param $filepath * String specifying the path to the image file. * @param $bypass_browser_cache @@ -309,7 +309,7 @@ function imagecache_action_definition($a * the visitors browser will not be able to use a previously cached version. * This is */ -function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) { +function imagecache_create_url($presetnamespace, $filepath, $bypass_browser_cache = FALSE) { $path = _imagecache_strip_file_directory($filepath); if (module_exists('transliteration')) { $path = transliteration_get($path); @@ -318,9 +318,9 @@ function imagecache_create_url($presetna $args = array('absolute' => TRUE, 'query' => $bypass_browser_cache ? time() : $bypass_browser_cache); switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { case FILE_DOWNLOADS_PUBLIC: - return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args); + return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetnamespace .'/'. $path, $args); case FILE_DOWNLOADS_PRIVATE: - return url('system/files/imagecache/'. $presetname .'/'. $path, $args); + return url('system/files/imagecache/'. $presetnamespace .'/'. $path, $args); } } @@ -329,9 +329,9 @@ function imagecache_create_url($presetna * of the original image at @p $path, transformed with the given @p $preset. * Keep in mind that the image might not yet exist and won't be created. */ -function imagecache_create_path($presetname, $path) { +function imagecache_create_path($presetnamespace, $path) { $path = _imagecache_strip_file_directory($path); - return file_create_path() .'/imagecache/'. $presetname .'/'. $path; + return file_create_path() .'/imagecache/'. $presetnamespace .'/'. $path; } /** @@ -383,8 +383,8 @@ function imagecache_cache_private() { /** * handle request validation and responses to imagecache requests. */ -function _imagecache_cache($presetname, $path) { - if (!$preset = imagecache_preset_by_name($presetname)) { +function _imagecache_cache($presetnamespace, $path) { + if (!$preset = imagecache_preset_by_name($presetnamespace)) { // Send a 404 if we don't know of a preset. header("HTTP/1.0 404 Not Found"); exit; @@ -392,7 +392,7 @@ function _imagecache_cache($presetname, // umm yeah deliver it early if it is there. especially useful // to prevent lock files from being created when delivering private files. - $dst = imagecache_create_path($preset['presetname'], $path); + $dst = imagecache_create_path($preset['presetnamespace'], $path); if (is_file($dst)) { imagecache_transfer($dst); } @@ -415,7 +415,7 @@ function _imagecache_cache($presetname, exit; } - $lockfile = file_directory_temp() .'/'. $preset['presetname'] . basename($src); + $lockfile = file_directory_temp() .'/'. $preset['presetnamespace'] . basename($src); if (file_exists($lockfile)) { watchdog('imagecache', 'ImageCache already generating: %dst, Lock file: %tmp.', array('%dst' => $dst, '%tmp' => $lockfile), WATCHDOG_NOTICE); // 307 Temporary Redirect, to myself. Lets hope the image is done next time around. @@ -621,7 +621,7 @@ function imagecache_file_delete($file) { /** * Implementation of hook_field_formatter_info(). * - * imagecache formatters are named as $presetname_$style + * imagecache formatters are named as $presetnamespace_$style * $style is used to determine how the preset should be rendered. * If you are implementing custom imagecache formatters please treat _ as * reserved. @@ -632,23 +632,23 @@ function imagecache_file_delete($file) { function imagecache_field_formatter_info() { $formatters = array(); foreach (imagecache_presets() as $preset) { - $formatters[$preset['presetname'] .'_default'] = array( + $formatters[$preset['presetnamespace'] .'_default'] = array( 'label' => t('@preset image', array('@preset' => $preset['presetname'])), 'field types' => array('image', 'filefield'), ); - $formatters[$preset['presetname'] .'_linked'] = array( + $formatters[$preset['presetnamespace'] .'_linked'] = array( 'label' => t('@preset image linked to node', array('@preset' => $preset['presetname'])), 'field types' => array('image', 'filefield'), ); - $formatters[$preset['presetname'] .'_imagelink'] = array( + $formatters[$preset['presetnamespace'] .'_imagelink'] = array( 'label' => t('@preset image linked to image', array('@preset' => $preset['presetname'])), 'field types' => array('image', 'filefield'), ); - $formatters[$preset['presetname'] .'_path'] = array( + $formatters[$preset['presetnamespace'] .'_path'] = array( 'label' => t('@preset file path', array('@preset' => $preset['presetname'])), 'field types' => array('image', 'filefield'), ); - $formatters[$preset['presetname'] .'_url'] = array( + $formatters[$preset['presetnamespace'] .'_url'] = array( 'label' => t('@preset URL', array('@preset' => $preset['presetname'])), 'field types' => array('image', 'filefield'), ); @@ -663,7 +663,7 @@ function theme_imagecache_formatter_defa } // Extract the preset name from the formatter name. - $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); + $presetnamespace = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); $style = 'linked'; $style = 'default'; @@ -671,8 +671,8 @@ function theme_imagecache_formatter_defa $item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : ''; $item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL; - $class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}"; - return theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title'], array('class' => $class)); + $class = "imagecache imagecache-$presetnamespace imagecache-$style imagecache-{$element['#formatter']}"; + return theme('imagecache', $presetnamespace, $item['filepath'], $item['data']['alt'], $item['data']['title'], array('class' => $class)); } function theme_imagecache_formatter_linked($element) { @@ -682,16 +682,16 @@ function theme_imagecache_formatter_link } // Extract the preset name from the formatter name. - $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); + $presetnamespace = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); $style = 'linked'; $item = $element['#item']; $item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : ''; $item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL; - $imagetag = theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title']); + $imagetag = theme('imagecache', $presetnamespace, $item['filepath'], $item['data']['alt'], $item['data']['title']); $path = empty($item['nid']) ? '' : 'node/'. $item['nid']; - $class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}"; + $class = "imagecache imagecache-$presetnamespace imagecache-$style imagecache-{$element['#formatter']}"; return l($imagetag, $path, array('attributes' => array('class' => $class), 'html' => TRUE)); } @@ -702,16 +702,16 @@ function theme_imagecache_formatter_imag } // Extract the preset name from the formatter name. - $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); + $presetnamespace = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); $style = 'imagelink'; $item = $element['#item']; $item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : ''; $item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL; - $imagetag = theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title']); + $imagetag = theme('imagecache', $presetnamespace, $item['filepath'], $item['data']['alt'], $item['data']['title']); $path = file_create_url($item['filepath']); - $class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}"; + $class = "imagecache imagecache-$presetnamespace imagecache-$style imagecache-{$element['#formatter']}"; return l($imagetag, $path, array('attributes' => array('class' => $class), 'html' => TRUE)); } @@ -722,9 +722,9 @@ function theme_imagecache_formatter_path } // Extract the preset name from the formatter name. - $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); + $presetnamespace = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); - return imagecache_create_path($presetname, $element['#item']['filepath']); + return imagecache_create_path($presetnamespace, $element['#item']['filepath']); } function theme_imagecache_formatter_url($element) { @@ -734,9 +734,9 @@ function theme_imagecache_formatter_url( } // Extract the preset name from the formatter name. - $presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); + $presetnamespace = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_')); - return imagecache_create_url($presetname, $element['#item']['filepath']); + return imagecache_create_url($presetnamespace, $element['#item']['filepath']); } /** @@ -802,8 +802,8 @@ function _imagecache_recursive_delete($p /** * Create and image tag for an imagecache derivative * - * @param $presetname - * String with the name of the preset used to generate the derivative image. + * @param $presetnamespace + * String with the namespace of the preset used to generate the derivative image. * @param $path * String path to the original image you wish to create a derivative image * tag for. @@ -821,19 +821,19 @@ function _imagecache_recursive_delete($p * @return * HTML img element string. */ -function theme_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) { +function theme_imagecache($presetnamespace, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) { // Check is_null() so people can intentionally pass an empty array of // to override the defaults completely. if (is_null($attributes)) { - $attributes = array('class' => 'imagecache imagecache-'. $presetname); + $attributes = array('class' => 'imagecache imagecache-'. $presetnamespace); } - if ($getsize && ($image = image_get_info(imagecache_create_path($presetname, $path)))) { + if ($getsize && ($image = image_get_info(imagecache_create_path($presetnamespace, $path)))) { $attributes['width'] = $image['width']; $attributes['height'] = $image['height']; } $attributes = drupal_attributes($attributes); - $imagecache_url = imagecache_create_url($presetname, $path); + $imagecache_url = imagecache_create_url($presetnamespace, $path); return ''. check_plain($alt) .''; } @@ -854,8 +854,8 @@ function theme_imagecache($presetname, $ * @return * An HTML string. */ -function theme_imagecache_imagelink($presetname, $path, $alt = '', $title = '', $attributes = NULL) { - $image = theme('imagecache', $presetname, $path, $alt, $title); +function theme_imagecache_imagelink($presetnamespace, $path, $alt = '', $title = '', $attributes = NULL) { + $image = theme('imagecache', $presetnamespace, $path, $alt, $title); $original_image_url = file_create_url($path); return l($image, $original_image_url, array('absolute' => FALSE, 'html' => TRUE)); } @@ -904,14 +904,18 @@ function imagecache_presets($reset = FAL else { $normal_presets = array(); - $result = db_query('SELECT * FROM {imagecache_preset} ORDER BY presetname'); + $result = db_query('SELECT * FROM {imagecache_preset} ORDER BY presetname, presetnamespace'); while ($preset = db_fetch_array($result)) { + if (empty($preset['presetname'])) { + // If there is no name given, use the namespace instead. + $preset['presetname'] = $preset['presetnamespace']; + } $presets[$preset['presetid']] = $preset; $presets[$preset['presetid']]['actions'] = imagecache_preset_actions($preset); $presets[$preset['presetid']]['storage'] = IMAGECACHE_STORAGE_NORMAL; // Collect normal preset names so we can skip defaults and mark overrides accordingly - $normal_presets[$preset['presetname']] = $preset['presetid']; + $normal_presets[$preset['presetnamespace']] = $preset['presetid']; } // Collect default presets and allow modules to modify them before they @@ -922,15 +926,15 @@ function imagecache_presets($reset = FAL // Add in default presets if they don't conflict with any normal presets. // Mark normal presets that take the same preset namespace as overrides. foreach ($default_presets as $preset) { - if (!empty($preset['presetname'])) { - if (!isset($normal_presets[$preset['presetname']])) { + if (!empty($preset['presetnamespace'])) { + if (!isset($normal_presets[$preset['presetnamespace']])) { $preset['storage'] = IMAGECACHE_STORAGE_DEFAULT; // Use a string preset identifier - $preset['presetid'] = $preset['presetname']; - $presets[$preset['presetname']] = $preset; + $preset['presetid'] = $preset['presetnamespace']; + $presets[$preset['presetnamespace']] = $preset; } else { - $presetid = $normal_presets[$preset['presetname']]; + $presetid = $normal_presets[$preset['presetnamespace']]; $presets[$presetid]['storage'] = IMAGECACHE_STORAGE_OVERRIDE; } } @@ -957,23 +961,23 @@ function imagecache_preset($preset_id, $ } /** - * Load a preset by name. + * Load a preset by namespace. * - * @param preset_name + * @param preset_namespace * * @return - * preset array( 'presetname' => string, 'presetid' => integer) - * empty array if preset_name is an invalid preset + * preset array( 'presetnamespace' => string, 'presetid' => integer) + * empty array if preset_namespace is an invalid preset */ -function imagecache_preset_by_name($preset_name) { +function imagecache_preset_by_name($preset_namespace) { static $presets_by_name = array(); - if (!$presets_by_name && $presets = imagecache_presets()) { + if (!$presets_by_name && $presets = imagecache_presets()) { foreach ($presets as $preset) { - $presets_by_name[$preset['presetname']] = $preset; + $presets_by_name[$preset['presetnamespace']] = $preset; } } - return (isset($presets_by_name[$preset_name])) ? $presets_by_name[$preset_name] : array(); + return (isset($presets_by_name[$preset_namespace])) ? $presets_by_name[$preset_namespace] : array(); } /** @@ -1032,7 +1036,7 @@ function imagecache_preset_actions($pres */ function imagecache_preset_flush($preset) { if (user_access('flush imagecache')) { - $presetdir = realpath(file_directory_path() .'/imagecache/'. $preset['presetname']); + $presetdir = realpath(file_directory_path() .'/imagecache/'. $preset['presetnamespace']); if (is_dir($presetdir)) { _imagecache_recursive_delete($presetdir); } @@ -1046,7 +1050,7 @@ function imagecache_preset_flush($preset */ function imagecache_image_flush($path) { foreach (imagecache_presets() as $preset) { - file_delete(imagecache_create_path($preset['presetname'], $path)); + file_delete(imagecache_create_path($preset['presetnamespace'], $path)); } } Index: imagecache_ui.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache_ui.module,v retrieving revision 1.32 diff -u -p -r1.32 imagecache_ui.module --- imagecache_ui.module 3 May 2009 16:31:43 -0000 1.32 +++ imagecache_ui.module 2 Oct 2009 21:13:20 -0000 @@ -133,7 +133,9 @@ function imagecache_ui_preset_load($pres function imagecache_preset_title_callback($title, $preset = array(), $action = array()) { $replacements = array(); if (!empty($preset)) { - $replacements['!presetname'] = $preset['presetname']; + $replacements['!presetname'] = empty($preset['presetname']) + ? $preset['presetnamespace'] + : $preset['presetname']; $replacements['!presetid'] = $preset['presetid']; } if (!empty($action) && !is_array($action)) { Index: imagecache_ui.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache_ui.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 imagecache_ui.pages.inc --- imagecache_ui.pages.inc 3 May 2009 17:27:46 -0000 1.6 +++ imagecache_ui.pages.inc 2 Oct 2009 21:13:21 -0000 @@ -115,7 +115,7 @@ function imagecache_ui_preset_export_for } $exported = '$presets = array();'; $exported .= "\n"; - $exported .= '$presets[\''. $preset['presetname'] .'\'] = '; + $exported .= '$presets[\''. $preset['presetnamespace'] .'\'] = '; $exported .= var_export($preset, TRUE) .';'; $rows = substr_count($exported, "\n") + 1; @@ -141,26 +141,28 @@ function imagecache_ui_preset_form($form // Browsers don't submit disabled form values so we've got to put two copies // of the name on the form: one for the submit handler and one for the user. if ($preset['storage'] === IMAGECACHE_STORAGE_DEFAULT) { - $form['presetname'] = array( + $form['presetnamespace'] = array( '#type' => 'value', - '#value' => $preset['presetname'], + '#value' => $preset['presetnamespace'], ); - $form['presetname_display'] = array( + $form['presetnamespace_display'] = array( '#type' => 'textfield', '#size' => '64', '#title' => t('Preset Namespace'), - '#default_value' => $preset['presetname'], + '#default_value' => $preset['presetnamespace'], '#disabled' => TRUE, + '#weight' => 0, ); } else { - $form['presetname'] = array( + $form['presetnamespace'] = array( '#type' => 'textfield', '#size' => '64', '#title' => t('Preset Namespace'), - '#default_value' => $preset['presetname'], + '#default_value' => $preset['presetnamespace'], '#description' => t('The namespace is used in URL\'s for images to tell imagecache how to process an image. Please only use alphanumeric characters, underscores (_), and hyphens (-) for preset names.'), - '#validate' => array('imagecache_element_presetname_validate' => array()), + '#validate' => array('imagecache_element_presetnamespace_validate' => array()), + '#weight' => 0, ); } @@ -175,11 +177,20 @@ function imagecache_ui_preset_form($form return $form; } + $form['presetname'] = array( + '#type' => 'textfield', + '#title' => t('Preset name'), + '#description' => t('Enter a human readable name for this preset. This name is displayed in listings of ImageCache presets.'), + '#default_value' => $preset['presetname'], + '#weight' => 1, + ); + $form['actions'] = array( '#type' => 'fieldset', '#title' => t('Actions'), '#tree' => TRUE, '#theme' => 'imagecache_ui_preset_actions', + '#weight' => 2, ); foreach ($preset['actions'] as $i => $action) { @@ -258,7 +269,7 @@ function imagecache_ui_preset_form($form file_copy($preview_path, 'imagecache_sample.png'); } imagecache_image_flush($preview_path); - $imagecache_path = imagecache_create_url($preset['presetname'], $preview_path, TRUE); + $imagecache_path = imagecache_create_url($preset['presetnamespace'], $preview_path, TRUE); $form['preview'] = array( '#type' => 'item', '#title' => t('Preview'), @@ -271,17 +282,17 @@ function imagecache_ui_preset_form($form function imagecache_ui_preset_form_validate($form, &$form_state) { $values = $form_state['values']; - // Check for duplicates + // Check for duplicate namespaces. foreach (imagecache_presets() as $preset) { - if ($values['presetname'] == $preset['presetname'] && $values['presetid'] != $preset['presetid']) { - form_set_error('presetname', t('The preset name you have chosen is already in use.')); + if ($values['presetnamespace'] == $preset['presetnamespace'] && $values['presetid'] != $preset['presetid']) { + form_set_error('presetnamespace', t('The preset name you have chosen is already in use.')); break; } } - // Check for illegal characters in preset names - if (preg_match('/[^0-9a-zA-Z_\-]/', $values['presetname'])) { - form_set_error('presetname', t('Please only use alphanumeric characters, underscores (_), and hyphens (-) for preset names.')); + // Check for illegal characters in preset namespaces. + if (preg_match('/[^0-9a-zA-Z_\-]/', $values['presetnamespace'])) { + form_set_error('presetnamespace', t('Please only use alphanumeric characters, underscores (_), and hyphens (-) for preset names.')); } }