diff -urpN /Volumes/Talaria/Downloads/imagecache_profiles/imagecache_profiles.install /Volumes/Talaria/Downloads/imagecache_profiles_349331/imagecache_profiles.install --- /Volumes/Talaria/Downloads/imagecache_profiles/imagecache_profiles.install 1969-12-31 19:00:00.000000000 -0500 +++ /Volumes/Talaria/Downloads/imagecache_profiles_349331/imagecache_profiles.install 2009-03-13 07:25:46.000000000 -0400 @@ -0,0 +1,65 @@ + 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. Update your profile picture presets manually ', array( + '%var' => $var, + '%value' => $value, + '@settings_page' => url('admin/user/settings'), + )) + ); + } + } + } + + return $ret; +} + +/* + * Implementation of hook_uninstall + * + * Delete all the variables created by imagecache_profiles + */ +function imagecache_profiles_uninstall() { + $variables = array( + 'user_picture_imagecache_profiles', + 'user_picture_imagecache_comments', + 'user_picture_imagecache_profiles_default', + 'user_picture_imagecache_profiles_min_width', + 'user_picture_imagecache_profiles_min_height', + ); + + foreach ($variables as $var) { + variable_del($var); + } +} diff -urpN /Volumes/Talaria/Downloads/imagecache_profiles/imagecache_profiles.module /Volumes/Talaria/Downloads/imagecache_profiles_349331/imagecache_profiles.module --- /Volumes/Talaria/Downloads/imagecache_profiles/imagecache_profiles.module 2008-12-19 13:05:14.000000000 -0500 +++ /Volumes/Talaria/Downloads/imagecache_profiles_349331/imagecache_profiles.module 2009-03-13 07:25:34.000000000 -0400 @@ -22,9 +22,9 @@ function imagecache_profiles_help($path, * @see user-picture.tpl.php */ function imagecache_profiles_preprocess_user_picture(&$variables) { - $variables['picture'] = ''; + $default = $variables['picture']; if (variable_get('user_pictures', 0)) { - $account = $variables['account']; + $account = $variables['account']; // Determine imagecache preset to use for user profile picture // First let's determine if we have a default imagecache preset if (variable_get('user_picture_imagecache_profiles_default', 0)) { @@ -43,7 +43,12 @@ function imagecache_profiles_preprocess_ $size = variable_get('user_picture_imagecache_comments', 0); } } - + + // If views set an imagecache preset + if ($account->imagecache_preset) { + $size = $account->imagecache_preset; + } + if (!empty($account->picture) && file_exists($account->picture)) { $picture = $account->picture; } @@ -53,14 +58,15 @@ function imagecache_profiles_preprocess_ if (isset($picture)) { $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')))); - if (isset($size)) { - $variables['picture'] = theme('imagecache', $size, $picture, $alt, $alt); + $preset = imagecache_preset($size); + if (empty($preset)) { + $variables['picture'] = $default;//theme('image', $picture, $alt, $alt, '', FALSE); } else { - $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE); - } - if (!empty($account->uid) && user_access('access user profiles')) { - $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE); - $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes); + $variables['picture'] = theme('imagecache', $preset['presetname'], $picture, $alt, $alt); + if (!empty($account->uid) && user_access('access user profiles')) { + $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE); + $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes); + } } } } @@ -69,7 +75,7 @@ function imagecache_profiles_preprocess_ /** * Implementation of hook_form_alter(). */ -function imagecache_profiles_form_alter(&$form, $form_state, $form_id) { +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'; @@ -77,11 +83,10 @@ function imagecache_profiles_form_alter( case 'user_admin_settings': // Load imagecache presets - $result = db_query('SELECT presetid, presetname FROM {imagecache_preset} ORDER BY presetname'); $presets = array(); $presets[] = ''; - while ($data = db_fetch_object($result)) { - $presets[check_plain($data->presetname)] = check_plain($data->presetname); + foreach (imagecache_presets() as $key => $preset) { + $presets[$key] = check_plain($preset['presetname']); } $form['pictures']['settings']['user_picture_imagecache_profiles'] = array( @@ -159,4 +164,10 @@ function imagecache_profiles_user($op, & imagecache_image_flush($edit['picture']); } } -} \ No newline at end of file +} +function imagecache_profiles_views_api() { + return array( + 'api' => 2, + 'path' => drupal_get_path('module', 'imagecache_profiles') .'/views', + ); +} diff -urpN /Volumes/Talaria/Downloads/imagecache_profiles/views/imagecache_profiles.views.inc /Volumes/Talaria/Downloads/imagecache_profiles_349331/views/imagecache_profiles.views.inc --- /Volumes/Talaria/Downloads/imagecache_profiles/views/imagecache_profiles.views.inc 1969-12-31 19:00:00.000000000 -0500 +++ /Volumes/Talaria/Downloads/imagecache_profiles_349331/views/imagecache_profiles.views.inc 2009-08-26 02:06:11.000000000 -0400 @@ -0,0 +1,19 @@ + array( + 'path' => drupal_get_path('module', 'imagecache_profiles') .'/views', + ), + 'handlers' => array( + 'imagecache_profiles_handler_field_user_picture' => array( + 'parent' => 'views_handler_field_user_picture', + ), + ), + ); +} + +function imagecache_profiles_views_data_alter(&$data) { + $data['users']['picture']['field']['handler'] = 'imagecache_profiles_handler_field_user_picture'; +} diff -urpN /Volumes/Talaria/Downloads/imagecache_profiles/views/imagecache_profiles_handler_field_user_picture.inc /Volumes/Talaria/Downloads/imagecache_profiles_349331/views/imagecache_profiles_handler_field_user_picture.inc --- /Volumes/Talaria/Downloads/imagecache_profiles/views/imagecache_profiles_handler_field_user_picture.inc 1969-12-31 19:00:00.000000000 -0500 +++ /Volumes/Talaria/Downloads/imagecache_profiles_349331/views/imagecache_profiles_handler_field_user_picture.inc 2009-08-26 02:06:19.000000000 -0400 @@ -0,0 +1,40 @@ + ''); + foreach ($presets as $key => $preset) { + $opt[$key] = check_plain($preset['presetname']); + } + $options = $this->options; + $form['imagecache_preset'] = array( + '#title' => t('Imagecache preset'), + '#type' => 'select', + '#options' => $opt, + '#default_value' => $options['imagecache_preset'], + ); + } + + function render($values) { + // Fake an account object. + $options = $this->options; + $account = new stdClass(); + $account->uid = $values->{$this->aliases['uid']}; + $account->name = $values->{$this->aliases['name']}; + $account->picture = $values->{$this->field_alias}; + + if ($options['imagecache_preset']) { + $account->imagecache_preset = $options['imagecache_preset']; + } + + return theme('user_picture', $account); + } +} \ No newline at end of file