source: sipes/modules_contrib/field_permissions/field_permissions.module @ 6e81fb4

stableversion-3.0
Last change on this file since 6e81fb4 was 663b989, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo el modulo

  • Propiedad mode establecida a 100644
File size: 3.3 KB
Línea 
1<?php
2// $Id: field_permissions.module,v 1.1.2.9 2009/11/14 12:38:20 markuspetrux Exp $
3
4/**
5 * @file
6 * This is the main script for the Field Permissions module. It merely contains
7 * the implementation of hooks invoked by Drupal core and CCK.
8 * All common functions are externalized into several scripts that are included
9 * on demand to save memory consumption during normal site operation.
10 */
11
12/**
13 * Implementation of hook_menu().
14 */
15function field_permissions_menu() {
16  module_load_include('inc', 'field_permissions', 'includes/admin');
17  return _field_permissions_menu();
18}
19
20/**
21 * Implementation of hook_theme().
22 */
23function field_permissions_theme() {
24  return array(
25    'field_permissions_troubleshooting_form' => array('arguments' => array('form' => NULL), 'file' => 'includes/admin.inc'),
26  );
27}
28
29/**
30 * Implementation of hook_perm().
31 */
32function field_permissions_perm() {
33  module_load_include('inc', 'field_permissions', 'includes/admin');
34  return _field_permissions_perm();
35}
36
37/**
38 * Implementation of hook_field_settings_alter().
39 */
40function field_permissions_field_settings_alter(&$settings, $op, $field) {
41  if ($op == 'form' || $op == 'save') {
42    module_load_include('inc', 'field_permissions', 'includes/admin');
43    return _field_permissions_field_settings_alter($settings, $op, $field);
44  }
45}
46
47/**
48 * Implementation of hook_field_access().
49 *
50 * @param $op
51 *   The operation to be performed. Possible values:
52 *   - 'edit'
53 *   - 'view'
54 * @param $field
55 *   The field on which the operation is to be performed.
56 * @param $account
57 *   The account to check.
58 *   Note that this argument is optional to content_access(), but it is
59 *   always passed to hook_field_access(), with current user if not supplied.
60 *   This is an argument that was added to CCK in 6.x-2.2 release.
61 * @param $node
62 *   (optional) The node on which the operation is to be performed.
63 *   Note that this argument is optional to content_access(), but it is
64 *   always passed to hook_field_access(), with NULL if not supplied.
65 *   This is an argument that was added to CCK in 6.x-2.5 release.
66 *
67 * @return
68 *   FALSE if the operation is not allowed.
69 *   Note when content_access() is invoked, access is granted unless one
70 *   implementation of hook_field_access() explicitly returns FALSE.
71 *
72 * @see content_access()
73 */
74function field_permissions_field_access($op, $field, $account, $node) {
75  // Ignore the request if permissions have not been enabled for this field.
76  $field_permissions = (isset($field['field_permissions']) && is_array($field['field_permissions']) ? array_filter($field['field_permissions']) : array());
77  if (empty($field_permissions)) {
78    return;
79  }
80
81  if ($op == 'view') {
82    if (!empty($field_permissions['view']) || !empty($field_permissions['view own'])) {
83      module_load_include('inc', 'field_permissions', 'includes/field_access');
84      return _field_permissions_field_view_access($field['field_name'], $field_permissions, $account, $node);
85    }
86  }
87  elseif ($op == 'edit') {
88    if (!empty($field_permissions['edit']) || !empty($field_permissions['edit own']) || !empty($field_permissions['create'])) {
89      module_load_include('inc', 'field_permissions', 'includes/field_access');
90      return _field_permissions_field_edit_access($field['field_name'], $field_permissions, $account, $node);
91    }
92  }
93}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.