/[drupal]/contributions/modules/birthdays/birthdays.install
ViewVC logotype

Contents of /contributions/modules/birthdays/birthdays.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.16 - (show annotations) (download) (as text)
Sun Oct 5 09:18:37 2008 UTC (13 months, 3 weeks ago) by maartenvg
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC1, DRUPAL-6--1-0, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.15: +16 -1 lines
File MIME type: text/x-php
Use user_mail_tokens() for birthday e-mails.
1 <?php
2 // $Id: birthdays.install,v 1.15 2008/10/04 09:10:40 maartenvg Exp $
3
4 /**
5 * @file
6 * Installation file for the Birthdays module.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function birthdays_install() {
13 drupal_install_schema('birthdays');
14
15 // Still necessary!
16 $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'profile'")) - 1;
17 db_query("UPDATE {system} SET weight = %d WHERE name = 'birthdays'", $weight);
18 }
19
20 /**
21 * Implementation of hook_schema().
22 */
23 function birthdays_schema() {
24 $schema = array();
25 $schema['dob'] = array(
26 'description' => t('Table containing birthdays of the users.'),
27 'fields' => array(
28 'uid' => array(
29 'description' => t('The current user identifier.'),
30 'type' => 'int',
31 'unsigned' => TRUE,
32 'not null' => TRUE,
33 ),
34 'birthday' => array(
35 'description' => t('The birthday of this user.'),
36 'type' => 'datetime',
37 'not null' => TRUE,
38 ),
39 ),
40 'primary key' => array('uid'),
41 );
42
43 return $schema;
44 }
45
46 /**
47 * Implementation of hook_requirements().
48 */
49 function birthdays_requirements($phase) {
50 global $_birthdays_field;
51 $t = get_t();
52 $requirements = array();
53
54 if ($phase == 'runtime') {
55 $value = $t('All requirements are met');
56 $severity = REQUIREMENT_OK;
57
58 $date_fields = _birthdays_get_date_fields();
59 if (empty($date_fields)) {
60 $value = $t('Missing profile field');
61 $severity = REQUIREMENT_ERROR;
62 $description = $t('No profile fields of type \'date\' were found, please <a href="@profile-settings-page">create one here</a>. Then visit the <a href="@birthdays-settings">birthdays settings page</a> to set up the module.', array('@profile-settings-page' => url('admin/user/profile/add/date'), '@birthdays-settings' => url('admin/settings/birthdays')));
63 }
64 elseif (!isset($_birthdays_field)) {
65 // Set warning/error message when the birthdays profile field hasn't been set yet.
66 $value = $t('No date field selected');
67 $severity = REQUIREMENT_ERROR;
68 $description = $t('The date field has not yet been selected as birthdays field. Please visit the <a href="@birthdays-settings">birthdays settings page</a> to do so.', array('@birthdays-settings' => url('admin/settings/birthdays')));
69 }
70
71 $requirements['birthdays'] = array(
72 'title' => $t('Birthdays'),
73 'value' => $value,
74 'description' => $description,
75 'severity' => $severity,
76 );
77 }
78
79 return $requirements;
80 }
81
82 /**
83 * Remove the variable 'birthdays_field_name'.
84 */
85 function birthdays_update_5003() {
86 $ret[] = array('success' => TRUE, 'query' => 'Variable "birthdays_field_name" has been deleted successfully');
87 variable_del('birthdays_field_name');
88
89 return $ret;
90 }
91
92 /**
93 * The placeholder @name in the user birthday message has been replaced by
94 * !username, because we now can use user_mail_tokens().
95 */
96 function birthdays_update_6000() {
97 $ret = array();
98 $current = variable_get('birthdays_send_user_message', FALSE);
99 if ($current !== FALSE) {
100 variable_set('birthdays_send_user_message', strtr($current, array('@name' => '!username')));
101 $ret[] = array('success' => TRUE, 'query' => 'Replaced @name with !username in user birthday e-mail.');
102 }
103
104 return $ret;
105 }
106
107 /**
108 * Implementation of hook_uninstall().
109 */
110 function birthdays_uninstall() {
111 drupal_uninstall_schema('birthdays');
112
113 variable_del('birthdays_show_starsign');
114 variable_del('birthdays_field_id');
115 variable_del('birthdays_send_user');
116 variable_del('birthdays_send_user_subject');
117 variable_del('birthdays_send_user_message');
118 variable_del('birthdays_remind');
119 variable_del('birthdays_hide_year');
120 variable_del('birthdays_block_number_by_days');
121 variable_del('birthdays_block_number_by_birthdays');
122 variable_del('birthdays_page_show_filters');
123 variable_del('birthdays_page_settings');
124 variable_del('birthdays_page_list_number');
125 variable_del('birthdays_block_hide');
126 variable_del('birthdays_last_cron');
127 variable_del('birthdays_last_cron_week');
128 }

  ViewVC Help
Powered by ViewVC 1.1.2