/** * Get the basic options for use in ege* functions * * @param bool $register_error display an error if one occures (default: false) * * @return bool|array */ function birthdays_get_basic_selection_options($register_error = false) { $result = false; if ($field_name = birthdays_get_configured_birthday_field()) { $interval = 3; if (elgg_get_plugin_setting("limit_upcoming", "birthdays") == "no") { $interval = 12; } $result = array("type" => "user", "metadata_name_value_pairs" => array("name" => $field_name, "value" => "", "operand" => "<>"), "selects" => array("DATE(msv1.string) + INTERVAL(YEAR(NOW()) - YEAR(DATE(msv1.string))) + 0 YEAR AS currbirthday"), "wheres" => array("((((DATE(msv1.string) + INTERVAL(YEAR(NOW()) - YEAR(DATE(msv1.string))) + 0 YEAR) >= DATE(NOW()))\n\t\t\t\tAND\n\t\t\t\t(DATE(msv1.string) + INTERVAL(YEAR(NOW()) - YEAR(DATE(msv1.string))) + 0 YEAR) BETWEEN DATE(NOW()) AND DATE(NOW()) + INTERVAL {$interval} MONTH)\n\t\t\t\t\n\t\t\t\tOR\n\t\t\t\t\n\t\t\t\t(((DATE(msv1.string) + INTERVAL(YEAR(NOW()) - YEAR(DATE(msv1.string))) + 0 YEAR) < DATE(NOW()))\n\t\t\t\tAND\n\t\t\t\t(DATE(msv1.string) + INTERVAL(YEAR(NOW()) - YEAR(DATE(msv1.string))) + 1 YEAR) BETWEEN DATE(NOW()) AND DATE(NOW()) + INTERVAL {$interval} MONTH)\n\t\t\t\t)"), "order_by" => "CASE WHEN currbirthday < DATE(NOW()) THEN currbirthday + INTERVAL 1 YEAR ELSE currbirthday END", "full_view" => false); } elseif ($register_error) { register_error(elgg_echo("birthdays:no_field_configured")); } return $result; }
function birthdays_get_upcoming_users($limit = 10) { if (!birthdays_get_configured_birthday_field()) { return false; } $limit = (int) $limit; $user_guids = birthdays_get_upcoming_user_guids(); if ($user_guids) { $users = array(); $i = 0; foreach ($user_guids as $user_guid) { $users[] = get_entity($user_guid); $i++; if ($i == $limit) { break; } } return $users; } else { return array(); } }
<?php /** * This page will display all the birthdays off the given day * */ // do we know which field contains birthdays if (!($field_name = birthdays_get_configured_birthday_field())) { register_error(elgg_echo("birthdays:no_field_configured")); forward(REFERER); } // get inputs $limit_month = (int) get_input("limit_month"); $limit_day = (int) get_input("limit_day"); if ($limit_month < 1 || $limit_month > 12) { unset($limit_month); } if ($limit_day < 1 || $limit_day > 31) { unset($limit_day); } // we need at least a month if (empty($limit_month)) { forward("birthdays"); } // make a readable date string $date_string = trim(elgg_echo("date:month:" . str_pad($limit_month, 2, 0, STR_PAD_LEFT), array($limit_day))); // add filter tab elgg_register_menu_item("filter", array("name" => "day", "text" => $date_string, "href" => current_page_url(), "priority" => 150)); // build page elements $title_text = elgg_echo("birthdays:page:day:title", array($date_string)); // breadcrumb