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) { ...@@ -211,15 +211,13 @@ function email_mail_page($object_type, $object_id, $field_name) {
global $user; global $user;
if (!is_numeric($object_id)) { if (!is_numeric($object_id)) {
drupal_not_found(); return MENU_NOT_FOUND;
return;
} }
//verify this is an email field //verify this is an email field
$field_info = field_info_field($field_name); $field_info = field_info_field($field_name);
if ($field_info['type'] != 'email') { if (!isset($field_info) || $field_info['type'] != 'email') {
drupal_not_found(); return MENU_NOT_FOUND;
return;
} }
$objects = entity_load($object_type, array($object_id)); $objects = entity_load($object_type, array($object_id));
...@@ -227,16 +225,12 @@ function email_mail_page($object_type, $object_id, $field_name) { ...@@ -227,16 +225,12 @@ function email_mail_page($object_type, $object_id, $field_name) {
//verify the object really exists //verify the object really exists
if (!$object) { if (!$object) {
drupal_not_found(); return MENU_NOT_FOUND;
return;
} }
//check field perm // Check for field access.
if (module_exists('field_permissions')) { if (!field_access('view', $field_info, $object_type, $object, $user)) {
if (!field_permissions_field_access('view', $field_info, $object_type, $object, $user)) { return MENU_ACCESS_DENIED;
drupal_not_found();
return;
}
} }
//use the first email address as receiver //use the first email address as receiver
...@@ -250,8 +244,7 @@ function email_mail_page($object_type, $object_id, $field_name) { ...@@ -250,8 +244,7 @@ function email_mail_page($object_type, $object_id, $field_name) {
//verify that the email address is not empty //verify that the email address is not empty
if (empty($email)) { if (empty($email)) {
drupal_not_found(); return MENU_NOT_FOUND;
return;
} }
$entity_info = entity_extract_ids($object_type, $object); $entity_info = entity_extract_ids($object_type, $object);
...@@ -264,8 +257,7 @@ function email_mail_page($object_type, $object_id, $field_name) { ...@@ -264,8 +257,7 @@ function email_mail_page($object_type, $object_id, $field_name) {
} }
} }
if (!$found) { if (!$found) {
drupal_not_found(); return MENU_NOT_FOUND;
return;
} }
if (!flood_is_allowed('email', variable_get('email_hourly_threshold', 3))) { 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