From b750ae41c4a531f36c9195d6be81129a50cab248 Mon Sep 17 00:00:00 2001 From: bachy Date: Tue, 30 Oct 2012 18:09:14 +0100 Subject: [PATCH] materio title access Signed-off-by: bachy --- materio_title_access.info | 29 +++++++++++++++++++++++++++++ materio_title_access.module | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 materio_title_access.info create mode 100644 materio_title_access.module diff --git a/materio_title_access.info b/materio_title_access.info new file mode 100644 index 00000000..7f70ddcc --- /dev/null +++ b/materio_title_access.info @@ -0,0 +1,29 @@ +name = Materio title access +description = "Materio title access" + +; Core version (required) +core = 7.x + +; Package name (see http://drupal.org/node/542202 for a list of names) +package = Materio + +; PHP version requirement (optional) +; php = 5.2 + +; Loadable code files +;files[] = materio_search_api.theme.inc +;files[] = materio_search_api.forms.inc +;files[] = materio_search_api.pages.inc +;files[] = materio_search_api.admin.inc +files[] = materio_title_access.module + +; Module dependencies +;dependencies[] = taxonomy +;dependencies[] = search_api +dependencies[] = title + +; Configuration page +; configure = admin/config/materiobasemod + +; For further information about configuration options, see +; - http://drupal.org/node/542202 diff --git a/materio_title_access.module b/materio_title_access.module new file mode 100644 index 00000000..8dfc80ce --- /dev/null +++ b/materio_title_access.module @@ -0,0 +1,36 @@ + $value) { + $perms['show '.$bundle.' title'] = array( + 'title' => t('Show !bundle node title.', array('!bundle'=>$value['label'])), + ); + } + return $perms; +} + + +/** + * Implements hook_field_access(). + */ +function materio_title_access_field_access($op, $field, $entity_type, $entity, $account) { + /* + *if ($field['field_name'] == 'field_of_interest' && $op == 'edit') { + * return user_access('edit field of interest', $account); + *} + */ + /* Your code here */ + // dsm($entity, 'entity'); + // dsm($entity_type, 'entity_type'); + + if($field['field_name'] == 'title_field' && $entity_type == 'node' && isset($entity->type)){ + return user_access('show '.$entity->type.' title'); + } + + return TRUE; +} \ No newline at end of file