function theme_webform_view_messages in Webform 6.2
Same name and namespace in other branches
- 5.2 webform.module \theme_webform_view_messages()
- 6.3 webform.module \theme_webform_view_messages()
- 7.4 webform.module \theme_webform_view_messages()
- 7.3 webform.module \theme_webform_view_messages()
Display a message to a user if they are not allowed to fill out a form.
Parameters
$node: The webform node object.
$teaser: If this webform is being displayed as the teaser view of the node.
$page: If this webform node is being viewed as the main content of the page.
$submission_count: The number of submissions this user has already submitted. Not calculated for anonymous users.
$limit_exceeded: Boolean value if the submission limit for this user has been exceeded.
$allowed_roles: A list of user roles that are allowed to submit this webform.
2 theme calls to theme_webform_view_messages()
- webform_client_form_validate in ./
webform.module - webform_view in ./
webform.module - Implementation of hook_view().
File
- ./
webform.module, line 1195
Code
function theme_webform_view_messages($node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles) {
global $user;
$type = 'notice';
// If not allowed to submit the form, give an explaination.
if (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) {
if (empty($allowed_roles)) {
// No roles are allowed to submit the form.
$message = t('Submissions for this form are closed.');
}
elseif (isset($allowed_roles[2])) {
// The "authenticated user" role is allowed to submit and the user is currently logged-out.
$login = url('user/login', array(
'query' => drupal_get_destination(),
));
$register = url('user/register', array(
'query' => drupal_get_destination(),
));
if (variable_get('user_register', 1) == 0) {
$message = t('You must <a href="!login">login</a> to view this form.', array(
'!login' => $login,
));
}
else {
$message = t('You must <a href="!login">login</a> or <a href="!register">register</a> to view this form.', array(
'!login' => $login,
'!register' => $register,
));
}
}
else {
// The user must be some other role to submit.
$message = t('You do not have permission to view this form.');
}
}
elseif ($limit_exceeded) {
if ($node->webform['submit_interval'] == -1 && $node->webform['submit_limit'] > 1) {
$message = t('You have submitted this form the maximum number of times (@count).', array(
'@count' => $node->webform['submit_limit'],
));
}
elseif ($node->webform['submit_interval'] == -1 && $node->webform['submit_limit'] == 1) {
$message = t('You have already submitted this form.');
}
else {
$message = t('You may not submit another entry at this time.');
}
$type = 'error';
}
// If the user has submitted before, give them a link to their submissions.
if ($submission_count > 0) {
if (empty($message)) {
$message = t('You have already submitted this form.') . ' ' . t('<a href="!url">View your previous submissions</a>.', array(
'!url' => url('node/' . $node->nid . '/submissions'),
));
}
else {
$message .= ' ' . t('<a href="!url">View your previous submissions</a>.', array(
'!url' => url('node/' . $node->nid . '/submissions'),
));
}
}
if ($page && isset($message)) {
drupal_set_message($message, $type);
}
}