function gravatar_requirements in Gravatar integration 7
Same name and namespace in other branches
- 5 gravatar.install \gravatar_requirements()
- 6 gravatar.install \gravatar_requirements()
Implementation of hook_requirements().
1 call to gravatar_requirements()
File
- ./
gravatar.install, line 39 - Install and uninstall schema and functions for the gravatar module.
Code
function gravatar_requirements($phase) {
$requirements = array();
$notifications = array();
if ($phase == 'runtime') {
// Warn if picture support is disabled.
if (!variable_get('user_pictures', 0)) {
$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/config/people/settings', array(
'fragment' => 'edit-user-pictures-0-wrapper',
)),
));
}
// Warn if no user roles have access to the 'user gravatar' permission.
$user_roles = user_roles(FALSE, 'use gravatar');
if (empty($user_roles)) {
$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/people/permissions', array(
'fragment' => 'module-gravatar',
)),
));
}
// Warn if user pictures are not enabled in the theme.
// @todo Stupid theme_get_settings generates errors on status report page.
$default_theme = variable_get('theme_default', 'garland');
if (!theme_get_setting('toggle_comment_user_picture', $theme = NULL) && !theme_get_setting('toggle_node_user_picture', $theme = NULL)) {
$notifications[] = t('Make sure user pictures are enabled in your <a href="@theme-settings">theme</a> settings.', array(
'@theme-settings' => url('admin/appearance/settings/' . $default_theme),
));
}
$global_default_image = variable_get('user_picture_default', '');
if (!$global_default_image) {
if (gravatar_var('default') == GRAVATAR_DEFAULT_GLOBAL) {
// Warn if global default user picture is empty and used for default gravatar image.
$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/config/people/settings', array(
'fragment' => 'edit-user-picture-default',
)),
));
}
}
else {
// Warn if the global default user image exceeds the user picture dimensions.
$info = function_exists('getimagesize') ? @getimagesize($global_default_image) : array();
$dimensions = explode('x', variable_get('user_picture_dimensions', '85x85'));
if ($info && ($info[0] > $dimensions[0] || $info[1] > $dimensions[1])) {
// @todo Create link to automatically resize image?
$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/config/people/settings', array(
'fragment' => 'edit-user-picture-default',
)),
'@size' => implode('x', $dimensions),
));
}
}
}
if (!empty($notifications)) {
$requirements['gravatar'] = array(
'title' => t('Gravatar'),
'value' => t('Potential issues'),
'description' => theme('item_list', array(
'items' => $notifications,
)),
'severity' => REQUIREMENT_WARNING,
);
}
return $requirements;
}