| 1 |
<?php
|
| 2 |
// $Id: subscriptions.install,v 1.18 2009/08/30 04:28:12 salvis Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Subscriptions module installation.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_schema().
|
| 11 |
*/
|
| 12 |
function subscriptions_schema() {
|
| 13 |
|
| 14 |
$schema['subscriptions'] = array(
|
| 15 |
'fields' => array(
|
| 16 |
'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 17 |
'module' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
|
| 18 |
'field' => array('type' => 'varchar', 'length' => '32', 'not null' => FALSE),
|
| 19 |
'value' => array('type' => 'varchar', 'length' => '237', 'not null' => FALSE),
|
| 20 |
'recipient_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
| 21 |
'send_interval' => array('type' => 'int', 'not null' => FALSE),
|
| 22 |
'author_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
| 23 |
'send_updates' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
|
| 24 |
'send_comments' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)),
|
| 25 |
'primary key' => array('sid'),
|
| 26 |
'indexes' => array(
|
| 27 |
'module' => array('module', 'field', 'value'),
|
| 28 |
'recipient_uid' => array('recipient_uid')),
|
| 29 |
);
|
| 30 |
|
| 31 |
|
| 32 |
$schema['subscriptions_queue'] = array(
|
| 33 |
'fields' => array(
|
| 34 |
'sqid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 35 |
'uid' => array('type' => 'int', 'not null' => FALSE),
|
| 36 |
'name' => array('type' => 'varchar', 'length' => '60', 'not null' => FALSE),
|
| 37 |
'mail' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
|
| 38 |
'language' => array('type' => 'varchar', 'length' => '12', 'not null' => FALSE),
|
| 39 |
'module' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
|
| 40 |
'field' => array('type' => 'varchar', 'length' => '32', 'not null' => FALSE),
|
| 41 |
'value' => array('type' => 'varchar', 'length' => '237', 'not null' => FALSE),
|
| 42 |
'author_uid' => array('type' => 'int', 'not null' => FALSE),
|
| 43 |
'send_interval' => array('type' => 'int', 'not null' => FALSE),
|
| 44 |
'digest' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE),
|
| 45 |
'load_args' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
|
| 46 |
'load_function' => array('type' => 'varchar', 'length' => '60', 'not null' => TRUE, 'default' => ''),
|
| 47 |
'is_new' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE),
|
| 48 |
'last_sent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)),
|
| 49 |
'primary key' => array('sqid'),
|
| 50 |
'indexes' => array(
|
| 51 |
'load_args' => array('load_args', 'load_function', 'uid'),
|
| 52 |
'uid' => array('uid')),
|
| 53 |
);
|
| 54 |
|
| 55 |
|
| 56 |
$schema['subscriptions_user'] = array(
|
| 57 |
'fields' => array(
|
| 58 |
'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
| 59 |
'digest' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 60 |
'send_interval' => array('type' => 'int', 'not null' => TRUE, 'default' => -1),
|
| 61 |
'send_updates' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 62 |
'send_comments' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 63 |
'send_interval_visible' => array('type' => 'int', 'not null' => TRUE, 'default' => -1),
|
| 64 |
'send_updates_visible' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 65 |
'send_comments_visible' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 66 |
'autosub_on_post' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 67 |
'autosub_on_update' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 68 |
'autosub_on_comment' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 69 |
'send_self' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1)),
|
| 70 |
'primary key' => array('uid'),
|
| 71 |
);
|
| 72 |
|
| 73 |
|
| 74 |
$schema['subscriptions_last_sent'] = array(
|
| 75 |
'fields' => array(
|
| 76 |
'uid' => array('type' => 'int', 'not null' => TRUE),
|
| 77 |
'send_interval' => array('type' => 'int', 'not null' => TRUE),
|
| 78 |
'last_sent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)),
|
| 79 |
'primary key' => array('uid', 'send_interval'),
|
| 80 |
);
|
| 81 |
|
| 82 |
return $schema;
|
| 83 |
}
|
| 84 |
|
| 85 |
/**
|
| 86 |
* Implementation of hook_install().
|
| 87 |
*/
|
| 88 |
function subscriptions_install() {
|
| 89 |
$ret = drupal_install_schema('subscriptions');
|
| 90 |
|
| 91 |
db_query("INSERT INTO {subscriptions_user} (uid, digest, send_interval, send_updates, send_comments, send_interval_visible, send_updates_visible, send_comments_visible, autosub_on_post, autosub_on_update, autosub_on_comment, send_self) VALUES(". -DRUPAL_AUTHENTICATED_RID .", 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1)");
|
| 92 |
db_query("INSERT INTO {subscriptions_user} (uid) SELECT uid FROM {users} WHERE uid > 0");
|
| 93 |
subscriptions_update_9(); // remove 5.x-1.x-dev template variables if found
|
| 94 |
|
| 95 |
include_once drupal_get_path('module', 'subscriptions') .'/subscriptions.install.inc';
|
| 96 |
_subscriptions_install_information();
|
| 97 |
return $ret;
|
| 98 |
}
|
| 99 |
|
| 100 |
/**
|
| 101 |
* Implementation of hook_uninstall().
|
| 102 |
*/
|
| 103 |
function subscriptions_uninstall() {
|
| 104 |
$ret = drupal_uninstall_schema('subscriptions');
|
| 105 |
|
| 106 |
if (db_table_exists('subscriptions_mail_edit')) {
|
| 107 |
db_drop_table($ret, 'subscriptions_mail_edit'); // old table from 5.x-2.x
|
| 108 |
}
|
| 109 |
if (db_table_exists('subscriptions_old')) {
|
| 110 |
db_drop_table($ret, 'subscriptions_old'); // old backup from 5.x-1.x
|
| 111 |
}
|
| 112 |
if (db_table_exists('subscriptions_holding')) {
|
| 113 |
db_drop_table($ret, 'subscriptions_holding'); // old left-over from 5.x-1.x
|
| 114 |
}
|
| 115 |
if (db_table_exists('subscriptions_holding_old')) {
|
| 116 |
db_drop_table($ret, 'subscriptions_holding_old'); // old backup from 5.x-1.x
|
| 117 |
}
|
| 118 |
if (db_table_exists('subscriptions_sent')) { // old left-over from first
|
| 119 |
db_drop_table($ret, 'subscriptions_sent'); // incarnation of 5.x-2.0
|
| 120 |
}
|
| 121 |
|
| 122 |
if (db_table_exists('mail_edit')) {
|
| 123 |
db_query("DELETE FROM {mail_edit} WHERE id LIKE 'subscriptions_%'");
|
| 124 |
}
|
| 125 |
if (db_table_exists('mail_edit_registry')) {
|
| 126 |
db_query("DELETE FROM {mail_edit_registry} WHERE id LIKE 'subscriptions_%'");
|
| 127 |
}
|
| 128 |
|
| 129 |
variable_del('subscriptions_avoid_empty_subscribe_links');
|
| 130 |
variable_del('subscriptions_blocked_content_types');
|
| 131 |
variable_del('subscriptions_blocked_nodes');
|
| 132 |
variable_del('subscriptions_cron_percent');
|
| 133 |
variable_del('subscriptions_form_expanded');
|
| 134 |
variable_del('subscriptions_form_in_block');
|
| 135 |
variable_del('subscriptions_form_link_only');
|
| 136 |
variable_del('subscriptions_generate_full_node');
|
| 137 |
variable_del('subscriptions_hide_overview_page');
|
| 138 |
variable_del('subscriptions_link_teaser');
|
| 139 |
variable_del('subscriptions_omitted_taxa');
|
| 140 |
variable_del('subscriptions_restricted_taxa');
|
| 141 |
variable_del('subscriptions_send_intervals');
|
| 142 |
variable_del('subscriptions_show_by_author_options');
|
| 143 |
variable_del('subscriptions_static_content_types');
|
| 144 |
variable_del('subscriptions_unlisted_content_types');
|
| 145 |
|
| 146 |
// also remove legacy 5.x-1.9(-dev) variables:
|
| 147 |
variable_del('subscriptions_allow_vid');
|
| 148 |
variable_del('subscriptions_autoset');
|
| 149 |
variable_del('subscriptions_email_body');
|
| 150 |
variable_del('subscriptions_email_subject');
|
| 151 |
variable_del('subscriptions_sendself');
|
| 152 |
variable_del('subscriptions_teaser');
|
| 153 |
variable_del('subscriptions_testpost');
|
| 154 |
variable_del('subscriptions_usecron');
|
| 155 |
variable_del('subscriptions_usersmenu');
|
| 156 |
}
|
| 157 |
|
| 158 |
/**
|
| 159 |
* Database update function 1 for first incarnation of 5.x-2.0.
|
| 160 |
*/
|
| 161 |
function subscriptions_update_1() {
|
| 162 |
|
| 163 |
$schema['subscriptions_mail_edit'] = array(
|
| 164 |
'fields' => array(
|
| 165 |
'mailkey' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
|
| 166 |
'item_body' => array('type' => 'text', 'not null' => FALSE)),
|
| 167 |
'primary key' => array('mailkey'),
|
| 168 |
);
|
| 169 |
|
| 170 |
db_create_table($ret, 'subscriptions_mail_edit', $schema['subscriptions_mail_edit']);
|
| 171 |
|
| 172 |
db_add_field($ret, 'subscriptions', 'send_interval', array('type' => 'int', 'not null' => FALSE));
|
| 173 |
|
| 174 |
if (variable_get('subscriptions_usecron', 0)) {
|
| 175 |
$ret[] = update_sql("UPDATE {subscriptions} SET send_interval = 1");
|
| 176 |
}
|
| 177 |
variable_del('subscriptions_usecron');
|
| 178 |
return $ret;
|
| 179 |
}
|
| 180 |
|
| 181 |
/**
|
| 182 |
* Database update dummy function 2, left-over from first incarnation of 5.x-2.0.
|
| 183 |
*/
|
| 184 |
function subscriptions_update_2() {
|
| 185 |
|
| 186 |
// intentionally left empty
|
| 187 |
|
| 188 |
return array();
|
| 189 |
}
|
| 190 |
|
| 191 |
/**
|
| 192 |
* Database update function 3 for 5.x-2.0 rewrite.
|
| 193 |
*/
|
| 194 |
function subscriptions_update_3() {
|
| 195 |
$ret = array();
|
| 196 |
$t = get_t();
|
| 197 |
|
| 198 |
if (db_table_exists('subscriptions_holding')) {
|
| 199 |
db_drop_table($ret, 'subscriptions_holding'); // old left-over from 5.x-1.x
|
| 200 |
}
|
| 201 |
|
| 202 |
if (db_table_exists('subscriptions_sent')) { // old left-over from first
|
| 203 |
db_drop_table($ret, 'subscriptions_sent'); // incarnation of 5.x-2.0
|
| 204 |
}
|
| 205 |
|
| 206 |
if (db_table_exists('subscriptions_old')) {
|
| 207 |
db_drop_table($ret, 'subscriptions_old');
|
| 208 |
}
|
| 209 |
db_rename_table($ret, subscriptions, subscriptions_old);
|
| 210 |
|
| 211 |
$schema['subscriptions'] = array(
|
| 212 |
'fields' => array(
|
| 213 |
'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 214 |
'module' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
|
| 215 |
'field' => array('type' => 'varchar', 'length' => '32', 'not null' => FALSE),
|
| 216 |
'value' => array('type' => 'varchar', 'length' => '237', 'not null' => FALSE),
|
| 217 |
'recipient_uid' => array('type' => 'int', 'not null' => TRUE),
|
| 218 |
'send_interval' => array('type' => 'int', 'not null' => FALSE),
|
| 219 |
'author_uid' => array('type' => 'int', 'not null' => TRUE),
|
| 220 |
'send_updates' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
|
| 221 |
'send_comments' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)),
|
| 222 |
'primary key' => array('sid'),
|
| 223 |
'indexes' => array(
|
| 224 |
'module' => array('module', 'field', 'value'),
|
| 225 |
'recipient_uid' => array('recipient_uid')),
|
| 226 |
);
|
| 227 |
db_create_table($ret, 'subscriptions', $schema['subscriptions']);
|
| 228 |
|
| 229 |
|
| 230 |
$ret[] = update_sql("INSERT INTO {subscriptions}
|
| 231 |
(module, field, value, recipient_uid, send_interval, author_uid, send_updates, send_comments)
|
| 232 |
SELECT 'node', 'nid', sid, uid, send_interval, -1, 0, 1
|
| 233 |
FROM {subscriptions_old}
|
| 234 |
WHERE stype = 'node'");
|
| 235 |
$ret[] = update_sql("INSERT INTO {subscriptions}
|
| 236 |
(module, field, value, recipient_uid, send_interval, author_uid, send_updates, send_comments)
|
| 237 |
SELECT 'node', 'tid', sid, uid, send_interval, -1, 0, 1
|
| 238 |
FROM {subscriptions_old}
|
| 239 |
WHERE stype = 'taxa'");
|
| 240 |
$ret[] = update_sql("INSERT INTO {subscriptions}
|
| 241 |
(module, field, value, recipient_uid, send_interval, author_uid, send_updates, send_comments)
|
| 242 |
SELECT 'node', 'type', SUBSTRING(stype FROM 5), uid, send_interval, -1, 0, 1
|
| 243 |
FROM {subscriptions_old}
|
| 244 |
WHERE stype LIKE 'type%'");
|
| 245 |
$ret[] = update_sql("UPDATE {subscriptions} SET send_interval = 1 WHERE send_interval < 1");
|
| 246 |
|
| 247 |
db_drop_table($ret, 'subscriptions_old');
|
| 248 |
|
| 249 |
|
| 250 |
$schema['subscriptions_queue'] = array(
|
| 251 |
'fields' => array(
|
| 252 |
'sqid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 253 |
'uid' => array('type' => 'int', 'not null' => FALSE),
|
| 254 |
'name' => array('type' => 'varchar', 'length' => '60', 'not null' => FALSE),
|
| 255 |
'mail' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
|
| 256 |
'language' => array('type' => 'varchar', 'length' => '12', 'not null' => FALSE),
|
| 257 |
'module' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
|
| 258 |
'field' => array('type' => 'varchar', 'length' => '32', 'not null' => FALSE),
|
| 259 |
'value' => array('type' => 'varchar', 'length' => '237', 'not null' => FALSE),
|
| 260 |
'author_uid' => array('type' => 'int', 'not null' => FALSE),
|
| 261 |
'send_interval' => array('type' => 'int', 'not null' => FALSE),
|
| 262 |
'digest' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE),
|
| 263 |
'load_args' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
|
| 264 |
'load_function' => array('type' => 'varchar', 'length' => '60', 'not null' => TRUE, 'default' => ''),
|
| 265 |
'last_sent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)),
|
| 266 |
'primary key' => array('sqid'),
|
| 267 |
'indexes' => array(
|
| 268 |
'load_args' => array('load_args', 'load_function', 'uid')),
|
| 269 |
);
|
| 270 |
db_create_table($ret, 'subscriptions_queue', $schema['subscriptions_queue']);
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
$schema['subscriptions_user'] = array(
|
| 277 |
'fields' => array(
|
| 278 |
'uid' => array('type' => 'int', 'not null' => TRUE),
|
| 279 |
'digest' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1),
|
| 280 |
'last_sent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)),
|
| 281 |
'primary key' => array('uid'),
|
| 282 |
);
|
| 283 |
db_create_table($ret, 'subscriptions_user', $schema['subscriptions_user']);
|
| 284 |
|
| 285 |
$ret[] = update_sql("INSERT INTO {subscriptions_user} (uid) SELECT uid FROM {users} WHERE uid > 0");
|
| 286 |
|
| 287 |
include_once drupal_get_path('module', 'subscriptions') .'/subscriptions.install.inc';
|
| 288 |
_subscriptions_install_information();
|
| 289 |
return $ret;
|
| 290 |
}
|
| 291 |
|
| 292 |
/**
|
| 293 |
* Database update function 4 for 5.x-2.0 rewrite.
|
| 294 |
*/
|
| 295 |
function subscriptions_update_4() {
|
| 296 |
$ret = array();
|
| 297 |
|
| 298 |
db_add_field($ret, 'subscriptions_user', 'send_interval', array('type' => 'int', 'not null' => TRUE, 'default' => -1));
|
| 299 |
db_add_field($ret, 'subscriptions_user', 'send_updates', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 300 |
db_add_field($ret, 'subscriptions_user', 'send_comments', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 301 |
|
| 302 |
$ret[] = update_sql("DELETE FROM {subscriptions_user} WHERE uid = 0");
|
| 303 |
$ret[] = update_sql("UPDATE {subscriptions_user} SET digest = -1");
|
| 304 |
$ret[] = update_sql("INSERT INTO {subscriptions_user} (uid, digest, send_interval, send_updates, send_comments) VALUES(". -DRUPAL_AUTHENTICATED_RID .", 0, 1, 0, 0)");
|
| 305 |
return $ret;
|
| 306 |
}
|
| 307 |
|
| 308 |
/**
|
| 309 |
* Database update function 5 for 5.x-2.0 rewrite.
|
| 310 |
*/
|
| 311 |
function subscriptions_update_5() {
|
| 312 |
$ret = array();
|
| 313 |
|
| 314 |
db_add_field($ret, 'subscriptions_user', 'send_interval_visible', array('type' => 'int', 'not null' => TRUE, 'default' => -1));
|
| 315 |
db_add_field($ret, 'subscriptions_user', 'send_updates_visible', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 316 |
db_add_field($ret, 'subscriptions_user', 'send_comments_visible', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 317 |
db_add_field($ret, 'subscriptions_queue', 'is_new', array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE));
|
| 318 |
|
| 319 |
$ret[] = update_sql("UPDATE {subscriptions_user} SET send_interval_visible = 0, send_updates_visible = 0, send_comments_visible = 0 WHERE uid = ". -DRUPAL_AUTHENTICATED_RID);
|
| 320 |
return $ret;
|
| 321 |
}
|
| 322 |
|
| 323 |
/**
|
| 324 |
* Database update function 6 for 5.x-2.0 rewrite.
|
| 325 |
*/
|
| 326 |
function subscriptions_update_6() {
|
| 327 |
$ret = array();
|
| 328 |
|
| 329 |
db_add_field($ret, 'subscriptions_user', 'autosub_on_post', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 330 |
db_add_field($ret, 'subscriptions_user', 'autosub_on_update', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 331 |
db_add_field($ret, 'subscriptions_user', 'autosub_on_comment', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 332 |
db_add_field($ret, 'subscriptions_user', 'send_self', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1));
|
| 333 |
|
| 334 |
return $ret;
|
| 335 |
}
|
| 336 |
|
| 337 |
/**
|
| 338 |
* Database update function 7 for 5.x-2.0 rewrite.
|
| 339 |
*/
|
| 340 |
function subscriptions_update_7() {
|
| 341 |
// Multi-part update to move subscriptions_auto and subscriptions_sendself from {users} to {subscriptions_user}
|
| 342 |
if (!isset($_SESSION['subscriptions_update_7'])) {
|
| 343 |
$_SESSION['subscriptions_update_7'] = 0;
|
| 344 |
$_SESSION['subscriptions_update_7_max'] = db_result(db_query('SELECT MAX(uid) FROM {users}'));
|
| 345 |
}
|
| 346 |
|
| 347 |
include_once './'. drupal_get_path('module', 'user') .'/user.module';
|
| 348 |
|
| 349 |
$limit = 50;
|
| 350 |
|
| 351 |
$result = db_query_range("SELECT uid FROM {users} WHERE uid > %d ORDER BY uid ASC", $_SESSION['subscriptions_update_7'], 0, $limit);
|
| 352 |
while ($usr = db_fetch_object($result)) {
|
| 353 |
$account = user_load(array('uid' => $usr->uid));
|
| 354 |
$settings = array();
|
| 355 |
if (isset($account->subscriptions_auto)) {
|
| 356 |
$settings['autosub_on_post = %d'] = $account->subscriptions_auto;
|
| 357 |
$settings['autosub_on_update = %d'] = $account->subscriptions_auto;
|
| 358 |
$settings['autosub_on_comment = %d'] = $account->subscriptions_auto;
|
| 359 |
}
|
| 360 |
if (isset($account->subscriptions_sendself)) {
|
| 361 |
$settings['send_self = %d'] = $account->subscriptions_sendself;
|
| 362 |
}
|
| 363 |
if (!empty($settings)) {
|
| 364 |
$sql = "UPDATE {subscriptions_user} SET ". implode(', ', array_keys($settings)) ." WHERE uid = %d";
|
| 365 |
$settings[] = $account->uid;
|
| 366 |
db_query($sql, array_values($settings));
|
| 367 |
user_save($account, array('subscriptions_auto' => NULL, 'subscriptions_sendself' => NULL));
|
| 368 |
}
|
| 369 |
|
| 370 |
$_SESSION['subscriptions_update_7'] = $usr->uid;
|
| 371 |
}
|
| 372 |
|
| 373 |
if ($_SESSION['subscriptions_update_7'] == $_SESSION['subscriptions_update_7_max']) {
|
| 374 |
variable_del('subscriptions_sendself');
|
| 375 |
variable_del('subscriptions_autoset');
|
| 376 |
unset($_SESSION['subscriptions_update_7']);
|
| 377 |
unset($_SESSION['subscriptions_update_7_max']);
|
| 378 |
return array();
|
| 379 |
}
|
| 380 |
return array('#finished' => $_SESSION['subscriptions_update_7'] / $_SESSION['subscriptions_update_7_max']);
|
| 381 |
}
|
| 382 |
|
| 383 |
/**
|
| 384 |
* Database update function 8: Empty.
|
| 385 |
*/
|
| 386 |
function subscriptions_update_8() {
|
| 387 |
}
|
| 388 |
|
| 389 |
/**
|
| 390 |
* Database update function 9: Remove 5.x-1.x-dev email templates.
|
| 391 |
*/
|
| 392 |
function subscriptions_update_9() {
|
| 393 |
$ret = array();
|
| 394 |
variable_del('subscriptions_email_body');
|
| 395 |
variable_del('subscriptions_email_subject');
|
| 396 |
return $ret;
|
| 397 |
}
|
| 398 |
|
| 399 |
/**
|
| 400 |
* Database update function 6101: Add the {subscriptions_last_sent} table.
|
| 401 |
*/
|
| 402 |
function subscriptions_update_6101() {
|
| 403 |
$ret = array();
|
| 404 |
|
| 405 |
$schema['subscriptions_last_sent'] = array(
|
| 406 |
'fields' => array(
|
| 407 |
'uid' => array('type' => 'int', 'not null' => TRUE),
|
| 408 |
'send_interval' => array('type' => 'int', 'not null' => TRUE),
|
| 409 |
'last_sent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)),
|
| 410 |
'primary key' => array('uid', 'send_interval'),
|
| 411 |
);
|
| 412 |
|
| 413 |
db_create_table($ret, 'subscriptions_last_sent', $schema['subscriptions_last_sent']);
|
| 414 |
db_add_index($ret, 'subscriptions_queue', 'uid', array('uid'));
|
| 415 |
|
| 416 |
include_once drupal_get_path('module', 'subscriptions') .'/subscriptions.admin.inc';
|
| 417 |
foreach (_subscriptions_send_intervals() as $send_interval => $text) {
|
| 418 |
db_query("INSERT INTO {subscriptions_last_sent} (uid, send_interval, last_sent) SELECT uid, %d, last_sent FROM {subscriptions_user} WHERE uid > 0", $send_interval);
|
| 419 |
}
|
| 420 |
return $ret;
|
| 421 |
}
|
| 422 |
|
| 423 |
/**
|
| 424 |
* Database update function 6102: Remove the obsolete
|
| 425 |
* {subscriptions_user}.last_sent column if it's still there.
|
| 426 |
*/
|
| 427 |
function subscriptions_update_6102() {
|
| 428 |
$ret = array();
|
| 429 |
|
| 430 |
if (db_column_exists('subscriptions_user', 'last_sent')) {
|
| 431 |
db_drop_field($ret, 'subscriptions_user', 'last_sent');
|
| 432 |
}
|
| 433 |
return $ret;
|
| 434 |
}
|
| 435 |
|