Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / 5.x / module_patches / cck_field_perms / cck_field_perms-views0.1.patch @ 36311992

History | View | Annotate | Download (2.8 KB)

1
### Eclipse Workspace Patch 1.0
2
#P cck_field_perms
3
Index: cck_field_perms.module
4
===================================================================
5
RCS file: /cvs/drupal-contrib/contributions/modules/cck_field_perms/cck_field_perms.module,v
6
retrieving revision 1.3.2.27
7
diff -u -r1.3.2.27 cck_field_perms.module
8
--- cck_field_perms.module        27 Aug 2007 21:25:36 -0000        1.3.2.27
9
+++ cck_field_perms.module        7 Nov 2007 18:51:24 -0000
10
@@ -81,8 +81,9 @@
11
           if ($disallowed_fields) {
12
             foreach ($disallowed_fields[$type] as $disallowed_field => $value ) {
13
               if ($value == 0) {continue; }
14
-              if (!(user_access(_cfp_content_to_readable($type, $disallowed_field, "view")))) {     
15
-                $node->$disallowed_field['#access'] = false;
16
+              if (!(user_access(_cfp_content_to_readable($type, $disallowed_field, "view")))) { 
17
+                $field_array = &$node->$disallowed_field;       
18
+                $field_array['#access'] = false;
19
                 $node->content[$disallowed_field]['#access'] = false;                   
20
               }   
21
             }
22
@@ -112,6 +113,20 @@
23
 }
24
 
25
 
26
+/**
27
+ * Implemenation of hook views_pre_view
28
+ */
29
+function cck_field_perms_views_pre_view(&$view, $items){
30
+  foreach($view->field as $idx => $field){
31
+    $field_name = substr($field['field'], 0, ( strlen($field['field']) - strlen('_value')) );
32
+    if(!cck_field_perms_access(null, $field_name, 'view')){
33
+      unset($view->field[$idx]);
34
+      unset($view->table_header[$idx]);
35
+    }
36
+  }
37
+}
38
+
39
+
40
 /* ********************************************* */
41
 /* CFP functions */
42
 /* ********************************************* */
43
@@ -237,6 +252,36 @@
44
 }
45
 
46
 
47
+function cck_field_perms_access($type, $field_name, $verb){
48
+  
49
+  global $disallowed;
50
+  if(!isset($disallowed)){
51
+    $disallowed = unserialize(variable_get('cfp_values', null));
52
+    if(!$disallowed) {
53
+      $disallowed = array();
54
+    }
55
+  }
56
+  if(!$type){
57
+    // -------------- hack for missing admin option to set permissions on fields per view
58
+    foreach($disallowed as $fields){
59
+      if( isset($fields[$field_name]) && $fields[$field_name] != 0) {
60
+        // return false if access to this field is denied for at least one content type
61
+        if(!user_access(_cfp_content_to_readable($type, $field_name, $verb))){
62
+          return false;
63
+        }
64
+      }
65
+    }
66
+    // -----------------------------------------------------------------------------------
67
+  } else {
68
+    if( isset($disallowed[$type][$field_name]) &&  $disallowed[$type][$field_name] != 0 ) {
69
+      return user_access(_cfp_content_to_readable($type, $field_name, $verb));
70
+    }
71
+  }
72
+  return true;
73
+}
74
+
75
+
76
+
77
 /* ************************ */
78
 /* ADMIN Functions */
79
 /* ************************ */
Add picture from clipboard (Maximum size: 40 MB)