function _birthdays_get in Birthdays 7
Queries the database for birthdays.
Parameters
$trigger: TRUE, if only birthdays should be returned, that are not opted out of triggers.
$instance: The field instance to query for.
$day: The day to look up. 0 for all days of a month.
$month: The month to look up.
$year: Optional. If that year is not a leap year and $day and $month indicate the first of March, then February 29 will be included in the query.
Return value
An array where both keys and values are entity ids.
1 call to _birthdays_get()
- birthdays_cron in ./
birthdays.module - Implements hook_cron().
File
- ./
birthdays.module, line 1022 - The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an email on their birthday automatically, and the administrator can receive daily reminders of…
Code
function _birthdays_get($trigger, $instance, $day, $month, $year = NULL) {
$field_name = $instance['field_name'];
$query = db_select('field_data_' . $field_name, 'f')
->fields('f', array(
'entity_id',
))
->condition($field_name . '_month', $month)
->condition('entity_type', $instance['entity_type'])
->condition('bundle', $instance['bundle']);
if ($day) {
$query
->condition($field_name . '_day', $day);
}
if ($trigger && $instance['settings']['triggers']['user']) {
$query
->condition($field_name . '_triggers', TRUE);
}
$result = $query
->execute()
->fetchAllKeyed(0, 0);
if ($year && $day == 1 && $month == 3 && !BirthdaysBirthday::isLeapYear($year)) {
$result += _birthdays_get($trigger, $instance, 29, 2);
}
return $result;
}