Commit aa73a5fb authored by Andrey Postnikov's avatar Andrey Postnikov
Browse files

Split hook_form_alter() into 2 functions. Code-style fixes.

parent 24c06849
Loading
Loading
Loading
Loading
+77 −56
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
// ; $Id$

/**
 * Implementation of hook_help().
 * Implements hook_help().
 */
function imagecache_profiles_help($path, $arg) {
  switch($path) {
@@ -12,8 +12,9 @@ function imagecache_profiles_help($path, $arg) {
}

/**
 * Override process variables for user-picture.tpl.php
 * originally built by template_preprocess_user_picture()
 * Overrides process variables for user-picture.tpl.php
 *
 * Originally variables are built by template_preprocess_user_picture()
 * locate in core user.module.
 *
 * The $variables array contains the following arguments:
@@ -84,15 +85,9 @@ function imagecache_profiles_preprocess_user_picture(&$variables) {
}

/**
 * Implementation of hook_form_alter().
 * Implements hook_form_FORM_ID_alter().
 */
function imagecache_profiles_form_alter(&$form, $form_state, $form_id) {
  switch($form_id) {
    case 'user_profile_form':
      $form['#validate'][] = 'imagecache_profiles_user_profile_form_validate';
      break;

    case 'user_admin_settings':
function imagecache_profiles_form_user_admin_settings_alter(&$form, $form_state) {
  // Load imagecache presets
  $presets = array();
  $presets[] = '';
@@ -139,12 +134,35 @@ function imagecache_profiles_form_alter(&$form, $form_state, $form_id) {
    '#description' => t('Minimum height dimension for picture, in pixels. To prevent upscaling this value should be set to your maximum imagecache preset height.'),
    '#size' => 10,
  );
}

      break;
/**
 * Implements hook_form_FORM_ID_alter().
 *
 * @see imagecache_profiles_user_profile_form_validate()
 */
function imagecache_profiles_form_user_profile_form_alter(&$form, $form_state) {
  $width = variable_get('user_picture_imagecache_profiles_min_width', '');
  $height = variable_get('user_picture_imagecache_profiles_min_height', '');
  $description = '';
  if (!empty($width)) {
    if (!empty($height)) {
      $description = t('Minimum dimensions are %dimensions.', array('%dimensions' => $width . 'x' . $height));
    }
    else {
      $description = t('Minimum width is %width.', array('%width' => $width));
    }
  }
  else {
    $description = t('Minimum height is %height.', array('%height' => $height));
  }
  if (!empty($description)) {
    $form['picture']['picture_upload']['#description'] .= ' ' . $description;
  }
  $form['#validate'][] = 'imagecache_profiles_user_profile_form_validate';
}

/*
/**
 * Custom form validation callback.
 *
 * @todo: Investigage validate $op of hook_user()
@@ -160,8 +178,8 @@ function imagecache_profiles_user_profile_form_validate($form, &$form_state) {
  }
}

/*
 * Implements hook_user()
/**
 * Implements hook_user().
 *
 * Flush imagecache picture if user is updating their
 * account picture.
@@ -180,6 +198,9 @@ function imagecache_profiles_user($op, &$edit, &$account, $category = NULL) {
  }
}

/**
 * Implements hook_views_api().
 */
function imagecache_profiles_views_api() {
  return array(
    'api' => 2,