| 1 |
<?php
|
| 2 |
// $Id: dailytwitter.install,v 1.4 2009/08/12 02:09:55 jadestorm Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Database setup and handling for Daily Twitter.
|
| 7 |
*/
|
| 8 |
function dailytwitter_schema() {
|
| 9 |
$schema['dailytwitter'] = array(
|
| 10 |
'description' => "Stores mapping of drupal user to twitter user and last check status.",
|
| 11 |
'fields' => array(
|
| 12 |
'uid' => array(
|
| 13 |
'description' => t("The Drupal ID of the user account associated with th
|
| 14 |
e Twitter account."),
|
| 15 |
'type' => 'int',
|
| 16 |
'not null' => TRUE
|
| 17 |
),
|
| 18 |
'screen_name' => array(
|
| 19 |
'description' => t("The unique login name for the Twitter account."),
|
| 20 |
'type' => 'varchar',
|
| 21 |
'length' => 255
|
| 22 |
),
|
| 23 |
'last_update' => array(
|
| 24 |
'description' => t("UNIX timestamp of the last time this account was updated."),
|
| 25 |
'type' => 'int',
|
| 26 |
),
|
| 27 |
'last_id' => array(
|
| 28 |
'description' => t("ID of last twitter post we used."),
|
| 29 |
'type' => 'int',
|
| 30 |
),
|
| 31 |
'when_to_post' => array(
|
| 32 |
'description' => t("Seconds since beginning of day representation of what time to post the twitter posts at."),
|
| 33 |
'type' => 'int',
|
| 34 |
),
|
| 35 |
'password' => array(
|
| 36 |
'description' => t("Password used to authenticate for private posts, optional."),
|
| 37 |
'type' => 'varchar',
|
| 38 |
'length' => 255
|
| 39 |
),
|
| 40 |
'tags' => array(
|
| 41 |
'description' => t("Comma separated list of tags to apply to posts, optional."),
|
| 42 |
'type' => 'varchar',
|
| 43 |
'length' => 255
|
| 44 |
),
|
| 45 |
),
|
| 46 |
'primary key' => array('uid'),
|
| 47 |
|
| 48 |
);
|
| 49 |
|
| 50 |
return $schema;
|
| 51 |
}
|
| 52 |
|
| 53 |
function dailytwitter_requirements($phase) {
|
| 54 |
$requirements = array();
|
| 55 |
// Ensure translations don't break at install time
|
| 56 |
$t = get_t();
|
| 57 |
|
| 58 |
switch ($phase) {
|
| 59 |
case 'runtime':
|
| 60 |
if (!(bool)ini_get('allow_url_fopen')) {
|
| 61 |
$requirements['php_allow_url_fopen'] = array(
|
| 62 |
'title' => $t('Daily Twitter requirements'),
|
| 63 |
'value' => $t('Daily Twitter requires that allow_url_fopen be enabled in your PHP configuration. Please contact your system administrator for more information.'),
|
| 64 |
'severity' => REQUIREMENT_ERROR,
|
| 65 |
);
|
| 66 |
}
|
| 67 |
break;
|
| 68 |
case 'install':
|
| 69 |
if (!(bool)ini_get('allow_url_fopen')) {
|
| 70 |
$requirements['php_allow_url_fopen'] = array(
|
| 71 |
'title' => $t('Daily Twitter requirements'),
|
| 72 |
'value' => $t('Daily Twitter requires that allow_url_fopen be enabled in your PHP configuration. Please contact your system administrator for more information.'),
|
| 73 |
'severity' => REQUIREMENT_ERROR,
|
| 74 |
);
|
| 75 |
}
|
| 76 |
break;
|
| 77 |
}
|
| 78 |
return $requirements;
|
| 79 |
}
|
| 80 |
|
| 81 |
function dailytwitter_install() {
|
| 82 |
// Create my tables.
|
| 83 |
drupal_install_schema('dailytwitter');
|
| 84 |
}
|
| 85 |
|
| 86 |
function dailytwitter_update_1() {
|
| 87 |
$ret = array();
|
| 88 |
|
| 89 |
$attributes = array(
|
| 90 |
'description' => t("UNIX timestamp of the last time this account was updated."),
|
| 91 |
);
|
| 92 |
db_add_column($ret, 'dailytwitter', 'last_update', 'int', $attributes);
|
| 93 |
|
| 94 |
$attributes = array(
|
| 95 |
'description' => t("ID of last twitter post we used."),
|
| 96 |
);
|
| 97 |
db_add_column($ret, 'dailytwitter', 'last_id', 'int', $attributes);
|
| 98 |
|
| 99 |
$attributes = array(
|
| 100 |
'description' => t("Seconds since beginning of day representation of what time to post the twitter posts at."),
|
| 101 |
);
|
| 102 |
db_add_column($ret, 'dailytwitter', 'when_to_post', 'int', $attributes);
|
| 103 |
|
| 104 |
return $ret;
|
| 105 |
}
|
| 106 |
|
| 107 |
function dailytwitter_update_2() {
|
| 108 |
$ret = array();
|
| 109 |
|
| 110 |
$attributes = array(
|
| 111 |
'description' => t("Password used to authenticate for private posts, optional."),
|
| 112 |
);
|
| 113 |
db_add_column($ret, 'dailytwitter', 'password', 'varchar(255)', $attributes);
|
| 114 |
|
| 115 |
$attributes = array(
|
| 116 |
'description' => t("Comma separated list of tags to apply to posts, optional."),
|
| 117 |
);
|
| 118 |
db_add_column($ret, 'dailytwitter', 'tags', 'varchar(255)', $attributes);
|
| 119 |
|
| 120 |
return $ret;
|
| 121 |
}
|
| 122 |
|
| 123 |
function dailytwitter_uninstall() {
|
| 124 |
// Drop my tables.
|
| 125 |
drupal_uninstall_schema('dailytwitter');
|
| 126 |
}
|