View source
<?php
function webform_install() {
$success = TRUE;
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$success = $success && db_query("CREATE TABLE if not exists {webform} (\n nid int(10) unsigned NOT NULL default '0',\n confirmation text,\n teaser tinyint not null default '0',\n submit_text varchar(255) default NULL,\n submit_limit tinyint not null default '-1',\n submit_interval int not null default '-1',\n email varchar(255) default NULL,\n email_from_name varchar(255) default NULL,\n email_from_address varchar(255) default NULL,\n email_subject varchar(255) default NULL,\n additional_validate text default NULL,\n additional_submit text default NULL,\n PRIMARY KEY (nid)\n ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
$success = $success && db_query("CREATE TABLE if not exists {webform_component} (\n nid int(10) unsigned NOT NULL default '0',\n cid smallint unsigned NOT NULL default '0',\n pid smallint unsigned NOT NULL default '0',\n form_key varchar(128) default NULL,\n name varchar(255) default NULL,\n type varchar(16) default NULL,\n value text default NULL,\n extra text,\n mandatory tinyint NOT NULL default '0',\n email tinyint NOT NULL default '0',\n weight smallint NOT NULL default '0',\n PRIMARY KEY (nid, cid)\n ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
$success = $success && db_query("CREATE TABLE if not exists {webform_roles} (\n nid int(10) unsigned NOT NULL default '0',\n rid int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (nid, rid)\n ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
$success = $success && db_query("CREATE TABLE if not exists {webform_submissions} (\n sid int(10) unsigned NOT NULL default '0',\n nid int(10) unsigned NOT NULL default '0',\n uid int(10) unsigned NOT NULL default '0',\n submitted int(11) NOT NULL default '0',\n remote_addr varchar(128),\n PRIMARY KEY (sid),\n UNIQUE KEY sid_nid (sid, nid)\n ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
$success = $success && db_query("CREATE TABLE if not exists {webform_submitted_data} (\n nid int(10) unsigned NOT NULL default '0',\n sid int(10) unsigned NOT NULL default '0',\n cid smallint unsigned NOT NULL default '0',\n no tinyint unsigned NOT NULL default '0',\n data longtext,\n PRIMARY KEY (sid, cid, no),\n INDEX nid (nid),\n INDEX sid_nid (sid, nid)\n ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
break;
case 'pgsql':
$success = $success && db_query("CREATE TABLE {webform} (\n nid integer NOT NULL default '0',\n confirmation text NOT NULL default '',\n teaser smallint NOT NULL default '0',\n submit_text varchar(255) default NULL,\n submit_limit smallint NOT NULL default '-1',\n submit_interval integer NOT NULL default '-1',\n email varchar(255) NOT NULL default '',\n email_from_name varchar(255) NOT NULL default '',\n email_from_address varchar(255) NOT NULL default '',\n email_subject varchar(255) NOT NULL default '',\n additional_validate text default NULL,\n additional_submit text default NULL,\n PRIMARY KEY (nid)\n )");
$success = $success && db_query("CREATE TABLE {webform_component} (\n nid integer NOT NULL default '0',\n cid smallint NOT NULL default '0',\n pid smallint NOT NULL default '0',\n form_key varchar(128) default NULL,\n name varchar(255) NOT NULL default '',\n type varchar(16) NOT NULL default '',\n value text NOT NULL default '',\n extra text NOT NULL default '',\n mandatory smallint NOT NULL default '0',\n email smallint NOT NULL default '0',\n weight smallint NOT NULL default '0',\n PRIMARY KEY (nid, cid)\n )");
$success = $success && db_query("CREATE TABLE {webform_roles} (\n nid integer NOT NULL default '0',\n rid integer NOT NULL default '0',\n PRIMARY KEY (nid, rid)\n )");
$success = $success && db_query("CREATE TABLE {webform_submissions} (\n sid serial UNIQUE,\n nid integer NOT NULL default '0',\n uid integer NOT NULL default '0',\n submitted integer NOT NULL default '0',\n remote_addr varchar(128) NOT NULL default '',\n PRIMARY KEY (sid)\n )");
$success = $success && db_query("CREATE UNIQUE INDEX {webform_submissions}_sid_nid_key ON {webform_submissions} (sid, nid)");
$success = $success && db_query("CREATE TABLE {webform_submitted_data} (\n nid integer NOT NULL default '0',\n sid integer NOT NULL default '0',\n cid smallint NOT NULL default '0',\n no smallint NOT NULL default '0',\n data text NOT NULL default '',\n PRIMARY KEY (sid, cid, no)\n )");
$success = $success && db_query("CREATE INDEX {webform_submitted_data}_nid_idx ON {webform_submitted_data} (sid)");
$success = $success && db_query("CREATE INDEX {webform_submitted_data}_sid_nid_idx ON {webform_submitted_data} (sid, nid)");
break;
}
$success = $success && db_query("UPDATE {system} SET weight = -1 WHERE name='webform' AND type='module'");
if ($success) {
drupal_set_message(t('Webform module installed module tables successfully.'));
}
else {
drupal_set_message(t('The installation of webform module was unsuccessful.'), 'error');
}
}
function webform_uninstall() {
variable_del('webform_use_cookies');
variable_del('webform_debug');
variable_del('webform_enable_fieldset');
variable_del('webform_default_from_address');
variable_del('webform_default_from_name');
variable_del('webform_default_subject');
variable_del('webform_csv_delimiter');
$component_list = array();
$path = drupal_get_path('module', 'webform') . '/components';
$files = file_scan_directory($path, '^.*\\.inc$');
foreach ($files as $filename => $file) {
variable_del('webform_enable_' . $file->name, 1);
}
$filepath = file_create_path('webform');
_webform_recursive_delete($filepath);
db_query("DROP TABLE {webform}");
db_query("DROP TABLE {webform_component}");
db_query("DROP TABLE {webform_roles}");
db_query("DROP TABLE {webform_submissions}");
db_query("DROP TABLE {webform_submitted_data}");
}
function webform_update_1() {
$ret = array();
$ret[] = update_sql('CREATE TABLE {webform_tmp} ( ' . " nid int(10) unsigned NOT NULL default '0', " . " sid int(10) unsigned NOT NULL default '0', " . " cid int(10) unsigned NOT NULL default '0', " . " no int(10) unsigned NOT NULL default '0', " . ' data longtext, ' . ' PRIMARY KEY (nid, sid, cid, no) ' . ')');
$result = db_query('SELECT ws.nid, ws.sid, wc.cid, ws.name, ws.data ' . ' FROM {webform_submitted_data} ws, {webform_component} wc ' . ' WHERE ws.nid = wc.nid ' . ' AND ws.name = wc.name ');
while ($row = db_fetch_object($result)) {
$data = unserialize($row->data);
if (is_array($data)) {
foreach ($data as $k => $v) {
db_query("INSERT INTO {webform_tmp} (nid, sid, cid, no, data) VALUES (%d, %d, %d, %d, '%s')", $row->nid, $row->sid, $row->cid, $k, $v);
}
}
else {
db_query("INSERT INTO {webform_tmp} (nid, sid, cid, no, data) VALUES (%d, %d, %d, %d, '%s')", $row->nid, $row->sid, $row->cid, 0, $row->data);
}
}
$ret[] = update_sql('DROP TABLE {webform_submitted_data}');
$ret[] = update_sql('ALTER TABLE {webform_tmp} RENAME TO {webform_submitted_data}');
$ret[] = update_sql('CREATE TABLE {webform_submissions} ( ' . " nid int(10) unsigned NOT NULL default '0', " . " sid int(10) unsigned NOT NULL default '0', " . " submitted int(11) NOT NULL default '0', " . ' PRIMARY KEY (nid, sid) ' . ')');
return $ret;
}
function webform_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {webform} ADD redirect_post int(1) UNSIGNED NOT NULL DEFAULT '0'");
break;
case 'mysqli':
case 'mysql':
$ret[] = update_sql("ALTER TABLE {webform} ADD redirect_post int(1) UNSIGNED NOT NULL DEFAULT '0' AFTER confirmation");
break;
}
return $ret;
}
function webform_update_3() {
return _system_update_utf8(array(
'webform',
'webform_component',
'webform_role_node',
'webform_submissions',
'webform_submitted_data',
));
}
function webform_update_4() {
$ret[] = update_sql('DROP TABLE if exists {webform_role_node}');
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD user varchar(128) AFTER submitted');
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD remote_addr varchar(128) AFTER user');
$ret[] = update_sql("ALTER TABLE {webform} ADD submit_limit int(2) NOT NULL DEFAULT '-1' AFTER redirect_post");
$ret[] = update_sql("ALTER TABLE {webform} ADD submit_interval int(10) NOT NULL DEFAULT '157784630' AFTER submit_limit");
$result = db_query('SELECT rid, perm FROM {permission}');
while ($row = db_fetch_object($result)) {
if (strpos($row->perm, 'maintain webforms') !== FALSE) {
$updated_perm = str_replace('maintain webforms', 'edit webforms, access webform results', $row->perm);
db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $updated_perm, $row->rid);
}
}
return $ret;
}
function webform_update_5() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
db_query('LOCK TABLES {sequences} WRITE');
$ret[] = update_sql(sprintf("UPDATE {sequences} SET name = '%s' WHERE name = '%s'", db_prefix_tables('{webform_submissions}_sid'), db_prefix_tables('{webform_submissions}_id')));
db_query('UNLOCK TABLES');
break;
}
return $ret;
}
function webform_update_6() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {webform_component} ADD pid integer NOT NULL DEFAULT '0'");
break;
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform_component} ADD pid int(10) NOT NULL DEFAULT 0 AFTER cid');
break;
}
return $ret;
}
function webform_update_7() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_change_column($ret, 'webform_component', 'value', 'value', 'TEXT', array(
'not null' => FALSE,
'default' => 'NULL',
));
break;
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform_component} CHANGE value value TEXT NULL DEFAULT NULL');
break;
}
return $ret;
}
function webform_update_8() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {webform} ADD additional_validate text DEFAULT NULL');
$ret[] = update_sql('ALTER TABLE {webform} ADD additional_submit text DEFAULT NULL');
break;
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform} ADD additional_validate text DEFAULT NULL AFTER email_subject');
$ret[] = update_sql('ALTER TABLE {webform} ADD additional_submit text DEFAULT NULL AFTER additional_validate');
break;
}
return $ret;
}
function webform_update_9() {
variable_del('webform_version');
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_change_column($ret, 'webform', 'email_from', 'email_from_address', 'varchar(255)', array(
'not null' => FALSE,
'default' => 'NULL',
));
$ret[] = update_sql('ALTER TABLE {webform} ADD email_from_name varchar(255) NULL DEFAULT NULL');
break;
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform} CHANGE email_from email_from_address varchar(255) NULL DEFAULT NULL');
$ret[] = update_sql('ALTER TABLE {webform} ADD email_from_name varchar(255) NULL DEFAULT NULL AFTER email');
break;
}
return $ret;
}
function webform_update_10() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {webform_component} ADD form_key varchar(128) NULL DEFAULT NULL');
break;
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform_component} ADD form_key varchar(128) NULL DEFAULT NULL AFTER pid');
break;
}
return $ret;
}
function webform_update_11() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql("ALTER TABLE {webform_submissions} ADD INDEX sid (sid)");
$ret[] = update_sql("ALTER TABLE {webform_submitted_data} ADD INDEX sid (sid)");
break;
case 'pgsql':
$ret[] = update_sql("CREATE INDEX {webform_submissions}_sid_idx ON {webform_submissions}(sid)");
$ret[] = update_sql("CREATE INDEX {webform_submitted_data}_sid_idx ON {webform_submitted_data}(sid)");
break;
}
return $ret;
}
function webform_update_12() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD uid int(10) NOT NULL DEFAULT 0 AFTER sid');
$ret[] = update_sql('UPDATE {webform_submissions} ws set uid = (SELECT uid FROM {users} u WHERE u.name = ws.user)');
$ret[] = update_sql('ALTER TABLE {webform_submissions} DROP user');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD uid integer NOT NULL DEFAULT 0');
$ret[] = update_sql('UPDATE {webform_submissions} ws set uid = (SELECT uid FROM {users} u WHERE u.name = ws.user)');
$ret[] = update_sql('ALTER TABLE {webform_submissions} DROP user');
break;
}
return $ret;
}
function webform_update_13() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE type = 'module' and name = 'webform'");
$ret[] = update_sql("DELETE FROM {webform} WHERE nid NOT IN (SELECT nid FROM {node} WHERE type = 'webform')");
$ret[] = update_sql("DELETE FROM {webform_component} WHERE nid NOT IN (SELECT nid FROM {node} WHERE type = 'webform')");
$ret[] = update_sql("DELETE FROM {webform_submissions} WHERE nid NOT IN (SELECT nid FROM {node} WHERE type = 'webform')");
$ret[] = update_sql("DELETE FROM {webform_submitted_data} WHERE nid NOT IN (SELECT nid FROM {node} WHERE type = 'webform')");
$result = db_query("SELECT nid, cid FROM {webform_component} ORDER BY nid ASC, cid ASC");
$nid = 0;
while ($component = db_fetch_array($result)) {
if ($component['nid'] != $nid) {
$nid = $component['nid'];
$cid = 1;
}
$ret[] = update_sql("UPDATE {webform_component} SET cid = " . $cid . " WHERE nid = " . $nid . " AND cid = " . $component['cid']);
$ret[] = update_sql("UPDATE {webform_component} SET pid = " . $cid . " WHERE nid = " . $nid . " AND pid = " . $component['cid']);
$ret[] = update_sql("UPDATE {webform_submitted_data} SET cid = " . $cid . " WHERE nid = " . $nid . " AND cid = " . $component['cid']);
$cid++;
}
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql("ALTER TABLE {webform_component} CHANGE cid cid smallint unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {webform_component} CHANGE pid pid smallint unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {webform_submitted_data} CHANGE cid cid smallint unsigned NOT NULL default '0'");
break;
case 'pgsql':
db_change_column($ret, 'webform_component', 'cid', 'cid', 'smallint', array(
'not null' => TRUE,
'default' => '0',
));
db_change_column($ret, 'webform_component', 'pid', 'pid', 'smallint', array(
'not null' => TRUE,
'default' => '0',
));
db_change_column($ret, 'webform_submitted_data', 'cid', 'cid', 'smallint', array(
'not null' => TRUE,
'default' => '0',
));
break;
}
return $ret;
}
function webform_update_14() {
$ret = array();
variable_set('webform_default_from_address', variable_get('webform_default_from_email', variable_get('site_mail', ini_get('sendmail_from'))));
variable_del('webform_default_from_email');
if ('Form submission from: ' == variable_get('webform_default_subject', 'Form submission from: ')) {
variable_set('webform_default_subject', 'Form submission from: %title');
}
return $ret;
}
function webform_update_15() {
$ret = array();
$result = db_query("SELECT nid, cid, extra, value FROM {webform_component} WHERE type = 'email'");
while ($row = db_fetch_array($result)) {
$extra = unserialize($row['extra']);
if ($extra['carboncopy']) {
$extra['email'] = 1;
unset($extra['carboncopy']);
}
$value = $row['value'] == 'user email' ? '%useremail' : '';
db_query("UPDATE {webform_component} SET extra = '%s', value = '%s' WHERE nid = %d and cid = %d", serialize($extra), $value, $row['nid'], $row['cid']);
}
$result = db_query("SELECT nid, cid, extra FROM {webform_component} WHERE type IN ('email', 'textfield', 'textarea')");
while ($row = db_fetch_array($result)) {
$extra = unserialize($row['extra']);
if ($extra['attributes']['disabled']) {
$extra['disabled'] = 1;
unset($extra['attributes']['disabled']);
db_query("UPDATE {webform_component} SET extra = '%s' WHERE nid = %d and cid = %d", serialize($extra), $row['nid'], $row['cid']);
}
}
return $ret;
}
function webform_update_16() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform} DROP redirect_post');
$ret[] = update_sql('ALTER TABLE {webform} ADD teaser tinyint NOT NULL DEFAULT 0 AFTER confirmation');
$ret[] = update_sql('ALTER TABLE {webform} ADD submit_text varchar(255) NULL DEFAULT NULL AFTER teaser');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {webform} DROP redirect_post');
$ret[] = update_sql('ALTER TABLE {webform} ADD teaser smallint NOT NULL DEFAULT 0');
$ret[] = update_sql('ALTER TABLE {webform} ADD submit_text varchar(255) NULL DEFAULT NULL');
break;
}
return $ret;
}
function webform_update_17() {
$ret = array();
$ret[] = update_sql('UPDATE {webform} SET submit_interval = -1 WHERE submit_interval = 157784630');
return $ret;
}
function webform_update_18() {
$ret = array();
$result = db_query('SELECT * FROM {webform}');
while ($webform = db_fetch_object($result)) {
foreach (array(
'email_from_name',
'email_from_address',
'email_subject',
) as $key) {
if ($webform->{$key} == 'Automatic' || $webform->{$key} == 'Default') {
$ret[] = update_sql('UPDATE {webform} SET ' . $key . " = 'default' WHERE nid = " . $webform->nid);
}
elseif (!is_numeric($webform->{$key})) {
$cid = db_result(db_query("SELECT cid FROM {webform_component} WHERE name = '%s' AND nid = %d", $webform->{$key}, $webform->nid));
if ($cid) {
$ret[] = update_sql('UPDATE {webform} SET ' . $key . " = '" . $cid . "' WHERE nid = " . $webform->nid);
}
}
}
}
return $ret;
}
function webform_update_19() {
$ret = array();
variable_del('webform_enable_captcha');
if ($GLOBALS['db_type'] == 'pgsql') {
$captcha_exists = db_result(db_query("SELECT table_name FROM {information_schema.tables} WHERE table_schema = 'public' AND table_name LIKE 'captcha_points'"));
}
else {
$captcha_exists = db_result(db_query("SHOW TABLES LIKE 'captcha_points'"));
}
if (module_exists('image_captcha')) {
$captcha_module = 'image_captcha';
$captcha_type = 'Image';
}
else {
$captcha_module = 'captcha';
$captcha_type = 'Math';
}
$result = db_query("SELECT nid, cid FROM {webform_component} WHERE type = 'captcha'");
while ($component = db_fetch_object($result)) {
$ret[] = update_sql('DELETE FROM {webform_component} WHERE cid = ' . $component->cid . ' AND nid = ' . $component->nid);
if ($captcha_exists) {
$added = db_result(db_query("SELECT form_id FROM {captcha_points} WHERE form_id = 'webform_client_form_" . $component->nid . "'"));
if (!$added) {
$ret[] = update_sql("INSERT INTO {captcha_points} (form_id, module, type) VALUES ('webform_client_form_" . $component->nid . "', '" . $captcha_module . "', '" . $captcha_type . "')");
}
}
}
return $ret;
}
function webform_update_20() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql('ALTER TABLE {webform_submissions} DROP INDEX sid');
$ret[] = update_sql('ALTER TABLE {webform_submissions} DROP PRIMARY KEY');
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD UNIQUE INDEX sid_nid (sid, nid)');
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD PRIMARY KEY (sid)');
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} DROP PRIMARY KEY');
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} DROP INDEX sid');
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} CHANGE no no tinyint NOT NULL DEFAULT 0');
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} ADD PRIMARY KEY (sid, cid, no)');
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} ADD INDEX nid (nid)');
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} ADD INDEX sid_nid (sid, nid)');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {webform_submissions} DROP CONSTRAINT {webform_submissions}_pkey');
$ret[] = update_sql('DROP INDEX {webform_submissions}_sid_idx');
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD PRIMARY KEY (sid)');
$ret[] = update_sql('ALTER TABLE {webform_submissions} ADD CONSTRAINT {webform_submissions}_sid_nid_key UNIQUE (sid, nid)');
$ret[] = update_sql('DROP INDEX {webform_submitted_data}_sid_idx');
db_change_column($ret, 'webform_submitted_data', 'no', 'no', 'smallint', array(
'not null' => TRUE,
'default' => '0',
));
$ret[] = update_sql('ALTER TABLE {webform_submitted_data} ADD PRIMARY KEY (sid, cid, no)');
$ret[] = update_sql('CREATE INDEX {webform_submitted_data}_nid_idx ON {webform_submitted_data} (nid)');
$ret[] = update_sql('CREATE INDEX {webform_submitted_data}_sid_nid_idx ON {webform_submitted_data} (sid, nid)');
$ret[] = update_sql('ALTER TABLE {webform_component} ADD PRIMARY KEY (nid, cid)');
break;
}
return $ret;
}
function webform_update_5200() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql("ALTER TABLE {webform_component} CHANGE name name varchar(255) DEFAULT NULL");
break;
case 'pgsql':
db_change_column($ret, 'webform_component', 'name', 'name', 'varchar(255)', array(
'not null' => TRUE,
'default' => "NULL",
));
break;
}
return $ret;
}
function webform_update_5201() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql("ALTER TABLE {webform_component} ADD email int(1) UNSIGNED NOT NULL DEFAULT '0'");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {webform_component} ADD email int NOT NULL DEFAULT '0'");
break;
}
$ret[] = update_sql("UPDATE {webform_component} SET email = 1");
return $ret;
}
function webform_update_5202() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql("CREATE TABLE {webform_roles} (\n nid int(10) unsigned NOT NULL default '0',\n rid int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (nid, rid)\n ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {webform_roles} (\n nid integer NOT NULL default '0',\n rid integer NOT NULL default '0',\n PRIMARY KEY (nid, rid)\n )");
break;
}
$result = db_query("SELECT nid FROM {node} WHERE type = 'webform'");
while ($node = db_fetch_object($result)) {
db_query("INSERT INTO {webform_roles} (nid, rid) VALUES (%d, 1)", $node->nid);
db_query("INSERT INTO {webform_roles} (nid, rid) VALUES (%d, 2)", $node->nid);
}
return $ret;
}
function webform_update_5203() {
$ret = array();
$result = db_query("SELECT nid, cid, extra FROM {webform_component} WHERE type = 'file'");
while ($component = db_fetch_object($result)) {
$extra = unserialize($component->extra);
$extensions = array();
if (!isset($extra['filtering']['types'])) {
$extra['filtering']['types'] = array(
'webimages' => drupal_map_assoc(array(
'png',
'gif',
'jpg',
)),
);
}
foreach ($extra['filtering']['types'] as $category => $category_extensions) {
foreach ((array) $category_extensions as $extension) {
if (!is_numeric($extension)) {
$extensions[] = $extension;
}
}
}
$additional_extensions = explode(',', $extra['filtering']['addextensions']);
foreach ($additional_extensions as $extension) {
$clean_extension = drupal_strtolower(trim($extension));
if (!empty($clean_extension) && !in_array($clean_extension, $extensions)) {
$extensions[] = $clean_extension;
}
}
$extra['filtering']['types'] = $extensions;
db_query("UPDATE {webform_component} SET extra = '%s' WHERE nid = %d AND cid = %d", serialize($extra), $component->nid, $component->cid);
}
return $ret;
}
function _webform_recursive_delete($path) {
if ($path) {
$listing = $path . '/*';
foreach (glob($listing) as $file) {
if (is_file($file) === TRUE) {
@unlink($file);
}
elseif (is_dir($file) === TRUE) {
_webform_recursive_delete($file);
}
}
@rmdir($path);
}
}