/[drupal]/contributions/modules/gravatar/gravatar.install
ViewVC logotype

Contents of /contributions/modules/gravatar/gravatar.install

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


Revision 1.2 - (show annotations) (download) (as text)
Wed Jul 29 16:27:23 2009 UTC (3 months, 4 weeks ago) by davereid
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +138 -0 lines
File MIME type: text/x-php
by Dave Reid: Merged with 6.x and updated for 7.x.
1 <?php
2 // $Id: gravatar.install,v 1.1.4.18 2009/06/27 04:19:11 davereid Exp $
3
4 /**
5 * @file
6 * Install and uninstall schema and functions for the gravatar module.
7 */
8
9 /**
10 * Implementation of hook_schema().
11 */
12 function gravatar_schema() {
13 $schema['cache_gravatar'] = drupal_get_schema_unprocessed('system', 'cache');
14 $schema['cache_gravatar']['description'] = t('Cache table for the Gravatar module to store already processed and cached images.');
15
16 return $schema;
17 }
18
19 /**
20 * Implementation of hook_install().
21 */
22 function gravatar_install() {
23 drupal_install_schema('gravatar');
24 }
25
26 /**
27 * Implementation of hook_uninstall().
28 */
29 function gravatar_uninstall() {
30 // Remove tables.
31 drupal_uninstall_schema('gravatar');
32
33 // Remove variables.
34 drupal_load('module', 'gravatar');
35 $variables = array_keys(gravatar_variables());
36 foreach ($variables as $variable) {
37 variable_del($variable);
38 }
39 }
40
41 function gravatar_check_requirements() {
42 $requirements = gravatar_requirements('runtime');
43 if (!empty($requirements['gravatar'])) {
44 drupal_set_message(t('Please check the following potential issues: !issues', array('!issues' => $requirements['gravatar']['description'])), 'warning', FALSE);
45 }
46 }
47
48 /**
49 * Implementation of hook_requirements().
50 */
51 function gravatar_requirements($phase) {
52 $requirements = array();
53 $notifications = array();
54
55 if ($phase == 'runtime') {
56 // Warn if picture support is disabled.
57 if (!variable_get('user_pictures', 0)) {
58 $notifications[] = t('Make sure <a href="@user-settings-link">user picture support</a> is enabled to allow gravatar integration.', array('@user-settings-link' => url('admin/user/settings', array('fragment' => 'edit-user-pictures-0-wrapper'))));
59 }
60
61 // Warn if no user roles have access to the 'user gravatar' permission.
62 $user_roles = user_roles(FALSE, 'use gravatar');
63 if (empty($user_roles)) {
64 $notifications[] = t('There are no user roles that have the <a href="@permissions-link">%permission permission</a>.', array('%permission' => t('use gravatar'), '@permissions-link' => url('admin/user/permissions', array('fragment' => 'module-gravatar'))));
65 }
66
67 // Warn if user pictures are not enabled in the theme.
68 // @todo Stupid theme_get_settings generates errors on status report page.
69 $default_theme = variable_get('theme_default', 'garland');
70 $theme_settings = theme_get_settings($default_theme);
71 if (!$theme_settings['toggle_comment_user_picture'] && !$theme_settings['toggle_node_user_picture']) {
72 $notifications[] = t('Make sure user pictures are enabled in your <a href="@theme-settings">theme</a> settings.', array('@theme-settings' => url('admin/build/themes/settings/' . $default_theme)));
73 }
74
75 $global_default_image = variable_get('user_picture_default', '');
76 if (!$global_default_image) {
77 if (gravatar_var('default') == GRAVATAR_DEFAULT_GLOBAL) {
78 // Warn if global default user picture is empty and used for default gravatar image.
79 $notifications[] = t('You have selected the global default user picture for the default gravatar picture, but you have not specified a <a href="@user-picture-link">global default user picture</a>.', array('@user-picture-link' => url('admin/user/settings', array('fragment' => 'edit-user-picture-default'))));
80 }
81 }
82 else {
83 // Warn if the global default user image exceeds the user picture dimensions.
84 $info = function_exists('getimagesize') ? @getimagesize($global_default_image) : array();
85 $dimensions = explode('x', variable_get('user_picture_dimensions', '85x85'));
86 if ($info && ($info[0] > $dimensions[0] || $info[1] > $dimensions[1])) {
87 // @todo Create link to automatically resize image?
88 $notifications[] = t('Your <a href="@user-picture-link">global default user picture</a> is too large (@widthx@height pixels) and may not display properly. Please resize it to fit the <a href="@user-picture-settings-link">preferred user picture size</a> (@size pixels).', array('@width' => $info[0], '@height' => $info[1], '@user-picture-link' => $global_default_image, '@user-picture-settings-link' => url('admin/user/settings', array('fragment' => 'edit-user-picture-default')), '@size' => implode('x', $dimensions)));
89 }
90 }
91 }
92
93 if (!empty($notifications)) {
94 $requirements['gravatar'] = array(
95 'title' => t('Gravatar'),
96 'value' => t('Potential issues'),
97 'description' => theme('item_list', $notifications),
98 'severity' => REQUIREMENT_WARNING,
99 );
100 }
101
102 return $requirements;
103 }
104
105 /**
106 * Variable and menu cleanup.
107 */
108 function gravatar_update_6000() {
109 // Integrate gravatar_defaulttype variable into the gravatar_imagedefault variable.
110 if (variable_get('gravatar_imagedefault', 2) == 2) {
111 $value = (int) variable_get('gravatar_default_type', 4);
112 variable_set('gravatar_imagedefault', $value + 2);
113 variable_del('gravatar_default_type');
114 }
115
116 // Rename gravatar_imagerating variable to gravatar_rating.
117 if ($value = variable_get('gravatar_imagerating', FALSE)) {
118 variable_set('gravatar_rating', $value);
119 variable_del('gravatar_imagerating');
120 }
121
122 // Rename gravatar_imagedefault to gravatar_default.
123 if ($value = variable_get('gravatar_imagedefault', FALSE)) {
124 variable_set('gravatar_default', $value);
125 variable_del('gravatar_imagedefault');
126 }
127
128 // Rename gravatar_displaysize to gravatar_size.
129 if ($value = variable_get('gravatar_displaysize', FALSE)) {
130 variable_set('gravatar_size', $value);
131 variable_del('gravatar_displaysize');
132 }
133
134 // Install cache table.
135 drupal_install_schema('gravatar');
136
137 return array();
138 }

  ViewVC Help
Powered by ViewVC 1.1.2