I'm getting a "button is undefined" Javascript error when loading a form where i'm not allowed to post image fields.
It seems that the upload.js is being loaded without matter that the module is setting the form access attribute for the field to FALSE.

Comments

paradigmshifter’s picture

I believe I'm experiencing this same problem. In IE it is stops the rest of my javascript from completing and leaves the users without FCKEditor.

paradigmshifter’s picture

Does anyone know of a solution to this problem? Or can possibly point me in the right direction to solve it. Thanks

TaPes’s picture

i have the same problem, does anyone have a solution?

wflorian’s picture

Priority: Normal » Critical

Same problem here!! I changed priority to critical because it makes the module useless to me, because other modules are not working when cck field permissions is turned on for image fields.

Nobody here who has a solution??

Please contact me, I am willing to honor working solutions with little extra money! ;)

wflorian’s picture

Version: 5.x-1.x-dev » 5.x-1.10

I did have some further research on this, because I really need to get this module working.

There is a module called Workflow Fields, which does not exactly do what CCK Field Permissions can do, but it can also make certain cck fields invisible.
If an image field is set invisible there is also an JS error, BECAUSE the javascript settings of the upload part of the form are not removed. This is critical because the collapsible fieldsets in the form stop working and stay collapsed. (http://drupal.org/node/238525)

They posted a patch which looks like that:

        if ($field['type'] == 'file') {
          unset($form[$key .'-attach-url']);
        }

SO we would really need a patch like that. Actually I am no PHP pro, so I would appreciate if someone with some knowledge in that can help us out here!

Like I said, I am willing to support your help with a little extra money. Please contact me.

wflorian’s picture

Thanks tu ufku (http://drupal.org/user/9910) I got a working patch:

change

$form[$disallowed_field]['#access'] = false;

to

$form[$disallowed_field]['#access'] = false; if (isset($form[$disallowed_field .'-attach-url'])) {
$form[$disallowed_field .'-attach-url']['#access'] = false; }

and change

unset($form[$name]);

to

unset($form[$name]);
if (isset($form[$name .'-attach-url'])) {
$form[$name .'-attach-url']['#access'] = false; }

pcorbett’s picture

#6 was a little off as of the most recent 5.x-1.x-dev. The basic concept is correct, but I found that the code had changed around a bit since then, so to get this working I added it around line 253 of cck_field_perms.module:

// now check fields
foreach ($disallowed_fields[$type] as $disallowed_field => $value) {
  if (isset($form[$disallowed_field .'-attach-url'])) {
    $form[$disallowed_field .'-attach-url']['#access'] = false; 
  }
  
  if ($value == 0 ) {continue;}
    if (! user_access(_cfp_content_to_readable($type, $disallowed_field, $verb))) {

     //check the display type

I'm not sure the unset() is necessary or not, but submitting the page works alright so far. AND, my TinyMCE is back, so my client is happy :)

behindthepage’s picture

For version 5.x-1.10 insert code after line 183 in function _cfp_form_helper

function _cfp_form_helper($form_id, $form, $verb){
  //content_video_node_form
  $types = variable_get('cfp_types', null);
  if ($types) {
    foreach ($types as $type) {
      if ($form_id == $type . "_node_form") {
        $disallowed_fields = unserialize(variable_get('cfp_values', null));
        if ($disallowed_fields) {
          // removes fieldgroups
          _cfp_form_group_fieldset_helper($form, $disallowed_fields[$type], $type, $verb);
          if (isset($disallowed_fields[$type])) {
            foreach ($disallowed_fields[$type] as $disallowed_field => $value){
              if (isset($form[$disallowed_field .'-attach-url'])) { // HERE
                $form[$disallowed_field .'-attach-url']['#access'] = false;  // HERE
              } // HERE
              if ($value == 0 ) {continue;}
                if (! user_access(_cfp_content_to_readable($type, $disallowed_field, $verb))) { 
                 $form[$disallowed_field]['#access'] = false;
              }
            }
          }
        }
      }
    }
  }
  return $form;
}
plan9’s picture

Code in number #7 worked better for me. #8 caused ajax form uploads (via upload image module) to flake out.