Merge branch 'seeddms-6.0.x-postgres' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2017-02-20 17:38:35 +01:00
commit fa5721c2cb
5 changed files with 239 additions and 13 deletions

View File

@ -4110,7 +4110,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res) {
return -1;
}
$receiptID = $db->getInsertID();
$receiptID = $db->getInsertID('tblDocumentRecipients', 'receiptID');
}
else {
$receiptID = isset($indstatus["receiptID"]) ? $indstatus["receiptID"] : NULL;
@ -4172,7 +4172,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res) {
return -1;
}
$receiptID = $db->getInsertID();
$receiptID = $db->getInsertID('tblDocumentRecipients', 'receiptID');
}
else {
$receiptID = isset($status["receiptID"]) ? $status["receiptID"] : NULL;
@ -4260,7 +4260,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res) {
return -1;
}
$revisionID = $db->getInsertID();
$revisionID = $db->getInsertID('tblDocumentRevisors', 'revisionID');
} else {
$revisionID = isset($indstatus["revisionID"]) ? $indstatus["revisionID"] : NULL;
}
@ -4338,7 +4338,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res)
return -1;
else {
$receiptLogID = $db->getInsertID();
$receiptLogID = $db->getInsertID('tblDocumentReceiptLog', 'receiptLogID');
return $receiptLogID;
}
} /* }}} */
@ -4387,7 +4387,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res)
return -1;
else {
$receiptLogID = $db->getInsertID();
$receiptLogID = $db->getInsertID('tblDocumentReceiptLog', 'receiptLogID');
return $receiptLogID;
}
} /* }}} */
@ -4469,7 +4469,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res)
return -1;
else {
$revisionLogID = $db->getInsertID();
$revisionLogID = $db->getInsertID('tblDocumentRevisionLog', 'revisionLogID');
return $revisionLogID;
}
} /* }}} */

View File

@ -255,7 +255,7 @@ class SeedDMS_Core_Transmittal {
if(!$res) {
return false;
}
$itemID = $db->getInsertID();
$itemID = $db->getInsertID('tblTransmittalItems');
return SeedDMS_Core_TransmittalItem::getInstance($itemID, $this->_dms);
} /* }}} */

View File

@ -266,8 +266,10 @@ class SeedDMS_Core_DatabaseAccess {
}
$res = $this->_conn->query($queryStr);
if ($res === false) {
if($this->_debug)
if($this->_debug) {
echo "error: ".$queryStr."<br />";
print_r($this->_conn->errorInfo());
}
return false;
}
$resArr = $res->fetchAll(PDO::FETCH_ASSOC);
@ -290,8 +292,10 @@ class SeedDMS_Core_DatabaseAccess {
}
$res = $this->_conn->exec($queryStr);
if($res === false) {
if($this->_debug)
if($this->_debug) {
echo "error: ".$queryStr."<br />";
print_r($this->_conn->errorInfo());
}
return false;
} else
return true;
@ -519,6 +523,14 @@ class SeedDMS_Core_DatabaseAccess {
"GROUP BY `tblDocumentReceiptLog`.`receiptID` ".
"ORDER BY `maxLogID`";
break;
case 'pgsql':
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttreceiptid` (`receiptID` INTEGER, `maxLogID` INTEGER, PRIMARY KEY (`receiptID`);".
"INSERT INTO `ttreceiptid` SELECT `tblDocumentReceiptLog`.`receiptID`, ".
"MAX(`tblDocumentReceiptLog`.`receiptLogID`) AS `maxLogID` ".
"FROM `tblDocumentReceiptLog` ".
"GROUP BY `tblDocumentReceiptLog`.`receiptID` ".
"ORDER BY `maxLogID`";
break;
default:
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttreceiptid` (PRIMARY KEY (`receiptID`), INDEX (`maxLogID`)) ".
"SELECT `tblDocumentReceiptLog`.`receiptID`, ".
@ -552,6 +564,14 @@ class SeedDMS_Core_DatabaseAccess {
"GROUP BY `tblDocumentRevisionLog`.`revisionID` ".
"ORDER BY `maxLogID`";
break;
case 'pgsql':
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttrevisionid` (`revisionID` INTEGER, `maxLogID` INTEGER, PRIMARY KEY (`revisionID`));".
"INSERT INTO `ttrevisionid` SELECT `tblDocumentRevisionLog`.`revisionID`, ".
"MAX(`tblDocumentRevisionLog`.`revisionLogID`) AS `maxLogID` ".
"FROM `tblDocumentRevisionLog` ".
"GROUP BY `tblDocumentRevisionLog`.`revisionID` ".
"ORDER BY `maxLogID`";
break;
default:
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttrevisionid` (PRIMARY KEY (`revisionID`), INDEX (`maxLogID`)) ".
"SELECT `tblDocumentRevisionLog`.`revisionID`, ".

View File

@ -44,6 +44,22 @@ CREATE TABLE "tblAttributeDefinitions" (
-- --------------------------------------------------------
--
<<<<<<< HEAD
=======
-- Table structure for table `tblUsers`
--
CREATE TABLE "tblRoles" (
"id" SERIAL UNIQUE,
"name" varchar(50) default NULL,
"role" INTEGER NOT NULL default '0',
"noaccess" varchar(30) NOT NULL default ''
) ;
-- --------------------------------------------------------
--
>>>>>>> seeddms-6.0.x-postgres
-- Table structure for table "tblUsers"
--
@ -51,6 +67,10 @@ CREATE TABLE "tblUsers" (
"id" SERIAL UNIQUE,
"login" varchar(50) default NULL,
"pwd" varchar(50) default NULL,
<<<<<<< HEAD
=======
"secret" varchar(50) default NULL,
>>>>>>> seeddms-6.0.x-postgres
"fullName" varchar(100) default NULL,
"email" varchar(70) default NULL,
"language" varchar(32) NOT NULL,
@ -61,7 +81,11 @@ CREATE TABLE "tblUsers" (
"pwdExpiration" TIMESTAMP default NULL,
"loginfailures" INTEGER NOT NULL default '0',
"disabled" INTEGER NOT NULL default '0',
<<<<<<< HEAD
"quota" BIGINT,
=======
"quota" INTEGER,
>>>>>>> seeddms-6.0.x-postgres
"homefolder" INTEGER default NULL,
UNIQUE ("login")
);
@ -69,6 +93,21 @@ CREATE TABLE "tblUsers" (
-- --------------------------------------------------------
--
<<<<<<< HEAD
=======
-- Table structure for table `tblUserSubstitutes`
--
CREATE TABLE "tblUserSubstitutes" (
"id" SERIAL UNIQUE,
"user" INTEGER NOT NULL default '0' REFERENCES "tblUsers" ("id") ON DELETE CASCADE,
"substitute" INTEGER NOT NULL default '0' REFERENCES "tblUsers" ("id") ON DELETE CASCADE
);
-- --------------------------------------------------------
--
>>>>>>> seeddms-6.0.x-postgres
-- Table structure for table "tblUserPasswordRequest"
--
@ -102,7 +141,11 @@ CREATE TABLE "tblUserImages" (
"id" SERIAL UNIQUE,
"userID" INTEGER NOT NULL default '0' REFERENCES "tblUsers" ("id") ON DELETE CASCADE,
"image" TEXT NOT NULL,
<<<<<<< HEAD
"mimeType" varchar(100) NOT NULL default ''
=======
"mimeType" varchar(10) NOT NULL default ''
>>>>>>> seeddms-6.0.x-postgres
) ;
-- --------------------------------------------------------
@ -225,6 +268,7 @@ CREATE TABLE "tblDocumentContent" (
"mimeType" varchar(100) NOT NULL default '',
"fileSize" BIGINT,
"checksum" char(32),
"revisiondate" TIMESTAMP default NULL,
UNIQUE ("document","version")
) ;
@ -290,6 +334,21 @@ CREATE TABLE "tblDocumentLocks" (
-- --------------------------------------------------------
--
-- Table structure for table `tblDocumentCheckOuts`
--
CREATE TABLE "tblDocumentCheckOuts" (
"document" INTEGER REFERENCES "tblDocuments" ("id") ON DELETE CASCADE,
"version" INTEGER NOT NULL default '0',
"userID" INTEGER NOT NULL default '0' REFERENCES "tblUsers" ("id"),
"date" TEXT NOT NULL,
"filename" varchar(255) NOT NULL default '',
UNIQUE ("document")
) ;
-- --------------------------------------------------------
--
-- Table structure for table "tblDocumentReviewers"
--
@ -320,6 +379,67 @@ CREATE TABLE "tblDocumentReviewLog" (
-- --------------------------------------------------------
--
-- Table structure for table `tblDocumentRecipients`
--
CREATE TABLE "tblDocumentRecipients" (
"receiptID" SERIAL UNIQUE,
"documentID" INTEGER NOT NULL default '0' REFERENCES "tblDocuments" ("id") ON DELETE CASCADE,
"version" INTEGER NOT NULL default '0',
"type" INTEGER NOT NULL default '0',
"required" INTEGER NOT NULL default '0',
UNIQUE ("documentID","version","type","required")
) ;
-- --------------------------------------------------------
--
-- Table structure for table "tblDocumentReceiptLog"
--
CREATE TABLE "tblDocumentReceiptLog" (
"receiptLogID" SERIAL UNIQUE,
"receiptID" INTEGER NOT NULL default 0 REFERENCES "tblDocumentRecipients" ("receiptID") ON DELETE CASCADE,
"status" INTEGER NOT NULL default 0,
"comment" TEXT NOT NULL,
"date" TEXT NOT NULL,
"userID" INTEGER NOT NULL default 0 REFERENCES "tblUsers" ("id") ON DELETE CASCADE
) ;
-- --------------------------------------------------------
--
-- Table structure for table `tblDocumentRevisors`
--
CREATE TABLE "tblDocumentRevisors" (
"revisionID" SERIAL UNIQUE,
"documentID" INTEGER NOT NULL default '0' REFERENCES "tblDocuments" ("id") ON DELETE CASCADE,
"version" INTEGER NOT NULL default '0',
"type" INTEGER NOT NULL default '0',
"required" INTEGER NOT NULL default '0',
"startdate" TIMESTAMP default NULL,
UNIQUE ("documentID","version","type","required")
) ;
-- --------------------------------------------------------
--
-- Table structure for table "tblDocumentRevisionLog"
--
CREATE TABLE "tblDocumentRevisionLog" (
"revisionLogID" SERIAL UNIQUE,
"revisionID" INTEGER NOT NULL default 0 REFERENCES "tblDocumentRevisors" ("revisionID") ON DELETE CASCADE,
"status" INTEGER NOT NULL default 0,
"comment" TEXT NOT NULL,
"date" TIMESTAMP default NULL,
"userID" INTEGER NOT NULL default 0 REFERENCES "tblUsers" ("id") ON DELETE CASCADE
) ;
-- --------------------------------------------------------
--
-- Table structure for table "tblDocumentStatus"
--
@ -514,7 +634,8 @@ CREATE TABLE "tblWorkflowActions" (
CREATE TABLE "tblWorkflows" (
"id" SERIAL UNIQUE,
"name" text NOT NULL,
"initstate" INTEGER NOT NULL REFERENCES "tblWorkflowStates" ("id") ON DELETE CASCADE
"initstate" INTEGER NOT NULL REFERENCES "tblWorkflowStates" ("id") ON DELETE CASCADE,
"layoutdata" text default NULL
) ;
-- --------------------------------------------------------
@ -603,6 +724,82 @@ CREATE TABLE "tblWorkflowMandatoryWorkflow" (
-- --------------------------------------------------------
--
-- Table structure for transmittal
--
CREATE TABLE "tblTransmittals" (
"id" SERIAL UNIQUE,
"name" text NOT NULL,
"comment" text NOT NULL,
"userID" INTEGER NOT NULL default '0' REFERENCES "tblUsers" ("id") ON DELETE CASCADE,
"date" TIMESTAMP default NULL,
"public" INTEGER NOT NULL default '0'
);
-- --------------------------------------------------------
--
-- Table structure for transmittal item
--
CREATE TABLE "tblTransmittalItems" (
"id" SERIAL UNIQUE,
"transmittal" INTEGER NOT NULL DEFAULT '0' REFERENCES "tblTransmittals" ("id") ON DELETE CASCADE,
"document" INTEGER default NULL REFERENCES "tblDocuments" ("id") ON DELETE CASCADE,
"version" INTEGER NOT NULL default '0',
"date" TIMESTAMP default NULL,
UNIQUE (transmittal, document, version)
);
-- --------------------------------------------------------
--
-- Table structure for access request objects
--
CREATE TABLE "tblAros" (
"id" SERIAL UNIQUE,
"parent" INTEGER,
"model" TEXT NOT NULL,
"foreignid" INTEGER NOT NULL DEFAULT '0',
"alias" TEXT
) ;
-- --------------------------------------------------------
--
-- Table structure for access control objects
--
CREATE TABLE "tblAcos" (
"id" SERIAL UNIQUE,
"parent" INTEGER,
"model" TEXT NOT NULL,
"foreignid" INTEGER NOT NULL DEFAULT '0',
"alias" TEXT
) ;
-- --------------------------------------------------------
--
-- Table structure for acos/aros relation
--
CREATE TABLE "tblArosAcos" (
"id" SERIAL UNIQUE,
"aro" INTEGER NOT NULL DEFAULT '0' REFERENCES "tblAros" ("id") ON DELETE CASCADE,
"aco" INTEGER NOT NULL DEFAULT '0' REFERENCES "tblAcos" ("id") ON DELETE CASCADE,
"create" INTEGER NOT NULL DEFAULT '-1',
"read" INTEGER NOT NULL DEFAULT '-1',
"update" INTEGER NOT NULL DEFAULT '-1',
"delete" INTEGER NOT NULL DEFAULT '-1',
UNIQUE (aco, aro)
) ;
-- --------------------------------------------------------
--
-- Table structure for version
--
@ -620,10 +817,16 @@ CREATE TABLE "tblVersion" (
-- Initial content for database
--
INSERT INTO "tblUsers" VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, NULL, 0, 0, 0, NULL);
INSERT INTO "tblRoles" ("id", "name", "role") VALUES (1, 'Admin', 1);
SELECT nextval('"tblRoles_id_seq"');
INSERT INTO "tblRoles" ("id", "name", "role") VALUES (2, 'Guest', 2);
SELECT nextval('"tblRoles_id_seq"');
INSERT INTO "tblRoles" ("id", "name", "role") VALUES (3, 'User', 0);
SELECT nextval('"tblRoles_id_seq"');
INSERT INTO "tblUsers" VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '', 'Administrator', 'address@server.com', '', '', '', 1, 0, NULL, 0, 0, 0, NULL);
SELECT nextval('"tblUsers_id_seq"');
INSERT INTO "tblUsers" VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, NULL, 0, 0, 0, NULL);
INSERT INTO "tblUsers" VALUES (2, 'guest', NULL, '', 'Guest User', NULL, '', '', '', 2, 0, NULL, 0, 0, 0, NULL);
SELECT nextval('"tblUsers_id_seq"');
INSERT INTO "tblFolders" VALUES (1, 'DMS', 0, '', 'DMS root', extract(epoch from now()), 1, 0, 2, 0);
SELECT nextval('"tblFolders_id_seq"');
INSERT INTO "tblVersion" VALUES (CURRENT_TIMESTAMP, 5, 0, 0);
INSERT INTO "tblVersion" VALUES (CURRENT_TIMESTAMP, 5, 1, 0);

View File

@ -232,6 +232,7 @@ function insert_role($role) { /* {{{ */
$logger->err("Could not add role");
return false;
}
/*
if($aro = SeedDMS_Aro::getInstance($newRole, $dms)) {
$logger->info("Added aro");
if($role['acos']) {
@ -253,6 +254,7 @@ function insert_role($role) { /* {{{ */
$logger->err("Could not add Aro");
return false;
}
*/
} else {
$newRole = null;
}
@ -1854,6 +1856,7 @@ require_once("SeedDMS/Core.php");
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
$db->_debug = 1;
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {