materio title access
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
761ffba48d
commit
b750ae41c4
29
materio_title_access.info
Normal file
29
materio_title_access.info
Normal file
@ -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
|
36
materio_title_access.module
Normal file
36
materio_title_access.module
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_permission().
|
||||||
|
*/
|
||||||
|
function materio_title_access_permission() {
|
||||||
|
$perms = array();
|
||||||
|
$entity_infos = entity_get_info();
|
||||||
|
foreach ($entity_infos['node']['bundles'] as $bundle => $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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user