I'm on PHP5...
I'm using the Content Permission module that's bundled with CCK. (Gives you field specific role based view/edit permissions).
I have a non-required date field attached to a node type that only the 'staff' role can edit, but everyone can view. If a non-staff member goes to create a new node of this type (or edit an existing one) I run into the following validation error:
warning: Invalid argument supplied for foreach() in /var/www/html/drupal/drupal-6.3/sites/all/modules/date/date/date_elements.inc on line 385.
The To date must be greater than the From date.
In looking at the code in date_combo_validate(), the problem appears to be that the "to date" information will never appear in $element['#post'] as the user doesn't have permissions to post the date field. However the existing value or default values seem to be in $form_state['values'] which could be used(?).
I don't really feel comfortable offering a patch here on *validation* code, but I will take a stab if you're totally burried. Date has to be the largest CCK field in existance :)
Let me know if there is anything else I can do to help or if you would like me to (cough) attempt a patch.
Comments
Comment #1
Moonshine commentedI would be willing to submit a patch for this if someone has a minute to discuss the "best" route. Should I just check against $form_state['values'] ?
Comment #2
karens commentedI'm focused on other issues now, so help would be appreciated. Yes, $form_state['values'] is probably where you should look.
Comment #3
Moonshine commentedWell I took some time this morning to try and dig into this a bit, as CCK Content Permissions are key to the site I'm working on. :)
In the process of trying to work this issue, I actually got stuck by a different bug that I'm having a very tough time tracking.
Basically the values sent into date_combo_validate() for $form_state look to be corrupted by 1 character (for users without edit permission).
For example, $form_values[$field_name] is sent in as:
Rather then:
I know you're very busy, but if you have any thought on where that might be happening I'd be happy to work through this further.
Thanks!
Comment #4
Moonshine commentedYipes! The bug described above in my last post actually appears to be a CCK bug, which is more important as it effects a variety of cck fields (like multi-value checkboxes) as well.
I'll post an issue in the CCK queue and put this issue on hold until it that's cleared up... :/
Comment #5
Moonshine commentedFWIW, this is the CCK issue I posted... it got a little long.
#298440: CCK Content Permissions - Mangled field data when users don't have edit permission.
Comment #6
seaneffel commentedMoonshine, I found this same problem with the 5.x-2.0-rc6 release. I moved up to today's 5.x-2.0-rc7 and the problem is gone. It should be pretty easy to hunt down the changes that solved it this and then apply them to the code in the 6.x version.
Comment #7
karens commentedI assume this was fixed by #298440: CCK Content Permissions - Mangled field data when users don't have edit permission.. If there's still a problem using the latest code, including the current version of CCK that has the above fixes, you can reopen.