/[drupal]/contributions/modules/imagecache_profiles/imagecache_profiles.module
ViewVC logotype

Diff of /contributions/modules/imagecache_profiles/imagecache_profiles.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Thu Dec 27 14:57:34 2007 UTC revision 1.1.2.1, Tue Jun 17 01:38:53 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // ; $Id: imagecache_profiles.module,v 1.3 2008/01/11 21:09:35 v1nce Exp $
3    
4  /**  /**
5  * Implementation of hook_help().  * Implementation of hook_help().
6  */  */
# Line 19  function phptemplate_user_picture($accou Line 21  function phptemplate_user_picture($accou
21    if (variable_get('user_pictures', 0)) {    if (variable_get('user_pictures', 0)) {
22      if (variable_get('user_picture_imagecache_profiles_default', 0)) {      if (variable_get('user_picture_imagecache_profiles_default', 0)) {
23        // Define default user picture size        // Define default user picture size
24        $defaultquery = db_query('SELECT presetname FROM {imagecache_preset} WHERE presetid = %s', variable_get('user_picture_imagecache_profiles_default', 0));        $defaultquery = db_query("SELECT presetname FROM {imagecache_preset} WHERE presetid = '%s'", variable_get('user_picture_imagecache_profiles_default', 0));
25        $size = db_result($defaultquery, '0');        $size = db_result($defaultquery, '0');
26      }      }
27      if (variable_get('user_picture_imagecache_profiles', 0)) {      if (variable_get('user_picture_imagecache_profiles', 0)) {
28        // If on user profile page        // If on user profile page
29        if (arg(0) == 'user' && is_numeric(arg(1))) {        if (arg(0) == 'user' && is_numeric(arg(1))) {
30          $query = db_query('SELECT presetname FROM {imagecache_preset} WHERE presetid = %s', variable_get('user_picture_imagecache_profiles', 0));          $query = db_query("SELECT presetname FROM {imagecache_preset} WHERE presetid = '%s'", variable_get('user_picture_imagecache_profiles', 0));
31          $size = db_result($query, '0');          $size = db_result($query, '0');
32        }        }
33      }      }
34        if (variable_get('user_picture_imagecache_comments', 0)) {
35          // If viewing a comment
36          if ($account->cid) {
37            $query = db_query("SELECT presetname FROM {imagecache_preset} WHERE presetid = '%s'", variable_get('user_picture_imagecache_comments', 0));
38            $size = db_result($query, '0');
39          }
40        }
41    
42      // Display the user's photo      // Display the user's photo
43        if (empty($account->picture)) {
44          $account->picture = variable_get('user_picture_default', '');
45        }
46      if ($account->picture && file_exists($account->picture)) {      if ($account->picture && file_exists($account->picture)) {
47        if (isset($size)) {        if (isset($size)) {
48          $picture = l(theme('imagecache', $size, $account->picture), 'user/'. $account->uid, array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);          if (user_access('access user profiles')) {
49        } else {            $picture = l(theme('imagecache', $size, $account->picture), 'user/'. $account->uid, array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
50          $picture = file_create_url($account->picture);          } else {
51          $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));            $picture = theme('imagecache', $size, $account->picture);
         $picture = theme('image', $picture, $alt, $alt, '', FALSE);  
         if (!empty($account->uid) && user_access('access user profiles')) {  
           $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);  
52          }          }
       }  
     }  
     elseif (variable_get('user_picture_default', '')) {  
       if (isset($size)) {  
         $picture = l(theme('imagecache', $size, $account->picture), 'user/'. $account->uid, array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);  
53        } else {        } else {
54          $picture = file_create_url($account->picture);          $picture = file_create_url($account->picture);
55          $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));          $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
56          $picture = theme('image', $picture, $alt, $alt, '', FALSE);          $picture = theme('image', $picture, $alt, $alt, '', FALSE);
57          if (!empty($account->uid) && user_access('access user profiles')) {          if (!empty($account->uid) && user_access('access user profiles')) {
58            $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);            $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
59          }          }
60        }        }
61      }      }
62      return '<div class="picture">'. $picture .'</div>';      return '<div class="picture">'. $picture .'</div>';
# Line 81  function imagecache_profiles_form_alter( Line 86  function imagecache_profiles_form_alter(
86          '#options' => $presets,          '#options' => $presets,
87          '#description' => t("This will set the picture size when viewing a user's profile page."),          '#description' => t("This will set the picture size when viewing a user's profile page."),
88        );        );
89          $form['pictures']['user_picture_imagecache_comments'] = array(
90            '#type' => 'select',
91            '#title' => t('Set the user picture size within comments with this ImageCache preset'),
92            '#default_value' => variable_get('user_picture_imagecache_comments', ''),
93            '#options' => $presets,
94            '#description' => t("This will set the picture size when viewing a comment post."),
95          );
96        $form['pictures']['user_picture_imagecache_profiles_default'] = array(        $form['pictures']['user_picture_imagecache_profiles_default'] = array(
97          '#type' => 'select',          '#type' => 'select',
98          '#title' => t('Set default user picture size with this ImageCache preset'),          '#title' => t('Set default user picture size with this ImageCache preset'),
# Line 138  function imagecache_profiles_user_admin_ Line 150  function imagecache_profiles_user_admin_
150    } else {    } else {
151      variable_del('user_picture_imagecache_profiles');      variable_del('user_picture_imagecache_profiles');
152    }    }
153      if ($form_values['user_picture_imagecache_comments'] != '0') {
154        variable_set('user_picture_imagecache_comments', check_plain($form_values['user_picture_imagecache_comments']));
155      } else {
156        variable_del('user_picture_imagecache_comments');
157      }
158    if ($form_values['user_picture_imagecache_profiles_default'] != '0') {    if ($form_values['user_picture_imagecache_profiles_default'] != '0') {
159      variable_set('user_picture_imagecache_profiles_default', check_plain($form_values['user_picture_imagecache_profiles_default']));      variable_set('user_picture_imagecache_profiles_default', check_plain($form_values['user_picture_imagecache_profiles_default']));
160    } else {    } else {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2