pgsql fix is more complicated than I thought...

This commit is contained in:
espie 2008-02-18 14:26:07 +00:00
parent d4fd8086da
commit 7748d39cc7
3 changed files with 64 additions and 16 deletions

View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.3 2008/02/18 10:46:07 espie Exp $
# $OpenBSD: Makefile,v 1.4 2008/02/18 14:26:07 espie Exp $
COMMENT = import CSV users to drupal
DISTNAME = user_import-5.x-1.3
PKGNAME = drupal5-user-import-1.3p1
PKGNAME = drupal5-user-import-1.3p2
.include <bsd.port.mk>

View File

@ -1,11 +1,42 @@
$OpenBSD: patch-user_import_install,v 1.1 2008/02/18 10:46:07 espie Exp $
--- user_import.install.orig Mon Feb 18 11:40:10 2008
+++ user_import.install Mon Feb 18 11:40:50 2008
@@ -15,6 +15,7 @@ function user_import_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$OpenBSD: patch-user_import_install,v 1.2 2008/02/18 14:26:07 espie Exp $
--- user_import.install.orig Mon Mar 5 02:39:43 2007
+++ user_import.install Mon Feb 18 15:06:55 2008
@@ -47,6 +47,38 @@ function user_import_install() {
$created = TRUE;
}
break;
+ case 'pgsql':
$query1 = db_query("CREATE TABLE IF NOT EXISTS {user_import} (
import_id int(10) unsigned NOT NULL auto_increment,
name varchar(25) NOT NULL default '',
+ $query1 = db_query("CREATE TABLE {user_import} (
+ import_id serial,
+ name varchar(25) NOT NULL default '',
+ filename varchar(50) NOT NULL default '',
+ oldfilename varchar(50) NOT NULL default '',
+ filepath text NOT NULL,
+ started int NOT NULL default '0',
+ pointer int NOT NULL default '0',
+ processed int NOT NULL default '0',
+ valid int NOT NULL default '0',
+ first_line_skip int NOT NULL default '0',
+ contact int NOT NULL default '0',
+ username_space int NOT NULL default '0',
+ send_email int NOT NULL default '0',
+ field_match text NOT NULL,
+ roles varchar(255) NOT NULL default '',
+ options text NOT NULL,
+ setting varchar(10) NOT NULL default '',
+ PRIMARY KEY (import_id)
+ ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
+
+ $query2 = db_query("CREATE TABLE {user_import_errors} (
+ import_id serial,
+ data text NOT NULL,
+ error varchar(25) NOT NULL default ''
+ ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
+
+ if ($query1 && $query2) {
+ $created = TRUE;
+ }
+ break;
}
if ($created) {

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-user_import_module,v 1.2 2008/02/17 12:37:22 espie Exp $
$OpenBSD: patch-user_import_module,v 1.3 2008/02/18 14:26:07 espie Exp $
--- user_import.module.orig Tue Jul 24 00:49:45 2007
+++ user_import.module Sun Feb 17 13:32:54 2008
+++ user_import.module Mon Feb 18 15:24:34 2008
@@ -1088,6 +1088,9 @@ function user_import_edit_match_fields(&$form, $import
$profile_fields[0] = '-------------';
$profile_fields['email'] = t('Email Address') . '*';
@ -20,7 +20,24 @@ $OpenBSD: patch-user_import_module,v 1.2 2008/02/17 12:37:22 espie Exp $
// username cannot contain multiple spaces in a row
$username = preg_replace('/[ ]+/', ' ', $username);
@@ -1549,6 +1552,7 @@ function _user_import_process($settings) {
@@ -1395,7 +1398,15 @@ function _user_import_settings_save($settings, $messag
VALUES ('%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s')
", trim($settings['name']), $settings['filename'], $settings['oldfilename'], $settings['filepath'], time(), $settings['pointer'], $settings['processed'], $settings['valid'], $settings['first_line_skip'], $settings['contact'], $settings['username_space'], $settings['send_email'], serialize($settings['field_match']), serialize($settings['roles']), serialize($settings['options']), $settings['setting']);
- $settings['import_id'] = db_result(db_query("SELECT LAST_INSERT_ID()"));
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $settings['import_id'] = db_result(db_query("SELECT LAST_INSERT_ID()"));
+ break;
+ case 'pgsql':
+ $settings['import_id'] = db_result(db_query("SELECT currval('user_import_import_id_seq')"));
+ break;
+ }
}
return $settings;
@@ -1549,6 +1560,7 @@ function _user_import_process($settings) {
$username_order[ $column_id ] = $setting['username'];
$username_abbreviate[$column_id]= $setting['abbreviate'];
}
@ -28,7 +45,7 @@ $OpenBSD: patch-user_import_module,v 1.2 2008/02/17 12:37:22 espie Exp $
}
if ($errors == 'duplicate email' && $settings['setting'] == 'import') _user_import_group_add($settings, $email, $fields);
@@ -1572,6 +1576,9 @@ function _user_import_process($settings) {
@@ -1572,6 +1584,9 @@ function _user_import_process($settings) {
'roles' => $roles,
'contact' => $contact
);