another field group issue

ricflomag - August 21, 2007 - 21:32
Project:CCK Field Permissions
Version:5.x-1.10
Component:Code
Category:bug report
Priority:normal
Assigned:ricflomag
Status:needs work
Description

In the CCK Field Permissions settings page (http://yoursite.com/admin/settings/cck_field_perms), checking the box in front of a field group name should do what the helper text says: "Checking this box will hide this complete field group". However, checking the group has no effect at all. For all the fields in the group to be hidden, one have to check them all.

I've patched the module to get the desired behavior: if a group is checked, the contained fields are considered to be checked too, and their being showed or editable depends on the settings for their containing group in the access control page (http://yoursite.com/admin/user/access)

This patch is against CCK Field Permissions v1.10 and works with CCK v1.6-1, which are the latest releases at the time of filing this bug.

AttachmentSize
cck_field_perms.module.patch1.43 KB

#1

pjb - August 24, 2007 - 03:23

I've tried to apply this and it seemed to be rejected by 'patch'; anyone else have issues?

#2

ricflomag - August 24, 2007 - 21:48

I've no idea. If it can help: i've used the command "diff -up" on linux to make the patch file.

As the patch is short, you can manually apply it by copy-paste, and publish your own diff file here.

#3

arthurf - August 27, 2007 - 21:22

if you patch against head you can do cvs diff -up original.php > filename.patch See http://drupal.org/patch/create for creating patches

#4

arthurf - August 27, 2007 - 21:58

Woops, I should be more clear. Make sure to patch against DRUPAL-5

#5

ricflomag - August 31, 2007 - 18:59

On install (or update), the fieldgroup module sets its weight to 9, which prevents cck_fieldperms (which has a weight of 0) to do anything on fieldgroups because its hook_form_alter is called before the hook_form_alter of fieldgroup.

The solution is to set the weight of cck_fieldperms to a value higher than 9. This has to be done when installing the module (see http://drupal.org/node/110238) and on updating it from older versions.

The patch i've submitted here (and i guess, anything in the cck_fieldperms that would alter groups of fields) will not work properly if the weight of cck_fieldperms is not set to a value higher than 9.

#6

yched - August 31, 2007 - 23:27

fieldgroup's weight has been set to 9 precisely so that modules with an inferior weight can find the fields in their hook_form_alter, while they're still in a predictible location ($form['field_name']), and have not yet been moved to their groups (which is less predictible, since it depends on the users settings)
So in theory, the job should be easier for modules with a 'regular' weight.

#7

ricflomag - September 3, 2007 - 22:33

Ok, I understand. This is how i imagine a solution so far:

When we want cck_fieldperm to hide a whole group, we make it hide all the fields of this group (done by the patch i've posted), but this is not enough, because fieldgroup will display an empty group instead of just hidding it...

This is not possible to fix on the side of cck_fielperm if we want cck_fieldperm to stick to its priority of 0. So i guess that we have to patch fieldgroup now, to make it check if a group contains any visible field before making it available for display. I don't know much about how fieldgroup works, but i've tried to patch it... See attached file. Code needs work !

AttachmentSize
fieldgroup.module_1.patch 1004 bytes

#8

jereme.guenther - September 10, 2007 - 04:37

Oh, I am so glad someone else had this issue as well. I couldn't figure out why this perms module was working perfectly on all the fields except for the groups. I spent several hours googling and digging through the php backend trying to figure it out ( I am new to the whole Drupal framework ).

Going into the MySQL backend and updating the weight of the module to 10 fixed it up nicely. I haven't done exhaustive testing to see if it causes problems, but it doesn't seem to prevent the perms module from effectively hiding single fields inside or outside of groups. It would be really nice to have this fix implemented in the next release.

#9

acrollet - March 5, 2008 - 15:35

that patch works great for me, thanks very much ricflomag!

#10

antipix - May 22, 2008 - 08:34

trying to use the first patch and just get :

patching file cck_field_perms.module
Hunk #1 FAILED at 79.
Hunk #2 FAILED at 189.
2 out of 2 hunks FAILED -- saving rejects to file cck_field_perms.module.rej

Any idea ?

#11

antipix - May 22, 2008 - 09:03

i applied the patch manually and it works, but i don't think patchs are created to be applied manually...

#12

ricflomag - May 26, 2008 - 17:49

@antipix: This is probably because of a version mismatch, as CCK and CCK Field Permissions have been updated since i posted the patches.

#13

antipix - May 27, 2008 - 12:40

okay i confess that i don't fully understand all those patchs mechanism...but i applied it manually with no problems ^^

#14

bgogoi - December 8, 2008 - 12:39

the patch worked for me :)

Thank you very much.

#15

SocialNicheGuru - January 2, 2009 - 14:13

Hi,

I enabled the patch and got a double padlock.

I also cannot get a padlock around individual fields

AttachmentSize
double padlocks around fieldgroup only.jpg 8.18 KB
 
 

Drupal is a registered trademark of Dries Buytaert.