Hi,

I think it might be useful to post an issue that is related between this module and One Page Profile (although not sure which of those two causes the problem!). If someone enables One Page Profile and Birthdays module , there is no option anymore of "Hide age and birth year" checkbox. I thought it might be useful to post this here and in case someone uses both to realize what is causing this problem. One Page Profile is very useful for simple profiles and it's pity to get this inconsistency between those two.

CommentFileSizeAuthor
#5 birthdays_onepageprofile.patch881 bytesmr.andrey

Comments

charos’s picture

Priority: Normal » Minor
davidbessler’s picture

Agreed. I have the same problem.

mr.andrey’s picture

In birthdays.module, find this:

if ($category == $_birthdays_field->category || ($_birthdays_field->register && $register)) {

... and replace with this:

if ($category == $_birthdays_field->category || ($_birthdays_field->register && $register) || module_exists('onepageprofile')) {

Andrey.

Niklas Fiekas’s picture

Priority: Minor » Normal

Looks good. Can you create a patch with this change? I'd happily commit it.

mr.andrey’s picture

StatusFileSize
new881 bytes

Actually, this should be the line, just to be more considerate:

if ($category == $_birthdays_field->category || ($_birthdays_field->register && $register) || (module_exists('onepageprofile') && $category == 'account')) {

And sure, here's the patch against the latest dev.

Niklas Fiekas’s picture

Status: Active » Fixed

Thank you, @mr.andrey. Committed and pushed to 6.x-1.x: http://drupalcode.org/project/birthdays.git/commitdiff/9a91c60.

mr.andrey’s picture

Status: Fixed » Active

I just found another bug, that's related to this, since it's in the same line.

If field visibility is set to Hidden, the "Hide age and birth year" checkbox still shows up for non-admin users.
We basically need a visibility and permission check in each of the conditional parameters.

So instead of this:

if ($category == $_birthdays_field->category || ($_birthdays_field->register && $register) || (module_exists('onepageprofile') && $category == 'account')) {

We'll need to use this:

  if (($category == $_birthdays_field->category || ($_birthdays_field->register && $register) || (module_exists('onepageprofile') && $category == 'account')) && (in_array($_birthdays_field->visibility, array(1,2,3)) || (user_access('administer users') && $_birthdays_field->visibility == 4))) {

The visibility values here are:
1 - private
2 - public, unlisted
3 - public, listed
4 - hidden, admin/theme only

Andrey.

Niklas Fiekas’s picture

Is ->visibility coming from the One page profile module?

mr.andrey’s picture

No, it's coming from the default profile module. The visibility is basically the four options that each profile field has to determine how the field shows up.

mr.andrey’s picture

Also, the "Hide age and birth year" checkbox doesn't seem to remember the values for users, or rather it stores them, but upon visiting the profile again, gets unchecked.

$form[$_birthdays_field->category][$_birthdays_field->name]['birthdays_user_hide_year'] = array(
...
'#default_value' => (int) $account->birthdays_user_hide_year,

I checked the $account object, and "birthdays_user_hide_year" isn't set at all, even though "birthdays_starsign" is.

Here's a fix:

After this:

      // Set the starsign for the user.module to save in the {users}.data field
      $edit['birthdays_starsign'] = _birthdays_get_starsign($day, $month);

... add this:

      // Set the hide year and age setting
      if ($birthdays_user_hide_year) {
        $edit['birthdays_user_hide_year'] = $birthdays_user_hide_year;
      }

This too, I believe is unrelated to the one page profile module. Perhaps the hide year/age functionality was added later to the module and this was overlooked.

Andrey.