home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (content_permissions.module)

This example Drupal source code file (content_permissions.module) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

account, array, case, content_fields, content_permissions_field_access, edit, field, foreach, function, op, perms, php, return, view

The content_permissions.module Drupal example source code

<?php
// $Id: content_permissions.module,v 1.5.2.6 2009/07/18 00:40:21 markuspetrux Exp $

/**
 *  Implementation of hook_perm().
 */
function content_permissions_perm() {
  $perms = array();
  foreach (content_fields() as $field) {
    $perms[] = 'edit '. $field['field_name'];
    $perms[] = 'view '. $field['field_name'];
  }
  return $perms;
}

/**
 * Implementation of hook_field_access().
 *
 * @see content_access().
 */
function content_permissions_field_access($op, $field, $account, $node = NULL) {
  switch ($op) {
    case 'view':
    case 'edit':
      return user_access($op .' '. $field['field_name'], $account);
  }
  return TRUE;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal content_permissions.module source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.