Commit 06aefa51 authored by Matthias Hutterer's avatar Matthias Hutterer
Browse files

Issue #1272394 by Matthew Davidson, cwells and mhh86: Fixed invoking of field...

Issue #1272394 by Matthew Davidson, cwells and mhh86: Fixed invoking of field perm and improved code.
parent 31bb57a4
......@@ -211,15 +211,13 @@ function email_mail_page($object_type, $object_id, $field_name) {
global $user;
if (!is_numeric($object_id)) {
drupal_not_found();
return;
return MENU_NOT_FOUND;
}
//verify this is an email field
$field_info = field_info_field($field_name);
if ($field_info['type'] != 'email') {
drupal_not_found();
return;
if (!isset($field_info) || $field_info['type'] != 'email') {
return MENU_NOT_FOUND;
}
$objects = entity_load($object_type, array($object_id));
......@@ -227,16 +225,12 @@ function email_mail_page($object_type, $object_id, $field_name) {
//verify the object really exists
if (!$object) {
drupal_not_found();
return;
return MENU_NOT_FOUND;
}
//check field perm
if (module_exists('field_permissions')) {
if (!field_permissions_field_access('view', $field_info, $object_type, $object, $user)) {
drupal_not_found();
return;
}
// Check for field access.
if (!field_access('view', $field_info, $object_type, $object, $user)) {
return MENU_ACCESS_DENIED;
}
//use the first email address as receiver
......@@ -250,8 +244,7 @@ function email_mail_page($object_type, $object_id, $field_name) {
//verify that the email address is not empty
if (empty($email)) {
drupal_not_found();
return;
return MENU_NOT_FOUND;
}
$entity_info = entity_extract_ids($object_type, $object);
......@@ -264,8 +257,7 @@ function email_mail_page($object_type, $object_id, $field_name) {
}
}
if (!$found) {
drupal_not_found();
return;
return MENU_NOT_FOUND;
}
if (!flood_is_allowed('email', variable_get('email_hourly_threshold', 3))) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment