Index: birthdays.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/birthdays/birthdays.module,v retrieving revision 1.2.2.28 diff -r1.2.2.28 birthdays.module 4,20c4,22 < * @file 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 e-mail on their birthday automatically, < * and the administrator can receive daily reminders of who are having < * their birthday. Requires Profile Module. < */ < < /** < * @TODO - Fire events < * @TODO - Add postcards < * @TODO - Make visible to VIEWS module < * @TODO - PGSQL patch < * @TODO - Regulate visibility of birthdays, birthday blocks, etc by means of the settings of the profile field < * @TODO - Make optional size & frequency: Once a week (on first day of week) == 7 days in advance or Every day == only today < * @TODO - Make POT file(s) < * @TODO - Proper DOCSYS commenting of functions < */ --- > * @file 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 e-mail on their birthday automatically, > * and the administrator can receive daily reminders of who are having > * their birthday. Requires Profile Module. > */ > > /** > * @TODO - Fire events > * @TODO - Add postcards > * @TODO - Make visible to VIEWS module > * @TODO - PGSQL patch > * @TODO - Regulate visibility of birthdays, birthday blocks, etc > * by means of the settings of the profile field > * @TODO - Make optional size & frequency: > * Once a week (on first day of week) == 7 days in advance or Every day == only today > * @TODO - Make POT file(s) > * @TODO - Proper DOCSYS commenting of functions > */ 24,25c26,27 < * Implementation of hook_help(). < */ --- > * Implementation of hook_help(). > */ 38a41 > 40,41c43,44 < * Implementation of hook_menu(). < */ --- > * Implementation of hook_menu(). > */ 89a93 > 91,92c95,96 < * @desc Callback for birthdays synchronisation system. < */ --- > * Callback for birthdays synchronisation system. > */ 101a106 > 103,104c108,109 < * Implementation of hook_form(). < */ --- > * Implementation of hook_form(). > */ 105a111 > 107,108c113,123 < $form['profile_fieldset']['description'] = array('#type' => 'item', '#title' => 'Profile to Birthdays', '#value' => t('Fill the Birthdays module\'s table with data from the Profile module\'s table. This is needed when you (re-)installed the Birthdays module, but already collected birthdays with the Profile module (e.g. for age verification).')); < $form['profile_fieldset']['submit'] = array('#type' => 'submit', '#value' => t('Copy Profile data to Birthdays module')); --- > > $form['profile_fieldset']['description'] = array( > '#type' => 'item', > '#title' => 'Profile to Birthdays', > '#value' => t('Fill the Birthdays module\'s table with data from the Profile module\'s table. This is needed when you (re-)installed the Birthdays module, but already collected birthdays with the Profile module (e.g. for age verification).'), > ); > > $form['profile_fieldset']['submit'] = array( > '#type' => 'submit', > '#value' => t('Copy Profile data to Birthdays module') > ); 111,112c126,136 < $form['birthdays_fieldset']['description'] = array('#type' => 'item', '#title' => 'Birthdays to Profile', '#value' => t('Fill the Profile module\'s table with data from the Birthdays module\'s table. You can use this to copy the old data collected by a previous version of the Birthdays module after an update. It is only necessary when updating from a version of the Birthdays module which didn\'t use the Profile module.')); < $form['birthdays_fieldset']['submit'] = array('#type' => 'submit', '#value' => t('Copy Birthdays data to Profile module')); --- > > $form['birthdays_fieldset']['description'] = array( > '#type' => 'item', > '#title' => 'Birthdays to Profile', > '#value' => t('Fill the Profile module\'s table with data from the Birthdays module\'s table. You can use this to copy the old data collected by a previous version of the Birthdays module after an update. It is only necessary when updating from a version of the Birthdays module which didn\'t use the Profile module.'), > ); > > $form['birthdays_fieldset']['submit'] = array( > '#type' => 'submit', > '#value' => t('Copy Birthdays data to Profile module'), > ); 117,118c141,142 < * Implementation of hook_form_submit(). < */ --- > * Implementation of hook_form_submit(). > */ 145a170 > 147,149c172,176 < * @desc Callback for birthdays menu item to show a page which lists all users. < * @return Themed birthday listing of all users < */ --- > * Show birthdays page > * @desc Callback for birthdays menu item to show a page which lists all users. > * @return string > * Themed birthday listing of all users > */ 175,177c202,204 < $u = user_load(array('uid' => $user->uid)); < if (empty($filter_year) || !$u->birthdays_user_hide_year) { < $accounts[] = $u; --- > $user = user_load(array('uid' => $user->uid)); > if (empty($filter_year) || !$user->birthdays_user_hide_year) { > $accounts[] = $user; 187a215,222 > > /** > * Return a form containing a select box to filter users by month of birth > * > * @param $filter_month > * @param int $filter_year > * @return array of the form > */ 198c233 < $form['#suffix'] = ""; --- > $form['#suffix'] = "\n"; 219,220c254,257 < '#type' => 'button', < '#value' => 'Filter', --- > '#type' => 'button', > '#prefix' => '', 225a263,268 > > /** > * > * @param $month > * @return unknown > */ 231,233c274,276 < * @desc Theme a birthdays page < * @var $accounts array of loaded user objects < */ --- > * @desc Theme a birthdays page > * @var $accounts array of loaded user objects > */ 276a320 > $output = ''; 279c323 < $str .= drupal_get_form('birthdays_page_filter', $filter_month, $filter_year); --- > $output .= drupal_get_form('birthdays_page_filter', $filter_month, $filter_year); 281,282c325,326 < $str .= theme('table', $header, $rows); < $str .= theme('pager', NULL, variable_get('birthdays_page_list_number', 25), 0); --- > $output .= theme('table', $header, $rows); > $output .= theme('pager', NULL, variable_get('birthdays_page_list_number', 25), 0); 284c328 < return $str; --- > return $output; 304d347 < 321d363 < 339a382 > 375c418,421 < '#options' => array(1 => t('Yes'), 0 => t('No')), --- > '#options' => array( > 0 => t('No'), > 1 => t('Yes'), > ), 415d460 < 419,420c464,472 < function birthdays_admin_settings_submit($form_id, $values) { < $field = _birthdays_get_field($values['birthdays_field_name']); --- > > /** > * Submit hook for admin settings form > * > * @param string $form_id > * @param array $values > */ > function birthdays_admin_settings_submit($form_id, $form_values) { > $field = _birthdays_get_field($form_values['birthdays_field_name']); 429c481 < return system_settings_form_submit($form_id, $values); --- > return system_settings_form_submit($form_id, $form_values); 434,435c486,490 < * Implementation of hook_perm(). < */ --- > * Implementation of hook_perm(). > * Permissions: > * - accesss birthday > * - delete birthday > */ 439a495 > 441,442c497,499 < * Implementation of hook_cron(). < */ --- > * Implementation of hook_cron(). > * Performed one time a day to send e-mails. > */ 455a513 > 457,458c515,516 < * Implementation of hook_block < */ --- > * Implementation of hook_block > */ 525a584 > 527,529c586,588 < * @desc Helper function for displaying only todays birthdays < * @return An array containing all user objects that have their birthday today < */ --- > * Helper function for displaying only todays birthdays > * @return An array containing all user objects that have their birthday today > */ 533a593 > 535,538c595,601 < * @desc Get all birthdays of the upcomming X days < * @var Integer stating the amount of days to look forward, including today. < * @return An array containing user objects meeting the criteria < */ --- > * Get all birthdays of the upcomming X days > * > * @var $amount > * Integer stating the amount of days to look forward, including today. > * @return array > * An array containing user objects meeting the criteria > */ 602,605c665,671 < * @desc Get the next X birthdays < * @var Integer stating the amount of birthdays to retrieve. < * @return An array containing user objects meeting the criteria < */ --- > * Get the next X birthdays > * > * @var $amount > * Integer stating the amount of birthdays to retrieve. > * @return array > * An array containing user objects meeting the criteria > */ 609c675 < // Current Logged in user --- > // Current logged in user 613c679 < // needed to determine what day 'today' is in the timezone of the user/website. --- > // Needed to determine what day 'today' is in the timezone of the user/website. 665a732 > 667,669c734,737 < * @desc Theme function of the blocks < * @returns themed content < */ --- > * Theme function of the blocks > * > * @returns themed content > */ 671c739 < --- > 674c742 < $str = ''; --- > $output = '
'; 682c750 < $str .= ''; --- > $output .= ''; 684c752 < $str .= '
'. theme('username', $user) .' '. $age .''. _birthdays_show_date($user->{$field}, $user) .'
'. theme('username', $user) .' '. $age .''. _birthdays_show_date($user->{$field}, $user) .'
'; --- > $output .= ''; 687c755 < $str = '

' . t('Nobody is having their birthday soon.') . '

'; --- > $output = '

' . t('Nobody is having their birthday soon.') . '

'; 690c758 < $str .= ''; --- > $output .= ''; 692c760 < return $str; --- > return $output; 697,698c765,766 < * Implementation of hook_user(). < */ --- > * Implementation of hook_user(). > */ 720a789 > 722,723c791,795 < * @desc Inject information on a user load < */ --- > * Inject information on a user load > * > * @param object $user > * User object passed by reference > */ 734c806 < $user->age = _birthdays_calculate_age($user->$field); --- > $user->age = _birthdays_get_age($user->$field); 737a810 > 739,740c812,813 < * @desc Inject information and save birthday when editing or adding a user < */ --- > * Inject information and save birthday when editing or adding a user > */ 768a842 > 770,771c844,845 < * @desc Alter the way the birthday is shown. This is fired after every module has filled the profile. < */ --- > * Alter the way the birthday is shown. This is fired after every module has filled the profile. > */ 806a881 > 808,811c883,886 < * @desc Adds user options to the profile form which are saved in {users}.data and < * are loaded during a user_load(). < * @return fields for the form < */ --- > * Adds user options to the profile form which are saved in {users}.data and > * are loaded during a user_load(). > * @return fields for the form > */ 816d890 < 866a941 > 868,870c943,946 < * @desc Sends e-mail to administrator once a day as reminder about the upcoming 7 days < * @todo Add frequency options (once a day, every week, monthly) < */ --- > * Sends e-mail to administrator once a day as reminder about the upcoming 7 days > * > * @todo Add frequency options (once a day, every week, monthly) > */ 900a977 > 902,904c979,982 < * @desc Send all birthdays on this day a message < * @todo re-introduce the postcard module to make it fun < */ --- > * Send all birthdays on this day a message > * > * @todo re-introduce the postcard module to make it fun > */ 934a1013 > 936,939c1015,1019 < * @desc Get starsign based on date of birth < * @var $day and $month, decribing date of birth < * @return The name of the starsign < */ --- > * Get starsign based on date of birth > * > * @var $day and $month, decribing date of birth > * @return The name of the starsign > */ 983a1064 > 985,987c1066,1068 < * @desc Retrieve all fields of type 'date' from the profile.module's tables < * @return array with fieldnames < */ --- > * Retrieve all fields of type 'date' from the profile.module's tables > * @return array with fieldnames > */ 998a1080 > 1000,1003c1082,1088 < * @desc Retrieve profile field object < * @var $field: name of field to retrieve < * @return profile field object < */ --- > * Retrieve profile field object > * > * @var string $field > * name of field to retrieve > * @return object > * profile field object > */ 1014a1100 > 1016,1017c1102,1110 < * @desc Return the picture of a starsign, given the name. Links to Yahoo! when option is selected. < */ --- > * Return the picture of a starsign, given the name. Links to Yahoo! when option is selected. > * > * @param string starsign > * name of the starsign to show (not translated) > * @param int $show > * Show starsigns for values > 0 > * @return string > * HTML of a picture link to Yahoo horoscopes > */ 1019c1112 < $str = ''; --- > $output = ''; 1024c1117 < $str = ''. t($starsign) .''; --- > $output = ''. t($starsign) .''; 1026c1119 < // If link should be shown: update $str --- > // If link should be shown: update $output 1028c1121 < $str = ''. $str .''; --- > $output = ''. $output .''; 1033c1126 < return $str; --- > return $output; 1035a1129,1136 > > /** > * Implementation of hook_form_alter to change profile_field_form > * > * @param string $form_id > * @param array $form > * passed by reference > */ 1041a1143,1149 > > /** > * Initiated when profile_field_form is submitted > * > * @param string $form_id > * @param array $form_values > */ 1047a1156 > 1049,1053c1158,1165 < * @desc Calculate age < * @var array containing fields 'year', 'month' and 'day' < * @return age < */ < function _birthdays_calculate_age($date) { --- > * Get age from a given date of birth > * > * @var array $date > * array containing fields with keys 'year', 'month' and 'day' > * @return int > * age > */ > function _birthdays_get_age($date) { 1055c1167 < if (is_array( $date)) { --- > if (is_array($date)) { 1060c1172 < return _birthdays_calculate_age_2($day, $month, $year); --- > return _birthdays_calculate_age($day, $month, $year); 1066a1179 > 1068,1072c1181,1187 < * @desc Calculate age < * @var $year, $month, $day as expected < * @return age < */ < function _birthdays_calculate_age_2($day, $month, $year) { --- > * Calculate age > * > * @var $year, $month, $day as expected > * @return int > * age > */ > function _birthdays_calculate_age($day, $month, $year) { 1081a1197,1204 > > /** > * Return age if user has agreed to show it > * > * @param object $user > * a user object having attribute "age" set > * @return int > */ 1089a1213 > 1091,1092c1215,1216 < * @desc Format date array < */ --- > * Format date array > */ 1105a1230 > 1107,1108c1232,1233 < * @desc Format date, optionally hide year < */ --- > * Format date, optionally hide year > */ 1110c1235 < $str = ''; --- > $output = ''; 1144,1145c1269,1270 < $str .= strtr($format, $replace); < $str = trim($str, '/ ,.:-'); --- > $output .= strtr($format, $replace); > $output = trim($output, '/ ,.:-'); 1147c1272 < return $str; --- > return $output;