birthdays.install in Birthdays 6
Same filename and directory in other branches
Installation file for the Birthdays module.
File
birthdays.installView source
<?php
/**
* @file
* Installation file for the Birthdays module.
*/
/**
* Implementation of hook_install().
*/
function birthdays_install() {
drupal_install_schema('birthdays');
// Still necessary!
$weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'profile'")) - 1;
db_query("UPDATE {system} SET weight = %d WHERE name = 'birthdays'", $weight);
}
/**
* Implementation of hook_schema().
*/
function birthdays_schema() {
$schema = array();
$schema['dob'] = array(
'description' => t('Table containing birthdays of the users.'),
'fields' => array(
'uid' => array(
'description' => t('The current user identifier.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'birthday' => array(
'description' => t('The birthday of this user.'),
'type' => 'datetime',
'not null' => TRUE,
),
),
'primary key' => array(
'uid',
),
);
return $schema;
}
/**
* Implementation of hook_requirements().
*/
function birthdays_requirements($phase) {
global $_birthdays_field;
$t = get_t();
$requirements = array();
if ($phase == 'runtime') {
$value = $t('All requirements are met');
$severity = REQUIREMENT_OK;
$date_fields = _birthdays_get_date_fields();
if (empty($date_fields)) {
$value = $t('Missing profile field');
$severity = REQUIREMENT_ERROR;
$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'),
));
}
elseif (!isset($_birthdays_field)) {
// Set warning/error message when the birthdays profile field hasn't been set yet.
$value = $t('No date field selected');
$severity = REQUIREMENT_ERROR;
$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'),
));
}
$requirements['birthdays'] = array(
'title' => $t('Birthdays'),
'value' => $value,
'description' => $description,
'severity' => $severity,
);
}
return $requirements;
}
/**
* Remove the variable 'birthdays_field_name'.
*/
function birthdays_update_5003() {
$ret[] = array(
'success' => TRUE,
'query' => 'Variable "birthdays_field_name" has been deleted successfully',
);
variable_del('birthdays_field_name');
return $ret;
}
/**
* The placeholder @name in the user birthday message has been replaced by
* !username, because we now can use user_mail_tokens().
*/
function birthdays_update_6000() {
$ret = array();
$current = variable_get('birthdays_send_user_message', FALSE);
if ($current !== FALSE) {
variable_set('birthdays_send_user_message', strtr($current, array(
'@name' => '!username',
)));
$ret[] = array(
'success' => TRUE,
'query' => 'Replaced @name with !username in user birthday e-mail.',
);
}
return $ret;
}
/**
* Implementation of hook_uninstall().
*/
function birthdays_uninstall() {
drupal_uninstall_schema('birthdays');
variable_del('birthdays_show_starsign');
variable_del('birthdays_field_id');
variable_del('birthdays_send_user');
variable_del('birthdays_send_user_subject');
variable_del('birthdays_send_user_message');
variable_del('birthdays_remind');
variable_del('birthdays_hide_year');
variable_del('birthdays_block_number_by_days');
variable_del('birthdays_block_number_by_birthdays');
variable_del('birthdays_page_show_filters');
variable_del('birthdays_page_settings');
variable_del('birthdays_page_list_number');
variable_del('birthdays_block_hide');
variable_del('birthdays_last_cron');
variable_del('birthdays_last_cron_week');
}
Functions
Name | Description |
---|---|
birthdays_install | Implementation of hook_install(). |
birthdays_requirements | Implementation of hook_requirements(). |
birthdays_schema | Implementation of hook_schema(). |
birthdays_uninstall | Implementation of hook_uninstall(). |
birthdays_update_5003 | Remove the variable 'birthdays_field_name'. |
birthdays_update_6000 | The placeholder @name in the user birthday message has been replaced by !username, because we now can use user_mail_tokens(). |