View source
<?php
function birthdays_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE IF NOT EXISTS {dob} (\n uid int(10) unsigned NOT NULL default 0,\n birthday date NOT NULL default '0000-00-00',\n PRIMARY KEY (uid)\n );");
break;
case 'pgsql':
db_query("CREATE TABLE {dob} (\n uid int NOT NULL default 0 check(uid >= 0),\n birthday date NOT NULL default '0000-01-01',\n PRIMARY KEY (uid)\n );");
break;
}
$weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'profile'")) - 1;
db_query("UPDATE {system} SET weight = %d WHERE name = 'birthdays'", $weight);
}
function birthdays_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'profile'")) - 1;
$ret[] = update_sql("UPDATE {system} SET weight = %d WHERE name = 'birthdays'", $weight);
break;
case 'pgsql':
break;
}
return $ret;
}
function birthdays_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
break;
case 'pgsql':
db_query("CREATE TABLE {dob} (\n uid int NOT NULL default 0 check(uid >= 0),\n birthday date NOT NULL default '0000-01-01',\n PRIMARY KEY (uid)\n );");
$weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'profile'")) - 1;
$ret[] = update_sql("UPDATE {system} SET weight = %d WHERE name = 'birthdays'", $weight);
break;
}
return $ret;
}
function birthdays_update_5003() {
$ret[] = array(
'success' => TRUE,
'query' => 'Variable "birthdays_field_name" has been deleted successfully',
);
variable_del('birthdays_field_name');
return $ret;
}
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)) {
$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;
}
function birthdays_uninstall() {
db_query('DROP TABLE {dob}');
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');
}