Download & Extend

Spaces Integration for CCK Fields

Project:Spaces
Version:6.x-3.0-beta6
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Patch whisks away all CCK fields associated with Features that are Spaces-aware but not enabled in the current Space.

AttachmentSize
spaces.cck_.patch918 bytes

Comments

#1

Status:active» needs review

>.>

#2

Fieldgroups too.

AttachmentSize
spaces.887272.patch 976 bytes

#3

Wrong module prefix. Copy and paste errorism!

AttachmentSize
spaces.887272-2.patch 972 bytes

#4

Okay, eye's paining so not making a patch atm but this is what I just altered to it.

For performance sake, I think it should be restrained to edit or be configurable.

<?php
  
// Why check fieldgroups ? They don't show if no enabled fields generally
    // And they don't match the pattern for key that fields have
    // Don't think they go through hook_field_access either
   
$map = features_get_component_map('content');
   
$key = $field['type_name'] . '-' . $field['field_name'];
   
$use_feature = NULL;
    if (!empty(
$map[$key])) {
      
// This needs to find the enabled module as more than one feature can
      // declare the same.
     
foreach ($map[$key] as $feature) {
        if (
module_exists($feature)) {
         
$use_feature = $feature;
        }
      }
    }
    if (isset(
$use_feature)) {
     
// Block any access to CCK fields in Features not enabled for the current Space.
     
if (!spaces_access_feature('view', $feature)) {
        return
FALSE;
      }
    }
   
// Make sure node reference fields have at least one enabled type.
   
if (!empty($field['referenceable_types'])) {
     
$map = features_get_component_map('node');
     
$has_accessible_type = FALSE;
      foreach (
array_filter($field['referenceable_types']) as $type) {
        if (!empty(
$map[$type])) {
         
$use_feature = NULL;
          foreach (
$map[$type] as $feature) {
            if (
module_exists($feature)) {
             
$use_feature = $feature;
            }
          }
          if (isset(
$use_feature)) {
            if (
spaces_access_feature('view', $use_feature)) {
             
$has_accessible_type = TRUE;
              break;
            }
            else {
              continue;
            }
          }
        }
       
// If not map or no enabled features, fallback to this.
       
if (node_get_types('type', $type)) {
         
$has_accessible_type = TRUE;
          break;
        }
      }
      return
$has_accessible_type;
    }
  }
  return
TRUE;
}
?>

#5

Status:needs review» needs work

Good advancement. I'm not sure about integrating the nodereference in this way. There could be solid use cases for using a nodereference field to target nodes outside the current space. Contradicting that use case, this check does not evaluate Views-based referencable types, which is what I usually use in a Spaces environment when I care about limiting the values to local content.

Performance-wise, I'm a bit on the fence. It would be nice to hide the CCK values from the user if you no longer want them to show up.
The results of features_get_component_map() is a static that should be available in memory on full node pages. spaces_access_feature() is cached and also a static. I haven't done actual performance testing, but this check should not be a big impact per field.

Marking as Needs Work to at least reroll with improved basic integration.

#6

Status:needs work» needs review

Reroll with some tweaks from #4. I skipped the node reference validation and the suggestion to limit it to edit only pending further discussion.

AttachmentSize
spaces.887272-6.patch 1.2 KB